2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
22 #include <dali-test-suite-utils.h>
27 void utc_dali_animation_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_animation_cleanup(void)
34 test_return_value = TET_PASS;
40 static const float ROTATION_EPSILON = 0.0001f;
41 static const float VECTOR4_EPSILON = 0.0001f;
43 // Functor to test whether a Finish signal is emitted
44 struct AnimationFinishCheck
46 AnimationFinishCheck(bool& signalReceived)
47 : mSignalReceived(signalReceived)
51 void operator()(Animation& animation)
53 mSignalReceived = true;
58 mSignalReceived = false;
61 void CheckSignalReceived()
65 tet_printf("Expected Finish signal was not received\n");
74 void CheckSignalNotReceived()
78 tet_printf("Unexpected Finish signal was received\n");
87 bool& mSignalReceived; // owned by individual tests
90 static bool ReturnFalseAfterProgressOne( float alpha, const bool& current )
95 struct AnimateFloatTestFunctor
97 AnimateFloatTestFunctor( float start, float end )
103 float operator()( float alpha, const float& current )
105 return mStart + ((mEnd - mStart) * alpha );
112 struct AnimateVector2TestFunctor
114 AnimateVector2TestFunctor( Vector2 start, Vector2 end )
120 Vector2 operator()( float alpha, const Vector2& current )
122 return mStart + ((mEnd - mStart) * alpha );
129 struct AnimateVector4TestFunctor
131 AnimateVector4TestFunctor( Vector4 start, Vector4 end )
137 Vector4 operator()( float alpha, const Vector4& current )
139 return mStart + ((mEnd - mStart) * alpha );
146 struct AnimateQuaternionTestFunctor
148 AnimateQuaternionTestFunctor( Quaternion start, Quaternion end )
154 Quaternion operator()( float alpha, const Quaternion& current )
156 return Quaternion::Slerp(mStart, mEnd, alpha);
165 BounceFunc(float x, float y, float z)
166 : mDistance(Vector3(x, y, z))
169 Vector3 operator()(float alpha, const Vector3& current)
171 if (alpha>0.001f && alpha<1.0f)
173 const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f;
174 Vector3 newTranslation(current);
175 newTranslation += mDistance * flip;
176 return newTranslation;
186 TumbleFunc(Vector3 axis) : tumbleAxis(axis){}
187 Quaternion operator()(float alpha, const Quaternion& current)
189 if (alpha>0.001f && alpha<1.0f)
191 Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis);
192 return tumbleRotation * current;
201 int UtcDaliAnimationNew01(void)
203 TestApplication application;
206 DALI_TEST_CHECK(!animation);
208 animation = Animation::New(1.0f);
210 DALI_TEST_CHECK(animation);
214 int UtcDaliAnimationNew02(void)
216 TestApplication application;
219 DALI_TEST_CHECK(!animation);
222 animation = Animation::New(0.0f);
224 catch (Dali::DaliException& e)
226 // TODO: Determine why catch doesn't.
229 // Tests that a negative test of an assertion succeeds
230 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
231 DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION);
236 int UtcDaliAnimationDownCast(void)
238 TestApplication application;
239 tet_infoline("Testing Dali::Animation::DownCast()");
241 float durationSeconds(1.0f);
242 Animation animation = Animation::New(durationSeconds);
244 BaseHandle object(animation);
246 Animation animation2 = Animation::DownCast(object);
247 DALI_TEST_CHECK(animation2);
249 Animation animation3 = DownCast< Animation >(object);
250 DALI_TEST_CHECK(animation3);
252 BaseHandle unInitializedObject;
253 Animation animation4 = Animation::DownCast(unInitializedObject);
254 DALI_TEST_CHECK(!animation4);
256 Animation animation5 = DownCast< Animation >(unInitializedObject);
257 DALI_TEST_CHECK(!animation5);
261 int UtcDaliAnimationSetDuration(void)
263 TestApplication application;
265 Actor actor = Actor::New();
266 Stage::GetCurrent().Add(actor);
268 // Build the animation
269 float durationSeconds(1.0f);
270 Animation animation = Animation::New(durationSeconds);
271 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
273 // Start the animation
274 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
275 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
278 bool signalReceived(false);
279 AnimationFinishCheck finishCheck(signalReceived);
280 animation.FinishedSignal().Connect(&application, finishCheck);
282 application.SendNotification();
283 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
285 // We didn't expect the animation to finish yet
286 application.SendNotification();
287 finishCheck.CheckSignalNotReceived();
289 application.Render(2u/*just beyond the animation duration*/);
291 // We did expect the animation to finish
292 application.SendNotification();
293 finishCheck.CheckSignalReceived();
294 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
296 // Restart the animation, with a different duration
298 actor.SetPosition(Vector3::ZERO);
299 durationSeconds = 3.5f;
300 animation.SetDuration(durationSeconds);
301 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
304 application.SendNotification();
305 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
307 // We didn't expect the animation to finish yet
308 application.SendNotification();
309 finishCheck.CheckSignalNotReceived();
311 application.Render(2u/*just beyond the animation duration*/);
313 // We did expect the animation to finish
314 application.SendNotification();
315 finishCheck.CheckSignalReceived();
316 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
318 // Check that nothing has changed after a couple of buffer swaps
319 application.Render(0);
320 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
321 application.Render(0);
322 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
326 int UtcDaliAnimationGetDuration(void)
328 TestApplication application;
330 Animation animation = Animation::New(1.0f);
331 DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
333 animation.SetDuration(2.0f);
334 DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
338 int UtcDaliAnimationSetLooping(void)
340 TestApplication application;
342 Actor actor = Actor::New();
343 Stage::GetCurrent().Add(actor);
345 // Build the animation
346 float durationSeconds(1.0f);
347 Animation animation = Animation::New(durationSeconds);
348 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
349 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
351 // Start the animation
352 animation.SetLooping(true);
353 DALI_TEST_CHECK(animation.IsLooping());
356 bool signalReceived(false);
357 AnimationFinishCheck finishCheck(signalReceived);
358 animation.FinishedSignal().Connect(&application, finishCheck);
360 application.SendNotification();
363 float intervalSeconds = 0.25f;
364 float progress = 0.0f;
365 for (int iterations = 0; iterations < 5;)
367 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
369 progress += intervalSeconds;
370 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
372 if (progress >= 1.0f)
374 progress = progress - 1.0f;
379 // We didn't expect the animation to finish yet
380 application.SendNotification();
381 finishCheck.CheckSignalNotReceived();
383 animation.SetLooping(false);
384 DALI_TEST_CHECK(!animation.IsLooping());
386 application.SendNotification();
387 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
389 // We did expect the animation to finish
390 application.SendNotification();
391 finishCheck.CheckSignalReceived();
392 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
394 // Check that nothing has changed after a couple of buffer swaps
395 application.Render(0);
396 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
397 application.Render(0);
398 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
402 int UtcDaliAnimationIsLooping(void)
404 TestApplication application;
406 Animation animation = Animation::New(1.0f);
407 DALI_TEST_CHECK(!animation.IsLooping());
409 animation.SetLooping(true);
410 DALI_TEST_CHECK(animation.IsLooping());
414 int UtcDaliAnimationSetEndAction(void)
416 TestApplication application;
418 Actor actor = Actor::New();
419 Stage::GetCurrent().Add(actor);
421 // Build the animation
422 float durationSeconds(1.0f);
423 Animation animation = Animation::New(durationSeconds);
424 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
426 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
427 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
429 // Start the animation
432 bool signalReceived(false);
433 AnimationFinishCheck finishCheck(signalReceived);
434 animation.FinishedSignal().Connect(&application, finishCheck);
436 application.SendNotification();
437 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
439 // We did expect the animation to finish
440 application.SendNotification();
441 finishCheck.CheckSignalReceived();
442 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
444 // Go back to the start
445 actor.SetPosition(Vector3::ZERO);
446 application.SendNotification();
447 application.Render(0);
448 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
450 // Animate again, but don't bake this time
452 animation.SetEndAction(Animation::Discard);
453 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
456 application.SendNotification();
457 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
459 // We did expect the animation to finish
460 application.SendNotification();
461 finishCheck.CheckSignalReceived();
462 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
464 // The position should be discarded in the next frame
465 application.Render(0);
466 DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
468 // Check that nothing has changed after a couple of buffer swaps
469 application.Render(0);
470 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
471 application.Render(0);
472 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
476 int UtcDaliAnimationGetEndAction(void)
478 TestApplication application;
480 Animation animation = Animation::New(1.0f);
481 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
483 animation.SetEndAction(Animation::Discard);
484 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
488 int UtcDaliAnimationGetDestroyAction(void)
490 TestApplication application;
491 Animation animation = Animation::New(1.0f);
492 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default!
494 animation.SetDestroyAction(Animation::Discard);
495 DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard);
500 int UtcDaliAnimationSetDefaultAlphaFunction(void)
502 TestApplication application;
504 Animation animation = Animation::New(1.0f);
505 AlphaFunction func = animation.GetDefaultAlphaFunction();
506 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
508 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
509 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
510 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
514 int UtcDaliAnimationGetDefaultAlphaFunction(void)
516 TestApplication application;
518 Animation animation = Animation::New(1.0f);
519 AlphaFunction func = animation.GetDefaultAlphaFunction();
521 // Test that the default is linear
522 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
526 int UtcDaliAnimationPlay(void)
528 TestApplication application;
530 Actor actor = Actor::New();
531 Stage::GetCurrent().Add(actor);
533 // Build the animation
534 float durationSeconds(1.0f);
535 Animation animation = Animation::New(durationSeconds);
536 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
537 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
539 // Start the animation
542 bool signalReceived(false);
543 AnimationFinishCheck finishCheck(signalReceived);
544 animation.FinishedSignal().Connect(&application, finishCheck);
546 application.SendNotification();
547 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
549 // We didn't expect the animation to finish yet
550 application.SendNotification();
551 finishCheck.CheckSignalNotReceived();
552 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
554 animation.Play(); // Test that calling play has no effect, when animation is already playing
555 application.SendNotification();
556 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
558 // We didn't expect the animation to finish yet
559 application.SendNotification();
560 finishCheck.CheckSignalNotReceived();
561 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
563 animation.Play(); // Test that calling play has no effect, when animation is already playing
564 application.SendNotification();
565 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
567 // We didn't expect the animation to finish yet
568 application.SendNotification();
569 finishCheck.CheckSignalNotReceived();
570 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
572 animation.Play(); // Test that calling play has no effect, when animation is already playing
573 application.SendNotification();
574 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
576 // We didn't expect the animation to finish yet
577 application.SendNotification();
578 finishCheck.CheckSignalNotReceived();
579 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
581 animation.Play(); // Test that calling play has no effect, when animation is already playing
582 application.SendNotification();
583 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
585 // We did expect the animation to finish
586 application.SendNotification();
587 finishCheck.CheckSignalReceived();
588 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
590 // Check that nothing has changed after a couple of buffer swaps
591 application.Render(0);
592 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
593 application.Render(0);
594 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
598 int UtcDaliAnimationPlayOffStage(void)
600 // Test that an animation can be played, when the actor is off-stage.
601 // When the actor is added to the stage, it should appear at the current position
602 // i.e. where it would have been anyway, if on-stage from the beginning.
604 TestApplication application;
606 Actor actor = Actor::New();
607 Vector3 basePosition(Vector3::ZERO);
608 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
609 // Not added to the stage!
611 // Build the animation
612 float durationSeconds(1.0f);
613 Animation animation = Animation::New(durationSeconds);
614 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
615 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
617 // Start the animation
620 bool signalReceived(false);
621 AnimationFinishCheck finishCheck(signalReceived);
622 animation.FinishedSignal().Connect(&application, finishCheck);
624 application.SendNotification();
625 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
627 // We didn't expect the animation to finish yet
628 application.SendNotification();
629 finishCheck.CheckSignalNotReceived();
630 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
633 Stage::GetCurrent().Add(actor);
635 application.SendNotification();
636 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
638 // We didn't expect the animation to finish yet
639 application.SendNotification();
640 finishCheck.CheckSignalNotReceived();
641 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
642 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
644 // Remove from the stage
645 Stage::GetCurrent().Remove(actor);
647 application.SendNotification();
648 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
650 // We didn't expect the animation to finish yet
651 application.SendNotification();
652 finishCheck.CheckSignalNotReceived();
653 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
656 Stage::GetCurrent().Add(actor);
658 application.SendNotification();
659 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
661 // We didn't expect the animation to finish yet
662 application.SendNotification();
663 finishCheck.CheckSignalNotReceived();
664 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
665 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
667 application.SendNotification();
668 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
670 // We did expect the animation to finish
671 application.SendNotification();
672 finishCheck.CheckSignalReceived();
673 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
675 // Check that nothing has changed after a couple of buffer swaps
676 application.Render(0);
677 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
678 application.Render(0);
679 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
683 int UtcDaliAnimationPlayDiscardHandle(void)
685 TestApplication application;
687 Actor actor = Actor::New();
688 Stage::GetCurrent().Add(actor);
690 // Build the animation
691 float durationSeconds(1.0f);
692 Animation animation = Animation::New(durationSeconds);
693 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
694 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
696 bool signalReceived(false);
697 AnimationFinishCheck finishCheck(signalReceived);
698 animation.FinishedSignal().Connect(&application, finishCheck);
700 // Start the animation
703 // This is a test of the "Fire and Forget" behaviour
704 // Discard the animation handle!
706 DALI_TEST_CHECK( !animation );
708 application.SendNotification();
709 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
711 // We didn't expect the animation to finish yet
712 application.SendNotification();
713 finishCheck.CheckSignalNotReceived();
714 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
716 application.SendNotification();
717 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
719 // We didn't expect the animation to finish yet
720 application.SendNotification();
721 finishCheck.CheckSignalNotReceived();
722 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
724 application.SendNotification();
725 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
727 // We didn't expect the animation to finish yet
728 application.SendNotification();
729 finishCheck.CheckSignalNotReceived();
730 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
732 application.SendNotification();
733 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
735 // We didn't expect the animation to finish yet
736 application.SendNotification();
737 finishCheck.CheckSignalNotReceived();
738 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
740 application.SendNotification();
741 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
743 // We did expect the animation to finish
744 application.SendNotification();
745 finishCheck.CheckSignalReceived();
746 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
748 // Check that nothing has changed after a couple of buffer swaps
749 application.Render(0);
750 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
751 application.Render(0);
752 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
756 int UtcDaliAnimationPlayStopDiscardHandle(void)
758 TestApplication application;
760 Actor actor = Actor::New();
761 Stage::GetCurrent().Add(actor);
763 // Build the animation
764 float durationSeconds(1.0f);
765 Animation animation = Animation::New(durationSeconds);
766 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
767 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
769 // Start the animation
772 bool signalReceived(false);
773 AnimationFinishCheck finishCheck(signalReceived);
774 animation.FinishedSignal().Connect(&application, finishCheck);
776 application.SendNotification();
777 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
779 // We didn't expect the animation to finish yet
780 application.SendNotification();
781 finishCheck.CheckSignalNotReceived();
782 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
784 // This is a test of the "Fire and Forget" behaviour
785 // Stop the animation, and Discard the animation handle!
788 DALI_TEST_CHECK( !animation );
790 application.SendNotification();
791 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
793 // We expect the animation to finish at 20% progress
794 application.SendNotification();
795 finishCheck.CheckSignalReceived();
797 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
799 application.SendNotification();
800 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
802 // Check that nothing has changed
803 application.SendNotification();
804 finishCheck.CheckSignalNotReceived();
805 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
807 application.SendNotification();
808 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
810 // Check that nothing has changed
811 application.SendNotification();
812 finishCheck.CheckSignalNotReceived();
813 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
815 application.SendNotification();
816 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
818 // Check that nothing has changed
819 application.SendNotification();
820 finishCheck.CheckSignalNotReceived();
821 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
825 int UtcDaliAnimationPause(void)
827 TestApplication application;
829 Actor actor = Actor::New();
830 Stage::GetCurrent().Add(actor);
832 // Build the animation
833 float durationSeconds(1.0f);
834 Animation animation = Animation::New(durationSeconds);
835 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
836 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
838 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
840 // Start the animation
843 bool signalReceived(false);
844 AnimationFinishCheck finishCheck(signalReceived);
845 animation.FinishedSignal().Connect(&application, finishCheck);
847 application.SendNotification();
848 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
850 // We didn't expect the animation to finish yet
851 application.SendNotification();
852 finishCheck.CheckSignalNotReceived();
853 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
855 // Pause the animation
857 application.SendNotification();
860 for (int i=0; i<5; ++i)
862 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
864 // We didn't expect the animation to finish yet
865 application.SendNotification();
866 finishCheck.CheckSignalNotReceived();
867 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
872 application.SendNotification();
873 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
875 // We didn't expect the animation to finish yet
876 application.SendNotification();
877 finishCheck.CheckSignalNotReceived();
879 application.SendNotification();
880 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
882 // We did expect the animation to finish
883 application.SendNotification();
884 finishCheck.CheckSignalReceived();
885 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
887 // Check that nothing has changed after a couple of buffer swaps
888 application.Render(0);
889 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
890 application.Render(0);
891 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
895 int UtcDaliAnimationStop(void)
897 TestApplication application;
899 Actor actor = Actor::New();
900 Stage::GetCurrent().Add(actor);
902 // Build the animation
903 float durationSeconds(1.0f);
904 Animation animation = Animation::New(durationSeconds);
905 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
906 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
908 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
910 // Start the animation
913 bool signalReceived(false);
914 AnimationFinishCheck finishCheck(signalReceived);
915 animation.FinishedSignal().Connect(&application, finishCheck);
917 application.SendNotification();
918 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
920 // We didn't expect the animation to finish yet
921 application.SendNotification();
922 finishCheck.CheckSignalNotReceived();
923 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
925 // Stop the animation
927 application.SendNotification();
930 for (int i=0; i<5; ++i)
932 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
934 // We did expect the animation to finish
935 application.SendNotification();
936 finishCheck.CheckSignalReceived();
937 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
942 int UtcDaliAnimationStopSetPosition(void)
944 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
945 // i.e. to check that the animation does not interfere with the position set.
947 TestApplication application;
949 Actor actor = Actor::New();
950 Stage::GetCurrent().Add(actor);
952 // Build the animation
953 float durationSeconds(1.0f);
954 Animation animation = Animation::New(durationSeconds);
955 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
956 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
958 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
960 // Start the animation
963 bool signalReceived(false);
964 AnimationFinishCheck finishCheck(signalReceived);
965 animation.FinishedSignal().Connect(&application, finishCheck);
967 application.SendNotification();
968 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
970 // We didn't expect the animation to finish yet
971 application.SendNotification();
972 finishCheck.CheckSignalNotReceived();
973 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
975 // Stop the animation
977 Vector3 positionSet(2.0f, 3.0f, 4.0f);
978 actor.SetPosition(positionSet);
979 application.SendNotification();
982 for (int i=0; i<5; ++i)
984 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
986 // We did expect the animation to finish
987 application.SendNotification();
988 finishCheck.CheckSignalReceived();
989 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
994 int UtcDaliAnimationClear(void)
996 TestApplication application;
998 Actor actor = Actor::New();
999 Stage::GetCurrent().Add(actor);
1001 // Build the animation
1002 float durationSeconds(1.0f);
1003 Animation animation = Animation::New(durationSeconds);
1004 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1005 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1007 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1009 // Start the animation
1012 bool signalReceived(false);
1013 AnimationFinishCheck finishCheck(signalReceived);
1014 animation.FinishedSignal().Connect(&application, finishCheck);
1016 application.SendNotification();
1017 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1019 // We didn't expect the animation to finish yet
1020 application.SendNotification();
1021 finishCheck.CheckSignalNotReceived();
1022 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1024 // Clear the animation
1026 application.SendNotification();
1028 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1030 // We don't expect the animation to finish now
1031 application.SendNotification();
1032 finishCheck.CheckSignalNotReceived();
1033 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1035 // Restart as a scale animation; this should not move the actor's position
1036 finishCheck.Reset();
1037 actor.SetPosition(Vector3::ZERO);
1038 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1039 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1042 application.SendNotification();
1043 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1045 // We didn't expect the animation to finish yet
1046 application.SendNotification();
1047 finishCheck.CheckSignalNotReceived();
1048 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1049 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1051 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1053 // We did expect the animation to finish
1054 application.SendNotification();
1055 finishCheck.CheckSignalReceived();
1056 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1057 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1061 int UtcDaliAnimationSignalFinish(void)
1063 TestApplication application;
1065 // Start the empty animation
1066 float durationSeconds(1.0f);
1067 Animation animation = Animation::New(durationSeconds);
1070 bool signalReceived(false);
1071 AnimationFinishCheck finishCheck(signalReceived);
1072 animation.FinishedSignal().Connect(&application, finishCheck);
1074 application.SendNotification();
1075 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1077 // We did expect the animation to finish
1078 application.SendNotification();
1079 finishCheck.CheckSignalReceived();
1083 int UtcDaliAnimationAnimateByBoolean(void)
1085 TestApplication application;
1087 Actor actor = Actor::New();
1089 // Register a boolean property
1090 bool startValue(false);
1091 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1092 Stage::GetCurrent().Add(actor);
1093 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1095 // Build the animation
1096 float durationSeconds(2.0f);
1097 Animation animation = Animation::New(durationSeconds);
1098 const bool relativeValue(true);
1099 const bool finalValue( false || relativeValue );
1100 animation.AnimateBy(Property(actor, index), relativeValue);
1102 // Start the animation
1105 bool signalReceived(false);
1106 AnimationFinishCheck finishCheck(signalReceived);
1107 animation.FinishedSignal().Connect(&application, finishCheck);
1109 application.SendNotification();
1110 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1112 // We didn't expect the animation to finish yet
1113 application.SendNotification();
1114 finishCheck.CheckSignalNotReceived();
1115 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1117 application.SendNotification();
1118 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1120 // We did expect the animation to finish
1121 application.SendNotification();
1122 finishCheck.CheckSignalReceived();
1123 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1125 // Check that nothing has changed after a couple of buffer swaps
1126 application.Render(0);
1127 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1128 application.Render(0);
1129 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1131 // Repeat with relative value "false" - this should be an NOOP
1132 animation = Animation::New(durationSeconds);
1133 bool noOpValue(false);
1134 animation.AnimateBy(Property(actor, index), noOpValue);
1136 // Start the animation
1139 finishCheck.Reset();
1140 animation.FinishedSignal().Connect(&application, finishCheck);
1142 application.SendNotification();
1143 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1145 // We didn't expect the animation to finish yet
1146 application.SendNotification();
1147 finishCheck.CheckSignalNotReceived();
1148 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1150 application.SendNotification();
1151 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1153 // We did expect the animation to finish
1154 application.SendNotification();
1155 finishCheck.CheckSignalReceived();
1156 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1158 // Check that nothing has changed after a couple of buffer swaps
1159 application.Render(0);
1160 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1161 application.Render(0);
1162 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1166 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1168 TestApplication application;
1170 Actor actor = Actor::New();
1172 // Register a boolean property
1173 bool startValue(false);
1174 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1175 Stage::GetCurrent().Add(actor);
1176 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1178 // Build the animation
1179 float durationSeconds(2.0f);
1180 Animation animation = Animation::New(durationSeconds);
1181 bool relativeValue(true);
1182 bool finalValue( false || relativeValue );
1183 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1185 // Start the animation
1188 bool signalReceived(false);
1189 AnimationFinishCheck finishCheck(signalReceived);
1190 animation.FinishedSignal().Connect(&application, finishCheck);
1192 application.SendNotification();
1193 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1195 // We didn't expect the animation to finish yet
1196 application.SendNotification();
1197 finishCheck.CheckSignalNotReceived();
1198 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1200 application.SendNotification();
1201 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1203 // We did expect the animation to finish
1204 application.SendNotification();
1205 finishCheck.CheckSignalReceived();
1206 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1208 // Check that nothing has changed after a couple of buffer swaps
1209 application.Render(0);
1210 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1211 application.Render(0);
1212 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1214 // Repeat with relative value "false" - this should be an NOOP
1215 animation = Animation::New(durationSeconds);
1216 bool noOpValue(false);
1217 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1219 // Start the animation
1222 finishCheck.Reset();
1223 animation.FinishedSignal().Connect(&application, finishCheck);
1225 application.SendNotification();
1226 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1228 // We didn't expect the animation to finish yet
1229 application.SendNotification();
1230 finishCheck.CheckSignalNotReceived();
1231 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1233 application.SendNotification();
1234 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1236 // We did expect the animation to finish
1237 application.SendNotification();
1238 finishCheck.CheckSignalReceived();
1239 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1243 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1245 TestApplication application;
1247 Actor actor = Actor::New();
1249 // Register a boolean property
1250 bool startValue(false);
1251 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1252 Stage::GetCurrent().Add(actor);
1253 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1255 // Build the animation
1256 float durationSeconds(2.0f);
1257 Animation animation = Animation::New(durationSeconds);
1258 bool relativeValue(true);
1259 bool finalValue( false || relativeValue );
1260 float animatorDurationSeconds(durationSeconds * 0.5f);
1261 animation.AnimateBy( Property(actor, index),
1263 TimePeriod( animatorDurationSeconds ) );
1265 // Start the animation
1268 bool signalReceived(false);
1269 AnimationFinishCheck finishCheck(signalReceived);
1270 animation.FinishedSignal().Connect(&application, finishCheck);
1272 application.SendNotification();
1273 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1275 // We didn't expect the animation to finish yet
1276 application.SendNotification();
1277 finishCheck.CheckSignalNotReceived();
1278 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1280 application.SendNotification();
1281 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1283 // We didn't expect the animation to finish yet...
1284 application.SendNotification();
1285 finishCheck.CheckSignalNotReceived();
1287 // ...however we should have reached the final value
1288 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1290 application.SendNotification();
1291 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1293 // We did expect the animation to finish
1294 application.SendNotification();
1295 finishCheck.CheckSignalReceived();
1296 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1298 // Check that nothing has changed after a couple of buffer swaps
1299 application.Render(0);
1300 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1301 application.Render(0);
1302 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1306 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1308 TestApplication application;
1310 Actor actor = Actor::New();
1312 // Register a boolean property
1313 bool startValue(false);
1314 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1315 Stage::GetCurrent().Add(actor);
1316 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1318 // Build the animation
1319 float durationSeconds(2.0f);
1320 Animation animation = Animation::New(durationSeconds);
1321 bool relativeValue(true);
1322 bool finalValue( false || relativeValue );
1323 float animatorDurationSeconds(durationSeconds * 0.5f);
1324 animation.AnimateBy( Property(actor, index),
1326 AlphaFunctions::EaseInOut,
1327 TimePeriod( animatorDurationSeconds ) );
1329 // Start the animation
1332 bool signalReceived(false);
1333 AnimationFinishCheck finishCheck(signalReceived);
1334 animation.FinishedSignal().Connect(&application, finishCheck);
1336 application.SendNotification();
1337 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1339 // We didn't expect the animation to finish yet
1340 application.SendNotification();
1341 finishCheck.CheckSignalNotReceived();
1342 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1344 application.SendNotification();
1345 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1347 // We didn't expect the animation to finish yet...
1348 application.SendNotification();
1349 finishCheck.CheckSignalNotReceived();
1351 // ...however we should have reached the final value
1352 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1354 application.SendNotification();
1355 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1357 // We did expect the animation to finish
1358 application.SendNotification();
1359 finishCheck.CheckSignalReceived();
1360 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1362 // Check that nothing has changed after a couple of buffer swaps
1363 application.Render(0);
1364 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1365 application.Render(0);
1366 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1370 int UtcDaliAnimationAnimateByFloat(void)
1372 TestApplication application;
1374 Actor actor = Actor::New();
1376 // Register a float property
1377 float startValue(10.0f);
1378 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1379 Stage::GetCurrent().Add(actor);
1380 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1382 // Build the animation
1383 float durationSeconds(2.0f);
1384 Animation animation = Animation::New(durationSeconds);
1385 float targetValue(50.0f);
1386 float relativeValue(targetValue - startValue);
1387 animation.AnimateBy(Property(actor, index), relativeValue);
1389 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1391 // Start the animation
1394 bool signalReceived(false);
1395 AnimationFinishCheck finishCheck(signalReceived);
1396 animation.FinishedSignal().Connect(&application, finishCheck);
1398 application.SendNotification();
1399 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1401 // We didn't expect the animation to finish yet
1402 application.SendNotification();
1403 finishCheck.CheckSignalNotReceived();
1404 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1406 application.SendNotification();
1407 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1409 // We did expect the animation to finish
1410 application.SendNotification();
1411 finishCheck.CheckSignalReceived();
1412 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1414 // Check that nothing has changed after a couple of buffer swaps
1415 application.Render(0);
1416 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1417 application.Render(0);
1418 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1422 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1424 TestApplication application;
1426 Actor actor = Actor::New();
1428 // Register a float property
1429 float startValue(10.0f);
1430 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1431 Stage::GetCurrent().Add(actor);
1432 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1434 // Build the animation
1435 float durationSeconds(1.0f);
1436 Animation animation = Animation::New(durationSeconds);
1437 float targetValue(90.0f);
1438 float relativeValue(targetValue - startValue);
1439 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1441 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1443 // Start the animation
1446 bool signalReceived(false);
1447 AnimationFinishCheck finishCheck(signalReceived);
1448 animation.FinishedSignal().Connect(&application, finishCheck);
1450 application.SendNotification();
1451 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1453 // We didn't expect the animation to finish yet
1454 application.SendNotification();
1455 finishCheck.CheckSignalNotReceived();
1457 // The position should have moved more, than with a linear alpha function
1458 float current(actor.GetProperty<float>(index));
1459 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1461 application.SendNotification();
1462 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1464 // We did expect the animation to finish
1465 application.SendNotification();
1466 finishCheck.CheckSignalReceived();
1467 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1469 // Check that nothing has changed after a couple of buffer swaps
1470 application.Render(0);
1471 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1472 application.Render(0);
1473 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1477 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1479 TestApplication application;
1481 Actor actor = Actor::New();
1483 // Register a float property
1484 float startValue(10.0f);
1485 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1486 Stage::GetCurrent().Add(actor);
1487 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1489 // Build the animation
1490 float durationSeconds(1.0f);
1491 Animation animation = Animation::New(durationSeconds);
1492 float targetValue(30.0f);
1493 float relativeValue(targetValue - startValue);
1495 animation.AnimateBy(Property(actor, index),
1497 TimePeriod(delay, durationSeconds - delay));
1499 // Start the animation
1502 bool signalReceived(false);
1503 AnimationFinishCheck finishCheck(signalReceived);
1504 animation.FinishedSignal().Connect(&application, finishCheck);
1506 application.SendNotification();
1507 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1509 // We didn't expect the animation to finish yet
1510 application.SendNotification();
1511 finishCheck.CheckSignalNotReceived();
1512 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1514 application.SendNotification();
1515 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1517 // We didn't expect the animation to finish yet
1518 application.SendNotification();
1519 finishCheck.CheckSignalNotReceived();
1520 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1522 application.SendNotification();
1523 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1525 // We did expect the animation to finish
1526 application.SendNotification();
1527 finishCheck.CheckSignalReceived();
1528 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1530 // Check that nothing has changed after a couple of buffer swaps
1531 application.Render(0);
1532 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1533 application.Render(0);
1534 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1538 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
1540 TestApplication application;
1542 Actor actor = Actor::New();
1544 // Register a float property
1545 float startValue(10.0f);
1546 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1547 Stage::GetCurrent().Add(actor);
1548 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1550 // Build the animation
1551 float durationSeconds(1.0f);
1552 Animation animation = Animation::New(durationSeconds);
1553 float targetValue(30.0f);
1554 float relativeValue(targetValue - startValue);
1556 animation.AnimateBy(Property(actor, index),
1558 AlphaFunctions::Linear,
1559 TimePeriod(delay, durationSeconds - delay));
1561 // Start the animation
1564 bool signalReceived(false);
1565 AnimationFinishCheck finishCheck(signalReceived);
1566 animation.FinishedSignal().Connect(&application, finishCheck);
1568 application.SendNotification();
1569 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1571 // We didn't expect the animation to finish yet
1572 application.SendNotification();
1573 finishCheck.CheckSignalNotReceived();
1574 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1576 application.SendNotification();
1577 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1579 // We didn't expect the animation to finish yet
1580 application.SendNotification();
1581 finishCheck.CheckSignalNotReceived();
1582 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1584 application.SendNotification();
1585 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1587 // We did expect the animation to finish
1588 application.SendNotification();
1589 finishCheck.CheckSignalReceived();
1590 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1592 // Check that nothing has changed after a couple of buffer swaps
1593 application.Render(0);
1594 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1595 application.Render(0);
1596 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1600 int UtcDaliAnimationAnimateByVector2(void)
1602 TestApplication application;
1604 Actor actor = Actor::New();
1606 // Register a Vector2 property
1607 Vector2 startValue(10.0f, 10.0f);
1608 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1609 Stage::GetCurrent().Add(actor);
1610 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1612 // Build the animation
1613 float durationSeconds(2.0f);
1614 Animation animation = Animation::New(durationSeconds);
1615 Vector2 targetValue(60.0f, 60.0f);
1616 Vector2 relativeValue(targetValue - startValue);
1617 animation.AnimateBy(Property(actor, index), relativeValue);
1619 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1621 // Start the animation
1624 bool signalReceived(false);
1625 AnimationFinishCheck finishCheck(signalReceived);
1626 animation.FinishedSignal().Connect(&application, finishCheck);
1628 application.SendNotification();
1629 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1631 // We didn't expect the animation to finish yet
1632 application.SendNotification();
1633 finishCheck.CheckSignalNotReceived();
1634 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
1636 application.SendNotification();
1637 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1639 // We did expect the animation to finish
1640 application.SendNotification();
1641 finishCheck.CheckSignalReceived();
1642 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1644 // Check that nothing has changed after a couple of buffer swaps
1645 application.Render(0);
1646 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1647 application.Render(0);
1648 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1652 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
1654 TestApplication application;
1656 Actor actor = Actor::New();
1658 // Register a Vector2 property
1659 Vector2 startValue(100.0f, 100.0f);
1660 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1661 Stage::GetCurrent().Add(actor);
1662 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1664 // Build the animation
1665 float durationSeconds(1.0f);
1666 Animation animation = Animation::New(durationSeconds);
1667 Vector2 targetValue(20.0f, 20.0f);
1668 Vector2 relativeValue(targetValue - startValue);
1669 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1671 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1673 // Start the animation
1676 bool signalReceived(false);
1677 AnimationFinishCheck finishCheck(signalReceived);
1678 animation.FinishedSignal().Connect(&application, finishCheck);
1680 application.SendNotification();
1681 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1683 // We didn't expect the animation to finish yet
1684 application.SendNotification();
1685 finishCheck.CheckSignalNotReceived();
1687 // The position should have moved more, than with a linear alpha function
1688 Vector2 current(actor.GetProperty<Vector2>(index));
1689 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
1690 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
1692 application.SendNotification();
1693 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1695 // We did expect the animation to finish
1696 application.SendNotification();
1697 finishCheck.CheckSignalReceived();
1698 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1700 // Check that nothing has changed after a couple of buffer swaps
1701 application.Render(0);
1702 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1703 application.Render(0);
1704 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1708 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
1710 TestApplication application;
1712 Actor actor = Actor::New();
1714 // Register a Vector2 property
1715 Vector2 startValue(10.0f, 10.0f);
1716 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1717 Stage::GetCurrent().Add(actor);
1718 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1720 // Build the animation
1721 float durationSeconds(1.0f);
1722 Animation animation = Animation::New(durationSeconds);
1723 Vector2 targetValue(30.0f, 30.0f);
1724 Vector2 relativeValue(targetValue - startValue);
1726 animation.AnimateBy(Property(actor, index),
1728 TimePeriod(delay, durationSeconds - delay));
1730 // Start the animation
1733 bool signalReceived(false);
1734 AnimationFinishCheck finishCheck(signalReceived);
1735 animation.FinishedSignal().Connect(&application, finishCheck);
1737 application.SendNotification();
1738 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1740 // We didn't expect the animation to finish yet
1741 application.SendNotification();
1742 finishCheck.CheckSignalNotReceived();
1743 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1745 application.SendNotification();
1746 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1748 // We didn't expect the animation to finish yet
1749 application.SendNotification();
1750 finishCheck.CheckSignalNotReceived();
1751 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1753 application.SendNotification();
1754 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1756 // We did expect the animation to finish
1757 application.SendNotification();
1758 finishCheck.CheckSignalReceived();
1759 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1761 // Check that nothing has changed after a couple of buffer swaps
1762 application.Render(0);
1763 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1764 application.Render(0);
1765 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1769 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
1771 TestApplication application;
1773 Actor actor = Actor::New();
1775 // Register a Vector2 property
1776 Vector2 startValue(5.0f, 5.0f);
1777 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1778 Stage::GetCurrent().Add(actor);
1779 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1781 // Build the animation
1782 float durationSeconds(1.0f);
1783 Animation animation = Animation::New(durationSeconds);
1784 Vector2 targetValue(10.0f, 10.0f);
1785 Vector2 relativeValue(targetValue - startValue);
1787 animation.AnimateBy(Property(actor, index),
1789 AlphaFunctions::Linear,
1790 TimePeriod(delay, durationSeconds - delay));
1792 // Start the animation
1795 bool signalReceived(false);
1796 AnimationFinishCheck finishCheck(signalReceived);
1797 animation.FinishedSignal().Connect(&application, finishCheck);
1799 application.SendNotification();
1800 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1802 // We didn't expect the animation to finish yet
1803 application.SendNotification();
1804 finishCheck.CheckSignalNotReceived();
1805 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1807 application.SendNotification();
1808 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1810 // We didn't expect the animation to finish yet
1811 application.SendNotification();
1812 finishCheck.CheckSignalNotReceived();
1813 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1815 application.SendNotification();
1816 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1818 // We did expect the animation to finish
1819 application.SendNotification();
1820 finishCheck.CheckSignalReceived();
1821 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1823 // Check that nothing has changed after a couple of buffer swaps
1824 application.Render(0);
1825 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1826 application.Render(0);
1827 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
1831 int UtcDaliAnimationAnimateByVector3(void)
1833 TestApplication application;
1835 Actor actor = Actor::New();
1837 // Register a Vector3 property
1838 Vector3 startValue(10.0f, 10.0f, 10.0f);
1839 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1840 Stage::GetCurrent().Add(actor);
1841 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1843 // Build the animation
1844 float durationSeconds(2.0f);
1845 Animation animation = Animation::New(durationSeconds);
1846 Vector3 targetValue(60.0f, 60.0f, 60.0f);
1847 Vector3 relativeValue(targetValue - startValue);
1848 animation.AnimateBy(Property(actor, index), relativeValue);
1850 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1852 // Start the animation
1855 bool signalReceived(false);
1856 AnimationFinishCheck finishCheck(signalReceived);
1857 animation.FinishedSignal().Connect(&application, finishCheck);
1859 application.SendNotification();
1860 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1862 // We didn't expect the animation to finish yet
1863 application.SendNotification();
1864 finishCheck.CheckSignalNotReceived();
1865 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
1867 application.SendNotification();
1868 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1870 // We did expect the animation to finish
1871 application.SendNotification();
1872 finishCheck.CheckSignalReceived();
1873 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1875 // Check that nothing has changed after a couple of buffer swaps
1876 application.Render(0);
1877 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1878 application.Render(0);
1879 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1883 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
1885 TestApplication application;
1887 Actor actor = Actor::New();
1889 // Register a Vector3 property
1890 Vector3 startValue(100.0f, 100.0f, 100.0f);
1891 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1892 Stage::GetCurrent().Add(actor);
1893 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1895 // Build the animation
1896 float durationSeconds(1.0f);
1897 Animation animation = Animation::New(durationSeconds);
1898 Vector3 targetValue(20.0f, 20.0f, 20.0f);
1899 Vector3 relativeValue(targetValue - startValue);
1900 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1902 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1904 // Start the animation
1907 bool signalReceived(false);
1908 AnimationFinishCheck finishCheck(signalReceived);
1909 animation.FinishedSignal().Connect(&application, finishCheck);
1911 application.SendNotification();
1912 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1914 // We didn't expect the animation to finish yet
1915 application.SendNotification();
1916 finishCheck.CheckSignalNotReceived();
1918 // The position should have moved more, than with a linear alpha function
1919 Vector3 current(actor.GetProperty<Vector3>(index));
1920 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
1921 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
1922 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
1924 application.SendNotification();
1925 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1927 // We did expect the animation to finish
1928 application.SendNotification();
1929 finishCheck.CheckSignalReceived();
1930 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1932 // Check that nothing has changed after a couple of buffer swaps
1933 application.Render(0);
1934 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1935 application.Render(0);
1936 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1940 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
1942 TestApplication application;
1944 Actor actor = Actor::New();
1946 // Register a Vector3 property
1947 Vector3 startValue(10.0f, 10.0f, 10.0f);
1948 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1949 Stage::GetCurrent().Add(actor);
1950 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1952 // Build the animation
1953 float durationSeconds(1.0f);
1954 Animation animation = Animation::New(durationSeconds);
1955 Vector3 targetValue(30.0f, 30.0f, 30.0f);
1956 Vector3 relativeValue(targetValue - startValue);
1958 animation.AnimateBy(Property(actor, index),
1960 TimePeriod(delay, durationSeconds - delay));
1962 // Start the animation
1965 bool signalReceived(false);
1966 AnimationFinishCheck finishCheck(signalReceived);
1967 animation.FinishedSignal().Connect(&application, finishCheck);
1969 application.SendNotification();
1970 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
1972 // We didn't expect the animation to finish yet
1973 application.SendNotification();
1974 finishCheck.CheckSignalNotReceived();
1975 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1977 application.SendNotification();
1978 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
1980 // We didn't expect the animation to finish yet
1981 application.SendNotification();
1982 finishCheck.CheckSignalNotReceived();
1983 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
1985 application.SendNotification();
1986 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
1988 // We did expect the animation to finish
1989 application.SendNotification();
1990 finishCheck.CheckSignalReceived();
1991 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1993 // Check that nothing has changed after a couple of buffer swaps
1994 application.Render(0);
1995 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
1996 application.Render(0);
1997 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2001 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2003 TestApplication application;
2005 Actor actor = Actor::New();
2007 // Register a Vector3 property
2008 Vector3 startValue(5.0f, 5.0f, 5.0f);
2009 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2010 Stage::GetCurrent().Add(actor);
2011 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2013 // Build the animation
2014 float durationSeconds(1.0f);
2015 Animation animation = Animation::New(durationSeconds);
2016 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2017 Vector3 relativeValue(targetValue - startValue);
2019 animation.AnimateBy(Property(actor, index),
2021 AlphaFunctions::Linear,
2022 TimePeriod(delay, durationSeconds - delay));
2024 // Start the animation
2027 bool signalReceived(false);
2028 AnimationFinishCheck finishCheck(signalReceived);
2029 animation.FinishedSignal().Connect(&application, finishCheck);
2031 application.SendNotification();
2032 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2034 // We didn't expect the animation to finish yet
2035 application.SendNotification();
2036 finishCheck.CheckSignalNotReceived();
2037 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2039 application.SendNotification();
2040 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2042 // We didn't expect the animation to finish yet
2043 application.SendNotification();
2044 finishCheck.CheckSignalNotReceived();
2045 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2047 application.SendNotification();
2048 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2050 // We did expect the animation to finish
2051 application.SendNotification();
2052 finishCheck.CheckSignalReceived();
2053 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2055 // Check that nothing has changed after a couple of buffer swaps
2056 application.Render(0);
2057 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2058 application.Render(0);
2059 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2063 int UtcDaliAnimationAnimateByVector4(void)
2065 TestApplication application;
2067 Actor actor = Actor::New();
2069 // Register a Vector4 property
2070 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2071 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2072 Stage::GetCurrent().Add(actor);
2073 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2075 // Build the animation
2076 float durationSeconds(2.0f);
2077 Animation animation = Animation::New(durationSeconds);
2078 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2079 Vector4 relativeValue(targetValue - startValue);
2080 animation.AnimateBy(Property(actor, index), relativeValue);
2082 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2084 // Start the animation
2087 bool signalReceived(false);
2088 AnimationFinishCheck finishCheck(signalReceived);
2089 animation.FinishedSignal().Connect(&application, finishCheck);
2091 application.SendNotification();
2092 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2094 // We didn't expect the animation to finish yet
2095 application.SendNotification();
2096 finishCheck.CheckSignalNotReceived();
2097 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2099 application.SendNotification();
2100 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2102 // We did expect the animation to finish
2103 application.SendNotification();
2104 finishCheck.CheckSignalReceived();
2105 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2107 // Check that nothing has changed after a couple of buffer swaps
2108 application.Render(0);
2109 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2110 application.Render(0);
2111 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2115 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2117 TestApplication application;
2119 Actor actor = Actor::New();
2121 // Register a Vector4 property
2122 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2123 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2124 Stage::GetCurrent().Add(actor);
2125 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2127 // Build the animation
2128 float durationSeconds(1.0f);
2129 Animation animation = Animation::New(durationSeconds);
2130 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2131 Vector4 relativeValue(targetValue - startValue);
2132 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2134 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2136 // Start the animation
2139 bool signalReceived(false);
2140 AnimationFinishCheck finishCheck(signalReceived);
2141 animation.FinishedSignal().Connect(&application, finishCheck);
2143 application.SendNotification();
2144 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2146 // We didn't expect the animation to finish yet
2147 application.SendNotification();
2148 finishCheck.CheckSignalNotReceived();
2150 // The position should have moved more, than with a linear alpha function
2151 Vector4 current(actor.GetProperty<Vector4>(index));
2152 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2153 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2154 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2155 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2157 application.SendNotification();
2158 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2160 // We did expect the animation to finish
2161 application.SendNotification();
2162 finishCheck.CheckSignalReceived();
2163 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2165 // Check that nothing has changed after a couple of buffer swaps
2166 application.Render(0);
2167 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2168 application.Render(0);
2169 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2173 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2175 TestApplication application;
2177 Actor actor = Actor::New();
2179 // Register a Vector4 property
2180 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2181 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2182 Stage::GetCurrent().Add(actor);
2183 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2185 // Build the animation
2186 float durationSeconds(1.0f);
2187 Animation animation = Animation::New(durationSeconds);
2188 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2189 Vector4 relativeValue(targetValue - startValue);
2191 animation.AnimateBy(Property(actor, index),
2193 TimePeriod(delay, durationSeconds - delay));
2195 // Start the animation
2198 bool signalReceived(false);
2199 AnimationFinishCheck finishCheck(signalReceived);
2200 animation.FinishedSignal().Connect(&application, finishCheck);
2202 application.SendNotification();
2203 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2205 // We didn't expect the animation to finish yet
2206 application.SendNotification();
2207 finishCheck.CheckSignalNotReceived();
2208 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2210 application.SendNotification();
2211 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2213 // We didn't expect the animation to finish yet
2214 application.SendNotification();
2215 finishCheck.CheckSignalNotReceived();
2216 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2218 application.SendNotification();
2219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2221 // We did expect the animation to finish
2222 application.SendNotification();
2223 finishCheck.CheckSignalReceived();
2224 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2226 // Check that nothing has changed after a couple of buffer swaps
2227 application.Render(0);
2228 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2229 application.Render(0);
2230 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2234 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2236 TestApplication application;
2238 Actor actor = Actor::New();
2240 // Register a Vector4 property
2241 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2242 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2243 Stage::GetCurrent().Add(actor);
2244 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2246 // Build the animation
2247 float durationSeconds(1.0f);
2248 Animation animation = Animation::New(durationSeconds);
2249 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2250 Vector4 relativeValue(targetValue - startValue);
2252 animation.AnimateBy(Property(actor, index),
2254 AlphaFunctions::Linear,
2255 TimePeriod(delay, durationSeconds - delay));
2257 // Start the animation
2260 bool signalReceived(false);
2261 AnimationFinishCheck finishCheck(signalReceived);
2262 animation.FinishedSignal().Connect(&application, finishCheck);
2264 application.SendNotification();
2265 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2267 // We didn't expect the animation to finish yet
2268 application.SendNotification();
2269 finishCheck.CheckSignalNotReceived();
2270 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2272 application.SendNotification();
2273 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2275 // We didn't expect the animation to finish yet
2276 application.SendNotification();
2277 finishCheck.CheckSignalNotReceived();
2278 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2280 application.SendNotification();
2281 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2283 // We did expect the animation to finish
2284 application.SendNotification();
2285 finishCheck.CheckSignalReceived();
2286 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2288 // Check that nothing has changed after a couple of buffer swaps
2289 application.Render(0);
2290 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2291 application.Render(0);
2292 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2296 int UtcDaliAnimationAnimateByActorPosition(void)
2298 TestApplication application;
2300 Actor actor = Actor::New();
2301 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2302 actor.SetPosition(startPosition);
2303 Stage::GetCurrent().Add(actor);
2304 application.SendNotification();
2305 application.Render(0);
2306 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2308 // Build the animation
2309 float durationSeconds(1.0f);
2310 Animation animation = Animation::New(durationSeconds);
2311 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2312 Vector3 relativePosition(targetPosition - startPosition);
2313 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
2315 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2317 // Start the animation
2320 bool signalReceived(false);
2321 AnimationFinishCheck finishCheck(signalReceived);
2322 animation.FinishedSignal().Connect(&application, finishCheck);
2324 application.SendNotification();
2325 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2327 // We didn't expect the animation to finish yet
2328 application.SendNotification();
2329 finishCheck.CheckSignalNotReceived();
2330 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
2332 application.SendNotification();
2333 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2335 // We did expect the animation to finish
2336 application.SendNotification();
2337 finishCheck.CheckSignalReceived();
2338 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2340 // Check that nothing has changed after a couple of buffer swaps
2341 application.Render(0);
2342 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2343 application.Render(0);
2344 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2348 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
2350 TestApplication application;
2352 Actor actor = Actor::New();
2353 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2354 actor.SetPosition(startPosition);
2355 Stage::GetCurrent().Add(actor);
2356 application.SendNotification();
2357 application.Render(0);
2358 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2360 // Build the animation
2361 float durationSeconds(1.0f);
2362 Animation animation = Animation::New(durationSeconds);
2363 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2364 Vector3 relativePosition(targetPosition - startPosition);
2365 animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
2367 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2369 // Start the animation
2372 bool signalReceived(false);
2373 AnimationFinishCheck finishCheck(signalReceived);
2374 animation.FinishedSignal().Connect(&application, finishCheck);
2376 application.SendNotification();
2377 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2379 // We didn't expect the animation to finish yet
2380 application.SendNotification();
2381 finishCheck.CheckSignalNotReceived();
2383 // The position should have moved more, than with a linear alpha function
2384 Vector3 current(actor.GetCurrentPosition());
2385 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
2386 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
2387 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
2389 application.SendNotification();
2390 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2392 // We did expect the animation to finish
2393 application.SendNotification();
2394 finishCheck.CheckSignalReceived();
2395 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2397 // Check that nothing has changed after a couple of buffer swaps
2398 application.Render(0);
2399 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2400 application.Render(0);
2401 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2405 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
2407 TestApplication application;
2409 Actor actor = Actor::New();
2410 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2411 actor.SetPosition(startPosition);
2412 Stage::GetCurrent().Add(actor);
2413 application.SendNotification();
2414 application.Render(0);
2415 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2417 // Build the animation
2418 float durationSeconds(1.0f);
2419 Animation animation = Animation::New(durationSeconds);
2420 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2421 Vector3 relativePosition(targetPosition - startPosition);
2423 animation.AnimateBy(Property(actor, Actor::POSITION),
2425 TimePeriod(delay, durationSeconds - delay));
2427 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2429 // Start the animation
2432 bool signalReceived(false);
2433 AnimationFinishCheck finishCheck(signalReceived);
2434 animation.FinishedSignal().Connect(&application, finishCheck);
2436 application.SendNotification();
2437 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2439 // We didn't expect the animation to finish yet
2440 application.SendNotification();
2441 finishCheck.CheckSignalNotReceived();
2442 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2444 application.SendNotification();
2445 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2447 // We did expect the animation to finish
2448 application.SendNotification();
2449 finishCheck.CheckSignalReceived();
2450 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2452 // Check that nothing has changed after a couple of buffer swaps
2453 application.Render(0);
2454 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2455 application.Render(0);
2456 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2460 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
2462 TestApplication application;
2464 Actor actor = Actor::New();
2465 Vector3 startPosition(10.0f, 10.0f, 10.0f);
2466 actor.SetPosition(startPosition);
2467 Stage::GetCurrent().Add(actor);
2468 application.SendNotification();
2469 application.Render(0);
2470 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2472 // Build the animation
2473 float durationSeconds(1.0f);
2474 Animation animation = Animation::New(durationSeconds);
2475 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
2476 Vector3 relativePosition(targetPosition - startPosition);
2478 animation.AnimateBy(Property(actor, Actor::POSITION),
2480 AlphaFunctions::Linear,
2481 TimePeriod(delay, durationSeconds - delay));
2483 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
2485 // Start the animation
2488 bool signalReceived(false);
2489 AnimationFinishCheck finishCheck(signalReceived);
2490 animation.FinishedSignal().Connect(&application, finishCheck);
2492 application.SendNotification();
2493 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2495 // We didn't expect the animation to finish yet
2496 application.SendNotification();
2497 finishCheck.CheckSignalNotReceived();
2498 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
2500 application.SendNotification();
2501 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2503 // We did expect the animation to finish
2504 application.SendNotification();
2505 finishCheck.CheckSignalReceived();
2506 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2508 // Check that nothing has changed after a couple of buffer swaps
2509 application.Render(0);
2510 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2511 application.Render(0);
2512 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2516 int UtcDaliAnimationAnimateToBoolean(void)
2518 TestApplication application;
2520 Actor actor = Actor::New();
2522 // Register a boolean property
2523 const bool startValue(false);
2524 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2525 Stage::GetCurrent().Add(actor);
2526 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2528 // Build the animation
2529 float durationSeconds(2.0f);
2530 Animation animation = Animation::New(durationSeconds);
2531 const bool targetValue( !startValue );
2532 animation.AnimateTo(Property(actor, index), targetValue);
2534 // Start the animation
2537 bool signalReceived(false);
2538 AnimationFinishCheck finishCheck(signalReceived);
2539 animation.FinishedSignal().Connect(&application, finishCheck);
2541 application.SendNotification();
2542 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2544 // We didn't expect the animation to finish yet
2545 application.SendNotification();
2546 finishCheck.CheckSignalNotReceived();
2547 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2549 application.SendNotification();
2550 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2552 // We did expect the animation to finish
2553 application.SendNotification();
2554 finishCheck.CheckSignalReceived();
2555 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2557 // Check that nothing has changed after a couple of buffer swaps
2558 application.Render(0);
2559 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2560 application.Render(0);
2561 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2563 // Repeat with target value "false"
2564 animation = Animation::New(durationSeconds);
2565 const bool finalValue( !targetValue );
2566 animation.AnimateTo(Property(actor, index), finalValue);
2568 // Start the animation
2571 finishCheck.Reset();
2572 animation.FinishedSignal().Connect(&application, finishCheck);
2574 application.SendNotification();
2575 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2577 // We didn't expect the animation to finish yet
2578 application.SendNotification();
2579 finishCheck.CheckSignalNotReceived();
2580 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2582 application.SendNotification();
2583 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2585 // We did expect the animation to finish
2586 application.SendNotification();
2587 finishCheck.CheckSignalReceived();
2588 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2590 // Check that nothing has changed after a couple of buffer swaps
2591 application.Render(0);
2592 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2593 application.Render(0);
2594 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2598 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
2600 TestApplication application;
2602 Actor actor = Actor::New();
2604 // Register a boolean property
2605 const bool startValue(false);
2606 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2607 Stage::GetCurrent().Add(actor);
2608 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2610 // Build the animation
2611 float durationSeconds(2.0f);
2612 Animation animation = Animation::New(durationSeconds);
2613 const bool targetValue( !startValue );
2614 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
2616 // Start the animation
2619 bool signalReceived(false);
2620 AnimationFinishCheck finishCheck(signalReceived);
2621 animation.FinishedSignal().Connect(&application, finishCheck);
2623 application.SendNotification();
2624 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2626 // We didn't expect the animation to finish yet
2627 application.SendNotification();
2628 finishCheck.CheckSignalNotReceived();
2629 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2631 application.SendNotification();
2632 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2634 // We did expect the animation to finish
2635 application.SendNotification();
2636 finishCheck.CheckSignalReceived();
2637 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2639 // Check that nothing has changed after a couple of buffer swaps
2640 application.Render(0);
2641 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2642 application.Render(0);
2643 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2645 // Repeat with target value "false"
2646 animation = Animation::New(durationSeconds);
2647 const bool finalValue( !targetValue );
2648 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
2650 // Start the animation
2653 finishCheck.Reset();
2654 animation.FinishedSignal().Connect(&application, finishCheck);
2656 application.SendNotification();
2657 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2659 // We didn't expect the animation to finish yet
2660 application.SendNotification();
2661 finishCheck.CheckSignalNotReceived();
2662 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
2664 application.SendNotification();
2665 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2667 // We did expect the animation to finish
2668 application.SendNotification();
2669 finishCheck.CheckSignalReceived();
2670 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2672 // Check that nothing has changed after a couple of buffer swaps
2673 application.Render(0);
2674 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2675 application.Render(0);
2676 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2680 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
2682 TestApplication application;
2684 Actor actor = Actor::New();
2686 // Register a boolean property
2687 bool startValue(false);
2688 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2689 Stage::GetCurrent().Add(actor);
2690 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2692 // Build the animation
2693 float durationSeconds(2.0f);
2694 Animation animation = Animation::New(durationSeconds);
2695 bool finalValue( !startValue );
2696 float animatorDurationSeconds(durationSeconds * 0.5f);
2697 animation.AnimateTo( Property(actor, index),
2699 TimePeriod( animatorDurationSeconds ) );
2701 // Start the animation
2704 bool signalReceived(false);
2705 AnimationFinishCheck finishCheck(signalReceived);
2706 animation.FinishedSignal().Connect(&application, finishCheck);
2708 application.SendNotification();
2709 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2711 // We didn't expect the animation to finish yet
2712 application.SendNotification();
2713 finishCheck.CheckSignalNotReceived();
2714 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2716 application.SendNotification();
2717 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2719 // We didn't expect the animation to finish yet...
2720 application.SendNotification();
2721 finishCheck.CheckSignalNotReceived();
2723 // ...however we should have reached the final value
2724 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2726 application.SendNotification();
2727 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2729 // We did expect the animation to finish
2730 application.SendNotification();
2731 finishCheck.CheckSignalReceived();
2732 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2734 // Check that nothing has changed after a couple of buffer swaps
2735 application.Render(0);
2736 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2737 application.Render(0);
2738 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2742 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
2744 TestApplication application;
2746 Actor actor = Actor::New();
2748 // Register a boolean property
2749 bool startValue(false);
2750 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2751 Stage::GetCurrent().Add(actor);
2752 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2754 // Build the animation
2755 float durationSeconds(2.0f);
2756 Animation animation = Animation::New(durationSeconds);
2757 bool finalValue( !startValue );
2758 float animatorDurationSeconds(durationSeconds * 0.5f);
2759 animation.AnimateTo( Property(actor, index),
2761 AlphaFunctions::Linear,
2762 TimePeriod( animatorDurationSeconds ) );
2764 // Start the animation
2767 bool signalReceived(false);
2768 AnimationFinishCheck finishCheck(signalReceived);
2769 animation.FinishedSignal().Connect(&application, finishCheck);
2771 application.SendNotification();
2772 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2774 // We didn't expect the animation to finish yet
2775 application.SendNotification();
2776 finishCheck.CheckSignalNotReceived();
2777 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2779 application.SendNotification();
2780 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2782 // We didn't expect the animation to finish yet...
2783 application.SendNotification();
2784 finishCheck.CheckSignalNotReceived();
2786 // ...however we should have reached the final value
2787 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2789 application.SendNotification();
2790 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2792 // We did expect the animation to finish
2793 application.SendNotification();
2794 finishCheck.CheckSignalReceived();
2795 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2797 // Check that nothing has changed after a couple of buffer swaps
2798 application.Render(0);
2799 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2800 application.Render(0);
2801 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2805 int UtcDaliAnimationAnimateToFloat(void)
2807 TestApplication application;
2809 Actor actor = Actor::New();
2811 // Register a float property
2812 float startValue(10.0f);
2813 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2814 Stage::GetCurrent().Add(actor);
2815 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2817 // Build the animation
2818 float durationSeconds(2.0f);
2819 Animation animation = Animation::New(durationSeconds);
2820 float targetValue(50.0f);
2821 float relativeValue(targetValue - startValue);
2822 animation.AnimateTo(Property(actor, "test-property"), targetValue);
2824 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2826 // Start the animation
2829 bool signalReceived(false);
2830 AnimationFinishCheck finishCheck(signalReceived);
2831 animation.FinishedSignal().Connect(&application, finishCheck);
2833 application.SendNotification();
2834 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2836 // We didn't expect the animation to finish yet
2837 application.SendNotification();
2838 finishCheck.CheckSignalNotReceived();
2839 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
2841 application.SendNotification();
2842 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2844 // We did expect the animation to finish
2845 application.SendNotification();
2846 finishCheck.CheckSignalReceived();
2847 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2851 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
2853 TestApplication application;
2855 Actor actor = Actor::New();
2857 // Register a float property
2858 float startValue(10.0f);
2859 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2860 Stage::GetCurrent().Add(actor);
2861 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2863 // Build the animation
2864 float durationSeconds(1.0f);
2865 Animation animation = Animation::New(durationSeconds);
2866 float targetValue(90.0f);
2867 float relativeValue(targetValue - startValue);
2868 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
2870 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2872 // Start the animation
2875 bool signalReceived(false);
2876 AnimationFinishCheck finishCheck(signalReceived);
2877 animation.FinishedSignal().Connect(&application, finishCheck);
2879 application.SendNotification();
2880 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2882 // We didn't expect the animation to finish yet
2883 application.SendNotification();
2884 finishCheck.CheckSignalNotReceived();
2886 // The position should have moved more, than with a linear alpha function
2887 float current(actor.GetProperty<float>(index));
2888 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2890 application.SendNotification();
2891 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2893 // We did expect the animation to finish
2894 application.SendNotification();
2895 finishCheck.CheckSignalReceived();
2896 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2900 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
2902 TestApplication application;
2904 Actor actor = Actor::New();
2906 // Register a float property
2907 float startValue(10.0f);
2908 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2909 Stage::GetCurrent().Add(actor);
2910 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2912 // Build the animation
2913 float durationSeconds(1.0f);
2914 Animation animation = Animation::New(durationSeconds);
2915 float targetValue(30.0f);
2916 float relativeValue(targetValue - startValue);
2918 animation.AnimateTo(Property(actor, index),
2920 TimePeriod(delay, durationSeconds - delay));
2922 // Start the animation
2925 bool signalReceived(false);
2926 AnimationFinishCheck finishCheck(signalReceived);
2927 animation.FinishedSignal().Connect(&application, finishCheck);
2929 application.SendNotification();
2930 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2932 // We didn't expect the animation to finish yet
2933 application.SendNotification();
2934 finishCheck.CheckSignalNotReceived();
2935 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2937 application.SendNotification();
2938 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2940 // We didn't expect the animation to finish yet
2941 application.SendNotification();
2942 finishCheck.CheckSignalNotReceived();
2943 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2945 application.SendNotification();
2946 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2948 // We did expect the animation to finish
2949 application.SendNotification();
2950 finishCheck.CheckSignalReceived();
2951 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2955 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
2957 TestApplication application;
2959 Actor actor = Actor::New();
2961 // Register a float property
2962 float startValue(10.0f);
2963 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2964 Stage::GetCurrent().Add(actor);
2965 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2967 // Build the animation
2968 float durationSeconds(1.0f);
2969 Animation animation = Animation::New(durationSeconds);
2970 float targetValue(30.0f);
2971 float relativeValue(targetValue - startValue);
2973 animation.AnimateTo(Property(actor, index),
2975 AlphaFunctions::Linear,
2976 TimePeriod(delay, durationSeconds - delay));
2978 // Start the animation
2981 bool signalReceived(false);
2982 AnimationFinishCheck finishCheck(signalReceived);
2983 animation.FinishedSignal().Connect(&application, finishCheck);
2985 application.SendNotification();
2986 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2988 // We didn't expect the animation to finish yet
2989 application.SendNotification();
2990 finishCheck.CheckSignalNotReceived();
2991 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2993 application.SendNotification();
2994 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2996 // We didn't expect the animation to finish yet
2997 application.SendNotification();
2998 finishCheck.CheckSignalNotReceived();
2999 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3001 application.SendNotification();
3002 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3004 // We did expect the animation to finish
3005 application.SendNotification();
3006 finishCheck.CheckSignalReceived();
3007 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3011 int UtcDaliAnimationAnimateToVector2(void)
3013 TestApplication application;
3015 Actor actor = Actor::New();
3017 // Register a Vector2 property
3018 Vector2 startValue(-50.0f, -50.0f);
3019 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3020 Stage::GetCurrent().Add(actor);
3021 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3023 // Build the animation
3024 float durationSeconds(2.0f);
3025 Animation animation = Animation::New(durationSeconds);
3026 Vector2 targetValue(50.0f, 50.0f);
3027 Vector2 relativeValue(targetValue - startValue);
3028 animation.AnimateTo(Property(actor, index), targetValue);
3030 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3032 // Start the animation
3035 bool signalReceived(false);
3036 AnimationFinishCheck finishCheck(signalReceived);
3037 animation.FinishedSignal().Connect(&application, finishCheck);
3039 application.SendNotification();
3040 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3042 // We didn't expect the animation to finish yet
3043 application.SendNotification();
3044 finishCheck.CheckSignalNotReceived();
3045 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3047 application.SendNotification();
3048 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3050 // We did expect the animation to finish
3051 application.SendNotification();
3052 finishCheck.CheckSignalReceived();
3053 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3057 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
3059 TestApplication application;
3061 Actor actor = Actor::New();
3063 // Register a Vector2 property
3064 Vector2 startValue(1000.0f, 1000.0f);
3065 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3066 Stage::GetCurrent().Add(actor);
3067 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3069 // Build the animation
3070 float durationSeconds(1.0f);
3071 Animation animation = Animation::New(durationSeconds);
3072 Vector2 targetValue(9000.0f, 9000.0f);
3073 Vector2 relativeValue(targetValue - startValue);
3074 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3076 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3078 // Start the animation
3081 bool signalReceived(false);
3082 AnimationFinishCheck finishCheck(signalReceived);
3083 animation.FinishedSignal().Connect(&application, finishCheck);
3085 application.SendNotification();
3086 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3088 // We didn't expect the animation to finish yet
3089 application.SendNotification();
3090 finishCheck.CheckSignalNotReceived();
3092 // The position should have moved more, than with a linear alpha function
3093 Vector2 current(actor.GetProperty<Vector2>(index));
3094 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3095 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3097 application.SendNotification();
3098 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3100 // We did expect the animation to finish
3101 application.SendNotification();
3102 finishCheck.CheckSignalReceived();
3103 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3107 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
3109 TestApplication application;
3111 Actor actor = Actor::New();
3113 // Register a Vector2 property
3114 Vector2 startValue(10.0f, 10.0f);
3115 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3116 Stage::GetCurrent().Add(actor);
3117 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3119 // Build the animation
3120 float durationSeconds(1.0f);
3121 Animation animation = Animation::New(durationSeconds);
3122 Vector2 targetValue(-10.0f, 20.0f);
3123 Vector2 relativeValue(targetValue - startValue);
3125 animation.AnimateTo(Property(actor, index),
3127 TimePeriod(delay, durationSeconds - delay));
3129 // Start the animation
3132 bool signalReceived(false);
3133 AnimationFinishCheck finishCheck(signalReceived);
3134 animation.FinishedSignal().Connect(&application, finishCheck);
3136 application.SendNotification();
3137 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3139 // We didn't expect the animation to finish yet
3140 application.SendNotification();
3141 finishCheck.CheckSignalNotReceived();
3142 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3144 application.SendNotification();
3145 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3147 // We didn't expect the animation to finish yet
3148 application.SendNotification();
3149 finishCheck.CheckSignalNotReceived();
3150 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3152 application.SendNotification();
3153 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3155 // We did expect the animation to finish
3156 application.SendNotification();
3157 finishCheck.CheckSignalReceived();
3158 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3162 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
3164 TestApplication application;
3166 Actor actor = Actor::New();
3168 // Register a Vector2 property
3169 Vector2 startValue(10.0f, 10.0f);
3170 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3171 Stage::GetCurrent().Add(actor);
3172 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3174 // Build the animation
3175 float durationSeconds(1.0f);
3176 Animation animation = Animation::New(durationSeconds);
3177 Vector2 targetValue(30.0f, 30.0f);
3178 Vector2 relativeValue(targetValue - startValue);
3180 animation.AnimateTo(Property(actor, index),
3182 AlphaFunctions::Linear,
3183 TimePeriod(delay, durationSeconds - delay));
3185 // Start the animation
3188 bool signalReceived(false);
3189 AnimationFinishCheck finishCheck(signalReceived);
3190 animation.FinishedSignal().Connect(&application, finishCheck);
3192 application.SendNotification();
3193 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3195 // We didn't expect the animation to finish yet
3196 application.SendNotification();
3197 finishCheck.CheckSignalNotReceived();
3198 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3200 application.SendNotification();
3201 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3203 // We didn't expect the animation to finish yet
3204 application.SendNotification();
3205 finishCheck.CheckSignalNotReceived();
3206 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3208 application.SendNotification();
3209 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3211 // We did expect the animation to finish
3212 application.SendNotification();
3213 finishCheck.CheckSignalReceived();
3214 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3218 int UtcDaliAnimationAnimateToVector3(void)
3220 TestApplication application;
3222 Actor actor = Actor::New();
3224 // Register a Vector3 property
3225 Vector3 startValue(-50.0f, -50.0f, -50.0f);
3226 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3227 Stage::GetCurrent().Add(actor);
3228 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3230 // Build the animation
3231 float durationSeconds(2.0f);
3232 Animation animation = Animation::New(durationSeconds);
3233 Vector3 targetValue(50.0f, 50.0f, 50.0f);
3234 Vector3 relativeValue(targetValue - startValue);
3235 animation.AnimateTo(Property(actor, index), targetValue);
3237 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3239 // Start the animation
3242 bool signalReceived(false);
3243 AnimationFinishCheck finishCheck(signalReceived);
3244 animation.FinishedSignal().Connect(&application, finishCheck);
3246 application.SendNotification();
3247 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3249 // We didn't expect the animation to finish yet
3250 application.SendNotification();
3251 finishCheck.CheckSignalNotReceived();
3252 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
3254 application.SendNotification();
3255 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3257 // We did expect the animation to finish
3258 application.SendNotification();
3259 finishCheck.CheckSignalReceived();
3260 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3264 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
3266 TestApplication application;
3268 Actor actor = Actor::New();
3270 // Register a Vector3 property
3271 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
3272 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3273 Stage::GetCurrent().Add(actor);
3274 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3276 // Build the animation
3277 float durationSeconds(1.0f);
3278 Animation animation = Animation::New(durationSeconds);
3279 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
3280 Vector3 relativeValue(targetValue - startValue);
3281 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3283 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3285 // Start the animation
3288 bool signalReceived(false);
3289 AnimationFinishCheck finishCheck(signalReceived);
3290 animation.FinishedSignal().Connect(&application, finishCheck);
3292 application.SendNotification();
3293 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3295 // We didn't expect the animation to finish yet
3296 application.SendNotification();
3297 finishCheck.CheckSignalNotReceived();
3299 // The position should have moved more, than with a linear alpha function
3300 Vector3 current(actor.GetProperty<Vector3>(index));
3301 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3302 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3303 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3305 application.SendNotification();
3306 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3308 // We did expect the animation to finish
3309 application.SendNotification();
3310 finishCheck.CheckSignalReceived();
3311 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3315 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
3317 TestApplication application;
3319 Actor actor = Actor::New();
3321 // Register a Vector3 property
3322 Vector3 startValue(10.0f, 10.0f, 10.0f);
3323 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3324 Stage::GetCurrent().Add(actor);
3325 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3327 // Build the animation
3328 float durationSeconds(1.0f);
3329 Animation animation = Animation::New(durationSeconds);
3330 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
3331 Vector3 relativeValue(targetValue - startValue);
3333 animation.AnimateTo(Property(actor, index),
3335 TimePeriod(delay, durationSeconds - delay));
3337 // Start the animation
3340 bool signalReceived(false);
3341 AnimationFinishCheck finishCheck(signalReceived);
3342 animation.FinishedSignal().Connect(&application, finishCheck);
3344 application.SendNotification();
3345 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3347 // We didn't expect the animation to finish yet
3348 application.SendNotification();
3349 finishCheck.CheckSignalNotReceived();
3350 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3352 application.SendNotification();
3353 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3355 // We didn't expect the animation to finish yet
3356 application.SendNotification();
3357 finishCheck.CheckSignalNotReceived();
3358 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3360 application.SendNotification();
3361 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3363 // We did expect the animation to finish
3364 application.SendNotification();
3365 finishCheck.CheckSignalReceived();
3366 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3370 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
3372 TestApplication application;
3374 Actor actor = Actor::New();
3376 // Register a Vector3 property
3377 Vector3 startValue(10.0f, 10.0f, 10.0f);
3378 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3379 Stage::GetCurrent().Add(actor);
3380 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3382 // Build the animation
3383 float durationSeconds(1.0f);
3384 Animation animation = Animation::New(durationSeconds);
3385 Vector3 targetValue(30.0f, 30.0f, 30.0f);
3386 Vector3 relativeValue(targetValue - startValue);
3388 animation.AnimateTo(Property(actor, "test-property"),
3390 AlphaFunctions::Linear,
3391 TimePeriod(delay, durationSeconds - delay));
3393 // Start the animation
3396 bool signalReceived(false);
3397 AnimationFinishCheck finishCheck(signalReceived);
3398 animation.FinishedSignal().Connect(&application, finishCheck);
3400 application.SendNotification();
3401 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3403 // We didn't expect the animation to finish yet
3404 application.SendNotification();
3405 finishCheck.CheckSignalNotReceived();
3406 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3408 application.SendNotification();
3409 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3411 // We didn't expect the animation to finish yet
3412 application.SendNotification();
3413 finishCheck.CheckSignalNotReceived();
3414 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3416 application.SendNotification();
3417 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3419 // We did expect the animation to finish
3420 application.SendNotification();
3421 finishCheck.CheckSignalReceived();
3422 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3426 int UtcDaliAnimationAnimateToVector3Component(void)
3428 TestApplication application;
3430 Actor actor = Actor::New();
3432 // Register a Vector3 property
3433 Vector3 startValue(10.0f, 10.0f, 10.0f);
3434 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3435 Stage::GetCurrent().Add(actor);
3436 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3438 // Build the animation
3439 float durationSeconds(1.0f);
3440 Animation animation = Animation::New(durationSeconds);
3441 Vector3 targetValue(30.0f, 30.0f, 10.0f);
3442 Vector3 relativeValue(targetValue - startValue);
3444 animation.AnimateTo(Property(actor, "test-property", 0),
3446 AlphaFunctions::Linear,
3447 TimePeriod(delay, durationSeconds - delay));
3448 animation.AnimateTo(Property(actor, index, 1),
3450 AlphaFunctions::Linear,
3451 TimePeriod(delay, durationSeconds - delay));
3453 // Start the animation
3456 bool signalReceived(false);
3457 AnimationFinishCheck finishCheck(signalReceived);
3458 animation.FinishedSignal().Connect(&application, finishCheck);
3460 application.SendNotification();
3461 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3463 // We didn't expect the animation to finish yet
3464 application.SendNotification();
3465 finishCheck.CheckSignalNotReceived();
3466 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3468 application.SendNotification();
3469 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3471 // We didn't expect the animation to finish yet
3472 application.SendNotification();
3473 finishCheck.CheckSignalNotReceived();
3474 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3476 application.SendNotification();
3477 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3479 // We did expect the animation to finish
3480 application.SendNotification();
3481 finishCheck.CheckSignalReceived();
3482 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3486 int UtcDaliAnimationAnimateToVector4(void)
3488 TestApplication application;
3490 Actor actor = Actor::New();
3492 // Register a Vector4 property
3493 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
3494 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3495 Stage::GetCurrent().Add(actor);
3496 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3498 // Build the animation
3499 float durationSeconds(2.0f);
3500 Animation animation = Animation::New(durationSeconds);
3501 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
3502 Vector4 relativeValue(targetValue - startValue);
3503 animation.AnimateTo(Property(actor, index), targetValue);
3505 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3507 // Start the animation
3510 bool signalReceived(false);
3511 AnimationFinishCheck finishCheck(signalReceived);
3512 animation.FinishedSignal().Connect(&application, finishCheck);
3514 application.SendNotification();
3515 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3517 // We didn't expect the animation to finish yet
3518 application.SendNotification();
3519 finishCheck.CheckSignalNotReceived();
3520 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
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<Vector4>(index), targetValue, TEST_LOCATION );
3532 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
3534 TestApplication application;
3536 Actor actor = Actor::New();
3538 // Register a Vector4 property
3539 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
3540 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3541 Stage::GetCurrent().Add(actor);
3542 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3544 // Build the animation
3545 float durationSeconds(1.0f);
3546 Animation animation = Animation::New(durationSeconds);
3547 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
3548 Vector4 relativeValue(targetValue - startValue);
3549 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3551 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3553 // Start the animation
3556 bool signalReceived(false);
3557 AnimationFinishCheck finishCheck(signalReceived);
3558 animation.FinishedSignal().Connect(&application, finishCheck);
3560 application.SendNotification();
3561 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3563 // We didn't expect the animation to finish yet
3564 application.SendNotification();
3565 finishCheck.CheckSignalNotReceived();
3567 // The position should have moved more, than with a linear alpha function
3568 Vector4 current(actor.GetProperty<Vector4>(index));
3569 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3570 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3571 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3572 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
3574 application.SendNotification();
3575 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3577 // We did expect the animation to finish
3578 application.SendNotification();
3579 finishCheck.CheckSignalReceived();
3580 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3584 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
3586 TestApplication application;
3588 Actor actor = Actor::New();
3590 // Register a Vector4 property
3591 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3592 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3593 Stage::GetCurrent().Add(actor);
3594 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
3596 // Build the animation
3597 float durationSeconds(1.0f);
3598 Animation animation = Animation::New(durationSeconds);
3599 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
3600 Vector4 relativeValue(targetValue - startValue);
3602 animation.AnimateTo(Property(actor, index),
3604 TimePeriod(delay, durationSeconds - delay));
3606 // Start the animation
3609 bool signalReceived(false);
3610 AnimationFinishCheck finishCheck(signalReceived);
3611 animation.FinishedSignal().Connect(&application, finishCheck);
3613 application.SendNotification();
3614 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3616 // We didn't expect the animation to finish yet
3617 application.SendNotification();
3618 finishCheck.CheckSignalNotReceived();
3619 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
3621 application.SendNotification();
3622 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3624 // We didn't expect the animation to finish yet
3625 application.SendNotification();
3626 finishCheck.CheckSignalNotReceived();
3627 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
3629 application.SendNotification();
3630 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3632 // We did expect the animation to finish
3633 application.SendNotification();
3634 finishCheck.CheckSignalReceived();
3635 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
3639 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
3641 TestApplication application;
3643 Actor actor = Actor::New();
3645 // Register a Vector4 property
3646 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3647 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3648 Stage::GetCurrent().Add(actor);
3649 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3651 // Build the animation
3652 float durationSeconds(1.0f);
3653 Animation animation = Animation::New(durationSeconds);
3654 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3655 Vector4 relativeValue(targetValue - startValue);
3657 animation.AnimateTo(Property(actor, index),
3659 AlphaFunctions::Linear,
3660 TimePeriod(delay, durationSeconds - delay));
3662 // Start the animation
3665 bool signalReceived(false);
3666 AnimationFinishCheck finishCheck(signalReceived);
3667 animation.FinishedSignal().Connect(&application, finishCheck);
3669 application.SendNotification();
3670 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3672 // We didn't expect the animation to finish yet
3673 application.SendNotification();
3674 finishCheck.CheckSignalNotReceived();
3675 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3677 application.SendNotification();
3678 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3680 // We didn't expect the animation to finish yet
3681 application.SendNotification();
3682 finishCheck.CheckSignalNotReceived();
3683 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3685 application.SendNotification();
3686 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3688 // We did expect the animation to finish
3689 application.SendNotification();
3690 finishCheck.CheckSignalReceived();
3691 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3695 int UtcDaliAnimationAnimateToActorParentOrigin(void)
3697 TestApplication application;
3699 Actor actor = Actor::New();
3700 Stage::GetCurrent().Add(actor);
3701 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3703 // Build the animation
3704 float durationSeconds(1.0f);
3705 Animation animation = Animation::New(durationSeconds);
3706 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
3710 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
3712 catch (Dali::DaliException& e)
3714 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3715 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3720 int UtcDaliAnimationAnimateToActorParentOriginX(void)
3722 TestApplication application;
3724 Actor actor = Actor::New();
3725 Stage::GetCurrent().Add(actor);
3726 float startValue(0.0f);
3727 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
3728 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
3730 // Build the animation
3731 float durationSeconds(1.0f);
3732 Animation animation = Animation::New(durationSeconds);
3733 float targetX(1.0f);
3737 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
3739 catch (Dali::DaliException& e)
3741 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3742 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3747 int UtcDaliAnimationAnimateToActorParentOriginY(void)
3749 TestApplication application;
3751 Actor actor = Actor::New();
3752 Stage::GetCurrent().Add(actor);
3753 float startValue(0.0f);
3754 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
3755 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
3757 // Build the animation
3758 float durationSeconds(1.0f);
3759 Animation animation = Animation::New(durationSeconds);
3760 float targetY(1.0f);
3764 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
3766 catch (Dali::DaliException& e)
3768 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3769 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3774 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
3776 TestApplication application;
3778 Actor actor = Actor::New();
3779 Stage::GetCurrent().Add(actor);
3780 float startValue(0.5f);
3781 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
3782 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
3784 // Build the animation
3785 float durationSeconds(1.0f);
3786 Animation animation = Animation::New(durationSeconds);
3787 float targetZ(1.0f);
3791 animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
3793 catch (Dali::DaliException& e)
3795 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3796 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3801 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
3803 TestApplication application;
3805 Actor actor = Actor::New();
3806 Stage::GetCurrent().Add(actor);
3807 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
3809 // Build the animation
3810 float durationSeconds(1.0f);
3811 Animation animation = Animation::New(durationSeconds);
3812 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
3816 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
3818 catch (Dali::DaliException& e)
3820 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3821 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3826 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
3828 TestApplication application;
3830 Actor actor = Actor::New();
3831 Stage::GetCurrent().Add(actor);
3832 float startValue(0.5f);
3833 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
3834 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
3836 // Build the animation
3837 float durationSeconds(1.0f);
3838 Animation animation = Animation::New(durationSeconds);
3839 float targetX(1.0f);
3843 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
3845 catch (Dali::DaliException& e)
3847 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3848 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3853 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
3855 TestApplication application;
3857 Actor actor = Actor::New();
3858 Stage::GetCurrent().Add(actor);
3859 float startValue(0.5f);
3860 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
3861 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
3863 // Build the animation
3864 float durationSeconds(1.0f);
3865 Animation animation = Animation::New(durationSeconds);
3866 float targetY(0.0f);
3870 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
3872 catch (Dali::DaliException& e)
3874 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3875 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3880 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
3882 TestApplication application;
3884 Actor actor = Actor::New();
3885 Stage::GetCurrent().Add(actor);
3886 float startValue(0.5f);
3887 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
3888 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
3890 // Build the animation
3891 float durationSeconds(1.0f);
3892 Animation animation = Animation::New(durationSeconds);
3893 float targetZ(100.0f);
3897 animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
3899 catch (Dali::DaliException& e)
3901 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
3902 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
3907 int UtcDaliAnimationAnimateToActorSize(void)
3909 TestApplication application;
3911 Actor actor = Actor::New();
3912 Stage::GetCurrent().Add(actor);
3913 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
3915 // Build the animation
3916 float durationSeconds(1.0f);
3917 Animation animation = Animation::New(durationSeconds);
3918 Vector3 targetSize(100.0f, 100.0f, 100.0f);
3919 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
3921 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
3923 // Start the animation
3926 bool signalReceived(false);
3927 AnimationFinishCheck finishCheck(signalReceived);
3928 animation.FinishedSignal().Connect(&application, finishCheck);
3930 application.SendNotification();
3931 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
3933 // We didn't expect the animation to finish yet
3934 application.SendNotification();
3935 finishCheck.CheckSignalNotReceived();
3936 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
3938 application.SendNotification();
3939 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
3941 // We did expect the animation to finish
3942 application.SendNotification();
3943 finishCheck.CheckSignalReceived();
3944 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
3947 finishCheck.Reset();
3948 actor.SetSize(Vector3::ZERO);
3949 application.SendNotification();
3950 application.Render(0);
3951 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
3953 // Repeat with a different (ease-in) alpha function
3954 animation = Animation::New(durationSeconds);
3955 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
3956 animation.FinishedSignal().Connect(&application, finishCheck);
3959 application.SendNotification();
3960 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
3962 // We didn't expect the animation to finish yet
3963 application.SendNotification();
3964 finishCheck.CheckSignalNotReceived();
3966 // The size should have travelled less, than with a linear alpha function
3967 Vector3 current(actor.GetCurrentSize());
3968 DALI_TEST_CHECK( current.x > 0.0f );
3969 DALI_TEST_CHECK( current.y > 0.0f );
3970 DALI_TEST_CHECK( current.z > 0.0f );
3971 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
3972 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
3973 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
3975 application.SendNotification();
3976 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
3978 // We did expect the animation to finish
3979 application.SendNotification();
3980 finishCheck.CheckSignalReceived();
3981 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
3984 finishCheck.Reset();
3985 actor.SetSize(Vector3::ZERO);
3986 application.SendNotification();
3987 application.Render(0);
3988 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
3990 // Repeat with a delay
3992 animation = Animation::New(durationSeconds);
3993 animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
3994 animation.FinishedSignal().Connect(&application, finishCheck);
3997 application.SendNotification();
3998 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4000 // We didn't expect the animation to finish yet
4001 application.SendNotification();
4002 finishCheck.CheckSignalNotReceived();
4003 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4005 application.SendNotification();
4006 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4008 // We did expect the animation to finish
4009 application.SendNotification();
4010 finishCheck.CheckSignalReceived();
4011 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4015 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4017 TestApplication application;
4019 Actor actor = Actor::New();
4020 Stage::GetCurrent().Add(actor);
4021 float startValue(0.0f);
4022 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4023 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
4025 // Build the animation
4026 float durationSeconds(1.0f);
4027 Animation animation = Animation::New(durationSeconds);
4028 float targetWidth(10.0f);
4029 animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
4031 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4033 // Start the animation
4036 bool signalReceived(false);
4037 AnimationFinishCheck finishCheck(signalReceived);
4038 animation.FinishedSignal().Connect(&application, finishCheck);
4040 application.SendNotification();
4041 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4043 // We didn't expect the animation to finish yet
4044 application.SendNotification();
4045 finishCheck.CheckSignalNotReceived();
4046 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4049 application.SendNotification();
4050 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4052 // We did expect the animation to finish
4053 application.SendNotification();
4054 finishCheck.CheckSignalReceived();
4055 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
4056 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
4060 int UtcDaliAnimationAnimateToActorSizeHeight(void)
4062 TestApplication application;
4064 Actor actor = Actor::New();
4065 Stage::GetCurrent().Add(actor);
4066 float startValue(0.0f);
4067 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
4068 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
4070 // Build the animation
4071 float durationSeconds(1.0f);
4072 Animation animation = Animation::New(durationSeconds);
4073 float targetHeight(-10.0f);
4074 animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
4076 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
4078 // Start the animation
4081 bool signalReceived(false);
4082 AnimationFinishCheck finishCheck(signalReceived);
4083 animation.FinishedSignal().Connect(&application, finishCheck);
4085 application.SendNotification();
4086 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4088 // We didn't expect the animation to finish yet
4089 application.SendNotification();
4090 finishCheck.CheckSignalNotReceived();
4091 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
4092 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
4094 application.SendNotification();
4095 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4097 // We did expect the animation to finish
4098 application.SendNotification();
4099 finishCheck.CheckSignalReceived();
4100 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
4101 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
4105 int UtcDaliAnimationAnimateToActorSizeDepth(void)
4107 TestApplication application;
4109 Actor actor = Actor::New();
4110 Stage::GetCurrent().Add(actor);
4111 float startValue(0.0f);
4112 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
4113 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
4115 // Build the animation
4116 float durationSeconds(1.0f);
4117 Animation animation = Animation::New(durationSeconds);
4118 float targetDepth(-10.0f);
4119 animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
4121 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
4123 // Start the animation
4126 bool signalReceived(false);
4127 AnimationFinishCheck finishCheck(signalReceived);
4128 animation.FinishedSignal().Connect(&application, finishCheck);
4130 application.SendNotification();
4131 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4133 // We didn't expect the animation to finish yet
4134 application.SendNotification();
4135 finishCheck.CheckSignalNotReceived();
4136 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
4137 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
4139 application.SendNotification();
4140 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4142 // We did expect the animation to finish
4143 application.SendNotification();
4144 finishCheck.CheckSignalReceived();
4145 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
4146 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
4150 int UtcDaliAnimationAnimateToActorPosition(void)
4152 TestApplication application;
4154 Actor actor = Actor::New();
4155 Stage::GetCurrent().Add(actor);
4156 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4158 // Build the animation
4159 float durationSeconds(1.0f);
4160 Animation animation = Animation::New(durationSeconds);
4161 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4162 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
4164 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4166 // Start the animation
4169 bool signalReceived(false);
4170 AnimationFinishCheck finishCheck(signalReceived);
4171 animation.FinishedSignal().Connect(&application, finishCheck);
4173 application.SendNotification();
4174 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4176 // We didn't expect the animation to finish yet
4177 application.SendNotification();
4178 finishCheck.CheckSignalNotReceived();
4179 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4181 application.SendNotification();
4182 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4184 // We did expect the animation to finish
4185 application.SendNotification();
4186 finishCheck.CheckSignalReceived();
4187 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4191 int UtcDaliAnimationAnimateToActorPositionX(void)
4193 TestApplication application;
4195 Actor actor = Actor::New();
4196 Stage::GetCurrent().Add(actor);
4197 float startValue(0.0f);
4198 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
4199 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4200 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4201 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4203 // Build the animation
4204 float durationSeconds(1.0f);
4205 Animation animation = Animation::New(durationSeconds);
4206 float targetX(1.0f);
4207 animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
4209 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
4211 // Start the animation
4214 bool signalReceived(false);
4215 AnimationFinishCheck finishCheck(signalReceived);
4216 animation.FinishedSignal().Connect(&application, finishCheck);
4218 application.SendNotification();
4219 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4221 // We didn't expect the animation to finish yet
4222 application.SendNotification();
4223 finishCheck.CheckSignalNotReceived();
4224 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
4225 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
4226 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4227 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4229 application.SendNotification();
4230 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4232 // We did expect the animation to finish
4233 application.SendNotification();
4234 finishCheck.CheckSignalReceived();
4235 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
4236 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
4237 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4238 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4242 int UtcDaliAnimationAnimateToActorPositionY(void)
4244 TestApplication application;
4246 Actor actor = Actor::New();
4247 Stage::GetCurrent().Add(actor);
4248 float startValue(0.0f);
4249 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
4250 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4251 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4252 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4254 // Build the animation
4255 float durationSeconds(1.0f);
4256 Animation animation = Animation::New(durationSeconds);
4257 float targetY(10.0f);
4258 animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
4260 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
4262 // Start the animation
4265 bool signalReceived(false);
4266 AnimationFinishCheck finishCheck(signalReceived);
4267 animation.FinishedSignal().Connect(&application, finishCheck);
4269 application.SendNotification();
4270 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4272 // We didn't expect the animation to finish yet
4273 application.SendNotification();
4274 finishCheck.CheckSignalNotReceived();
4275 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
4276 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4277 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
4278 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4280 application.SendNotification();
4281 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4283 // We did expect the animation to finish
4284 application.SendNotification();
4285 finishCheck.CheckSignalReceived();
4286 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
4287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4288 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
4289 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4293 int UtcDaliAnimationAnimateToActorPositionZ(void)
4295 TestApplication application;
4297 Actor actor = Actor::New();
4298 Stage::GetCurrent().Add(actor);
4299 float startValue(0.0f);
4300 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
4301 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4302 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4303 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
4305 // Build the animation
4306 float durationSeconds(1.0f);
4307 Animation animation = Animation::New(durationSeconds);
4308 float targetZ(-5.0f);
4309 animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
4311 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
4313 // Start the animation
4316 bool signalReceived(false);
4317 AnimationFinishCheck finishCheck(signalReceived);
4318 animation.FinishedSignal().Connect(&application, finishCheck);
4320 application.SendNotification();
4321 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4323 // We didn't expect the animation to finish yet
4324 application.SendNotification();
4325 finishCheck.CheckSignalNotReceived();
4326 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
4327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4328 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4329 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
4331 application.SendNotification();
4332 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4334 // We did expect the animation to finish
4335 application.SendNotification();
4336 finishCheck.CheckSignalReceived();
4337 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
4338 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
4339 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
4340 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
4344 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
4346 TestApplication application;
4348 Actor actor = Actor::New();
4349 Stage::GetCurrent().Add(actor);
4350 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4352 // Build the animation
4353 float durationSeconds(1.0f);
4354 Animation animation = Animation::New(durationSeconds);
4355 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4356 animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
4358 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4360 // Start the animation
4363 bool signalReceived(false);
4364 AnimationFinishCheck finishCheck(signalReceived);
4365 animation.FinishedSignal().Connect(&application, finishCheck);
4367 application.SendNotification();
4368 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
4370 // We didn't expect the animation to finish yet
4371 application.SendNotification();
4372 finishCheck.CheckSignalNotReceived();
4374 // The position should have moved less, than with a linear alpha function
4375 Vector3 current(actor.GetCurrentPosition());
4376 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
4377 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
4378 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
4379 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
4380 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
4381 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
4383 application.SendNotification();
4384 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4386 // We did expect the animation to finish
4387 application.SendNotification();
4388 finishCheck.CheckSignalReceived();
4389 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4393 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
4395 TestApplication application;
4397 Actor actor = Actor::New();
4398 Stage::GetCurrent().Add(actor);
4399 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4401 // Build the animation
4402 float durationSeconds(1.0f);
4403 Animation animation = Animation::New(durationSeconds);
4404 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4406 animation.AnimateTo( Property(actor, Actor::POSITION),
4408 TimePeriod( delay, durationSeconds - delay ) );
4410 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4412 // Start the animation
4415 bool signalReceived(false);
4416 AnimationFinishCheck finishCheck(signalReceived);
4417 animation.FinishedSignal().Connect(&application, finishCheck);
4419 application.SendNotification();
4420 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4422 // We didn't expect the animation to finish yet
4423 application.SendNotification();
4424 finishCheck.CheckSignalNotReceived();
4425 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4427 application.SendNotification();
4428 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
4430 // We didn't expect the animation to finish yet
4431 application.SendNotification();
4432 finishCheck.CheckSignalNotReceived();
4433 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4435 application.SendNotification();
4436 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
4438 // We did expect the animation to finish
4439 application.SendNotification();
4440 finishCheck.CheckSignalReceived();
4441 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4445 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
4447 TestApplication application;
4449 Actor actor = Actor::New();
4450 Stage::GetCurrent().Add(actor);
4451 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4453 // Build the animation
4454 float durationSeconds(1.0f);
4455 Animation animation = Animation::New(durationSeconds);
4456 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
4458 animation.AnimateTo( Property(actor, Actor::POSITION),
4460 AlphaFunctions::Linear,
4461 TimePeriod( delay, durationSeconds - delay ) );
4463 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
4465 // Start the animation
4468 bool signalReceived(false);
4469 AnimationFinishCheck finishCheck(signalReceived);
4470 animation.FinishedSignal().Connect(&application, finishCheck);
4472 application.SendNotification();
4473 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4475 // We didn't expect the animation to finish yet
4476 application.SendNotification();
4477 finishCheck.CheckSignalNotReceived();
4478 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4480 application.SendNotification();
4481 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
4483 // We didn't expect the animation to finish yet
4484 application.SendNotification();
4485 finishCheck.CheckSignalNotReceived();
4486 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
4488 application.SendNotification();
4489 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
4491 // We did expect the animation to finish
4492 application.SendNotification();
4493 finishCheck.CheckSignalReceived();
4494 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4498 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
4500 TestApplication application;
4502 Actor actor = Actor::New();
4503 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4504 Stage::GetCurrent().Add(actor);
4505 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4507 // Build the animation
4508 float durationSeconds(1.0f);
4509 Animation animation = Animation::New(durationSeconds);
4510 Degree targetRotationDegrees(90.0f);
4511 Radian targetRotationRadians(targetRotationDegrees);
4512 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
4514 // Start the animation
4517 bool signalReceived(false);
4518 AnimationFinishCheck finishCheck(signalReceived);
4519 animation.FinishedSignal().Connect(&application, finishCheck);
4521 application.SendNotification();
4522 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4524 // We didn't expect the animation to finish yet
4525 application.SendNotification();
4526 finishCheck.CheckSignalNotReceived();
4527 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4529 application.SendNotification();
4530 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4532 // We didn't expect the animation to finish yet
4533 application.SendNotification();
4534 finishCheck.CheckSignalNotReceived();
4535 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4537 application.SendNotification();
4538 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4540 // We didn't expect the animation to finish yet
4541 application.SendNotification();
4542 finishCheck.CheckSignalNotReceived();
4543 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4545 application.SendNotification();
4546 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4548 // We did expect the animation to finish
4549 application.SendNotification();
4550 finishCheck.CheckSignalReceived();
4551 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4555 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
4557 TestApplication application;
4559 Actor actor = Actor::New();
4560 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4561 Stage::GetCurrent().Add(actor);
4562 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4564 // Build the animation
4565 float durationSeconds(1.0f);
4566 Animation animation = Animation::New(durationSeconds);
4567 Degree targetRotationDegrees(90.0f);
4568 Radian targetRotationRadians(targetRotationDegrees);
4569 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
4570 animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
4572 // Start the animation
4575 bool signalReceived(false);
4576 AnimationFinishCheck finishCheck(signalReceived);
4577 animation.FinishedSignal().Connect(&application, finishCheck);
4579 application.SendNotification();
4580 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4582 // We didn't expect the animation to finish yet
4583 application.SendNotification();
4584 finishCheck.CheckSignalNotReceived();
4585 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4587 application.SendNotification();
4588 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4590 // We didn't expect the animation to finish yet
4591 application.SendNotification();
4592 finishCheck.CheckSignalNotReceived();
4593 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4595 application.SendNotification();
4596 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4598 // We didn't expect the animation to finish yet
4599 application.SendNotification();
4600 finishCheck.CheckSignalNotReceived();
4601 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4603 application.SendNotification();
4604 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4606 // We did expect the animation to finish
4607 application.SendNotification();
4608 finishCheck.CheckSignalReceived();
4609 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4613 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
4615 TestApplication application;
4617 Actor actor = Actor::New();
4618 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4619 Stage::GetCurrent().Add(actor);
4620 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4622 // Build the animation
4623 float durationSeconds(1.0f);
4624 Animation animation = Animation::New(durationSeconds);
4625 Degree targetRotationDegrees(90.0f);
4626 Radian targetRotationRadians(targetRotationDegrees);
4627 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
4629 // Start the animation
4632 bool signalReceived(false);
4633 AnimationFinishCheck finishCheck(signalReceived);
4634 animation.FinishedSignal().Connect(&application, finishCheck);
4636 application.SendNotification();
4637 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4639 // We didn't expect the animation to finish yet
4640 application.SendNotification();
4641 finishCheck.CheckSignalNotReceived();
4642 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4644 application.SendNotification();
4645 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4647 // We didn't expect the animation to finish yet
4648 application.SendNotification();
4649 finishCheck.CheckSignalNotReceived();
4650 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4652 application.SendNotification();
4653 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4655 // We didn't expect the animation to finish yet
4656 application.SendNotification();
4657 finishCheck.CheckSignalNotReceived();
4658 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4660 application.SendNotification();
4661 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4663 // We did expect the animation to finish
4664 application.SendNotification();
4665 finishCheck.CheckSignalReceived();
4666 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4670 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
4672 TestApplication application;
4674 Actor actor = Actor::New();
4675 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4676 Stage::GetCurrent().Add(actor);
4677 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4679 // Build the animation
4680 float durationSeconds(1.0f);
4681 Animation animation = Animation::New(durationSeconds);
4682 Degree targetRotationDegrees(90.0f);
4683 Radian targetRotationRadians(targetRotationDegrees);
4685 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
4687 // Start the animation
4690 bool signalReceived(false);
4691 AnimationFinishCheck finishCheck(signalReceived);
4692 animation.FinishedSignal().Connect(&application, finishCheck);
4694 application.SendNotification();
4695 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4697 // We didn't expect the animation to finish yet
4698 application.SendNotification();
4699 finishCheck.CheckSignalNotReceived();
4700 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4701 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4703 application.SendNotification();
4704 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4706 // We didn't expect the animation to finish yet
4707 application.SendNotification();
4708 finishCheck.CheckSignalNotReceived();
4709 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4710 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4712 application.SendNotification();
4713 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4715 // We didn't expect the animation to finish yet
4716 application.SendNotification();
4717 finishCheck.CheckSignalNotReceived();
4718 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4719 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4721 application.SendNotification();
4722 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4724 // We did expect the animation to finish
4725 application.SendNotification();
4726 finishCheck.CheckSignalReceived();
4727 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4731 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
4733 TestApplication application;
4735 Actor actor = Actor::New();
4736 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
4737 Stage::GetCurrent().Add(actor);
4738 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4740 // Build the animation
4741 float durationSeconds(1.0f);
4742 Animation animation = Animation::New(durationSeconds);
4743 Degree targetRotationDegrees(90.0f);
4744 Radian targetRotationRadians(targetRotationDegrees);
4746 animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
4748 // Start the animation
4751 bool signalReceived(false);
4752 AnimationFinishCheck finishCheck(signalReceived);
4753 animation.FinishedSignal().Connect(&application, finishCheck);
4755 application.SendNotification();
4756 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4758 // We didn't expect the animation to finish yet
4759 application.SendNotification();
4760 finishCheck.CheckSignalNotReceived();
4761 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4762 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4764 application.SendNotification();
4765 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4767 // We didn't expect the animation to finish yet
4768 application.SendNotification();
4769 finishCheck.CheckSignalNotReceived();
4770 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4771 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4773 application.SendNotification();
4774 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4776 // We didn't expect the animation to finish yet
4777 application.SendNotification();
4778 finishCheck.CheckSignalNotReceived();
4779 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4780 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4782 application.SendNotification();
4783 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4785 // We did expect the animation to finish
4786 application.SendNotification();
4787 finishCheck.CheckSignalReceived();
4788 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4792 int UtcDaliAnimationAnimateToActorScale(void)
4794 TestApplication application;
4796 Actor actor = Actor::New();
4797 Stage::GetCurrent().Add(actor);
4798 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4800 // Build the animation
4801 float durationSeconds(1.0f);
4802 Animation animation = Animation::New(durationSeconds);
4803 Vector3 targetScale(2.0f, 2.0f, 2.0f);
4804 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
4806 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
4808 // Start the animation
4811 bool signalReceived(false);
4812 AnimationFinishCheck finishCheck(signalReceived);
4813 animation.FinishedSignal().Connect(&application, finishCheck);
4815 application.SendNotification();
4816 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4818 // We didn't expect the animation to finish yet
4819 application.SendNotification();
4820 finishCheck.CheckSignalNotReceived();
4821 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4823 application.SendNotification();
4824 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4826 // We did expect the animation to finish
4827 application.SendNotification();
4828 finishCheck.CheckSignalReceived();
4829 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4832 finishCheck.Reset();
4833 actor.SetScale(Vector3::ONE);
4834 application.SendNotification();
4835 application.Render(0);
4836 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4838 // Repeat with a different (ease-in) alpha function
4839 animation = Animation::New(durationSeconds);
4840 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
4841 animation.FinishedSignal().Connect(&application, finishCheck);
4844 application.SendNotification();
4845 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4847 // We didn't expect the animation to finish yet
4848 application.SendNotification();
4849 finishCheck.CheckSignalNotReceived();
4851 // The scale should have grown less, than with a linear alpha function
4852 Vector3 current(actor.GetCurrentScale());
4853 DALI_TEST_CHECK( current.x > 1.0f );
4854 DALI_TEST_CHECK( current.y > 1.0f );
4855 DALI_TEST_CHECK( current.z > 1.0f );
4856 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4857 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4858 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4860 application.SendNotification();
4861 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4863 // We did expect the animation to finish
4864 application.SendNotification();
4865 finishCheck.CheckSignalReceived();
4866 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4869 finishCheck.Reset();
4870 actor.SetScale(Vector3::ONE);
4871 application.SendNotification();
4872 application.Render(0);
4873 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4875 // Repeat with a delay
4877 animation = Animation::New(durationSeconds);
4878 animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4879 animation.FinishedSignal().Connect(&application, finishCheck);
4882 application.SendNotification();
4883 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4885 // We didn't expect the animation to finish yet
4886 application.SendNotification();
4887 finishCheck.CheckSignalNotReceived();
4888 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4890 application.SendNotification();
4891 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4893 // We did expect the animation to finish
4894 application.SendNotification();
4895 finishCheck.CheckSignalReceived();
4896 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4900 int UtcDaliAnimationAnimateToActorScaleX(void)
4902 TestApplication application;
4904 Actor actor = Actor::New();
4905 Stage::GetCurrent().Add(actor);
4906 float startValue(1.0f);
4907 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
4908 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
4909 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
4910 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
4912 // Build the animation
4913 float durationSeconds(1.0f);
4914 Animation animation = Animation::New(durationSeconds);
4915 float targetX(10.0f);
4916 animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
4918 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
4920 // Start the animation
4923 bool signalReceived(false);
4924 AnimationFinishCheck finishCheck(signalReceived);
4925 animation.FinishedSignal().Connect(&application, finishCheck);
4927 application.SendNotification();
4928 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4930 // We didn't expect the animation to finish yet
4931 application.SendNotification();
4932 finishCheck.CheckSignalNotReceived();
4933 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
4934 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
4935 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
4936 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
4938 application.SendNotification();
4939 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4941 // We did expect the animation to finish
4942 application.SendNotification();
4943 finishCheck.CheckSignalReceived();
4944 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
4945 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
4946 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
4947 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
4951 int UtcDaliAnimationAnimateToActorScaleY(void)
4953 TestApplication application;
4955 Actor actor = Actor::New();
4956 Stage::GetCurrent().Add(actor);
4957 float startValue(1.0f);
4958 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
4959 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
4960 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
4961 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
4963 // Build the animation
4964 float durationSeconds(1.0f);
4965 Animation animation = Animation::New(durationSeconds);
4966 float targetY(1000.0f);
4967 animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
4969 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
4971 // Start the animation
4974 bool signalReceived(false);
4975 AnimationFinishCheck finishCheck(signalReceived);
4976 animation.FinishedSignal().Connect(&application, finishCheck);
4978 application.SendNotification();
4979 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4981 // We didn't expect the animation to finish yet
4982 application.SendNotification();
4983 finishCheck.CheckSignalNotReceived();
4984 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
4985 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
4986 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
4987 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
4989 application.SendNotification();
4990 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4992 // We did expect the animation to finish
4993 application.SendNotification();
4994 finishCheck.CheckSignalReceived();
4995 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
4996 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
4997 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
4998 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5002 int UtcDaliAnimationAnimateToActorScaleZ(void)
5004 TestApplication application;
5006 Actor actor = Actor::New();
5007 Stage::GetCurrent().Add(actor);
5008 float startValue(1.0f);
5009 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5010 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5011 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5012 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5014 // Build the animation
5015 float durationSeconds(1.0f);
5016 Animation animation = Animation::New(durationSeconds);
5017 float targetZ(-1000.0f);
5018 animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
5020 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5022 // Start the animation
5025 bool signalReceived(false);
5026 AnimationFinishCheck finishCheck(signalReceived);
5027 animation.FinishedSignal().Connect(&application, finishCheck);
5029 application.SendNotification();
5030 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5032 // We didn't expect the animation to finish yet
5033 application.SendNotification();
5034 finishCheck.CheckSignalNotReceived();
5035 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5036 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5037 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5038 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5040 application.SendNotification();
5041 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5043 // We did expect the animation to finish
5044 application.SendNotification();
5045 finishCheck.CheckSignalReceived();
5046 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5048 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5049 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
5053 int UtcDaliAnimationAnimateToActorColor(void)
5055 TestApplication application;
5057 Actor actor = Actor::New();
5058 Stage::GetCurrent().Add(actor);
5059 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5061 // Build the animation
5062 float durationSeconds(1.0f);
5063 Animation animation = Animation::New(durationSeconds);
5064 Vector4 targetColor(Color::RED);
5065 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
5067 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
5068 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
5070 // Start the animation
5073 bool signalReceived(false);
5074 AnimationFinishCheck finishCheck(signalReceived);
5075 animation.FinishedSignal().Connect(&application, finishCheck);
5077 application.SendNotification();
5078 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5080 // We didn't expect the animation to finish yet
5081 application.SendNotification();
5082 finishCheck.CheckSignalNotReceived();
5083 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
5085 application.SendNotification();
5086 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5088 // We did expect the animation to finish
5089 application.SendNotification();
5090 finishCheck.CheckSignalReceived();
5091 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5094 finishCheck.Reset();
5095 actor.SetColor(Color::WHITE);
5096 application.SendNotification();
5097 application.Render(0);
5098 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5100 // Repeat with a different (ease-in) alpha function
5101 animation = Animation::New(durationSeconds);
5102 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
5103 animation.FinishedSignal().Connect(&application, finishCheck);
5106 application.SendNotification();
5107 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5109 // We didn't expect the animation to finish yet
5110 application.SendNotification();
5111 finishCheck.CheckSignalNotReceived();
5113 // The color should have changed less, than with a linear alpha function
5114 Vector4 current(actor.GetCurrentColor());
5115 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
5116 DALI_TEST_CHECK( current.y < 1.0f );
5117 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
5118 DALI_TEST_CHECK( current.z < 1.0f );
5119 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
5120 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
5122 application.SendNotification();
5123 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
5125 // We did expect the animation to finish
5126 application.SendNotification();
5127 finishCheck.CheckSignalReceived();
5128 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5131 finishCheck.Reset();
5132 actor.SetColor(Color::WHITE);
5133 application.SendNotification();
5134 application.Render(0);
5135 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5137 // Repeat with a shorter animator duration
5138 float animatorDuration = 0.5f;
5139 animation = Animation::New(durationSeconds);
5140 animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
5141 animation.FinishedSignal().Connect(&application, finishCheck);
5144 application.SendNotification();
5145 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
5147 // We didn't expect the animation to finish yet
5148 application.SendNotification();
5149 finishCheck.CheckSignalNotReceived();
5150 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
5152 application.SendNotification();
5153 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
5155 // We didn't expect the animation to finish yet
5156 application.SendNotification();
5157 finishCheck.CheckSignalNotReceived();
5158 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5160 application.SendNotification();
5161 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5163 // We did expect the animation to finish
5164 application.SendNotification();
5165 finishCheck.CheckSignalReceived();
5166 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5170 int UtcDaliAnimationAnimateToActorColorRed(void)
5172 TestApplication application;
5174 Actor actor = Actor::New();
5175 Stage::GetCurrent().Add(actor);
5176 float startValue(1.0f);
5177 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
5178 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5179 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5180 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5181 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5183 // Build the animation
5184 float durationSeconds(1.0f);
5185 Animation animation = Animation::New(durationSeconds);
5186 float targetRed(0.5f);
5187 animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
5189 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
5191 // Start the animation
5194 bool signalReceived(false);
5195 AnimationFinishCheck finishCheck(signalReceived);
5196 animation.FinishedSignal().Connect(&application, finishCheck);
5198 application.SendNotification();
5199 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5201 // We didn't expect the animation to finish yet
5202 application.SendNotification();
5203 finishCheck.CheckSignalNotReceived();
5204 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
5205 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
5206 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5207 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5208 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5210 application.SendNotification();
5211 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5213 // We did expect the animation to finish
5214 application.SendNotification();
5215 finishCheck.CheckSignalReceived();
5216 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
5217 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), targetRed, TEST_LOCATION );
5218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5219 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5220 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5224 int UtcDaliAnimationAnimateToActorColorGreen(void)
5226 TestApplication application;
5228 Actor actor = Actor::New();
5229 Stage::GetCurrent().Add(actor);
5230 float startValue(1.0f);
5231 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
5232 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5233 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5234 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5235 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5237 // Build the animation
5238 float durationSeconds(1.0f);
5239 Animation animation = Animation::New(durationSeconds);
5240 float targetGreen(0.5f);
5241 animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
5243 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
5245 // Start the animation
5248 bool signalReceived(false);
5249 AnimationFinishCheck finishCheck(signalReceived);
5250 animation.FinishedSignal().Connect(&application, finishCheck);
5252 application.SendNotification();
5253 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5255 // We didn't expect the animation to finish yet
5256 application.SendNotification();
5257 finishCheck.CheckSignalNotReceived();
5258 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
5259 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5260 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
5261 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5262 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5264 application.SendNotification();
5265 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5267 // We did expect the animation to finish
5268 application.SendNotification();
5269 finishCheck.CheckSignalReceived();
5270 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
5271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
5273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5274 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5278 int UtcDaliAnimationAnimateToActorColorBlue(void)
5280 TestApplication application;
5282 Actor actor = Actor::New();
5283 Stage::GetCurrent().Add(actor);
5284 float startValue(1.0f);
5285 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
5286 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5287 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5288 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5289 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5291 // Build the animation
5292 float durationSeconds(1.0f);
5293 Animation animation = Animation::New(durationSeconds);
5294 float targetBlue(0.5f);
5295 animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
5297 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
5299 // Start the animation
5302 bool signalReceived(false);
5303 AnimationFinishCheck finishCheck(signalReceived);
5304 animation.FinishedSignal().Connect(&application, finishCheck);
5306 application.SendNotification();
5307 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5309 // We didn't expect the animation to finish yet
5310 application.SendNotification();
5311 finishCheck.CheckSignalNotReceived();
5312 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
5313 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5314 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5315 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
5316 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5318 application.SendNotification();
5319 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5321 // We did expect the animation to finish
5322 application.SendNotification();
5323 finishCheck.CheckSignalReceived();
5324 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
5325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION );
5328 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5332 int UtcDaliAnimationAnimateToActorColorAlpha(void)
5334 TestApplication application;
5336 Actor actor = Actor::New();
5337 Stage::GetCurrent().Add(actor);
5338 float startValue(1.0f);
5339 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5340 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5341 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5342 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5343 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5345 // Build the animation
5346 float durationSeconds(1.0f);
5347 Animation animation = Animation::New(durationSeconds);
5348 float targetAlpha(0.5f);
5349 animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
5351 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
5353 // Start the animation
5356 bool signalReceived(false);
5357 AnimationFinishCheck finishCheck(signalReceived);
5358 animation.FinishedSignal().Connect(&application, finishCheck);
5360 application.SendNotification();
5361 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5363 // We didn't expect the animation to finish yet
5364 application.SendNotification();
5365 finishCheck.CheckSignalNotReceived();
5366 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
5367 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5368 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5369 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5370 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
5372 application.SendNotification();
5373 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5375 // We did expect the animation to finish
5376 application.SendNotification();
5377 finishCheck.CheckSignalReceived();
5378 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
5379 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5380 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5381 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5382 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
5388 int UtcDaliAnimationKeyFrames01(void)
5390 TestApplication application;
5392 KeyFrames keyFrames = KeyFrames::New();
5393 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5395 keyFrames.Add(0.0f, 0.1f);
5396 keyFrames.Add(0.2f, 0.5f);
5397 keyFrames.Add(0.4f, 0.0f);
5398 keyFrames.Add(0.6f, 1.0f);
5399 keyFrames.Add(0.8f, 0.7f);
5400 keyFrames.Add(1.0f, 0.9f);
5402 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
5406 keyFrames.Add(1.9f, false);
5408 catch (Dali::DaliException& e)
5410 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5411 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5416 int UtcDaliAnimationKeyFrames02(void)
5418 TestApplication application;
5420 KeyFrames keyFrames = KeyFrames::New();
5421 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5423 keyFrames.Add(0.0f, true);
5424 keyFrames.Add(0.2f, false);
5425 keyFrames.Add(0.4f, false);
5426 keyFrames.Add(0.6f, true);
5427 keyFrames.Add(0.8f, true);
5428 keyFrames.Add(1.0f, false);
5430 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
5434 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
5436 catch (Dali::DaliException& e)
5438 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5439 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5445 int UtcDaliAnimationKeyFrames03(void)
5447 TestApplication application;
5449 KeyFrames keyFrames = KeyFrames::New();
5450 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5452 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
5453 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
5454 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
5455 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
5456 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
5457 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
5459 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
5463 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
5465 catch (Dali::DaliException& e)
5467 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5468 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5474 int UtcDaliAnimationKeyFrames04(void)
5476 TestApplication application;
5478 KeyFrames keyFrames = KeyFrames::New();
5479 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5481 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
5482 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
5483 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
5484 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
5485 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
5486 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
5488 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
5492 keyFrames.Add(0.7f, 1.0f);
5494 catch (Dali::DaliException& e)
5496 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5497 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5502 int UtcDaliAnimationKeyFrames05(void)
5504 TestApplication application;
5506 KeyFrames keyFrames = KeyFrames::New();
5507 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5509 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
5510 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
5511 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
5512 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
5513 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
5514 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
5516 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
5520 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
5522 catch (Dali::DaliException& e)
5524 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5525 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5531 int UtcDaliAnimationKeyFrames06(void)
5533 TestApplication application;
5535 KeyFrames keyFrames = KeyFrames::New();
5536 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
5538 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
5539 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
5540 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
5541 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
5542 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
5543 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
5545 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
5549 keyFrames.Add(0.7f, 1.1f);
5551 catch (Dali::DaliException& e)
5553 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
5554 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
5563 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
5565 TestApplication application;
5567 float startValue(1.0f);
5568 Actor actor = Actor::New();
5569 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
5570 Stage::GetCurrent().Add(actor);
5572 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5573 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5574 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5575 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5576 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5578 // Build the animation
5579 float durationSeconds(1.0f);
5580 Animation animation = Animation::New(durationSeconds);
5582 KeyFrames keyFrames = KeyFrames::New();
5583 keyFrames.Add(0.0f, 0.1f);
5584 keyFrames.Add(0.2f, 0.5f);
5585 keyFrames.Add(0.4f, 0.0f);
5586 keyFrames.Add(0.6f, 1.0f);
5587 keyFrames.Add(0.8f, 0.7f);
5588 keyFrames.Add(1.0f, 0.9f);
5590 animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
5592 // Start the animation
5595 bool signalReceived(false);
5596 AnimationFinishCheck finishCheck(signalReceived);
5597 animation.FinishedSignal().Connect(&application, finishCheck);
5598 application.SendNotification();
5599 application.Render(0);
5600 application.SendNotification();
5601 finishCheck.CheckSignalNotReceived();
5602 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
5604 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
5605 application.SendNotification();
5606 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5607 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5608 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5609 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
5610 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
5612 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
5613 application.SendNotification();
5614 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5615 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5616 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5617 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
5618 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
5620 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
5621 application.SendNotification();
5622 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5623 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5624 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5625 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
5626 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
5628 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
5629 application.SendNotification();
5630 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5631 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5632 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
5634 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
5636 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
5637 application.SendNotification();
5638 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5639 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5640 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5641 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
5642 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
5644 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
5645 application.SendNotification();
5646 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5647 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5648 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5649 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
5650 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
5652 // We did expect the animation to finish
5654 finishCheck.CheckSignalReceived();
5659 int UtcDaliAnimationAnimateBetweenActorColor(void)
5661 TestApplication application;
5663 float startValue(1.0f);
5664 Actor actor = Actor::New();
5665 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
5666 Stage::GetCurrent().Add(actor);
5668 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
5669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
5670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
5671 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
5672 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
5674 // Build the animation
5675 float durationSeconds(1.0f);
5676 Animation animation = Animation::New(durationSeconds);
5678 KeyFrames keyFrames = KeyFrames::New();
5679 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
5680 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
5681 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
5683 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
5685 // Start the animation
5688 bool signalReceived(false);
5689 AnimationFinishCheck finishCheck(signalReceived);
5690 animation.FinishedSignal().Connect(&application, finishCheck);
5691 application.SendNotification();
5692 application.Render(0);
5693 application.SendNotification();
5694 finishCheck.CheckSignalNotReceived();
5695 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
5696 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
5697 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
5698 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
5700 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5701 application.SendNotification();
5702 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
5703 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
5704 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
5705 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
5707 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5708 application.SendNotification();
5709 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
5710 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
5711 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
5712 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
5714 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5715 application.SendNotification();
5716 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
5717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
5718 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
5719 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
5721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
5722 application.SendNotification();
5723 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
5724 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
5725 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
5726 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
5728 // We did expect the animation to finish
5730 finishCheck.CheckSignalReceived();
5734 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
5736 TestApplication application;
5738 Actor actor = Actor::New();
5739 AngleAxis aa(Degree(90), Vector3::XAXIS);
5740 actor.SetRotation(aa.angle, aa.axis);
5741 Stage::GetCurrent().Add(actor);
5743 application.SendNotification();
5744 application.Render(0);
5746 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5748 // Build the animation
5749 float durationSeconds(1.0f);
5750 Animation animation = Animation::New(durationSeconds);
5752 KeyFrames keyFrames = KeyFrames::New();
5753 keyFrames.Add(0.0f, false);
5754 keyFrames.Add(0.2f, true);
5755 keyFrames.Add(0.4f, true);
5756 keyFrames.Add(0.8f, false);
5757 keyFrames.Add(1.0f, true);
5759 animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
5761 // Start the animation
5764 bool signalReceived(false);
5765 AnimationFinishCheck finishCheck(signalReceived);
5766 animation.FinishedSignal().Connect(&application, finishCheck);
5767 application.SendNotification();
5768 application.SendNotification();
5769 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
5770 application.SendNotification();
5771 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
5772 application.SendNotification();
5774 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
5775 finishCheck.CheckSignalReceived();
5779 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
5781 TestApplication application;
5783 Actor actor = Actor::New();
5784 AngleAxis aa(Degree(90), Vector3::XAXIS);
5785 actor.SetRotation(aa.angle, aa.axis);
5786 Stage::GetCurrent().Add(actor);
5788 application.SendNotification();
5789 application.Render(0);
5790 Quaternion start(Radian(aa.angle), aa.axis);
5791 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
5793 // Build the animation
5794 float durationSeconds(1.0f);
5795 Animation animation = Animation::New(durationSeconds);
5797 KeyFrames keyFrames = KeyFrames::New();
5798 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
5800 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
5802 // Start the animation
5805 bool signalReceived(false);
5806 AnimationFinishCheck finishCheck(signalReceived);
5807 animation.FinishedSignal().Connect(&application, finishCheck);
5808 application.SendNotification();
5809 application.SendNotification();
5810 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
5811 application.SendNotification();
5812 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
5813 application.SendNotification();
5815 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
5817 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5818 finishCheck.CheckSignalReceived();
5822 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
5824 TestApplication application;
5826 Actor actor = Actor::New();
5827 AngleAxis aa(Degree(90), Vector3::XAXIS);
5828 actor.SetRotation(aa.angle, aa.axis);
5829 application.SendNotification();
5830 application.Render(0);
5831 Stage::GetCurrent().Add(actor);
5833 Quaternion start(Radian(aa.angle), aa.axis);
5834 DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
5836 // Build the animation
5837 float durationSeconds(1.0f);
5838 Animation animation = Animation::New(durationSeconds);
5840 KeyFrames keyFrames = KeyFrames::New();
5841 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
5842 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
5843 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
5845 animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
5847 // Start the animation
5850 bool signalReceived(false);
5851 AnimationFinishCheck finishCheck(signalReceived);
5852 animation.FinishedSignal().Connect(&application, finishCheck);
5853 application.SendNotification();
5854 application.Render(0);
5855 application.SendNotification();
5856 finishCheck.CheckSignalNotReceived();
5858 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
5859 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5861 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5862 application.SendNotification();
5863 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
5864 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5866 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5867 application.SendNotification();
5868 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
5869 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5871 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5872 application.SendNotification();
5873 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
5874 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5876 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
5877 application.SendNotification();
5878 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
5879 DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
5881 // We did expect the animation to finish
5883 finishCheck.CheckSignalReceived();
5887 int UtcDaliAnimationMoveByFloat3(void)
5889 TestApplication application;
5891 Actor actor = Actor::New();
5892 Vector3 startPosition(10.0f, 10.0f, 10.0f);
5893 actor.SetPosition(startPosition);
5894 Stage::GetCurrent().Add(actor);
5895 application.SendNotification();
5896 application.Render(0);
5897 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
5899 // Build the animation
5900 float durationSeconds(1.0f);
5901 Animation animation = Animation::New(durationSeconds);
5902 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
5903 Vector3 relativePosition(targetPosition - startPosition);
5904 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
5906 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
5908 // Start the animation
5911 bool signalReceived(false);
5912 AnimationFinishCheck finishCheck(signalReceived);
5913 animation.FinishedSignal().Connect(&application, finishCheck);
5915 application.SendNotification();
5916 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5918 // We didn't expect the animation to finish yet
5919 application.SendNotification();
5920 finishCheck.CheckSignalNotReceived();
5921 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
5923 application.SendNotification();
5924 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5926 // We did expect the animation to finish
5927 application.SendNotification();
5928 finishCheck.CheckSignalReceived();
5929 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5933 int UtcDaliAnimationMoveByVector3Alpha(void)
5935 TestApplication application;
5937 Actor actor = Actor::New();
5938 Vector3 startPosition(10.0f, 10.0f, 10.0f);
5939 actor.SetPosition(startPosition);
5940 Stage::GetCurrent().Add(actor);
5941 application.SendNotification();
5942 application.Render(0);
5943 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
5945 // Build the animation
5946 float durationSeconds(1.0f);
5947 Animation animation = Animation::New(durationSeconds);
5948 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
5949 Vector3 relativePosition(targetPosition - startPosition);
5950 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
5952 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
5954 // Start the animation
5957 bool signalReceived(false);
5958 AnimationFinishCheck finishCheck(signalReceived);
5959 animation.FinishedSignal().Connect(&application, finishCheck);
5961 application.SendNotification();
5962 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5964 // We didn't expect the animation to finish yet
5965 application.SendNotification();
5966 finishCheck.CheckSignalNotReceived();
5968 // The position should have moved more, than with a linear alpha function
5969 Vector3 current(actor.GetCurrentPosition());
5970 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
5971 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
5972 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
5974 application.SendNotification();
5975 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5977 // We did expect the animation to finish
5978 application.SendNotification();
5979 finishCheck.CheckSignalReceived();
5980 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5984 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
5986 TestApplication application;
5988 Actor actor = Actor::New();
5989 Vector3 startPosition(10.0f, 10.0f, 10.0f);
5990 actor.SetPosition(startPosition);
5991 Stage::GetCurrent().Add(actor);
5992 application.SendNotification();
5993 application.Render(0);
5994 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
5996 // Build the animation
5997 float durationSeconds(1.0f);
5998 Animation animation = Animation::New(durationSeconds);
5999 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6000 Vector3 relativePosition(targetPosition - startPosition);
6002 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6004 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6006 // Start the animation
6009 bool signalReceived(false);
6010 AnimationFinishCheck finishCheck(signalReceived);
6011 animation.FinishedSignal().Connect(&application, finishCheck);
6013 application.SendNotification();
6014 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6016 // We didn't expect the animation to finish yet
6017 application.SendNotification();
6018 finishCheck.CheckSignalNotReceived();
6019 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6021 application.SendNotification();
6022 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6024 // We did expect the animation to finish
6025 application.SendNotification();
6026 finishCheck.CheckSignalReceived();
6027 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6031 int UtcDaliAnimationMoveToFloat3(void)
6033 TestApplication application;
6035 Actor actor = Actor::New();
6036 Stage::GetCurrent().Add(actor);
6037 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6039 // Build the animation
6040 float durationSeconds(1.0f);
6041 Animation animation = Animation::New(durationSeconds);
6042 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6043 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
6045 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6047 // Start the animation
6050 bool signalReceived(false);
6051 AnimationFinishCheck finishCheck(signalReceived);
6052 animation.FinishedSignal().Connect(&application, finishCheck);
6054 application.SendNotification();
6055 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6057 // We didn't expect the animation to finish yet
6058 application.SendNotification();
6059 finishCheck.CheckSignalNotReceived();
6060 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6062 application.SendNotification();
6063 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6065 // We did expect the animation to finish
6066 application.SendNotification();
6067 finishCheck.CheckSignalReceived();
6068 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6072 int UtcDaliAnimationMoveToVector3Alpha(void)
6074 TestApplication application;
6076 Actor actor = Actor::New();
6077 Stage::GetCurrent().Add(actor);
6078 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6080 // Build the animation
6081 float durationSeconds(1.0f);
6082 Animation animation = Animation::New(durationSeconds);
6083 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6084 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
6086 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6088 // Start the animation
6091 bool signalReceived(false);
6092 AnimationFinishCheck finishCheck(signalReceived);
6093 animation.FinishedSignal().Connect(&application, finishCheck);
6095 application.SendNotification();
6096 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6098 // We didn't expect the animation to finish yet
6099 application.SendNotification();
6100 finishCheck.CheckSignalNotReceived();
6102 // The position should have moved less, than with a linear alpha function
6103 Vector3 current(actor.GetCurrentPosition());
6104 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
6105 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
6106 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
6107 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
6108 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
6109 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
6111 application.SendNotification();
6112 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6114 // We did expect the animation to finish
6115 application.SendNotification();
6116 finishCheck.CheckSignalReceived();
6117 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6121 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
6123 TestApplication application;
6125 Actor actor = Actor::New();
6126 Stage::GetCurrent().Add(actor);
6127 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6129 // Build the animation
6130 float durationSeconds(1.0f);
6131 Animation animation = Animation::New(durationSeconds);
6132 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6134 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
6136 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6138 // Start the animation
6141 bool signalReceived(false);
6142 AnimationFinishCheck finishCheck(signalReceived);
6143 animation.FinishedSignal().Connect(&application, finishCheck);
6145 application.SendNotification();
6146 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6148 // We didn't expect the animation to finish yet
6149 application.SendNotification();
6150 finishCheck.CheckSignalNotReceived();
6151 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6153 application.SendNotification();
6154 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6156 // We didn't expect the animation to finish yet
6157 application.SendNotification();
6158 finishCheck.CheckSignalNotReceived();
6159 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6161 application.SendNotification();
6162 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6164 // We did expect the animation to finish
6165 application.SendNotification();
6166 finishCheck.CheckSignalReceived();
6167 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6171 int UtcDaliAnimationMove(void)
6173 TestApplication application;
6175 Actor actor = Actor::New();
6176 Vector3 initialPosition(Vector3::ZERO);
6177 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6178 Stage::GetCurrent().Add(actor);
6180 // Build the animation
6181 float durationSeconds(10.0f);
6182 Animation animation = Animation::New(durationSeconds);
6183 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6184 BounceFunc func(0.0f, 0.0f, -100.0f);
6185 animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
6187 // Start the animation
6190 bool signalReceived(false);
6191 AnimationFinishCheck finishCheck(signalReceived);
6192 animation.FinishedSignal().Connect(&application, finishCheck);
6194 application.SendNotification();
6195 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6197 // We didn't expect the animation to finish yet
6198 application.SendNotification();
6199 finishCheck.CheckSignalNotReceived();
6200 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
6202 application.SendNotification();
6203 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6205 // We didn't expect the animation to finish yet
6206 application.SendNotification();
6207 finishCheck.CheckSignalNotReceived();
6208 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
6210 application.SendNotification();
6211 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6213 // We didn't expect the animation to finish yet
6214 application.SendNotification();
6215 finishCheck.CheckSignalNotReceived();
6216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
6218 application.SendNotification();
6219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6221 // We did expect the animation to finish
6222 application.SendNotification();
6223 finishCheck.CheckSignalReceived();
6224 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
6228 int UtcDaliAnimationRotateByDegreeVector3(void)
6230 TestApplication application;
6232 Actor actor = Actor::New();
6233 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6234 Stage::GetCurrent().Add(actor);
6235 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6237 // Build the animation
6238 float durationSeconds(1.0f);
6239 Animation animation = Animation::New(durationSeconds);
6240 Degree relativeRotationDegrees(360.0f);
6241 Radian relativeRotationRadians(relativeRotationDegrees);
6242 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
6244 // Start the animation
6247 bool signalReceived(false);
6248 AnimationFinishCheck finishCheck(signalReceived);
6249 animation.FinishedSignal().Connect(&application, finishCheck);
6251 application.SendNotification();
6252 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6254 // We didn't expect the animation to finish yet
6255 application.SendNotification();
6256 finishCheck.CheckSignalNotReceived();
6257 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6259 application.SendNotification();
6260 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6262 // We didn't expect the animation to finish yet
6263 application.SendNotification();
6264 finishCheck.CheckSignalNotReceived();
6265 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6267 application.SendNotification();
6268 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6270 // We didn't expect the animation to finish yet
6271 application.SendNotification();
6272 finishCheck.CheckSignalNotReceived();
6273 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6275 application.SendNotification();
6276 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6278 // We did expect the animation to finish
6279 application.SendNotification();
6280 finishCheck.CheckSignalReceived();
6281 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6285 int UtcDaliAnimationRotateByRadianVector3(void)
6287 TestApplication application;
6289 Actor actor = Actor::New();
6290 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6291 Stage::GetCurrent().Add(actor);
6292 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6294 // Build the animation
6295 float durationSeconds(1.0f);
6296 Animation animation = Animation::New(durationSeconds);
6297 Degree relativeRotationDegrees(360.0f);
6298 Radian relativeRotationRadians(relativeRotationDegrees);
6299 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
6301 // Start the animation
6304 bool signalReceived(false);
6305 AnimationFinishCheck finishCheck(signalReceived);
6306 animation.FinishedSignal().Connect(&application, finishCheck);
6308 application.SendNotification();
6309 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6311 // We didn't expect the animation to finish yet
6312 application.SendNotification();
6313 finishCheck.CheckSignalNotReceived();
6314 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6316 application.SendNotification();
6317 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6319 // We didn't expect the animation to finish yet
6320 application.SendNotification();
6321 finishCheck.CheckSignalNotReceived();
6322 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6324 application.SendNotification();
6325 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6327 // We didn't expect the animation to finish yet
6328 application.SendNotification();
6329 finishCheck.CheckSignalNotReceived();
6330 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6332 application.SendNotification();
6333 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6335 // We did expect the animation to finish
6336 application.SendNotification();
6337 finishCheck.CheckSignalReceived();
6338 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6342 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
6344 TestApplication application;
6346 Actor actor = Actor::New();
6347 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6348 Stage::GetCurrent().Add(actor);
6349 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6351 // Build the animation
6352 float durationSeconds(1.0f);
6353 Animation animation = Animation::New(durationSeconds);
6354 Degree relativeRotationDegrees(360.0f);
6355 Radian relativeRotationRadians(relativeRotationDegrees);
6356 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6358 // Start the animation
6361 bool signalReceived(false);
6362 AnimationFinishCheck finishCheck(signalReceived);
6363 animation.FinishedSignal().Connect(&application, finishCheck);
6365 application.SendNotification();
6366 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6368 // We didn't expect the animation to finish yet
6369 application.SendNotification();
6370 finishCheck.CheckSignalNotReceived();
6371 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6373 application.SendNotification();
6374 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6376 // We didn't expect the animation to finish yet
6377 application.SendNotification();
6378 finishCheck.CheckSignalNotReceived();
6379 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6381 application.SendNotification();
6382 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6384 // We didn't expect the animation to finish yet
6385 application.SendNotification();
6386 finishCheck.CheckSignalNotReceived();
6387 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6389 application.SendNotification();
6390 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6392 // We did expect the animation to finish
6393 application.SendNotification();
6394 finishCheck.CheckSignalReceived();
6395 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6399 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
6401 TestApplication application;
6403 Actor actor = Actor::New();
6404 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6405 Stage::GetCurrent().Add(actor);
6406 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6408 // Build the animation
6409 float durationSeconds(1.0f);
6410 Animation animation = Animation::New(durationSeconds);
6411 Degree relativeRotationDegrees(360.0f);
6412 Radian relativeRotationRadians(relativeRotationDegrees);
6413 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6415 // Start the animation
6418 bool signalReceived(false);
6419 AnimationFinishCheck finishCheck(signalReceived);
6420 animation.FinishedSignal().Connect(&application, finishCheck);
6422 application.SendNotification();
6423 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6425 // We didn't expect the animation to finish yet
6426 application.SendNotification();
6427 finishCheck.CheckSignalNotReceived();
6428 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6430 application.SendNotification();
6431 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6433 // We didn't expect the animation to finish yet
6434 application.SendNotification();
6435 finishCheck.CheckSignalNotReceived();
6436 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6438 application.SendNotification();
6439 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6441 // We didn't expect the animation to finish yet
6442 application.SendNotification();
6443 finishCheck.CheckSignalNotReceived();
6444 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6446 application.SendNotification();
6447 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6449 // We did expect the animation to finish
6450 application.SendNotification();
6451 finishCheck.CheckSignalReceived();
6452 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6456 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
6458 TestApplication application;
6460 Actor actor = Actor::New();
6461 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6462 Stage::GetCurrent().Add(actor);
6463 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6465 // Build the animation
6466 float durationSeconds(1.0f);
6467 Animation animation = Animation::New(durationSeconds);
6468 Degree relativeRotationDegrees(360.0f);
6469 Radian relativeRotationRadians(relativeRotationDegrees);
6471 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
6473 // Start the animation
6476 bool signalReceived(false);
6477 AnimationFinishCheck finishCheck(signalReceived);
6478 animation.FinishedSignal().Connect(&application, finishCheck);
6480 application.SendNotification();
6481 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6483 // We didn't expect the animation to finish yet
6484 application.SendNotification();
6485 finishCheck.CheckSignalNotReceived();
6486 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6487 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6489 application.SendNotification();
6490 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6492 // We didn't expect the animation to finish yet
6493 application.SendNotification();
6494 finishCheck.CheckSignalNotReceived();
6495 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6496 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6498 application.SendNotification();
6499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6501 // We didn't expect the animation to finish yet
6502 application.SendNotification();
6503 finishCheck.CheckSignalNotReceived();
6504 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6505 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6507 application.SendNotification();
6508 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6510 // We did expect the animation to finish
6511 application.SendNotification();
6512 finishCheck.CheckSignalReceived();
6513 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6518 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
6520 TestApplication application;
6522 Actor actor = Actor::New();
6523 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6524 Stage::GetCurrent().Add(actor);
6525 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6527 // Build the animation
6528 float durationSeconds(1.0f);
6529 Animation animation = Animation::New(durationSeconds);
6530 Degree relativeRotationDegrees(360.0f);
6531 Radian relativeRotationRadians(relativeRotationDegrees);
6533 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
6535 // Start the animation
6538 bool signalReceived(false);
6539 AnimationFinishCheck finishCheck(signalReceived);
6540 animation.FinishedSignal().Connect(&application, finishCheck);
6542 application.SendNotification();
6543 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6545 // We didn't expect the animation to finish yet
6546 application.SendNotification();
6547 finishCheck.CheckSignalNotReceived();
6548 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6549 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6551 application.SendNotification();
6552 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6554 // We didn't expect the animation to finish yet
6555 application.SendNotification();
6556 finishCheck.CheckSignalNotReceived();
6557 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6558 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6560 application.SendNotification();
6561 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6563 // We didn't expect the animation to finish yet
6564 application.SendNotification();
6565 finishCheck.CheckSignalNotReceived();
6566 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6567 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6569 application.SendNotification();
6570 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6572 // We did expect the animation to finish
6573 application.SendNotification();
6574 finishCheck.CheckSignalReceived();
6575 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6579 int UtcDaliAnimationRotateToDegreeVector3(void)
6581 TestApplication application;
6583 Actor actor = Actor::New();
6584 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6585 Stage::GetCurrent().Add(actor);
6586 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6588 // Build the animation
6589 float durationSeconds(1.0f);
6590 Animation animation = Animation::New(durationSeconds);
6591 Degree targetRotationDegrees(90.0f);
6592 Radian targetRotationRadians(targetRotationDegrees);
6593 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
6595 // Start the animation
6598 bool signalReceived(false);
6599 AnimationFinishCheck finishCheck(signalReceived);
6600 animation.FinishedSignal().Connect(&application, finishCheck);
6602 application.SendNotification();
6603 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6605 // We didn't expect the animation to finish yet
6606 application.SendNotification();
6607 finishCheck.CheckSignalNotReceived();
6608 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6610 application.SendNotification();
6611 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6613 // We didn't expect the animation to finish yet
6614 application.SendNotification();
6615 finishCheck.CheckSignalNotReceived();
6616 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6618 application.SendNotification();
6619 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6621 // We didn't expect the animation to finish yet
6622 application.SendNotification();
6623 finishCheck.CheckSignalNotReceived();
6624 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6626 application.SendNotification();
6627 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6629 // We did expect the animation to finish
6630 application.SendNotification();
6631 finishCheck.CheckSignalReceived();
6632 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6636 int UtcDaliAnimationRotateToRadianVector3(void)
6638 TestApplication application;
6640 Actor actor = Actor::New();
6641 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6642 Stage::GetCurrent().Add(actor);
6643 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6645 // Build the animation
6646 float durationSeconds(1.0f);
6647 Animation animation = Animation::New(durationSeconds);
6648 Degree targetRotationDegrees(90.0f);
6649 Radian targetRotationRadians(targetRotationDegrees);
6650 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
6652 // Start the animation
6655 bool signalReceived(false);
6656 AnimationFinishCheck finishCheck(signalReceived);
6657 animation.FinishedSignal().Connect(&application, finishCheck);
6659 application.SendNotification();
6660 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6662 // We didn't expect the animation to finish yet
6663 application.SendNotification();
6664 finishCheck.CheckSignalNotReceived();
6665 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6667 application.SendNotification();
6668 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6670 // We didn't expect the animation to finish yet
6671 application.SendNotification();
6672 finishCheck.CheckSignalNotReceived();
6673 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6675 application.SendNotification();
6676 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6678 // We didn't expect the animation to finish yet
6679 application.SendNotification();
6680 finishCheck.CheckSignalNotReceived();
6681 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6683 application.SendNotification();
6684 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6686 // We did expect the animation to finish
6687 application.SendNotification();
6688 finishCheck.CheckSignalReceived();
6689 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6693 int UtcDaliAnimationRotateToQuaternion(void)
6695 TestApplication application;
6697 Actor actor = Actor::New();
6698 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6699 Stage::GetCurrent().Add(actor);
6700 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6702 // Build the animation
6703 float durationSeconds(1.0f);
6704 Animation animation = Animation::New(durationSeconds);
6705 Degree targetRotationDegrees(90.0f);
6706 Radian targetRotationRadians(targetRotationDegrees);
6707 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
6708 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
6710 // Start the animation
6713 bool signalReceived(false);
6714 AnimationFinishCheck finishCheck(signalReceived);
6715 animation.FinishedSignal().Connect(&application, finishCheck);
6717 application.SendNotification();
6718 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6720 // We didn't expect the animation to finish yet
6721 application.SendNotification();
6722 finishCheck.CheckSignalNotReceived();
6723 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6725 application.SendNotification();
6726 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6728 // We didn't expect the animation to finish yet
6729 application.SendNotification();
6730 finishCheck.CheckSignalNotReceived();
6731 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6733 application.SendNotification();
6734 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6736 // We didn't expect the animation to finish yet
6737 application.SendNotification();
6738 finishCheck.CheckSignalNotReceived();
6739 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6741 application.SendNotification();
6742 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6744 // We did expect the animation to finish
6745 application.SendNotification();
6746 finishCheck.CheckSignalReceived();
6747 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6751 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
6753 TestApplication application;
6755 Actor actor = Actor::New();
6756 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6757 Stage::GetCurrent().Add(actor);
6758 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6760 // Build the animation
6761 float durationSeconds(1.0f);
6762 Animation animation = Animation::New(durationSeconds);
6763 Degree targetRotationDegrees(90.0f);
6764 Radian targetRotationRadians(targetRotationDegrees);
6765 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6767 // Start the animation
6770 bool signalReceived(false);
6771 AnimationFinishCheck finishCheck(signalReceived);
6772 animation.FinishedSignal().Connect(&application, finishCheck);
6774 application.SendNotification();
6775 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6777 // We didn't expect the animation to finish yet
6778 application.SendNotification();
6779 finishCheck.CheckSignalNotReceived();
6780 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6782 application.SendNotification();
6783 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6785 // We didn't expect the animation to finish yet
6786 application.SendNotification();
6787 finishCheck.CheckSignalNotReceived();
6788 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6790 application.SendNotification();
6791 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6793 // We didn't expect the animation to finish yet
6794 application.SendNotification();
6795 finishCheck.CheckSignalNotReceived();
6796 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6798 application.SendNotification();
6799 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6801 // We did expect the animation to finish
6802 application.SendNotification();
6803 finishCheck.CheckSignalReceived();
6804 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6808 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
6810 TestApplication application;
6812 Actor actor = Actor::New();
6813 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6814 Stage::GetCurrent().Add(actor);
6815 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6817 // Build the animation
6818 float durationSeconds(1.0f);
6819 Animation animation = Animation::New(durationSeconds);
6820 Degree targetRotationDegrees(90.0f);
6821 Radian targetRotationRadians(targetRotationDegrees);
6822 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
6824 // Start the animation
6827 bool signalReceived(false);
6828 AnimationFinishCheck finishCheck(signalReceived);
6829 animation.FinishedSignal().Connect(&application, finishCheck);
6831 application.SendNotification();
6832 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6834 // We didn't expect the animation to finish yet
6835 application.SendNotification();
6836 finishCheck.CheckSignalNotReceived();
6837 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6839 application.SendNotification();
6840 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6842 // We didn't expect the animation to finish yet
6843 application.SendNotification();
6844 finishCheck.CheckSignalNotReceived();
6845 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6847 application.SendNotification();
6848 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6850 // We didn't expect the animation to finish yet
6851 application.SendNotification();
6852 finishCheck.CheckSignalNotReceived();
6853 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6855 application.SendNotification();
6856 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6858 // We did expect the animation to finish
6859 application.SendNotification();
6860 finishCheck.CheckSignalReceived();
6861 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6865 int UtcDaliAnimationRotateToQuaternionAlpha(void)
6867 TestApplication application;
6869 Actor actor = Actor::New();
6870 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6871 Stage::GetCurrent().Add(actor);
6872 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6874 // Build the animation
6875 float durationSeconds(1.0f);
6876 Animation animation = Animation::New(durationSeconds);
6877 Degree targetRotationDegrees(90.0f);
6878 Radian targetRotationRadians(targetRotationDegrees);
6879 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
6880 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
6882 // Start the animation
6885 bool signalReceived(false);
6886 AnimationFinishCheck finishCheck(signalReceived);
6887 animation.FinishedSignal().Connect(&application, finishCheck);
6889 application.SendNotification();
6890 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6892 // We didn't expect the animation to finish yet
6893 application.SendNotification();
6894 finishCheck.CheckSignalNotReceived();
6895 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6897 application.SendNotification();
6898 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6900 // We didn't expect the animation to finish yet
6901 application.SendNotification();
6902 finishCheck.CheckSignalNotReceived();
6903 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6905 application.SendNotification();
6906 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6908 // We didn't expect the animation to finish yet
6909 application.SendNotification();
6910 finishCheck.CheckSignalNotReceived();
6911 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6913 application.SendNotification();
6914 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6916 // We did expect the animation to finish
6917 application.SendNotification();
6918 finishCheck.CheckSignalReceived();
6919 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6923 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
6925 TestApplication application;
6927 Actor actor = Actor::New();
6928 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6929 Stage::GetCurrent().Add(actor);
6930 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6932 // Build the animation
6933 float durationSeconds(1.0f);
6934 Animation animation = Animation::New(durationSeconds);
6935 Degree targetRotationDegrees(90.0f);
6936 Radian targetRotationRadians(targetRotationDegrees);
6938 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
6940 // Start the animation
6943 bool signalReceived(false);
6944 AnimationFinishCheck finishCheck(signalReceived);
6945 animation.FinishedSignal().Connect(&application, finishCheck);
6947 application.SendNotification();
6948 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6950 // We didn't expect the animation to finish yet
6951 application.SendNotification();
6952 finishCheck.CheckSignalNotReceived();
6953 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6954 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6956 application.SendNotification();
6957 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6959 // We didn't expect the animation to finish yet
6960 application.SendNotification();
6961 finishCheck.CheckSignalNotReceived();
6962 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6963 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6965 application.SendNotification();
6966 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6968 // We didn't expect the animation to finish yet
6969 application.SendNotification();
6970 finishCheck.CheckSignalNotReceived();
6971 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6972 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6974 application.SendNotification();
6975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6977 // We did expect the animation to finish
6978 application.SendNotification();
6979 finishCheck.CheckSignalReceived();
6980 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6984 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
6986 TestApplication application;
6988 Actor actor = Actor::New();
6989 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
6990 Stage::GetCurrent().Add(actor);
6991 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6993 // Build the animation
6994 float durationSeconds(1.0f);
6995 Animation animation = Animation::New(durationSeconds);
6996 Degree targetRotationDegrees(90.0f);
6997 Radian targetRotationRadians(targetRotationDegrees);
6999 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7001 // Start the animation
7004 bool signalReceived(false);
7005 AnimationFinishCheck finishCheck(signalReceived);
7006 animation.FinishedSignal().Connect(&application, finishCheck);
7008 application.SendNotification();
7009 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7011 // We didn't expect the animation to finish yet
7012 application.SendNotification();
7013 finishCheck.CheckSignalNotReceived();
7014 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7015 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7017 application.SendNotification();
7018 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7020 // We didn't expect the animation to finish yet
7021 application.SendNotification();
7022 finishCheck.CheckSignalNotReceived();
7023 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7024 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7026 application.SendNotification();
7027 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7029 // We didn't expect the animation to finish yet
7030 application.SendNotification();
7031 finishCheck.CheckSignalNotReceived();
7032 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7033 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7035 application.SendNotification();
7036 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7038 // We did expect the animation to finish
7039 application.SendNotification();
7040 finishCheck.CheckSignalReceived();
7041 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7045 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
7047 TestApplication application;
7049 Actor actor = Actor::New();
7050 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7051 Stage::GetCurrent().Add(actor);
7052 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7054 // Build the animation
7055 float durationSeconds(1.0f);
7056 Animation animation = Animation::New(durationSeconds);
7057 Degree targetRotationDegrees(90.0f);
7058 Radian targetRotationRadians(targetRotationDegrees);
7060 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7061 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7063 // Start the animation
7066 bool signalReceived(false);
7067 AnimationFinishCheck finishCheck(signalReceived);
7068 animation.FinishedSignal().Connect(&application, finishCheck);
7070 application.SendNotification();
7071 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7073 // We didn't expect the animation to finish yet
7074 application.SendNotification();
7075 finishCheck.CheckSignalNotReceived();
7076 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7077 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7079 application.SendNotification();
7080 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7082 // We didn't expect the animation to finish yet
7083 application.SendNotification();
7084 finishCheck.CheckSignalNotReceived();
7085 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7086 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7088 application.SendNotification();
7089 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7091 // We didn't expect the animation to finish yet
7092 application.SendNotification();
7093 finishCheck.CheckSignalNotReceived();
7094 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7095 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7097 application.SendNotification();
7098 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7100 // We did expect the animation to finish
7101 application.SendNotification();
7102 finishCheck.CheckSignalReceived();
7103 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7107 int UtcDaliAnimationRotate(void)
7109 TestApplication application;
7111 Actor actor = Actor::New();
7112 Quaternion initialRotation(0.0f, Vector3::YAXIS);
7113 actor.SetRotation(initialRotation);
7114 Stage::GetCurrent().Add(actor);
7115 DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
7117 // Build the animation
7118 float durationSeconds(1.0f);
7119 Animation animation = Animation::New(durationSeconds);
7120 TumbleFunc func(Vector3::YAXIS);
7121 animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7123 // Start the animation
7126 bool signalReceived(false);
7127 AnimationFinishCheck finishCheck(signalReceived);
7128 animation.FinishedSignal().Connect(&application, finishCheck);
7130 application.SendNotification();
7131 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7133 // We didn't expect the animation to finish yet
7134 application.SendNotification();
7135 finishCheck.CheckSignalNotReceived();
7136 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7138 application.SendNotification();
7139 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7141 // We didn't expect the animation to finish yet
7142 application.SendNotification();
7143 finishCheck.CheckSignalNotReceived();
7144 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7146 application.SendNotification();
7147 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7149 // We didn't expect the animation to finish yet
7150 application.SendNotification();
7151 finishCheck.CheckSignalNotReceived();
7152 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7154 application.SendNotification();
7155 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7157 // We did expect the animation to finish
7158 application.SendNotification();
7159 finishCheck.CheckSignalReceived();
7160 DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
7164 int UtcDaliAnimationScaleBy(void)
7166 TestApplication application;
7168 Actor actor = Actor::New();
7169 Stage::GetCurrent().Add(actor);
7170 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7172 // Build the animation
7173 float durationSeconds(1.0f);
7174 Animation animation = Animation::New(durationSeconds);
7175 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7176 Vector3 relativeScale(targetScale - Vector3::ONE);
7177 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
7179 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
7181 // Start the animation
7184 bool signalReceived(false);
7185 AnimationFinishCheck finishCheck(signalReceived);
7186 animation.FinishedSignal().Connect(&application, finishCheck);
7188 application.SendNotification();
7189 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7191 // We didn't expect the animation to finish yet
7192 application.SendNotification();
7193 finishCheck.CheckSignalNotReceived();
7194 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7196 application.SendNotification();
7197 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7199 // We did expect the animation to finish
7200 application.SendNotification();
7201 finishCheck.CheckSignalReceived();
7202 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7205 finishCheck.Reset();
7206 actor.SetScale(Vector3::ONE);
7207 application.SendNotification();
7208 application.Render(0);
7209 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7211 // Repeat with a different (ease-in) alpha function
7212 animation = Animation::New(durationSeconds);
7213 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
7214 animation.FinishedSignal().Connect(&application, finishCheck);
7217 application.SendNotification();
7218 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7220 // We didn't expect the animation to finish yet
7221 application.SendNotification();
7222 finishCheck.CheckSignalNotReceived();
7224 // The scale should have grown less, than with a linear alpha function
7225 Vector3 current(actor.GetCurrentScale());
7226 DALI_TEST_CHECK( current.x > 1.0f );
7227 DALI_TEST_CHECK( current.y > 1.0f );
7228 DALI_TEST_CHECK( current.z > 1.0f );
7229 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7230 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7231 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7233 application.SendNotification();
7234 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7236 // We did expect the animation to finish
7237 application.SendNotification();
7238 finishCheck.CheckSignalReceived();
7239 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7242 finishCheck.Reset();
7243 actor.SetScale(Vector3::ONE);
7244 application.SendNotification();
7245 application.Render(0);
7246 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7248 // Repeat with a delay
7250 animation = Animation::New(durationSeconds);
7251 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7252 animation.FinishedSignal().Connect(&application, finishCheck);
7255 application.SendNotification();
7256 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7258 // We didn't expect the animation to finish yet
7259 application.SendNotification();
7260 finishCheck.CheckSignalNotReceived();
7261 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7263 application.SendNotification();
7264 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7266 // We did expect the animation to finish
7267 application.SendNotification();
7268 finishCheck.CheckSignalReceived();
7269 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7273 int UtcDaliAnimationScaleTo(void)
7275 TestApplication application;
7277 Actor actor = Actor::New();
7278 Stage::GetCurrent().Add(actor);
7279 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7281 // Build the animation
7282 float durationSeconds(1.0f);
7283 Animation animation = Animation::New(durationSeconds);
7284 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7285 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
7287 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7289 // Start the animation
7292 bool signalReceived(false);
7293 AnimationFinishCheck finishCheck(signalReceived);
7294 animation.FinishedSignal().Connect(&application, finishCheck);
7296 application.SendNotification();
7297 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7299 // We didn't expect the animation to finish yet
7300 application.SendNotification();
7301 finishCheck.CheckSignalNotReceived();
7302 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7304 application.SendNotification();
7305 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7307 // We did expect the animation to finish
7308 application.SendNotification();
7309 finishCheck.CheckSignalReceived();
7310 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7313 finishCheck.Reset();
7314 actor.SetScale(Vector3::ONE);
7315 application.SendNotification();
7316 application.Render(0);
7317 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7319 // Repeat with a different (ease-in) alpha function
7320 animation = Animation::New(durationSeconds);
7321 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
7322 animation.FinishedSignal().Connect(&application, finishCheck);
7325 application.SendNotification();
7326 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7328 // We didn't expect the animation to finish yet
7329 application.SendNotification();
7330 finishCheck.CheckSignalNotReceived();
7332 // The scale should have grown less, than with a linear alpha function
7333 Vector3 current(actor.GetCurrentScale());
7334 DALI_TEST_CHECK( current.x > 1.0f );
7335 DALI_TEST_CHECK( current.y > 1.0f );
7336 DALI_TEST_CHECK( current.z > 1.0f );
7337 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7338 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7339 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7341 application.SendNotification();
7342 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7344 // We did expect the animation to finish
7345 application.SendNotification();
7346 finishCheck.CheckSignalReceived();
7347 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7350 finishCheck.Reset();
7351 actor.SetScale(Vector3::ONE);
7352 application.SendNotification();
7353 application.Render(0);
7354 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7356 // Repeat with a delay
7358 animation = Animation::New(durationSeconds);
7359 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
7360 animation.FinishedSignal().Connect(&application, finishCheck);
7363 application.SendNotification();
7364 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7366 // We didn't expect the animation to finish yet
7367 application.SendNotification();
7368 finishCheck.CheckSignalNotReceived();
7369 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7371 application.SendNotification();
7372 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7374 // We did expect the animation to finish
7375 application.SendNotification();
7376 finishCheck.CheckSignalReceived();
7377 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7381 int UtcDaliAnimationShow(void)
7383 TestApplication application;
7385 Actor actor = Actor::New();
7386 actor.SetVisible(false);
7387 application.SendNotification();
7388 application.Render(0);
7389 DALI_TEST_CHECK( !actor.IsVisible() );
7390 Stage::GetCurrent().Add(actor);
7392 // Start the animation
7393 float durationSeconds(10.0f);
7394 Animation animation = Animation::New(durationSeconds);
7395 animation.Show(actor, durationSeconds*0.5f);
7398 bool signalReceived(false);
7399 AnimationFinishCheck finishCheck(signalReceived);
7400 animation.FinishedSignal().Connect(&application, finishCheck);
7402 application.SendNotification();
7403 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
7405 // We didn't expect the animation to finish yet
7406 application.SendNotification();
7407 finishCheck.CheckSignalNotReceived();
7408 DALI_TEST_CHECK( !actor.IsVisible() );
7410 application.SendNotification();
7411 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
7413 // We didn't expect the animation to finish yet
7414 application.SendNotification();
7415 finishCheck.CheckSignalNotReceived();
7416 DALI_TEST_CHECK( actor.IsVisible() );
7418 application.SendNotification();
7419 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7421 // We did expect the animation to finish
7422 application.SendNotification();
7423 finishCheck.CheckSignalReceived();
7424 DALI_TEST_CHECK( actor.IsVisible() );
7428 int UtcDaliAnimationHide(void)
7430 TestApplication application;
7432 Actor actor = Actor::New();
7433 DALI_TEST_CHECK( actor.IsVisible() );
7434 Stage::GetCurrent().Add(actor);
7436 // Start the animation
7437 float durationSeconds(10.0f);
7438 Animation animation = Animation::New(durationSeconds);
7439 animation.Hide(actor, durationSeconds*0.5f);
7442 bool signalReceived(false);
7443 AnimationFinishCheck finishCheck(signalReceived);
7444 animation.FinishedSignal().Connect(&application, finishCheck);
7446 application.SendNotification();
7447 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
7449 // We didn't expect the animation to finish yet
7450 application.SendNotification();
7451 finishCheck.CheckSignalNotReceived();
7452 DALI_TEST_CHECK( actor.IsVisible() );
7454 application.SendNotification();
7455 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
7457 // We didn't expect the animation to finish yet
7458 application.SendNotification();
7459 finishCheck.CheckSignalNotReceived();
7460 DALI_TEST_CHECK( !actor.IsVisible() );
7462 application.SendNotification();
7463 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7465 // We did expect the animation to finish
7466 application.SendNotification();
7467 finishCheck.CheckSignalReceived();
7468 DALI_TEST_CHECK( !actor.IsVisible() );
7472 int UtcDaliAnimationShowHideAtEnd(void)
7474 // Test that show/hide delay can be the same as animation duration
7475 // i.e. to show/hide at the end of the animation
7477 TestApplication application;
7479 Actor actor = Actor::New();
7480 DALI_TEST_CHECK( actor.IsVisible() );
7481 Stage::GetCurrent().Add(actor);
7483 // Start Hide animation
7484 float durationSeconds(10.0f);
7485 Animation animation = Animation::New(durationSeconds);
7486 animation.Hide(actor, durationSeconds/*Hide at end*/);
7489 bool signalReceived(false);
7490 AnimationFinishCheck finishCheck(signalReceived);
7491 animation.FinishedSignal().Connect(&application, finishCheck);
7493 application.SendNotification();
7494 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
7496 // We did expect the animation to finish
7497 application.SendNotification();
7498 finishCheck.CheckSignalReceived();
7499 DALI_TEST_CHECK( !actor.IsVisible() );
7501 // Start Show animation
7502 animation = Animation::New(durationSeconds);
7503 animation.Show(actor, durationSeconds/*Show at end*/);
7504 animation.FinishedSignal().Connect(&application, finishCheck);
7507 application.SendNotification();
7508 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
7510 // We did expect the animation to finish
7511 application.SendNotification();
7512 finishCheck.CheckSignalReceived();
7513 DALI_TEST_CHECK( actor.IsVisible() );
7517 int UtcDaliAnimationOpacityBy(void)
7519 TestApplication application;
7520 Actor actor = Actor::New();
7521 float startingOpacity(0.5f);
7522 actor.SetOpacity(startingOpacity);
7523 application.SendNotification();
7524 application.Render(0);
7525 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7526 Stage::GetCurrent().Add(actor);
7528 // Build the animation
7529 float durationSeconds(1.0f);
7530 Animation animation = Animation::New(durationSeconds);
7531 float relativeOpacity(-0.5f); // target of zero
7532 animation.OpacityBy(actor, relativeOpacity);
7534 float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
7536 // Start the animation
7539 bool signalReceived(false);
7540 AnimationFinishCheck finishCheck(signalReceived);
7541 animation.FinishedSignal().Connect(&application, finishCheck);
7543 application.SendNotification();
7544 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7546 // We didn't expect the animation to finish yet
7547 application.SendNotification();
7548 finishCheck.CheckSignalNotReceived();
7549 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
7551 application.SendNotification();
7552 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7554 // We did expect the animation to finish
7555 application.SendNotification();
7556 finishCheck.CheckSignalReceived();
7557 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7560 finishCheck.Reset();
7561 actor.SetOpacity(startingOpacity);
7562 application.SendNotification();
7563 application.Render(0);
7564 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7566 // Repeat with a different (ease-in) alpha function
7567 animation = Animation::New(durationSeconds);
7568 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
7569 animation.FinishedSignal().Connect(&application, finishCheck);
7572 application.SendNotification();
7573 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7575 // We didn't expect the animation to finish yet
7576 application.SendNotification();
7577 finishCheck.CheckSignalNotReceived();
7579 // The opacity should reduce less, than with a linear alpha function
7580 float current(actor.GetCurrentOpacity());
7581 DALI_TEST_CHECK( current < 1.0f );
7582 DALI_TEST_CHECK( current > seventyFivePercentProgress );
7584 application.SendNotification();
7585 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7587 // We did expect the animation to finish
7588 application.SendNotification();
7589 finishCheck.CheckSignalReceived();
7590 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7593 finishCheck.Reset();
7594 actor.SetOpacity(startingOpacity);
7595 application.SendNotification();
7596 application.Render(0);
7597 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7599 // Repeat with a delay
7601 animation = Animation::New(durationSeconds);
7602 animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
7603 animation.FinishedSignal().Connect(&application, finishCheck);
7606 application.SendNotification();
7607 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7609 // We didn't expect the animation to finish yet
7610 application.SendNotification();
7611 finishCheck.CheckSignalNotReceived();
7612 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
7614 application.SendNotification();
7615 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7617 // We didn't expect the animation to finish yet
7618 application.SendNotification();
7619 finishCheck.CheckSignalNotReceived();
7620 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
7622 application.SendNotification();
7623 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7625 // We did expect the animation to finish
7626 application.SendNotification();
7627 finishCheck.CheckSignalReceived();
7628 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
7632 int UtcDaliAnimationOpacityTo(void)
7634 TestApplication application;
7636 Actor actor = Actor::New();
7637 Stage::GetCurrent().Add(actor);
7638 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7640 // Build the animation
7641 float durationSeconds(1.0f);
7642 Animation animation = Animation::New(durationSeconds);
7643 float targetOpacity(0.0f);
7644 animation.OpacityTo(actor, targetOpacity);
7646 float ninetyNinePercentProgress(0.01f);
7648 // Start the animation
7651 bool signalReceived(false);
7652 AnimationFinishCheck finishCheck(signalReceived);
7653 animation.FinishedSignal().Connect(&application, finishCheck);
7655 application.SendNotification();
7656 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7658 // We didn't expect the animation to finish yet
7659 application.SendNotification();
7660 finishCheck.CheckSignalNotReceived();
7661 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
7663 application.SendNotification();
7664 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7666 // We did expect the animation to finish
7667 application.SendNotification();
7668 finishCheck.CheckSignalReceived();
7669 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7672 finishCheck.Reset();
7673 actor.SetOpacity(1.0f);
7674 application.SendNotification();
7675 application.Render(0);
7676 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7678 // Repeat with a different (ease-in) alpha function
7679 animation = Animation::New(durationSeconds);
7680 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
7681 animation.FinishedSignal().Connect(&application, finishCheck);
7684 application.SendNotification();
7685 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7687 // We didn't expect the animation to finish yet
7688 application.SendNotification();
7689 finishCheck.CheckSignalNotReceived();
7691 // The opacity should reduce less, than with a linear alpha function
7692 float current(actor.GetCurrentOpacity());
7693 DALI_TEST_CHECK( current < 1.0f );
7694 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
7696 application.SendNotification();
7697 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7699 // We did expect the animation to finish
7700 application.SendNotification();
7701 finishCheck.CheckSignalReceived();
7702 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7705 finishCheck.Reset();
7706 actor.SetOpacity(1.0f);
7707 application.SendNotification();
7708 application.Render(0);
7709 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7711 // Repeat with a delay
7713 animation = Animation::New(durationSeconds);
7714 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
7715 animation.FinishedSignal().Connect(&application, finishCheck);
7718 application.SendNotification();
7719 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7721 // We didn't expect the animation to finish yet
7722 application.SendNotification();
7723 finishCheck.CheckSignalNotReceived();
7724 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
7726 application.SendNotification();
7727 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7729 // We did expect the animation to finish
7730 application.SendNotification();
7731 finishCheck.CheckSignalReceived();
7732 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
7736 int UtcDaliAnimationColorBy(void)
7738 TestApplication application;
7740 Actor actor = Actor::New();
7741 actor.SetColor(Color::BLACK);
7742 application.SendNotification();
7743 application.Render(0);
7744 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
7745 Stage::GetCurrent().Add(actor);
7747 // Build the animation
7748 float durationSeconds(1.0f);
7749 Animation animation = Animation::New(durationSeconds);
7750 Vector4 targetColor(Color::GREEN);
7751 Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
7752 animation.ColorBy(actor, relativeColor);
7754 Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
7755 Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
7757 // Start the animation
7760 bool signalReceived(false);
7761 AnimationFinishCheck finishCheck(signalReceived);
7762 animation.FinishedSignal().Connect(&application, finishCheck);
7764 application.SendNotification();
7765 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7767 // We didn't expect the animation to finish yet
7768 application.SendNotification();
7769 finishCheck.CheckSignalNotReceived();
7770 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
7772 application.SendNotification();
7773 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7775 // We did expect the animation to finish
7776 application.SendNotification();
7777 finishCheck.CheckSignalReceived();
7778 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7781 finishCheck.Reset();
7782 actor.SetColor(Color::BLACK);
7783 application.SendNotification();
7784 application.Render(0);
7785 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
7787 // Repeat with a different (ease-in) alpha function
7788 animation = Animation::New(durationSeconds);
7789 animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
7790 animation.FinishedSignal().Connect(&application, finishCheck);
7793 application.SendNotification();
7794 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7796 // We didn't expect the animation to finish yet
7797 application.SendNotification();
7798 finishCheck.CheckSignalNotReceived();
7800 // The color should have changed less, than with a linear alpha function
7801 Vector4 current(actor.GetCurrentWorldColor());
7802 DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
7803 DALI_TEST_CHECK( current.y > 0.0f );
7804 DALI_TEST_CHECK( current.y < tenPercentProgress.y );
7805 DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
7806 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
7808 application.SendNotification();
7809 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7811 // We did expect the animation to finish
7812 application.SendNotification();
7813 finishCheck.CheckSignalReceived();
7814 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7817 finishCheck.Reset();
7818 actor.SetColor(Color::BLACK);
7819 application.SendNotification();
7820 application.Render(0);
7821 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
7823 // Repeat with a shorter animator duration
7824 float animatorDuration = 0.5f;
7825 animation = Animation::New(durationSeconds);
7826 animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
7827 animation.FinishedSignal().Connect(&application, finishCheck);
7830 application.SendNotification();
7831 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
7833 // We didn't expect the animation to finish yet
7834 application.SendNotification();
7835 finishCheck.CheckSignalNotReceived();
7836 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
7838 application.SendNotification();
7839 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
7841 // We didn't expect the animation to finish yet
7842 application.SendNotification();
7843 finishCheck.CheckSignalNotReceived();
7844 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7846 application.SendNotification();
7847 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7849 // We did expect the animation to finish
7850 application.SendNotification();
7851 finishCheck.CheckSignalReceived();
7852 DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
7856 int UtcDaliAnimationColorTo(void)
7858 TestApplication application;
7860 Actor actor = Actor::New();
7861 Stage::GetCurrent().Add(actor);
7862 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7864 // Build the animation
7865 float durationSeconds(1.0f);
7866 Animation animation = Animation::New(durationSeconds);
7867 Vector4 targetColor(Color::RED);
7868 animation.ColorTo(actor, targetColor);
7870 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
7871 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
7873 // Start the animation
7876 bool signalReceived(false);
7877 AnimationFinishCheck finishCheck(signalReceived);
7878 animation.FinishedSignal().Connect(&application, finishCheck);
7880 application.SendNotification();
7881 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7883 // We didn't expect the animation to finish yet
7884 application.SendNotification();
7885 finishCheck.CheckSignalNotReceived();
7886 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
7888 application.SendNotification();
7889 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7891 // We did expect the animation to finish
7892 application.SendNotification();
7893 finishCheck.CheckSignalReceived();
7894 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7897 finishCheck.Reset();
7898 actor.SetColor(Color::WHITE);
7899 application.SendNotification();
7900 application.Render(0);
7901 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7903 // Repeat with a different (ease-in) alpha function
7904 animation = Animation::New(durationSeconds);
7905 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
7906 animation.FinishedSignal().Connect(&application, finishCheck);
7909 application.SendNotification();
7910 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7912 // We didn't expect the animation to finish yet
7913 application.SendNotification();
7914 finishCheck.CheckSignalNotReceived();
7916 // The color should have changed less, than with a linear alpha function
7917 Vector4 current(actor.GetCurrentColor());
7918 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
7919 DALI_TEST_CHECK( current.y < 1.0f );
7920 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
7921 DALI_TEST_CHECK( current.z < 1.0f );
7922 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
7923 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
7925 application.SendNotification();
7926 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7928 // We did expect the animation to finish
7929 application.SendNotification();
7930 finishCheck.CheckSignalReceived();
7931 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7934 finishCheck.Reset();
7935 actor.SetColor(Color::WHITE);
7936 application.SendNotification();
7937 application.Render(0);
7938 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7940 // Repeat with a shorter animator duration
7941 float animatorDuration = 0.5f;
7942 animation = Animation::New(durationSeconds);
7943 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
7944 animation.FinishedSignal().Connect(&application, finishCheck);
7947 application.SendNotification();
7948 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
7950 // We didn't expect the animation to finish yet
7951 application.SendNotification();
7952 finishCheck.CheckSignalNotReceived();
7953 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
7955 application.SendNotification();
7956 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
7958 // We didn't expect the animation to finish yet
7959 application.SendNotification();
7960 finishCheck.CheckSignalNotReceived();
7961 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7963 application.SendNotification();
7964 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7966 // We did expect the animation to finish
7967 application.SendNotification();
7968 finishCheck.CheckSignalReceived();
7969 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7973 int UtcDaliAnimationResize(void)
7975 TestApplication application;
7977 Actor actor = Actor::New();
7978 Stage::GetCurrent().Add(actor);
7979 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7981 // Build the animation
7982 float durationSeconds(1.0f);
7983 Animation animation = Animation::New(durationSeconds);
7984 Vector3 targetSize(100.0f, 100.0f, 100.0f);
7985 animation.Resize(actor, targetSize);
7987 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7989 // Start the animation
7992 bool signalReceived(false);
7993 AnimationFinishCheck finishCheck(signalReceived);
7994 animation.FinishedSignal().Connect(&application, finishCheck);
7996 application.SendNotification();
7997 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7999 // We didn't expect the animation to finish yet
8000 application.SendNotification();
8001 finishCheck.CheckSignalNotReceived();
8002 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8004 application.SendNotification();
8005 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8007 // We did expect the animation to finish
8008 application.SendNotification();
8009 finishCheck.CheckSignalReceived();
8010 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8013 finishCheck.Reset();
8014 actor.SetSize(Vector3::ZERO);
8015 application.SendNotification();
8016 application.Render(0);
8017 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8019 // Repeat with a different (ease-in) alpha function
8020 animation = Animation::New(durationSeconds);
8021 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8022 animation.FinishedSignal().Connect(&application, finishCheck);
8025 application.SendNotification();
8026 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8028 // We didn't expect the animation to finish yet
8029 application.SendNotification();
8030 finishCheck.CheckSignalNotReceived();
8032 // The size should have travelled less, than with a linear alpha function
8033 Vector3 current(actor.GetCurrentSize());
8034 DALI_TEST_CHECK( current.x > 0.0f );
8035 DALI_TEST_CHECK( current.y > 0.0f );
8036 DALI_TEST_CHECK( current.z > 0.0f );
8037 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8038 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8039 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8041 application.SendNotification();
8042 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8044 // We did expect the animation to finish
8045 application.SendNotification();
8046 finishCheck.CheckSignalReceived();
8047 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8050 finishCheck.Reset();
8051 actor.SetSize(Vector3::ZERO);
8052 application.SendNotification();
8053 application.Render(0);
8054 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8056 // Repeat with a delay
8058 animation = Animation::New(durationSeconds);
8059 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
8060 animation.FinishedSignal().Connect(&application, finishCheck);
8063 application.SendNotification();
8064 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8066 // We didn't expect the animation to finish yet
8067 application.SendNotification();
8068 finishCheck.CheckSignalNotReceived();
8069 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8071 application.SendNotification();
8072 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8074 // We did expect the animation to finish
8075 application.SendNotification();
8076 finishCheck.CheckSignalReceived();
8077 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8081 int UtcDaliAnimationAnimateBool(void)
8083 TestApplication application;
8085 Actor actor = Actor::New();
8086 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8087 Stage::GetCurrent().Add(actor);
8089 // Build the animation
8090 float durationSeconds(10.0f);
8091 Animation animation = Animation::New(durationSeconds);
8092 animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
8094 // Start the animation
8097 bool signalReceived(false);
8098 AnimationFinishCheck finishCheck(signalReceived);
8099 animation.FinishedSignal().Connect(&application, finishCheck);
8101 application.SendNotification();
8102 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8104 // We didn't expect the animation to finish yet
8105 application.SendNotification();
8106 finishCheck.CheckSignalNotReceived();
8108 // Should still be visible
8109 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8111 application.SendNotification();
8112 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8114 // We didn't expect the animation to finish yet
8115 application.SendNotification();
8116 finishCheck.CheckSignalNotReceived();
8118 // Now animate functor should have hidden the actor
8119 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8121 application.SendNotification();
8122 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8124 // We did expect the animation to finish
8125 application.SendNotification();
8126 finishCheck.CheckSignalReceived();
8127 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
8131 int UtcDaliAnimationAnimateFloat(void)
8133 TestApplication application;
8135 Actor actor = Actor::New();
8136 Stage::GetCurrent().Add(actor);
8138 // Register a float property
8139 float startValue(10.0f);
8140 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8141 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8143 // Build the animation
8144 float durationSeconds(10.0f);
8145 Animation animation = Animation::New(durationSeconds);
8146 float targetPosition(0.0f);
8147 AnimateFloatTestFunctor func( 100, targetPosition );
8148 animation.Animate<float>( Property(actor, index), func );
8150 // Start the animation
8153 bool signalReceived(false);
8154 AnimationFinishCheck finishCheck(signalReceived);
8155 animation.FinishedSignal().Connect(&application, finishCheck);
8157 application.SendNotification();
8158 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8160 // We didn't expect the animation to finish yet
8161 application.SendNotification();
8162 finishCheck.CheckSignalNotReceived();
8163 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
8165 application.SendNotification();
8166 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8168 // We didn't expect the animation to finish yet
8169 application.SendNotification();
8170 finishCheck.CheckSignalNotReceived();
8171 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
8173 application.SendNotification();
8174 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8176 // We didn't expect the animation to finish yet
8177 application.SendNotification();
8178 finishCheck.CheckSignalNotReceived();
8179 DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
8181 application.SendNotification();
8182 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8184 // We did expect the animation to finish
8185 application.SendNotification();
8186 finishCheck.CheckSignalReceived();
8187 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
8191 int UtcDaliAnimationAnimateVector2(void)
8193 TestApplication application;
8195 Actor actor = Actor::New();
8196 Stage::GetCurrent().Add(actor);
8198 // Register a Vector2 property
8199 Vector2 startValue(10.0f, 10.0f);
8200 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8201 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
8203 // Build the animation
8204 float durationSeconds(10.0f);
8205 Animation animation = Animation::New(durationSeconds);
8206 Vector2 targetPosition(0.0f, 0.0f);
8207 AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
8208 animation.Animate<Vector2>( Property(actor, index), func );
8210 // Start the animation
8213 bool signalReceived(false);
8214 AnimationFinishCheck finishCheck(signalReceived);
8215 animation.FinishedSignal().Connect(&application, finishCheck);
8217 application.SendNotification();
8218 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8220 // We didn't expect the animation to finish yet
8221 application.SendNotification();
8222 finishCheck.CheckSignalNotReceived();
8223 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
8225 application.SendNotification();
8226 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8228 // We didn't expect the animation to finish yet
8229 application.SendNotification();
8230 finishCheck.CheckSignalNotReceived();
8231 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
8233 application.SendNotification();
8234 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8236 // We didn't expect the animation to finish yet
8237 application.SendNotification();
8238 finishCheck.CheckSignalNotReceived();
8239 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
8241 application.SendNotification();
8242 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8244 // We did expect the animation to finish
8245 application.SendNotification();
8246 finishCheck.CheckSignalReceived();
8247 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
8251 int UtcDaliAnimationAnimateVector3(void)
8253 TestApplication application;
8255 Actor actor = Actor::New();
8256 Vector3 initialPosition(Vector3::ZERO);
8257 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8258 Stage::GetCurrent().Add(actor);
8260 // Build the animation
8261 float durationSeconds(10.0f);
8262 Animation animation = Animation::New(durationSeconds);
8263 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
8264 BounceFunc func(0.0f, 0.0f, -100.0f);
8265 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
8267 // Start the animation
8270 bool signalReceived(false);
8271 AnimationFinishCheck finishCheck(signalReceived);
8272 animation.FinishedSignal().Connect(&application, finishCheck);
8274 application.SendNotification();
8275 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8277 // We didn't expect the animation to finish yet
8278 application.SendNotification();
8279 finishCheck.CheckSignalNotReceived();
8280 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
8282 application.SendNotification();
8283 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8285 // We didn't expect the animation to finish yet
8286 application.SendNotification();
8287 finishCheck.CheckSignalNotReceived();
8288 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
8290 application.SendNotification();
8291 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8293 // We didn't expect the animation to finish yet
8294 application.SendNotification();
8295 finishCheck.CheckSignalNotReceived();
8296 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
8298 application.SendNotification();
8299 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8301 // We did expect the animation to finish
8302 application.SendNotification();
8303 finishCheck.CheckSignalReceived();
8304 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8308 int UtcDaliAnimationAnimateVector4(void)
8310 TestApplication application;
8312 Actor actor = Actor::New();
8313 Stage::GetCurrent().Add(actor);
8315 // Register a Vector4 property
8316 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
8317 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8318 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
8320 // Build the animation
8321 float durationSeconds(10.0f);
8322 Animation animation = Animation::New(durationSeconds);
8323 Vector4 targetPosition(200,400,0,-1000);
8324 AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
8325 animation.Animate<Vector4>( Property(actor, index), func );
8327 // Start the animation
8330 bool signalReceived(false);
8331 AnimationFinishCheck finishCheck(signalReceived);
8332 animation.FinishedSignal().Connect(&application, finishCheck);
8334 application.SendNotification();
8335 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8337 // We didn't expect the animation to finish yet
8338 application.SendNotification();
8339 finishCheck.CheckSignalNotReceived();
8340 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
8342 application.SendNotification();
8343 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8345 // We didn't expect the animation to finish yet
8346 application.SendNotification();
8347 finishCheck.CheckSignalNotReceived();
8348 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
8350 application.SendNotification();
8351 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8353 // We didn't expect the animation to finish yet
8354 application.SendNotification();
8355 finishCheck.CheckSignalNotReceived();
8356 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
8358 application.SendNotification();
8359 application.Render(static_cast<unsigned int>(durationSeconds*250.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.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
8368 int UtcDaliAnimationAnimateQuaternion(void)
8370 TestApplication application;
8372 Actor actor = Actor::New();
8373 actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8374 Stage::GetCurrent().Add(actor);
8375 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8377 // Build the animation
8378 float durationSeconds(1.0f);
8379 Animation animation = Animation::New(durationSeconds);
8381 Degree sourceRotationDegrees(90.0f);
8382 Radian sourceRotationRadians(sourceRotationDegrees);
8383 Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
8385 Degree targetRotationDegrees(150.0f);
8386 Radian targetRotationRadians(targetRotationDegrees);
8387 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8389 AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
8390 animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
8392 // Start the animation
8395 bool signalReceived(false);
8396 AnimationFinishCheck finishCheck(signalReceived);
8397 animation.FinishedSignal().Connect(&application, finishCheck);
8399 application.SendNotification();
8400 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8402 // We didn't expect the animation to finish yet
8403 application.SendNotification();
8404 finishCheck.CheckSignalNotReceived();
8405 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8407 application.SendNotification();
8408 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8410 // We didn't expect the animation to finish yet
8411 application.SendNotification();
8412 finishCheck.CheckSignalNotReceived();
8413 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8415 application.SendNotification();
8416 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8418 // We didn't expect the animation to finish yet
8419 application.SendNotification();
8420 finishCheck.CheckSignalNotReceived();
8421 DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8423 application.SendNotification();
8424 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8426 // We did expect the animation to finish
8427 application.SendNotification();
8428 finishCheck.CheckSignalReceived();
8429 DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
8433 int UtcDaliKeyFramesCreateDestroy(void)
8435 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8437 KeyFrames* keyFrames = new KeyFrames;
8439 DALI_TEST_CHECK( true );
8443 int UtcDaliKeyFramesDownCast(void)
8445 TestApplication application;
8446 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
8448 KeyFrames keyFrames = KeyFrames::New();
8449 BaseHandle object(keyFrames);
8451 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
8452 DALI_TEST_CHECK(keyFrames2);
8454 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
8455 DALI_TEST_CHECK(keyFrames3);
8457 BaseHandle unInitializedObject;
8458 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
8459 DALI_TEST_CHECK(!keyFrames4);
8461 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
8462 DALI_TEST_CHECK(!keyFrames5);
8466 int UtcDaliAnimationResizeByXY(void)
8468 TestApplication application;
8470 Actor actor = Actor::New();
8471 Stage::GetCurrent().Add(actor);
8472 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8474 // Build the animation
8475 float durationSeconds(1.0f);
8476 Animation animation = Animation::New(durationSeconds);
8477 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8478 animation.Resize(actor, targetSize);
8480 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8482 // Start the animation
8485 bool signalReceived(false);
8486 AnimationFinishCheck finishCheck(signalReceived);
8487 animation.FinishedSignal().Connect(&application, finishCheck);
8489 application.SendNotification();
8490 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8492 // We didn't expect the animation to finish yet
8493 application.SendNotification();
8494 finishCheck.CheckSignalNotReceived();
8495 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8497 application.SendNotification();
8498 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8500 // We did expect the animation to finish
8501 application.SendNotification();
8502 finishCheck.CheckSignalReceived();
8503 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8506 finishCheck.Reset();
8507 actor.SetSize(Vector3::ZERO);
8508 application.SendNotification();
8509 application.Render(0);
8510 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8512 // Repeat with a different (ease-in) alpha function
8513 animation = Animation::New(durationSeconds);
8514 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
8515 animation.FinishedSignal().Connect(&application, finishCheck);
8518 application.SendNotification();
8519 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8521 // We didn't expect the animation to finish yet
8522 application.SendNotification();
8523 finishCheck.CheckSignalNotReceived();
8525 // The size should have travelled less, than with a linear alpha function
8526 Vector3 current(actor.GetCurrentSize());
8527 DALI_TEST_CHECK( current.x > 0.0f );
8528 DALI_TEST_CHECK( current.y > 0.0f );
8529 DALI_TEST_CHECK( current.z > 0.0f );
8530 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8531 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8532 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8534 application.SendNotification();
8535 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8537 // We did expect the animation to finish
8538 application.SendNotification();
8539 finishCheck.CheckSignalReceived();
8540 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8543 finishCheck.Reset();
8544 actor.SetSize(Vector3::ZERO);
8545 application.SendNotification();
8546 application.Render(0);
8547 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8549 // Repeat with a delay
8551 animation = Animation::New(durationSeconds);
8552 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
8553 animation.FinishedSignal().Connect(&application, finishCheck);
8556 application.SendNotification();
8557 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8559 // We didn't expect the animation to finish yet
8560 application.SendNotification();
8561 finishCheck.CheckSignalNotReceived();
8562 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8564 application.SendNotification();
8565 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8567 // We did expect the animation to finish
8568 application.SendNotification();
8569 finishCheck.CheckSignalReceived();
8570 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8575 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
8577 TestApplication application;
8579 float startValue(1.0f);
8580 Actor actor = Actor::New();
8581 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8582 Stage::GetCurrent().Add(actor);
8584 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8585 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8586 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8587 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8588 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8590 // Build the animation
8591 float durationSeconds(1.0f);
8592 Animation animation = Animation::New(durationSeconds);
8594 KeyFrames keyFrames = KeyFrames::New();
8595 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8596 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8597 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8599 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
8601 // Start the animation
8604 bool signalReceived(false);
8605 AnimationFinishCheck finishCheck(signalReceived);
8606 animation.FinishedSignal().Connect(&application, finishCheck);
8607 application.SendNotification();
8608 application.Render(0);
8609 application.SendNotification();
8610 finishCheck.CheckSignalNotReceived();
8611 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8612 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8613 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8614 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8616 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8617 application.SendNotification();
8618 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8619 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8620 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8621 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8623 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8624 application.SendNotification();
8625 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8626 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8627 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8628 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8630 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8631 application.SendNotification();
8632 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8634 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8635 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8637 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8638 application.SendNotification();
8639 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8640 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8641 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8644 // We did expect the animation to finish
8646 finishCheck.CheckSignalReceived();
8650 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
8652 TestApplication application;
8654 float startValue(1.0f);
8655 Actor actor = Actor::New();
8656 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8657 Stage::GetCurrent().Add(actor);
8659 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8660 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8661 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8662 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8663 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8665 // Build the animation
8666 float durationSeconds(1.0f);
8667 Animation animation = Animation::New(durationSeconds);
8669 KeyFrames keyFrames = KeyFrames::New();
8670 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8671 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8672 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8674 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
8676 // Start the animation
8679 bool signalReceived(false);
8680 AnimationFinishCheck finishCheck(signalReceived);
8681 animation.FinishedSignal().Connect(&application, finishCheck);
8682 application.SendNotification();
8683 application.Render(0);
8684 application.SendNotification();
8685 finishCheck.CheckSignalNotReceived();
8686 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8687 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8688 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8689 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8691 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8692 application.SendNotification();
8693 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8694 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8695 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8696 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8698 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8699 application.SendNotification();
8700 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8701 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8702 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8703 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8705 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8706 application.SendNotification();
8707 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8708 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8709 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8710 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8713 application.SendNotification();
8714 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8715 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8716 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8719 // We did expect the animation to finish
8721 finishCheck.CheckSignalReceived();
8725 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
8727 TestApplication application;
8729 float startValue(1.0f);
8730 Actor actor = Actor::New();
8731 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8732 Stage::GetCurrent().Add(actor);
8734 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8735 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), startValue, TEST_LOCATION );
8736 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
8737 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), startValue, TEST_LOCATION );
8738 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
8740 // Build the animation
8741 float durationSeconds(1.0f);
8742 Animation animation = Animation::New(durationSeconds);
8744 KeyFrames keyFrames = KeyFrames::New();
8745 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8746 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8747 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8749 animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
8751 // Start the animation
8754 bool signalReceived(false);
8755 AnimationFinishCheck finishCheck(signalReceived);
8756 animation.FinishedSignal().Connect(&application, finishCheck);
8757 application.SendNotification();
8758 application.Render(0);
8759 application.SendNotification();
8760 finishCheck.CheckSignalNotReceived();
8761 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8762 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8763 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8764 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8766 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8767 application.SendNotification();
8768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8771 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8773 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8774 application.SendNotification();
8775 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8776 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8777 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8778 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8780 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8781 application.SendNotification();
8782 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8783 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8784 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8785 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8787 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8788 application.SendNotification();
8789 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8790 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8791 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8794 // We did expect the animation to finish
8796 finishCheck.CheckSignalReceived();
8800 int UtcDaliAnimationAnimateVector3Func(void)
8802 TestApplication application;
8804 Actor actor = Actor::New();
8805 Vector3 initialPosition(Vector3::ZERO);
8806 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8807 Stage::GetCurrent().Add(actor);
8809 // Build the animation
8810 float durationSeconds(10.0f);
8811 Animation animation = Animation::New(durationSeconds);
8812 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
8813 BounceFunc func(0.0f, 0.0f, -100.0f);
8814 animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
8816 // Start the animation
8819 bool signalReceived(false);
8820 AnimationFinishCheck finishCheck(signalReceived);
8821 animation.FinishedSignal().Connect(&application, finishCheck);
8823 application.SendNotification();
8824 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8826 // We didn't expect the animation to finish yet
8827 application.SendNotification();
8828 finishCheck.CheckSignalNotReceived();
8829 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
8831 application.SendNotification();
8832 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8834 // We didn't expect the animation to finish yet
8835 application.SendNotification();
8836 finishCheck.CheckSignalNotReceived();
8837 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
8839 application.SendNotification();
8840 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8842 // We didn't expect the animation to finish yet
8843 application.SendNotification();
8844 finishCheck.CheckSignalNotReceived();
8845 DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
8847 application.SendNotification();
8848 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8850 // We did expect the animation to finish
8851 application.SendNotification();
8852 finishCheck.CheckSignalReceived();
8853 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
8857 int UtcDaliAnimationCreateDestroy(void)
8859 TestApplication application;
8860 Animation* animation = new Animation;
8861 DALI_TEST_CHECK( animation );