2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/dali-core.h>
23 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali-test-suite-utils.h>
25 #include <dali/devel-api/animation/animation-devel.h>
30 void utc_dali_animation_startuP(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_animation_cleanuP(void)
37 test_return_value = TET_PASS;
43 static const float ROTATION_EPSILON = 0.0001f;
44 static const float VECTOR4_EPSILON = 0.0001f;
46 // Functor to test whether a Finish signal is emitted
47 struct AnimationFinishCheck
49 AnimationFinishCheck(bool& signalReceived)
50 : mSignalReceived(signalReceived)
54 void operator()(Animation& animation)
56 mSignalReceived = true;
61 mSignalReceived = false;
64 void CheckSignalReceived()
68 tet_printf("Expected Finish signal was not received\n");
77 void CheckSignalNotReceived()
81 tet_printf("Unexpected Finish signal was received\n");
90 bool& mSignalReceived; // owned by individual tests
93 // Functor to test whether a Progress signal is emitted
94 struct AnimationProgressCheck
96 AnimationProgressCheck(bool& signalReceived, std::string name = " ")
97 : mSignalReceived(signalReceived),
102 void operator()(Animation& animation)
104 mSignalReceived = true;
109 mSignalReceived = false;
112 void CheckSignalReceived()
114 if (!mSignalReceived)
116 tet_printf("Expected Progress reached signal was not received %s \n", mName.c_str() );
117 tet_result(TET_FAIL);
121 tet_result(TET_PASS);
125 void CheckSignalNotReceived()
129 tet_printf("Unexpected Progress reached signal was received %s \n", mName.c_str());
130 tet_result(TET_FAIL);
134 tet_result(TET_PASS);
138 bool& mSignalReceived; // owned by individual tests
144 int UtcDaliAnimationConstructorP(void)
146 TestApplication application;
150 DALI_TEST_CHECK( !animation );
154 int UtcDaliAnimationNewP(void)
156 TestApplication application;
158 Animation animation = Animation::New( 1.0f );
160 DALI_TEST_CHECK(animation);
164 int UtcDaliAnimationNewN(void)
166 TestApplication application;
168 Animation animation = Animation::New( -1.0f );
170 DALI_TEST_CHECK(animation);
171 DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
175 int UtcDaliAnimationDownCastP(void)
177 TestApplication application;
179 tet_infoline("Testing Dali::Animation::DownCast()");
181 float durationSeconds(1.0f);
182 Animation animation = Animation::New(durationSeconds);
184 BaseHandle object(animation);
186 Animation animation2 = Animation::DownCast(object);
187 DALI_TEST_CHECK(animation2);
189 Animation animation3 = DownCast< Animation >(object);
190 DALI_TEST_CHECK(animation3);
194 int UtcDaliAnimationDownCastN(void)
196 TestApplication application;
198 BaseHandle unInitializedObject;
200 Animation animation1 = Animation::DownCast( unInitializedObject );
201 DALI_TEST_CHECK( !animation1 );
203 Animation animation2 = DownCast< Animation >( unInitializedObject );
204 DALI_TEST_CHECK( !animation2 );
208 int UtcDaliAnimationCopyConstructorP(void)
210 TestApplication application;
212 // Initialize an object, ref count == 1
213 Animation animation = Animation::New( 1.0f );
215 Animation copy( animation );
216 DALI_TEST_CHECK( copy );
218 DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
222 int UtcDaliAnimationAssignmentOperatorP(void)
224 TestApplication application;
226 Animation animation = Animation::New( 1.0f );
228 Animation copy = animation;
229 DALI_TEST_CHECK( copy );
231 DALI_TEST_CHECK( animation == copy );
233 DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
237 int UtcDaliAnimationSetDurationP(void)
239 TestApplication application;
241 Actor actor = Actor::New();
242 Stage::GetCurrent().Add(actor);
244 // Build the animation
245 float durationSeconds(1.0f);
246 Animation animation = Animation::New(durationSeconds);
247 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
249 // Start the animation
250 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
251 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
254 bool signalReceived(false);
255 AnimationFinishCheck finishCheck(signalReceived);
256 animation.FinishedSignal().Connect(&application, finishCheck);
258 application.SendNotification();
259 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
261 // We didn't expect the animation to finish yet
262 application.SendNotification();
263 finishCheck.CheckSignalNotReceived();
265 application.Render(2u/*just beyond the animation duration*/);
267 // We did expect the animation to finish
268 application.SendNotification();
269 finishCheck.CheckSignalReceived();
270 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
272 // Restart the animation, with a different duration
274 actor.SetPosition(Vector3::ZERO);
275 durationSeconds = 3.5f;
276 animation.SetDuration(durationSeconds);
277 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
280 application.SendNotification();
281 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
283 // We didn't expect the animation to finish yet
284 application.SendNotification();
285 finishCheck.CheckSignalNotReceived();
287 application.Render(2u/*just beyond the animation duration*/);
289 // We did expect the animation to finish
290 application.SendNotification();
291 finishCheck.CheckSignalReceived();
292 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
294 // Check that nothing has changed after a couple of buffer swaps
295 application.Render(0);
296 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
297 application.Render(0);
298 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
302 int UtcDaliAnimationSetDurationN(void)
304 TestApplication application;
306 Animation animation = Animation::New( 1.0f );
307 DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
309 animation.SetDuration( -1.0f );
310 DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
314 int UtcDaliAnimationGetDurationP(void)
316 TestApplication application;
318 Animation animation = Animation::New(1.0f);
319 DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
321 animation.SetDuration(2.0f);
322 DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
326 int UtcDaliAnimationSetLoopingP(void)
328 TestApplication application;
330 Actor actor = Actor::New();
331 Stage::GetCurrent().Add(actor);
333 // Build the animation
334 float durationSeconds(1.0f);
335 Animation animation = Animation::New(durationSeconds);
336 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
337 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
339 // Start the animation
340 animation.SetLooping(true);
341 DALI_TEST_CHECK(animation.IsLooping());
344 bool signalReceived(false);
345 AnimationFinishCheck finishCheck(signalReceived);
346 animation.FinishedSignal().Connect(&application, finishCheck);
348 application.SendNotification();
351 float intervalSeconds = 0.25f;
352 float progress = 0.0f;
353 for (int iterations = 0; iterations < 5;)
355 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
357 progress += intervalSeconds;
358 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
360 if (progress >= 1.0f)
362 progress = progress - 1.0f;
367 // We didn't expect the animation to finish yet
368 application.SendNotification();
369 finishCheck.CheckSignalNotReceived();
371 animation.SetLooping(false);
372 DALI_TEST_CHECK(!animation.IsLooping());
374 application.SendNotification();
375 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
377 // We did expect the animation to finish
378 application.SendNotification();
379 finishCheck.CheckSignalReceived();
380 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
382 // Check that nothing has changed after a couple of buffer swaps
383 application.Render(0);
384 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
385 application.Render(0);
386 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
390 int UtcDaliAnimationSetLoopCountP(void)
392 TestApplication application;
394 Actor actor = Actor::New();
395 Stage::GetCurrent().Add(actor);
397 // Build the animation
398 float durationSeconds(1.0f);
399 Animation animation = Animation::New(durationSeconds);
400 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
401 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
403 // Start the animation
404 animation.SetLoopCount(3);
405 DALI_TEST_CHECK(animation.IsLooping());
408 bool signalReceived(false);
409 AnimationFinishCheck finishCheck(signalReceived);
410 animation.FinishedSignal().Connect(&application, finishCheck);
412 application.Render(0);
413 application.SendNotification();
414 application.Render(0);
415 application.SendNotification();
416 application.Render(0);
417 application.SendNotification();
418 application.Render(0);
419 application.SendNotification();
422 float intervalSeconds = 3.0f;
424 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
425 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
427 application.Render(0);
428 application.SendNotification();
429 application.Render(0);
430 application.SendNotification();
431 application.Render(0);
432 application.SendNotification();
433 application.Render(0);
434 application.SendNotification();
435 finishCheck.CheckSignalNotReceived();
437 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
439 application.SendNotification();
440 finishCheck.CheckSignalReceived();
441 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
445 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
446 application.SendNotification();
447 finishCheck.CheckSignalNotReceived();
449 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
450 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
451 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
452 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
453 application.SendNotification();
454 finishCheck.CheckSignalNotReceived();
459 int UtcDaliAnimationSetLoopCountP2(void)
461 TestApplication application;
464 // switching between forever and loop count
467 Actor actor = Actor::New();
468 Stage::GetCurrent().Add(actor);
470 // Build the animation
471 float durationSeconds(1.0f);
472 Animation animation = Animation::New(durationSeconds);
473 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
474 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
475 animation.SetEndAction(Animation::Discard);
477 // Start the animation
478 animation.SetLoopCount(3);
479 DALI_TEST_CHECK(animation.IsLooping());
482 bool signalReceived(false);
483 AnimationFinishCheck finishCheck(signalReceived);
484 animation.FinishedSignal().Connect(&application, finishCheck);
486 float intervalSeconds = 3.0f;
488 application.SendNotification();
489 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
490 application.SendNotification();
491 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
492 application.SendNotification();
493 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
494 application.SendNotification();
496 application.SendNotification();
497 finishCheck.CheckSignalReceived();
502 animation.SetLooping(true);
503 DALI_TEST_CHECK(animation.IsLooping());
505 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
506 application.SendNotification();
507 finishCheck.CheckSignalNotReceived();
509 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
510 application.SendNotification();
511 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
512 application.SendNotification();
513 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
514 application.SendNotification();
515 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
516 application.SendNotification();
517 application.SendNotification();
518 finishCheck.CheckSignalNotReceived();
523 animation.SetLoopCount(3);
524 DALI_TEST_CHECK(animation.IsLooping());
527 application.SendNotification();
528 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
529 application.SendNotification();
530 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
531 application.SendNotification();
532 finishCheck.CheckSignalNotReceived();
534 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
535 application.SendNotification();
536 finishCheck.CheckSignalReceived();
541 animation.SetLooping(true);
542 DALI_TEST_CHECK(animation.IsLooping());
544 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
545 application.SendNotification();
546 finishCheck.CheckSignalNotReceived();
548 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
549 application.SendNotification();
550 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
551 application.SendNotification();
552 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
553 application.SendNotification();
554 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
555 application.SendNotification();
556 finishCheck.CheckSignalNotReceived();
561 animation.SetLoopCount(3);
562 DALI_TEST_CHECK(animation.IsLooping());
564 application.SendNotification();
565 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
566 application.SendNotification();
567 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
568 application.SendNotification();
569 finishCheck.CheckSignalNotReceived();
571 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
572 application.SendNotification();
573 finishCheck.CheckSignalNotReceived(); // we never hit play
581 int UtcDaliAnimationSetLoopCountP3(void)
583 TestApplication application;
586 // switching between forever and loop count
588 Actor actor = Actor::New();
589 Stage::GetCurrent().Add(actor);
591 // Build the animation
592 float durationSeconds(1.0f);
593 Animation animation = Animation::New(durationSeconds);
594 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
595 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
596 animation.SetEndAction(Animation::Discard);
598 float intervalSeconds = 3.0f;
600 bool signalReceived(false);
601 AnimationFinishCheck finishCheck(signalReceived);
602 animation.FinishedSignal().Connect(&application, finishCheck);
605 animation.SetLooping(true);
606 DALI_TEST_CHECK(animation.IsLooping());
608 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
609 application.SendNotification();
610 finishCheck.CheckSignalNotReceived();
612 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
613 application.SendNotification();
614 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
615 application.SendNotification();
616 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
617 application.SendNotification();
618 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
619 application.SendNotification();
620 finishCheck.CheckSignalNotReceived();
625 animation.SetLoopCount(3);
626 DALI_TEST_CHECK(animation.IsLooping());
628 application.SendNotification();
629 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
630 application.SendNotification();
631 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
632 application.SendNotification();
633 finishCheck.CheckSignalNotReceived();
635 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
636 application.SendNotification();
637 finishCheck.CheckSignalNotReceived(); // we never hit play
645 int UtcDaliAnimationSetLoopCountP4(void)
647 TestApplication application;
652 Actor actor = Actor::New();
653 Stage::GetCurrent().Add(actor);
655 // Build the animation
656 float durationSeconds(1.0f);
657 Animation animation = Animation::New(durationSeconds);
658 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
659 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
660 animation.SetEndAction(Animation::Bake);
662 float intervalSeconds = 3.0f;
664 bool signalReceived(false);
665 AnimationFinishCheck finishCheck(signalReceived);
666 animation.FinishedSignal().Connect(&application, finishCheck);
668 animation.SetLoopCount(1);
670 DALI_TEST_CHECK(!animation.IsLooping());
672 application.SendNotification();
673 finishCheck.CheckSignalNotReceived();
674 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
675 application.SendNotification();
676 finishCheck.CheckSignalReceived();
678 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
679 actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
683 animation.Play(); // again
684 DALI_TEST_CHECK(!animation.IsLooping());
686 application.SendNotification();
687 finishCheck.CheckSignalNotReceived();
688 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
689 application.SendNotification();
690 finishCheck.CheckSignalReceived();
692 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
697 int UtcDaliAnimationGetLoopCountP(void)
699 TestApplication application;
701 Actor actor = Actor::New();
702 Stage::GetCurrent().Add(actor);
704 // Build the animation
705 float durationSeconds(1.0f);
706 Animation animation = Animation::New(durationSeconds);
707 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
708 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
710 DALI_TEST_CHECK(1 == animation.GetLoopCount());
712 // Start the animation
713 animation.SetLoopCount(3);
714 DALI_TEST_CHECK(animation.IsLooping());
715 DALI_TEST_CHECK(3 == animation.GetLoopCount());
719 application.Render(0);
720 application.SendNotification();
723 float intervalSeconds = 3.0f;
725 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
726 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
728 application.Render(0);
729 application.SendNotification();
731 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
732 application.SendNotification();
734 animation.SetLoopCount(0);
735 DALI_TEST_CHECK(animation.IsLooping());
736 DALI_TEST_CHECK(0 == animation.GetLoopCount());
738 animation.SetLoopCount(1);
739 DALI_TEST_CHECK(!animation.IsLooping());
740 DALI_TEST_CHECK(1 == animation.GetLoopCount());
746 int UtcDaliAnimationGetCurrentLoopP(void)
748 TestApplication application;
750 Actor actor = Actor::New();
751 Stage::GetCurrent().Add(actor);
753 // Build the animation
754 float durationSeconds(1.0f);
755 Animation animation = Animation::New(durationSeconds);
756 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
757 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
759 // Start the animation
760 animation.SetLoopCount(3);
761 DALI_TEST_CHECK(animation.IsLooping());
762 DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
765 bool signalReceived(false);
766 AnimationFinishCheck finishCheck(signalReceived);
767 animation.FinishedSignal().Connect(&application, finishCheck);
769 application.SendNotification();
772 float intervalSeconds = 3.0f;
774 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
775 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
777 application.SendNotification();
778 finishCheck.CheckSignalNotReceived();
779 DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
781 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
783 application.SendNotification();
784 finishCheck.CheckSignalReceived();
785 DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
786 DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
790 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
791 application.SendNotification();
792 finishCheck.CheckSignalNotReceived();
793 DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
795 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
796 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
797 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
798 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
799 application.SendNotification();
800 finishCheck.CheckSignalNotReceived();
801 DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
806 int UtcDaliAnimationIsLoopingP(void)
808 TestApplication application;
810 Animation animation = Animation::New(1.0f);
811 DALI_TEST_CHECK(!animation.IsLooping());
813 animation.SetLooping(true);
814 DALI_TEST_CHECK(animation.IsLooping());
818 int UtcDaliAnimationSetEndActioN(void)
820 TestApplication application;
822 Actor actor = Actor::New();
823 Stage::GetCurrent().Add(actor);
825 // Build the animation
826 float durationSeconds(1.0f);
827 Animation animation = Animation::New(durationSeconds);
828 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
830 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
831 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
833 // Start the animation
836 bool signalReceived(false);
837 AnimationFinishCheck finishCheck(signalReceived);
838 animation.FinishedSignal().Connect(&application, finishCheck);
840 application.SendNotification();
841 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
843 // We did expect the animation to finish
844 application.SendNotification();
845 finishCheck.CheckSignalReceived();
846 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
848 // Go back to the start
849 actor.SetPosition(Vector3::ZERO);
850 application.SendNotification();
851 application.Render(0);
852 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
854 // Test BakeFinal, animate again, for half the duration
856 animation.SetEndAction(Animation::BakeFinal);
857 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
860 application.SendNotification();
861 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
863 // Stop the animation early
866 // We did NOT expect the animation to finish
867 application.SendNotification();
868 finishCheck.CheckSignalNotReceived();
869 DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
871 // The position should be same with target position in the next frame
872 application.Render(0);
873 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
875 // Go back to the start
876 actor.SetPosition(Vector3::ZERO);
877 application.SendNotification();
878 application.Render(0);
879 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
881 // Test EndAction::Discard, animate again, but don't bake this time
883 animation.SetEndAction(Animation::Discard);
884 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
887 application.SendNotification();
888 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
890 // We did expect the animation to finish
891 application.SendNotification();
892 finishCheck.CheckSignalReceived();
893 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
895 // The position should be discarded in the next frame
896 application.Render(0);
897 DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
899 // Check that nothing has changed after a couple of buffer swaps
900 application.Render(0);
901 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
902 application.Render(0);
903 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
907 int UtcDaliAnimationGetEndActionP(void)
909 TestApplication application;
911 Animation animation = Animation::New(1.0f);
912 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
914 animation.SetEndAction(Animation::Discard);
915 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
917 animation.SetEndAction(Animation::BakeFinal);
918 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
923 int UtcDaliAnimationSetDisconnectActionP(void)
925 TestApplication application;
926 Stage stage( Stage::GetCurrent() );
928 // Default: BakeFinal
930 Actor actor = Actor::New();
933 // Build the animation
934 float durationSeconds(1.0f);
935 Animation animation = Animation::New(durationSeconds);
936 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
938 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
939 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
941 // Start the animation
944 application.SendNotification();
945 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
957 Actor actor = Actor::New();
960 // Build the animation
961 float durationSeconds(1.0f);
962 Animation animation = Animation::New(durationSeconds);
963 animation.SetDisconnectAction( Animation::Bake );
965 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
966 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
968 // Start the animation
971 application.SendNotification();
972 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
984 Actor actor = Actor::New();
987 // Build the animation
988 float durationSeconds(1.0f);
989 Animation animation = Animation::New(durationSeconds);
990 animation.SetDisconnectAction( Animation::Discard );
992 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
993 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
995 // Start the animation
998 application.SendNotification();
999 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1003 application.SendNotification();
1004 application.Render();
1006 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
1009 // Don't play the animation: disconnect action should not be applied
1011 Actor actor = Actor::New();
1014 // Build the animation
1015 float durationSeconds(1.0f);
1016 Animation animation = Animation::New(durationSeconds);
1018 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
1019 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1021 application.SendNotification();
1022 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
1035 int UtcDaliAnimationGetDisconnectActionP(void)
1037 TestApplication application;
1038 Animation animation = Animation::New(1.0f);
1039 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
1041 animation.SetDisconnectAction(Animation::Discard);
1042 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
1044 animation.SetDisconnectAction(Animation::Bake);
1045 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
1050 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
1052 TestApplication application;
1054 Animation animation = Animation::New(1.0f);
1055 AlphaFunction func = animation.GetDefaultAlphaFunction();
1056 DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1058 animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1059 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1060 DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1064 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
1066 TestApplication application;
1068 Animation animation = Animation::New(1.0f);
1069 AlphaFunction func = animation.GetDefaultAlphaFunction();
1071 // Test that the default is linear
1072 DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1074 animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1075 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1076 DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1081 int UtcDaliAnimationSetCurrentProgressP(void)
1083 TestApplication application;
1085 Actor actor = Actor::New();
1086 Stage::GetCurrent().Add(actor);
1088 // Build the animation
1089 Animation animation = Animation::New(0.0f);
1092 float durationSeconds(1.0f);
1093 animation.SetDuration(durationSeconds);
1095 bool signalReceived(false);
1096 AnimationFinishCheck finishCheck(signalReceived);
1097 animation.FinishedSignal().Connect(&application, finishCheck);
1098 application.SendNotification();
1100 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1101 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1103 // Start the animation from 40% progress
1104 animation.SetCurrentProgress( 0.4f );
1107 application.SendNotification();
1108 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1110 // We didn't expect the animation to finish yet
1111 application.SendNotification();
1112 finishCheck.CheckSignalNotReceived();
1113 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1114 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1116 animation.Play(); // Test that calling play has no effect, when animation is already playing
1117 application.SendNotification();
1119 //Set the progress to 70%
1120 animation.SetCurrentProgress( 0.7f );
1121 application.SendNotification();
1122 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1123 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1125 application.SendNotification();
1126 finishCheck.CheckSignalNotReceived();
1127 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1128 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1130 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1131 // We did expect the animation to finish
1132 application.SendNotification();
1133 finishCheck.CheckSignalReceived();
1134 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1136 // Check that nothing has changed after a couple of buffer swaps
1137 application.Render(0);
1138 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1139 application.Render(0);
1140 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1144 int UtcDaliAnimationSetCurrentProgressN(void)
1146 TestApplication application;
1148 Actor actor = Actor::New();
1149 Stage::GetCurrent().Add(actor);
1151 // Build the animation
1152 Animation animation = Animation::New(0.0f);
1155 float durationSeconds(1.0f);
1156 animation.SetDuration(durationSeconds);
1158 bool signalReceived(false);
1159 AnimationFinishCheck finishCheck(signalReceived);
1160 animation.FinishedSignal().Connect(&application, finishCheck);
1161 application.SendNotification();
1163 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1164 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1166 //Trying to set the current cursor outside the range [0..1] is ignored
1167 animation.SetCurrentProgress( -1.0f);
1168 application.SendNotification();
1169 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1171 animation.SetCurrentProgress( 100.0f);
1172 application.SendNotification();
1173 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1177 int UtcDaliAnimationGetCurrentProgressP(void)
1179 TestApplication application;
1181 Actor actor = Actor::New();
1182 Stage::GetCurrent().Add(actor);
1184 // Build the animation
1185 Animation animation = Animation::New(0.0f);
1188 //Test GetCurrentProgress return 0.0 as the duration is 0.0
1189 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1191 animation.SetCurrentProgress( 0.5f );
1192 application.SendNotification();
1193 application.Render(static_cast<unsigned int>(100.0f));
1195 //Progress should still be 0.0
1196 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1199 float durationSeconds(1.0f);
1200 animation.SetDuration(durationSeconds);
1201 application.SendNotification();
1203 bool signalReceived(false);
1204 AnimationFinishCheck finishCheck(signalReceived);
1205 animation.FinishedSignal().Connect(&application, finishCheck);
1206 application.SendNotification();
1208 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1209 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1211 // Start the animation from 40% progress
1212 animation.SetCurrentProgress( 0.4f );
1215 application.SendNotification();
1216 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1218 // We didn't expect the animation to finish yet
1219 application.SendNotification();
1220 finishCheck.CheckSignalNotReceived();
1221 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1223 animation.Play(); // Test that calling play has no effect, when animation is already playing
1224 application.SendNotification();
1226 //Set the progress to 70%
1227 animation.SetCurrentProgress( 0.7f );
1228 application.SendNotification();
1229 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1230 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1232 application.SendNotification();
1233 finishCheck.CheckSignalNotReceived();
1234 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1236 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1237 // We did expect the animation to finish
1238 application.SendNotification();
1239 finishCheck.CheckSignalReceived();
1243 int UtcDaliAnimationSetSpeedFactorP1(void)
1245 TestApplication application;
1247 tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1249 Actor actor = Actor::New();
1250 Stage::GetCurrent().Add(actor);
1252 // Build the animation
1253 float durationSeconds(1.0f);
1254 Animation animation = Animation::New(durationSeconds);
1256 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1257 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1259 KeyFrames keyframes = KeyFrames::New();
1260 keyframes.Add( 0.0f, initialPosition);
1261 keyframes.Add( 1.0f, targetPosition );
1262 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1264 //Set speed to be x2
1265 animation.SetSpeedFactor(2.0f);
1267 // Start the animation
1270 bool signalReceived(false);
1271 AnimationFinishCheck finishCheck(signalReceived);
1272 animation.FinishedSignal().Connect(&application, finishCheck);
1274 application.SendNotification();
1275 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1277 // We didn't expect the animation to finish yet
1278 application.SendNotification();
1279 finishCheck.CheckSignalNotReceived();
1280 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1282 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1284 // We didn't expect the animation to finish yet
1285 application.SendNotification();
1286 finishCheck.CheckSignalNotReceived();
1287 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1289 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1291 // We did expect the animation to finish
1292 application.SendNotification();
1293 finishCheck.CheckSignalReceived();
1294 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1296 // Check that nothing has changed after a couple of buffer swaps
1297 application.Render(0);
1298 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1299 application.Render(0);
1300 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1305 int UtcDaliAnimationSetSpeedFactorP2(void)
1307 TestApplication application;
1309 Actor actor = Actor::New();
1310 Stage::GetCurrent().Add(actor);
1312 // Build the animation
1313 float durationSeconds(1.0f);
1314 Animation animation = Animation::New(durationSeconds);
1316 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1317 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1319 KeyFrames keyframes = KeyFrames::New();
1320 keyframes.Add( 0.0f, initialPosition);
1321 keyframes.Add( 1.0f, targetPosition );
1322 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1324 tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1325 animation.SetSpeedFactor( -1.0f );
1327 // Start the animation
1330 bool signalReceived(false);
1331 AnimationFinishCheck finishCheck(signalReceived);
1332 animation.FinishedSignal().Connect(&application, finishCheck);
1334 application.SendNotification();
1335 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1337 // We didn't expect the animation to finish yet
1338 application.SendNotification();
1339 finishCheck.CheckSignalNotReceived();
1340 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1342 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1344 // We didn't expect the animation to finish yet
1345 application.SendNotification();
1346 finishCheck.CheckSignalNotReceived();
1347 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1349 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1351 // We didn't expect the animation to finish yet
1352 application.SendNotification();
1353 finishCheck.CheckSignalNotReceived();
1354 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1356 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1358 // We didn't expect the animation to finish yet
1359 application.SendNotification();
1360 finishCheck.CheckSignalNotReceived();
1361 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1363 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1365 // We did expect the animation to finish
1366 application.SendNotification();
1367 finishCheck.CheckSignalReceived();
1368 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1370 // Check that nothing has changed after a couple of buffer swaps
1371 application.Render(0);
1372 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1373 application.Render(0);
1374 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1379 int UtcDaliAnimationSetSpeedFactorP3(void)
1381 TestApplication application;
1383 Actor actor = Actor::New();
1384 Stage::GetCurrent().Add(actor);
1386 // Build the animation
1387 float durationSeconds(1.0f);
1388 Animation animation = Animation::New(durationSeconds);
1390 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1391 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1393 KeyFrames keyframes = KeyFrames::New();
1394 keyframes.Add( 0.0f, initialPosition);
1395 keyframes.Add( 1.0f, targetPosition );
1396 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1398 bool signalReceived(false);
1399 AnimationFinishCheck finishCheck(signalReceived);
1400 animation.FinishedSignal().Connect(&application, finishCheck);
1402 tet_printf("Test half speed factor. Animation will take twice the duration\n");
1404 //Set speed to be half of normal speed
1405 animation.SetSpeedFactor( 0.5f );
1407 // Start the animation
1410 application.SendNotification();
1411 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1413 // We didn't expect the animation to finish yet
1414 application.SendNotification();
1415 finishCheck.CheckSignalNotReceived();
1416 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1418 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1420 // We didn't expect the animation to finish yet
1421 application.SendNotification();
1422 finishCheck.CheckSignalNotReceived();
1423 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1425 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1427 // We didn't expect the animation to finish yet
1428 application.SendNotification();
1429 finishCheck.CheckSignalNotReceived();
1430 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1432 application.SendNotification();
1433 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1435 // We didn't expect the animation to finish yet
1436 application.SendNotification();
1437 finishCheck.CheckSignalNotReceived();
1438 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1440 application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1442 // We did expect the animation to finish
1443 application.SendNotification();
1444 finishCheck.CheckSignalReceived();
1445 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1447 // Check that nothing has changed after a couple of buffer swaps
1448 application.Render(0);
1449 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1450 application.Render(0);
1451 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1456 int UtcDaliAnimationSetSpeedFactorP4(void)
1458 TestApplication application;
1460 Actor actor = Actor::New();
1461 Stage::GetCurrent().Add(actor);
1463 // Build the animation
1464 float durationSeconds(1.0f);
1465 Animation animation = Animation::New(durationSeconds);
1467 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1468 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1470 KeyFrames keyframes = KeyFrames::New();
1471 keyframes.Add( 0.0f, initialPosition);
1472 keyframes.Add( 1.0f, targetPosition );
1473 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1475 bool signalReceived(false);
1476 AnimationFinishCheck finishCheck(signalReceived);
1477 animation.FinishedSignal().Connect(&application, finishCheck);
1479 tet_printf("Test half speed factor. Animation will take twice the duration\n");
1481 tet_printf("Set speed to be half of normal speed\n");
1482 tet_printf("SetSpeedFactor(0.5f)\n");
1483 animation.SetSpeedFactor( 0.5f );
1485 // Start the animation
1488 application.SendNotification();
1489 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1491 // We didn't expect the animation to finish yet
1492 application.SendNotification();
1493 finishCheck.CheckSignalNotReceived();
1494 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1496 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1498 // We didn't expect the animation to finish yet
1499 application.SendNotification();
1500 finishCheck.CheckSignalNotReceived();
1501 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1503 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1505 // We didn't expect the animation to finish yet
1506 application.SendNotification();
1507 finishCheck.CheckSignalNotReceived();
1508 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1510 tet_printf("Reverse direction of animation whilst playing\n");
1511 tet_printf("SetSpeedFactor(-0.5f)\n");
1512 animation.SetSpeedFactor(-0.5f);
1514 application.SendNotification();
1515 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1517 // We didn't expect the animation to finish yet
1518 application.SendNotification();
1519 finishCheck.CheckSignalNotReceived();
1520 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1522 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1524 // We didn't expect the animation to finish yet
1525 application.SendNotification();
1526 finishCheck.CheckSignalNotReceived();
1527 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1529 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1531 // We did expect the animation to finish
1532 application.SendNotification();
1533 finishCheck.CheckSignalReceived();
1534 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1536 // Check that nothing has changed after a couple of buffer swaps
1537 application.Render(0);
1538 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1539 application.Render(0);
1540 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1544 int UtcDaliAnimationSetSpeedFactorAndRange(void)
1546 TestApplication application;
1548 const unsigned int NUM_FRAMES(15);
1556 float expected[NUM_FRAMES];
1559 TestData testData[] = {
1561 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1562 /* |----------PlayRange---------------| */
1564 { 0.0f, 1.0f, // TimePeriod
1565 0.0f, 100.0f, // POS
1566 {/**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1567 /**/ 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1578 // ACTOR 1 - Across start of range
1579 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1580 /* |----------PlayRange---------------| */
1582 { 0.2f, 0.5f, // TimePeriod
1583 20.0f, 50.0f, // POS
1584 {/**/ 30.0f, 40.0f, 50.0f, 50.0f, 50.0f, /* Loop */
1585 /**/ 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1595 // ACTOR 2 - Across end of range
1596 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1597 /* |----------PlayRange---------------| */
1599 {/**/ 0.5f, 0.9f, // TimePeriod
1600 /**/ 50.0f, 90.0f, // POS
1601 { /**/ 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1602 /**/ 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1611 // ACTOR 3 - Before beginning of range
1612 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1613 /* |----------PlayRange---------------| */
1615 {/**/ 0.1f, 0.25f, // TimePeriod
1616 /**/ 10.0f, 25.0f, // POS
1618 /**/ 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f
1623 // ACTOR 4 - After end of range
1624 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1625 /* |----------PlayRange---------------| */
1627 {/**/ 0.85f, 1.0f, // TimePeriod
1628 /**/ 85.0f, 100.0f, // POS
1630 /**/ 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f
1634 // Actor 5 - Middle of range
1635 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1636 /* |----------PlayRange---------------| */
1638 {/**/ 0.4f, 0.65f, // Time Period
1639 /**/ 40.0f, 65.0f, // Position
1640 { /**/ 40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1641 /**/ 40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1652 const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1654 // Build the animation
1655 float durationSeconds(1.0f);
1656 Animation animation = Animation::New(durationSeconds);
1657 bool signalReceived(false);
1658 AnimationFinishCheck finishCheck(signalReceived);
1659 animation.FinishedSignal().Connect(&application, finishCheck);
1661 std::vector<Dali::Actor> actors;
1663 for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1665 Actor actor = Actor::New();
1666 actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1667 actors.push_back(actor);
1668 Stage::GetCurrent().Add(actor);
1670 if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1672 KeyFrames keyframes = KeyFrames::New();
1673 keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1674 keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1675 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1679 animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1683 tet_printf("Test half speed factor. Animation will take twice the duration\n");
1684 tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1685 tet_printf("SetSpeedFactor(0.5f)\n");
1686 animation.SetSpeedFactor( 0.5f );
1687 animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1688 animation.SetLooping(true);
1690 // Start the animation
1692 application.SendNotification();
1693 application.Render(0); // Frame 0 tests initial values
1695 for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1697 unsigned int actorIndex = 0u;
1698 for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1700 DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1701 if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) )
1703 tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1709 tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1710 tet_printf("SetSpeedFactor(-0.5f)\n");
1711 animation.SetSpeedFactor(-0.5f);
1712 application.SendNotification();
1714 application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1716 // We didn't expect the animation to finish yet
1717 application.SendNotification();
1718 finishCheck.CheckSignalNotReceived();
1724 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void)
1726 TestApplication application;
1728 const unsigned int NUM_FRAMES(15);
1736 float expected[NUM_FRAMES];
1741 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1742 /* |----------PlayRange---------------| */
1743 { 0.0f, 1.0f, // TimePeriod
1744 0.0f, 100.0f, // POS
1745 {/**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1746 /**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1747 /**/ 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1753 // Build the animation
1754 float durationSeconds(1.0f);
1755 Animation animation = Animation::New(durationSeconds);
1756 bool signalReceived(false);
1757 AnimationFinishCheck finishCheck(signalReceived);
1758 animation.FinishedSignal().Connect(&application, finishCheck);
1760 std::vector<Dali::Actor> actors;
1762 Actor actor = Actor::New();
1763 actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1764 actors.push_back(actor);
1765 Stage::GetCurrent().Add(actor);
1767 KeyFrames keyframes = KeyFrames::New();
1768 keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1769 keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1770 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1772 tet_printf("Test half speed factor. Animation will take twice the duration\n");
1773 tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1774 tet_printf("SetSpeedFactor(0.5f)\n");
1775 tet_printf("SetLoopCount(3)\n");
1776 animation.SetSpeedFactor( 0.5f );
1777 animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1778 animation.SetLoopCount(3);
1780 // Start the animation
1782 application.SendNotification();
1783 application.Render(0); // Frame 0 tests initial values
1785 for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1787 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1789 application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1791 if( frame < NUM_FRAMES-1 )
1793 // We didn't expect the animation to finish yet
1794 application.SendNotification();
1795 finishCheck.CheckSignalNotReceived();
1799 // We did expect the animation to finish
1800 application.SendNotification();
1801 finishCheck.CheckSignalReceived();
1802 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION );
1807 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void)
1809 TestApplication application;
1811 const unsigned int NUM_FRAMES(15);
1819 float expected[NUM_FRAMES];
1824 /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1825 /* |----------PlayRange---------------| */
1826 { 0.0f, 1.0f, // TimePeriod
1827 0.0f, 100.0f, // POS
1828 {/**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1829 /**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1830 /**/ 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1835 // Build the animation
1836 float durationSeconds(1.0f);
1837 Animation animation = Animation::New(durationSeconds);
1838 bool signalReceived(false);
1839 AnimationFinishCheck finishCheck(signalReceived);
1840 animation.FinishedSignal().Connect(&application, finishCheck);
1842 std::vector<Dali::Actor> actors;
1844 Actor actor = Actor::New();
1845 actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1846 actors.push_back(actor);
1847 Stage::GetCurrent().Add(actor);
1849 KeyFrames keyframes = KeyFrames::New();
1850 keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1851 keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1852 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1854 tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1855 tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1856 tet_printf("SetSpeedFactor(-0.5f)\n");
1857 tet_printf("SetLoopCount(3)\n");
1858 animation.SetSpeedFactor( -0.5f );
1859 animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1860 animation.SetLoopCount(3);
1862 // Start the animation
1864 application.SendNotification();
1865 application.Render(0); // Frame 0 tests initial values
1867 for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1869 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1871 application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1873 if( frame < NUM_FRAMES-1 )
1875 // We didn't expect the animation to finish yet
1876 application.SendNotification();
1877 finishCheck.CheckSignalNotReceived();
1881 // We did expect the animation to finish
1882 application.SendNotification();
1883 finishCheck.CheckSignalReceived();
1884 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION );
1890 int UtcDaliAnimationGetSpeedFactorP(void)
1892 TestApplication application;
1894 Animation animation = Animation::New(1.0f);
1895 animation.SetSpeedFactor(0.5f);
1896 DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1898 animation.SetSpeedFactor(-2.5f);
1899 DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1903 int UtcDaliAnimationSetPlayRangeP(void)
1905 TestApplication application;
1907 Actor actor = Actor::New();
1908 Stage::GetCurrent().Add( actor );
1910 // Build the animation
1911 float durationSeconds( 1.0f );
1912 Animation animation = Animation::New( durationSeconds );
1914 bool signalReceived( false );
1915 AnimationFinishCheck finishCheck( signalReceived );
1916 animation.FinishedSignal().Connect( &application, finishCheck );
1917 application.SendNotification();
1919 // Set range between 0.4 and 0.8
1920 animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1921 application.SendNotification();
1922 DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1924 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1925 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1927 // Start the animation from 40% progress
1930 application.SendNotification();
1931 application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1933 // We didn't expect the animation to finish yet
1934 application.SendNotification();
1935 finishCheck.CheckSignalNotReceived();
1936 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
1938 application.SendNotification();
1939 application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1941 application.SendNotification();
1942 finishCheck.CheckSignalNotReceived();
1943 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
1945 application.SendNotification();
1946 application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1948 // We did expect the animation to finish
1949 application.SendNotification();
1950 finishCheck.CheckSignalReceived();
1951 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1955 int UtcDaliAnimationSetPlayRangeN(void)
1957 TestApplication application;
1959 Actor actor = Actor::New();
1960 Stage::GetCurrent().Add(actor);
1962 // Build the animation
1963 Animation animation = Animation::New(0);
1964 application.SendNotification();
1966 //PlayRange out of bounds
1967 animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1968 application.SendNotification();
1969 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1970 animation.SetPlayRange( Vector2(0.0f,2.0f) );
1971 application.SendNotification();
1972 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1974 //If playRange is not in the correct order it has to be ordered
1975 animation.SetPlayRange( Vector2(0.8f,0.2f) );
1976 application.SendNotification();
1977 DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1982 int UtcDaliAnimationGetPlayRangeP(void)
1984 TestApplication application;
1986 Actor actor = Actor::New();
1987 Stage::GetCurrent().Add( actor );
1989 // Build the animation
1990 Animation animation = Animation::New( 1.0f );
1991 application.SendNotification();
1993 //If PlayRange not specified it should be 0.0-1.0 by default
1994 DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1996 // Set range between 0.4 and 0.8
1997 animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1998 application.SendNotification();
1999 DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
2004 int UtcDaliAnimationPlayP(void)
2006 TestApplication application;
2008 Actor actor = Actor::New();
2009 Stage::GetCurrent().Add(actor);
2011 // Build the animation
2012 float durationSeconds(1.0f);
2013 Animation animation = Animation::New(durationSeconds);
2014 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2015 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2017 // Start the animation
2020 bool signalReceived(false);
2021 AnimationFinishCheck finishCheck(signalReceived);
2022 animation.FinishedSignal().Connect(&application, finishCheck);
2024 application.SendNotification();
2025 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2027 // We didn't expect the animation to finish yet
2028 application.SendNotification();
2029 finishCheck.CheckSignalNotReceived();
2030 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2032 animation.Play(); // Test that calling play has no effect, when animation is already playing
2033 application.SendNotification();
2034 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2036 // We didn't expect the animation to finish yet
2037 application.SendNotification();
2038 finishCheck.CheckSignalNotReceived();
2039 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2041 animation.Play(); // Test that calling play has no effect, when animation is already playing
2042 application.SendNotification();
2043 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2045 // We didn't expect the animation to finish yet
2046 application.SendNotification();
2047 finishCheck.CheckSignalNotReceived();
2048 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2050 animation.Play(); // Test that calling play has no effect, when animation is already playing
2051 application.SendNotification();
2052 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2054 // We didn't expect the animation to finish yet
2055 application.SendNotification();
2056 finishCheck.CheckSignalNotReceived();
2057 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2059 animation.Play(); // Test that calling play has no effect, when animation is already playing
2060 application.SendNotification();
2061 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2063 // We did expect the animation to finish
2064 application.SendNotification();
2065 finishCheck.CheckSignalReceived();
2066 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2068 // Check that nothing has changed after a couple of buffer swaps
2069 application.Render(0);
2070 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2071 application.Render(0);
2072 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2076 int UtcDaliAnimationPlayOffStageP(void)
2078 // Test that an animation can be played, when the actor is off-stage.
2079 // When the actor is added to the stage, it should appear at the current position
2080 // i.e. where it would have been anyway, if on-stage from the beginning.
2082 TestApplication application;
2084 Actor actor = Actor::New();
2085 Vector3 basePosition(Vector3::ZERO);
2086 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
2087 // Not added to the stage!
2089 // Build the animation
2090 float durationSeconds(1.0f);
2091 Animation animation = Animation::New(durationSeconds);
2092 animation.SetDisconnectAction( Animation::Discard );
2093 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2094 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2096 // Start the animation
2099 bool signalReceived(false);
2100 AnimationFinishCheck finishCheck(signalReceived);
2101 animation.FinishedSignal().Connect(&application, finishCheck);
2103 application.SendNotification();
2104 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2106 // We didn't expect the animation to finish yet
2107 application.SendNotification();
2108 finishCheck.CheckSignalNotReceived();
2109 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
2112 Stage::GetCurrent().Add(actor);
2114 application.SendNotification();
2115 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2117 // We didn't expect the animation to finish yet
2118 application.SendNotification();
2119 finishCheck.CheckSignalNotReceived();
2120 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
2121 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
2123 // Remove from the stage
2124 Stage::GetCurrent().Remove(actor);
2126 application.SendNotification();
2127 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2129 // We didn't expect the animation to finish yet
2130 application.SendNotification();
2131 finishCheck.CheckSignalNotReceived();
2132 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
2135 Stage::GetCurrent().Add(actor);
2137 application.SendNotification();
2138 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2140 // We didn't expect the animation to finish yet
2141 application.SendNotification();
2142 finishCheck.CheckSignalNotReceived();
2143 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
2144 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
2146 application.SendNotification();
2147 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2149 // We did expect the animation to finish
2150 application.SendNotification();
2151 finishCheck.CheckSignalReceived();
2152 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2154 // Check that nothing has changed after a couple of buffer swaps
2155 application.Render(0);
2156 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2157 application.Render(0);
2158 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2162 int UtcDaliAnimationPlayDiscardHandleP(void)
2164 TestApplication application;
2166 Actor actor = Actor::New();
2167 Stage::GetCurrent().Add(actor);
2169 // Build the animation
2170 float durationSeconds(1.0f);
2171 Animation animation = Animation::New(durationSeconds);
2172 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2173 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2175 bool signalReceived(false);
2176 AnimationFinishCheck finishCheck(signalReceived);
2177 animation.FinishedSignal().Connect(&application, finishCheck);
2179 // Start the animation
2182 // This is a test of the "Fire and Forget" behaviour
2183 // Discard the animation handle!
2185 DALI_TEST_CHECK( !animation );
2187 application.SendNotification();
2188 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2190 // We didn't expect the animation to finish yet
2191 application.SendNotification();
2192 finishCheck.CheckSignalNotReceived();
2193 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2195 application.SendNotification();
2196 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2198 // We didn't expect the animation to finish yet
2199 application.SendNotification();
2200 finishCheck.CheckSignalNotReceived();
2201 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2203 application.SendNotification();
2204 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2206 // We didn't expect the animation to finish yet
2207 application.SendNotification();
2208 finishCheck.CheckSignalNotReceived();
2209 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2211 application.SendNotification();
2212 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2214 // We didn't expect the animation to finish yet
2215 application.SendNotification();
2216 finishCheck.CheckSignalNotReceived();
2217 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2219 application.SendNotification();
2220 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2222 // We did expect the animation to finish
2223 application.SendNotification();
2224 finishCheck.CheckSignalReceived();
2225 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2227 // Check that nothing has changed after a couple of buffer swaps
2228 application.Render(0);
2229 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2230 application.Render(0);
2231 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2235 int UtcDaliAnimationPlayStopDiscardHandleP(void)
2237 TestApplication application;
2239 Actor actor = Actor::New();
2240 Stage::GetCurrent().Add(actor);
2242 // Build the animation
2243 float durationSeconds(1.0f);
2244 Animation animation = Animation::New(durationSeconds);
2245 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2246 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2248 // Start the animation
2251 bool signalReceived(false);
2252 AnimationFinishCheck finishCheck(signalReceived);
2253 animation.FinishedSignal().Connect(&application, finishCheck);
2255 application.SendNotification();
2256 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2258 // We didn't expect the animation to finish yet
2259 application.SendNotification();
2260 finishCheck.CheckSignalNotReceived();
2261 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2263 // This is a test of the "Fire and Forget" behaviour
2264 // Stop the animation, and Discard the animation handle!
2267 DALI_TEST_CHECK( !animation );
2269 application.SendNotification();
2270 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2272 // We expect the animation to finish at 20% progress
2273 application.SendNotification();
2274 finishCheck.CheckSignalReceived();
2275 finishCheck.Reset();
2276 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2278 application.SendNotification();
2279 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2281 // Check that nothing has changed
2282 application.SendNotification();
2283 finishCheck.CheckSignalNotReceived();
2284 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2286 application.SendNotification();
2287 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2289 // Check that nothing has changed
2290 application.SendNotification();
2291 finishCheck.CheckSignalNotReceived();
2292 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2294 application.SendNotification();
2295 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2297 // Check that nothing has changed
2298 application.SendNotification();
2299 finishCheck.CheckSignalNotReceived();
2300 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2304 int UtcDaliAnimationPlayRangeP(void)
2306 TestApplication application;
2308 Actor actor = Actor::New();
2309 Stage::GetCurrent().Add(actor);
2311 // Build the animation
2312 float durationSeconds(1.0f);
2313 Animation animation = Animation::New(durationSeconds);
2314 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2315 KeyFrames keyframes = KeyFrames::New();
2316 keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2317 keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2319 animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2321 // Set range between 0.4 and 0.8
2322 animation.SetPlayRange( Vector2(0.4f,0.8f) );
2325 bool signalReceived(false);
2326 AnimationFinishCheck finishCheck(signalReceived);
2327 animation.FinishedSignal().Connect(&application, finishCheck);
2329 //Test that setting progress outside the range doesn't work
2330 animation.SetCurrentProgress( 0.9f );
2331 application.SendNotification();
2332 application.Render(0);
2333 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2334 animation.SetCurrentProgress( 0.2f );
2335 application.SendNotification();
2336 application.Render(0);
2337 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2339 application.SendNotification();
2340 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2342 // We didn't expect the animation to finish yet
2343 application.SendNotification();
2344 finishCheck.CheckSignalNotReceived();
2345 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2347 animation.Play(); // Test that calling play has no effect, when animation is already playing
2348 application.SendNotification();
2349 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2351 // We did expect the animation to finish
2352 application.SendNotification();
2353 finishCheck.CheckSignalReceived();
2354 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2356 // Check that nothing has changed after a couple of buffer swaps
2357 application.Render(0);
2358 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2359 application.Render(0);
2360 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2363 //Loop inside the range
2364 finishCheck.Reset();
2365 animation.SetLooping( true );
2367 application.SendNotification();
2368 float intervalSeconds = 0.1f;
2369 float progress = 0.4f;
2370 for (int iterations = 0; iterations < 10; ++iterations )
2372 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2374 progress += intervalSeconds;
2375 if (progress > 0.8f)
2377 progress = progress - 0.4f;
2380 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2383 // We didn't expect the animation to finish yet
2384 application.SendNotification();
2385 finishCheck.CheckSignalNotReceived();
2388 //Test change range on the fly
2389 animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2390 application.SendNotification();
2392 for (int iterations = 0; iterations < 10; ++iterations )
2394 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2396 progress += intervalSeconds;
2397 if (progress > 0.9f)
2399 progress = progress - 0.7f;
2402 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2408 int UtcDaliAnimationPlayFromP(void)
2410 TestApplication application;
2412 Actor actor = Actor::New();
2413 Stage::GetCurrent().Add(actor);
2415 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2417 // Build the animation
2418 float durationSeconds(1.0f);
2419 Animation animation = Animation::New(durationSeconds);
2420 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2421 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2423 // Start the animation from 40% progress
2424 animation.PlayFrom( 0.4f );
2426 // Target value should be updated straight away
2427 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2429 bool signalReceived(false);
2430 AnimationFinishCheck finishCheck(signalReceived);
2431 animation.FinishedSignal().Connect(&application, finishCheck);
2433 application.SendNotification();
2434 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2436 // We didn't expect the animation to finish yet
2437 application.SendNotification();
2438 finishCheck.CheckSignalNotReceived();
2439 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2441 animation.Play(); // Test that calling play has no effect, when animation is already playing
2442 application.SendNotification();
2443 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2445 // We didn't expect the animation to finish yet
2446 application.SendNotification();
2447 finishCheck.CheckSignalNotReceived();
2448 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2450 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2451 // We did expect the animation to finish
2452 application.SendNotification();
2453 finishCheck.CheckSignalReceived();
2454 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2456 // Check that nothing has changed after a couple of buffer swaps
2457 application.Render(0);
2458 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2459 application.Render(0);
2460 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2464 int UtcDaliAnimationPlayFromN(void)
2466 TestApplication application;
2468 Actor actor = Actor::New();
2469 Stage::GetCurrent().Add(actor);
2471 // Build the animation
2472 float durationSeconds(1.0f);
2473 Animation animation = Animation::New(durationSeconds);
2474 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2475 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2477 //PlayFrom with an argument outside the range [0..1] will be ignored
2478 animation.PlayFrom(-1.0f);
2479 application.SendNotification();
2480 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2482 animation.PlayFrom(100.0f);
2483 application.SendNotification();
2484 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2488 int UtcDaliAnimationPauseP(void)
2490 TestApplication application;
2492 Actor actor = Actor::New();
2493 Stage::GetCurrent().Add(actor);
2495 // Build the animation
2496 float durationSeconds(1.0f);
2497 Animation animation = Animation::New(durationSeconds);
2498 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2499 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2501 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2503 // Start the animation
2506 bool signalReceived(false);
2507 AnimationFinishCheck finishCheck(signalReceived);
2508 animation.FinishedSignal().Connect(&application, finishCheck);
2510 application.SendNotification();
2511 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2513 // We didn't expect the animation to finish yet
2514 application.SendNotification();
2515 finishCheck.CheckSignalNotReceived();
2516 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2518 // Pause the animation
2520 application.SendNotification();
2523 for (int i=0; i<5; ++i)
2525 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2527 // We didn't expect the animation to finish yet
2528 application.SendNotification();
2529 finishCheck.CheckSignalNotReceived();
2530 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2535 application.SendNotification();
2536 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2538 // We didn't expect the animation to finish yet
2539 application.SendNotification();
2540 finishCheck.CheckSignalNotReceived();
2542 application.SendNotification();
2543 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2545 // We did expect the animation to finish
2546 application.SendNotification();
2547 finishCheck.CheckSignalReceived();
2548 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2550 // Check that nothing has changed after a couple of buffer swaps
2551 application.Render(0);
2552 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2553 application.Render(0);
2554 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2559 int UtcDaliAnimationGetStateP(void)
2561 TestApplication application;
2563 Actor actor = Actor::New();
2564 Stage::GetCurrent().Add(actor);
2566 // Build the animation
2567 float durationSeconds(1.0f);
2568 Animation animation = Animation::New(durationSeconds);
2569 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2570 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2571 DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2573 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2575 // Start the animation
2578 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2580 bool signalReceived(false);
2581 AnimationFinishCheck finishCheck(signalReceived);
2582 animation.FinishedSignal().Connect(&application, finishCheck);
2584 application.SendNotification();
2585 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2587 // We didn't expect the animation to finish yet
2588 application.SendNotification();
2589 finishCheck.CheckSignalNotReceived();
2590 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2591 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2593 // Pause the animation
2595 DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2596 application.SendNotification();
2597 application.Render(0.f);
2600 for (int i=0; i<5; ++i)
2602 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2604 // We didn't expect the animation to finish yet
2605 application.SendNotification();
2606 finishCheck.CheckSignalNotReceived();
2607 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2608 DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2612 finishCheck.Reset();
2614 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2615 application.SendNotification();
2616 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2617 // We didn't expect the animation to finish yet
2618 application.SendNotification();
2619 finishCheck.CheckSignalNotReceived();
2620 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2622 application.SendNotification();
2623 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2625 // We did expect the animation to finish
2626 application.SendNotification();
2627 finishCheck.CheckSignalReceived();
2628 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2629 DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2631 // Check that nothing has changed after a couple of buffer swaps
2632 application.Render(0);
2633 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2634 application.Render(0);
2635 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2636 DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2639 finishCheck.Reset();
2641 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2642 application.SendNotification();
2643 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2644 application.SendNotification();
2645 finishCheck.CheckSignalNotReceived();
2646 DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2652 int UtcDaliAnimationStopP(void)
2654 TestApplication application;
2656 Actor actor = Actor::New();
2657 Stage::GetCurrent().Add(actor);
2659 // Build the animation
2660 float durationSeconds(1.0f);
2661 Animation animation = Animation::New(durationSeconds);
2662 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2663 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2665 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2667 // Start the animation
2670 bool signalReceived(false);
2671 AnimationFinishCheck finishCheck(signalReceived);
2672 animation.FinishedSignal().Connect(&application, finishCheck);
2674 application.SendNotification();
2675 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2677 // We didn't expect the animation to finish yet
2678 application.SendNotification();
2679 finishCheck.CheckSignalNotReceived();
2680 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2682 // Stop the animation
2684 application.SendNotification();
2687 for (int i=0; i<5; ++i)
2689 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2691 // We did expect the animation to finish
2692 application.SendNotification();
2693 finishCheck.CheckSignalReceived();
2694 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2699 int UtcDaliAnimationStopSetPositionP(void)
2701 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2702 // i.e. to check that the animation does not interfere with the position set.
2704 TestApplication application;
2706 Actor actor = Actor::New();
2707 Stage::GetCurrent().Add(actor);
2709 // Build the animation
2710 float durationSeconds(1.0f);
2711 Animation animation = Animation::New(durationSeconds);
2712 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2713 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2715 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2717 // Start the animation
2720 bool signalReceived(false);
2721 AnimationFinishCheck finishCheck(signalReceived);
2722 animation.FinishedSignal().Connect(&application, finishCheck);
2724 application.SendNotification();
2725 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2727 // We didn't expect the animation to finish yet
2728 application.SendNotification();
2729 finishCheck.CheckSignalNotReceived();
2730 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2732 // Stop the animation
2734 Vector3 positionSet(2.0f, 3.0f, 4.0f);
2735 actor.SetPosition(positionSet);
2736 application.SendNotification();
2739 for (int i=0; i<5; ++i)
2741 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2743 // We did expect the animation to finish
2744 application.SendNotification();
2745 finishCheck.CheckSignalReceived();
2746 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2751 int UtcDaliAnimationClearP(void)
2753 TestApplication application;
2755 Actor actor = Actor::New();
2756 Stage::GetCurrent().Add(actor);
2758 // Build the animation
2759 float durationSeconds(1.0f);
2760 Animation animation = Animation::New(durationSeconds);
2761 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2762 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2764 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2766 // Start the animation
2769 bool signalReceived(false);
2770 AnimationFinishCheck finishCheck(signalReceived);
2771 animation.FinishedSignal().Connect(&application, finishCheck);
2773 application.SendNotification();
2774 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2776 // We didn't expect the animation to finish yet
2777 application.SendNotification();
2778 finishCheck.CheckSignalNotReceived();
2779 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2781 // Clear the animation
2783 application.SendNotification();
2785 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2787 // We don't expect the animation to finish now
2788 application.SendNotification();
2789 finishCheck.CheckSignalNotReceived();
2790 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2792 // Restart as a scale animation; this should not move the actor's position
2793 finishCheck.Reset();
2794 actor.SetPosition(Vector3::ZERO);
2795 Vector3 targetScale(3.0f, 3.0f, 3.0f);
2796 animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2799 application.SendNotification();
2800 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2802 // We didn't expect the animation to finish yet
2803 application.SendNotification();
2804 finishCheck.CheckSignalNotReceived();
2805 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2806 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2808 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2810 // We did expect the animation to finish
2811 application.SendNotification();
2812 finishCheck.CheckSignalReceived();
2813 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2814 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2818 int UtcDaliAnimationFinishedSignalP(void)
2820 TestApplication application;
2822 // Start the empty animation
2823 float durationSeconds(1.0f);
2824 Animation animation = Animation::New(durationSeconds);
2827 bool signalReceived(false);
2828 AnimationFinishCheck finishCheck(signalReceived);
2829 animation.FinishedSignal().Connect(&application, finishCheck);
2831 application.SendNotification();
2832 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2834 // We did expect the animation to finish
2835 application.SendNotification();
2836 finishCheck.CheckSignalReceived();
2840 int UtcDaliAnimationAnimateByBooleanP(void)
2842 TestApplication application;
2844 Actor actor = Actor::New();
2846 // Register a boolean property
2847 bool startValue(false);
2848 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
2849 Stage::GetCurrent().Add(actor);
2850 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2851 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2853 // Build the animation
2854 float durationSeconds(2.0f);
2855 Animation animation = Animation::New(durationSeconds);
2856 const bool relativeValue(true);
2857 const bool finalValue( false || relativeValue );
2858 animation.AnimateBy(Property(actor, index), relativeValue);
2860 // Start the animation
2863 // Target value should be retrievable straight away
2864 DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
2866 bool signalReceived(false);
2867 AnimationFinishCheck finishCheck(signalReceived);
2868 animation.FinishedSignal().Connect(&application, finishCheck);
2870 application.SendNotification();
2871 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2873 // We didn't expect the animation to finish yet
2874 application.SendNotification();
2875 finishCheck.CheckSignalNotReceived();
2876 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2878 application.SendNotification();
2879 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2881 // We did expect the animation to finish
2882 application.SendNotification();
2883 finishCheck.CheckSignalReceived();
2884 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2886 // Check that nothing has changed after a couple of buffer swaps
2887 application.Render(0);
2888 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2889 application.Render(0);
2890 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2892 // Repeat with relative value "false" - this should be an NOOP
2893 animation = Animation::New(durationSeconds);
2894 bool noOpValue(false);
2895 animation.AnimateBy(Property(actor, index), noOpValue);
2897 // Start the animation
2900 finishCheck.Reset();
2901 animation.FinishedSignal().Connect(&application, finishCheck);
2903 application.SendNotification();
2904 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2906 // We didn't expect the animation to finish yet
2907 application.SendNotification();
2908 finishCheck.CheckSignalNotReceived();
2909 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2911 application.SendNotification();
2912 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2914 // We did expect the animation to finish
2915 application.SendNotification();
2916 finishCheck.CheckSignalReceived();
2917 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2919 // Check that nothing has changed after a couple of buffer swaps
2920 application.Render(0);
2921 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2922 application.Render(0);
2923 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2927 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
2929 TestApplication application;
2931 Actor actor = Actor::New();
2933 // Register a boolean property
2934 bool startValue(false);
2935 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
2936 Stage::GetCurrent().Add(actor);
2937 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2938 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2940 // Build the animation
2941 float durationSeconds(2.0f);
2942 Animation animation = Animation::New(durationSeconds);
2943 bool relativeValue(true);
2944 bool finalValue( false || relativeValue );
2945 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2947 // Start the animation
2950 bool signalReceived(false);
2951 AnimationFinishCheck finishCheck(signalReceived);
2952 animation.FinishedSignal().Connect(&application, finishCheck);
2954 application.SendNotification();
2955 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2957 // We didn't expect the animation to finish yet
2958 application.SendNotification();
2959 finishCheck.CheckSignalNotReceived();
2960 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2962 application.SendNotification();
2963 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2965 // We did expect the animation to finish
2966 application.SendNotification();
2967 finishCheck.CheckSignalReceived();
2968 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2970 // Check that nothing has changed after a couple of buffer swaps
2971 application.Render(0);
2972 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2973 application.Render(0);
2974 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2976 // Repeat with relative value "false" - this should be an NOOP
2977 animation = Animation::New(durationSeconds);
2978 bool noOpValue(false);
2979 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2981 // Start the animation
2984 finishCheck.Reset();
2985 animation.FinishedSignal().Connect(&application, finishCheck);
2987 application.SendNotification();
2988 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2990 // We didn't expect the animation to finish yet
2991 application.SendNotification();
2992 finishCheck.CheckSignalNotReceived();
2993 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2995 application.SendNotification();
2996 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2998 // We did expect the animation to finish
2999 application.SendNotification();
3000 finishCheck.CheckSignalReceived();
3001 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3005 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
3007 TestApplication application;
3009 Actor actor = Actor::New();
3011 // Register a boolean property
3012 bool startValue(false);
3013 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3014 Stage::GetCurrent().Add(actor);
3015 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3016 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3018 // Build the animation
3019 float durationSeconds(2.0f);
3020 Animation animation = Animation::New(durationSeconds);
3021 bool relativeValue(true);
3022 bool finalValue( false || relativeValue );
3023 float animatorDurationSeconds(durationSeconds * 0.5f);
3024 animation.AnimateBy( Property(actor, index),
3026 TimePeriod( animatorDurationSeconds ) );
3028 // Start the animation
3031 bool signalReceived(false);
3032 AnimationFinishCheck finishCheck(signalReceived);
3033 animation.FinishedSignal().Connect(&application, finishCheck);
3035 application.SendNotification();
3036 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3038 // We didn't expect the animation to finish yet
3039 application.SendNotification();
3040 finishCheck.CheckSignalNotReceived();
3041 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3043 application.SendNotification();
3044 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3046 // We didn't expect the animation to finish yet...
3047 application.SendNotification();
3048 finishCheck.CheckSignalNotReceived();
3050 // ...however we should have reached the final value
3051 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3053 application.SendNotification();
3054 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3056 // We did expect the animation to finish
3057 application.SendNotification();
3058 finishCheck.CheckSignalReceived();
3059 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3061 // Check that nothing has changed after a couple of buffer swaps
3062 application.Render(0);
3063 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3064 application.Render(0);
3065 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3069 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3071 TestApplication application;
3073 Actor actor = Actor::New();
3075 // Register a boolean property
3076 bool startValue(false);
3077 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3078 Stage::GetCurrent().Add(actor);
3079 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3080 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3082 // Build the animation
3083 float durationSeconds(2.0f);
3084 Animation animation = Animation::New(durationSeconds);
3085 bool relativeValue(true);
3086 bool finalValue( false || relativeValue );
3087 float animatorDurationSeconds(durationSeconds * 0.5f);
3088 animation.AnimateBy( Property(actor, index),
3090 AlphaFunction::EASE_IN_OUT,
3091 TimePeriod( animatorDurationSeconds ) );
3093 // Start the animation
3096 bool signalReceived(false);
3097 AnimationFinishCheck finishCheck(signalReceived);
3098 animation.FinishedSignal().Connect(&application, finishCheck);
3100 application.SendNotification();
3101 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3103 // We didn't expect the animation to finish yet
3104 application.SendNotification();
3105 finishCheck.CheckSignalNotReceived();
3106 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3108 application.SendNotification();
3109 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3111 // We didn't expect the animation to finish yet...
3112 application.SendNotification();
3113 finishCheck.CheckSignalNotReceived();
3115 // ...however we should have reached the final value
3116 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3118 application.SendNotification();
3119 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3121 // We did expect the animation to finish
3122 application.SendNotification();
3123 finishCheck.CheckSignalReceived();
3124 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3126 // Check that nothing has changed after a couple of buffer swaps
3127 application.Render(0);
3128 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3129 application.Render(0);
3130 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3134 int UtcDaliAnimationAnimateByFloatP(void)
3136 TestApplication application;
3138 Actor actor = Actor::New();
3140 // Register a float property
3141 float startValue(10.0f);
3142 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3143 Stage::GetCurrent().Add(actor);
3144 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3145 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3147 // Build the animation
3148 float durationSeconds(2.0f);
3149 Animation animation = Animation::New(durationSeconds);
3150 float targetValue(50.0f);
3151 float relativeValue(targetValue - startValue);
3152 animation.AnimateBy(Property(actor, index), relativeValue);
3154 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3156 // Start the animation
3159 // Target value should be retrievable straight away
3160 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
3162 bool signalReceived(false);
3163 AnimationFinishCheck finishCheck(signalReceived);
3164 animation.FinishedSignal().Connect(&application, finishCheck);
3166 application.SendNotification();
3167 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3169 // We didn't expect the animation to finish yet
3170 application.SendNotification();
3171 finishCheck.CheckSignalNotReceived();
3172 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3174 application.SendNotification();
3175 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3177 // We did expect the animation to finish
3178 application.SendNotification();
3179 finishCheck.CheckSignalReceived();
3180 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3182 // Check that nothing has changed after a couple of buffer swaps
3183 application.Render(0);
3184 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3185 application.Render(0);
3186 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3190 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3192 TestApplication application;
3194 Actor actor = Actor::New();
3196 // Register a float property
3197 float startValue(10.0f);
3198 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3199 Stage::GetCurrent().Add(actor);
3200 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3201 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3203 // Build the animation
3204 float durationSeconds(1.0f);
3205 Animation animation = Animation::New(durationSeconds);
3206 float targetValue(90.0f);
3207 float relativeValue(targetValue - startValue);
3208 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3210 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3212 // Start the animation
3215 bool signalReceived(false);
3216 AnimationFinishCheck finishCheck(signalReceived);
3217 animation.FinishedSignal().Connect(&application, finishCheck);
3219 application.SendNotification();
3220 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3222 // We didn't expect the animation to finish yet
3223 application.SendNotification();
3224 finishCheck.CheckSignalNotReceived();
3226 // The position should have moved more, than with a linear alpha function
3227 float current( actor.GetCurrentProperty< float >( index ) );
3228 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3230 application.SendNotification();
3231 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3233 // We did expect the animation to finish
3234 application.SendNotification();
3235 finishCheck.CheckSignalReceived();
3236 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3238 // Check that nothing has changed after a couple of buffer swaps
3239 application.Render(0);
3240 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3241 application.Render(0);
3242 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3246 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3248 TestApplication application;
3250 Actor actor = Actor::New();
3252 // Register a float property
3253 float startValue(10.0f);
3254 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3255 Stage::GetCurrent().Add(actor);
3256 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3257 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3259 // Build the animation
3260 float durationSeconds(1.0f);
3261 Animation animation = Animation::New(durationSeconds);
3262 float targetValue(30.0f);
3263 float relativeValue(targetValue - startValue);
3265 animation.AnimateBy(Property(actor, index),
3267 TimePeriod(delay, durationSeconds - delay));
3269 // Start the animation
3272 bool signalReceived(false);
3273 AnimationFinishCheck finishCheck(signalReceived);
3274 animation.FinishedSignal().Connect(&application, finishCheck);
3276 application.SendNotification();
3277 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3279 // We didn't expect the animation to finish yet
3280 application.SendNotification();
3281 finishCheck.CheckSignalNotReceived();
3282 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3284 application.SendNotification();
3285 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3287 // We didn't expect the animation to finish yet
3288 application.SendNotification();
3289 finishCheck.CheckSignalNotReceived();
3290 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3292 application.SendNotification();
3293 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3295 // We did expect the animation to finish
3296 application.SendNotification();
3297 finishCheck.CheckSignalReceived();
3298 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3300 // Check that nothing has changed after a couple of buffer swaps
3301 application.Render(0);
3302 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3303 application.Render(0);
3304 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3308 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3310 TestApplication application;
3312 Actor actor = Actor::New();
3314 // Register a float property
3315 float startValue(10.0f);
3316 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3317 Stage::GetCurrent().Add(actor);
3318 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3319 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3321 // Build the animation
3322 float durationSeconds(1.0f);
3323 Animation animation = Animation::New(durationSeconds);
3324 float targetValue(30.0f);
3325 float relativeValue(targetValue - startValue);
3327 animation.AnimateBy(Property(actor, index),
3329 AlphaFunction::LINEAR,
3330 TimePeriod(delay, durationSeconds - delay));
3332 // Start the animation
3335 bool signalReceived(false);
3336 AnimationFinishCheck finishCheck(signalReceived);
3337 animation.FinishedSignal().Connect(&application, finishCheck);
3339 application.SendNotification();
3340 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3342 // We didn't expect the animation to finish yet
3343 application.SendNotification();
3344 finishCheck.CheckSignalNotReceived();
3345 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3347 application.SendNotification();
3348 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3350 // We didn't expect the animation to finish yet
3351 application.SendNotification();
3352 finishCheck.CheckSignalNotReceived();
3353 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3355 application.SendNotification();
3356 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3358 // We did expect the animation to finish
3359 application.SendNotification();
3360 finishCheck.CheckSignalReceived();
3361 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3363 // Check that nothing has changed after a couple of buffer swaps
3364 application.Render(0);
3365 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3366 application.Render(0);
3367 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3371 int UtcDaliAnimationAnimateByIntegerP(void)
3373 TestApplication application;
3375 Actor actor = Actor::New();
3377 // Register an integer property
3379 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3380 Stage::GetCurrent().Add(actor);
3381 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3382 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3384 // Build the animation
3385 float durationSeconds(2.0f);
3386 Animation animation = Animation::New(durationSeconds);
3387 int targetValue(50);
3388 int relativeValue(targetValue - startValue);
3389 animation.AnimateBy(Property(actor, index), relativeValue);
3391 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3393 // Start the animation
3396 // Target value should be retrievable straight away
3397 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
3399 bool signalReceived(false);
3400 AnimationFinishCheck finishCheck(signalReceived);
3401 animation.FinishedSignal().Connect(&application, finishCheck);
3403 application.SendNotification();
3404 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3406 // We didn't expect the animation to finish yet
3407 application.SendNotification();
3408 finishCheck.CheckSignalNotReceived();
3409 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3411 application.SendNotification();
3412 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3414 // We did expect the animation to finish
3415 application.SendNotification();
3416 finishCheck.CheckSignalReceived();
3417 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3419 // Check that nothing has changed after a couple of buffer swaps
3420 application.Render(0);
3421 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3422 application.Render(0);
3423 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3427 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3429 TestApplication application;
3431 Actor actor = Actor::New();
3433 // Register an integer property
3435 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3436 Stage::GetCurrent().Add(actor);
3437 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3438 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3440 // Build the animation
3441 float durationSeconds(1.0f);
3442 Animation animation = Animation::New(durationSeconds);
3443 int targetValue(90);
3444 int relativeValue(targetValue - startValue);
3445 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3447 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3449 // Start the animation
3452 bool signalReceived(false);
3453 AnimationFinishCheck finishCheck(signalReceived);
3454 animation.FinishedSignal().Connect(&application, finishCheck);
3456 application.SendNotification();
3457 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3459 // We didn't expect the animation to finish yet
3460 application.SendNotification();
3461 finishCheck.CheckSignalNotReceived();
3463 // The position should have moved more, than with a linear alpha function
3464 int current( actor.GetCurrentProperty< int >( index ) );
3465 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3467 application.SendNotification();
3468 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3470 // We did expect the animation to finish
3471 application.SendNotification();
3472 finishCheck.CheckSignalReceived();
3473 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3475 // Check that nothing has changed after a couple of buffer swaps
3476 application.Render(0);
3477 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3478 application.Render(0);
3479 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3483 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3485 TestApplication application;
3487 Actor actor = Actor::New();
3489 // Register an integer property
3491 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3492 Stage::GetCurrent().Add(actor);
3493 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3494 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3496 // Build the animation
3497 float durationSeconds(1.0f);
3498 Animation animation = Animation::New(durationSeconds);
3499 int targetValue(30);
3500 int relativeValue(targetValue - startValue);
3502 animation.AnimateBy(Property(actor, index),
3504 TimePeriod(delay, durationSeconds - delay));
3506 // Start the animation
3509 bool signalReceived(false);
3510 AnimationFinishCheck finishCheck(signalReceived);
3511 animation.FinishedSignal().Connect(&application, finishCheck);
3513 application.SendNotification();
3514 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3516 // We didn't expect the animation to finish yet
3517 application.SendNotification();
3518 finishCheck.CheckSignalNotReceived();
3519 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3521 application.SendNotification();
3522 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3524 // We didn't expect the animation to finish yet
3525 application.SendNotification();
3526 finishCheck.CheckSignalNotReceived();
3527 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3529 application.SendNotification();
3530 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3532 // We did expect the animation to finish
3533 application.SendNotification();
3534 finishCheck.CheckSignalReceived();
3535 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3537 // Check that nothing has changed after a couple of buffer swaps
3538 application.Render(0);
3539 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3540 application.Render(0);
3541 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3545 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3547 TestApplication application;
3549 Actor actor = Actor::New();
3551 // Register an integer property
3553 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3554 Stage::GetCurrent().Add(actor);
3555 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3556 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3558 // Build the animation
3559 float durationSeconds(1.0f);
3560 Animation animation = Animation::New(durationSeconds);
3561 int targetValue(30);
3562 int relativeValue(targetValue - startValue);
3564 animation.AnimateBy(Property(actor, index),
3566 AlphaFunction::LINEAR,
3567 TimePeriod(delay, durationSeconds - delay));
3569 // Start the animation
3572 bool signalReceived(false);
3573 AnimationFinishCheck finishCheck(signalReceived);
3574 animation.FinishedSignal().Connect(&application, finishCheck);
3576 application.SendNotification();
3577 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3579 // We didn't expect the animation to finish yet
3580 application.SendNotification();
3581 finishCheck.CheckSignalNotReceived();
3582 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3584 application.SendNotification();
3585 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3587 // We didn't expect the animation to finish yet
3588 application.SendNotification();
3589 finishCheck.CheckSignalNotReceived();
3590 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3592 application.SendNotification();
3593 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3595 // We did expect the animation to finish
3596 application.SendNotification();
3597 finishCheck.CheckSignalReceived();
3598 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3600 // Check that nothing has changed after a couple of buffer swaps
3601 application.Render(0);
3602 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3603 application.Render(0);
3604 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3608 int UtcDaliAnimationAnimateByQuaternionP(void)
3610 TestApplication application;
3612 Actor actor = Actor::New();
3614 // Register a quaternion property
3615 const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
3616 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3617 Stage::GetCurrent().Add(actor);
3618 DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3619 DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3621 // Build the animation
3622 float durationSeconds(2.0f);
3623 Animation animation = Animation::New(durationSeconds);
3624 const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
3625 const Quaternion finalValue( startValue * relativeValue );
3626 animation.AnimateBy(Property(actor, index), relativeValue);
3628 DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3629 DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3631 // Start the animation
3634 // Target value should be retrievable straight away
3635 DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3637 application.SendNotification();
3638 application.Render( 2000 ); // animation complete
3640 DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3641 DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
3646 int UtcDaliAnimationAnimateByVector2P(void)
3648 TestApplication application;
3650 Actor actor = Actor::New();
3652 // Register a Vector2 property
3653 Vector2 startValue(10.0f, 10.0f);
3654 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3655 Stage::GetCurrent().Add(actor);
3656 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3657 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3659 // Build the animation
3660 float durationSeconds(2.0f);
3661 Animation animation = Animation::New(durationSeconds);
3662 Vector2 targetValue(60.0f, 60.0f);
3663 Vector2 relativeValue(targetValue - startValue);
3664 animation.AnimateBy(Property(actor, index), relativeValue);
3666 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3668 // Start the animation
3671 // Target value should be retrievable straight away
3672 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3674 bool signalReceived(false);
3675 AnimationFinishCheck finishCheck(signalReceived);
3676 animation.FinishedSignal().Connect(&application, finishCheck);
3678 application.SendNotification();
3679 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3681 // We didn't expect the animation to finish yet
3682 application.SendNotification();
3683 finishCheck.CheckSignalNotReceived();
3684 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3686 application.SendNotification();
3687 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3689 // We did expect the animation to finish
3690 application.SendNotification();
3691 finishCheck.CheckSignalReceived();
3692 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3694 // Check that nothing has changed after a couple of buffer swaps
3695 application.Render(0);
3696 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3697 application.Render(0);
3698 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3702 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3704 TestApplication application;
3706 Actor actor = Actor::New();
3708 // Register a Vector2 property
3709 Vector2 startValue(100.0f, 100.0f);
3710 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3711 Stage::GetCurrent().Add(actor);
3712 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3713 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3715 // Build the animation
3716 float durationSeconds(1.0f);
3717 Animation animation = Animation::New(durationSeconds);
3718 Vector2 targetValue(20.0f, 20.0f);
3719 Vector2 relativeValue(targetValue - startValue);
3720 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3722 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3724 // Start the animation
3727 bool signalReceived(false);
3728 AnimationFinishCheck finishCheck(signalReceived);
3729 animation.FinishedSignal().Connect(&application, finishCheck);
3731 application.SendNotification();
3732 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3734 // We didn't expect the animation to finish yet
3735 application.SendNotification();
3736 finishCheck.CheckSignalNotReceived();
3738 // The position should have moved more, than with a linear alpha function
3739 Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3740 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3741 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3743 application.SendNotification();
3744 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3746 // We did expect the animation to finish
3747 application.SendNotification();
3748 finishCheck.CheckSignalReceived();
3749 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3751 // Check that nothing has changed after a couple of buffer swaps
3752 application.Render(0);
3753 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3754 application.Render(0);
3755 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3759 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3761 TestApplication application;
3763 Actor actor = Actor::New();
3765 // Register a Vector2 property
3766 Vector2 startValue(10.0f, 10.0f);
3767 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3768 Stage::GetCurrent().Add(actor);
3769 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3770 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3772 // Build the animation
3773 float durationSeconds(1.0f);
3774 Animation animation = Animation::New(durationSeconds);
3775 Vector2 targetValue(30.0f, 30.0f);
3776 Vector2 relativeValue(targetValue - startValue);
3778 animation.AnimateBy(Property(actor, index),
3780 TimePeriod(delay, durationSeconds - delay));
3782 // Start the animation
3785 bool signalReceived(false);
3786 AnimationFinishCheck finishCheck(signalReceived);
3787 animation.FinishedSignal().Connect(&application, finishCheck);
3789 application.SendNotification();
3790 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3792 // We didn't expect the animation to finish yet
3793 application.SendNotification();
3794 finishCheck.CheckSignalNotReceived();
3795 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3797 application.SendNotification();
3798 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3800 // We didn't expect the animation to finish yet
3801 application.SendNotification();
3802 finishCheck.CheckSignalNotReceived();
3803 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3805 application.SendNotification();
3806 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3808 // We did expect the animation to finish
3809 application.SendNotification();
3810 finishCheck.CheckSignalReceived();
3811 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3813 // Check that nothing has changed after a couple of buffer swaps
3814 application.Render(0);
3815 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3816 application.Render(0);
3817 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3821 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
3823 TestApplication application;
3825 Actor actor = Actor::New();
3827 // Register a Vector2 property
3828 Vector2 startValue(5.0f, 5.0f);
3829 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3830 Stage::GetCurrent().Add(actor);
3831 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3832 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3834 // Build the animation
3835 float durationSeconds(1.0f);
3836 Animation animation = Animation::New(durationSeconds);
3837 Vector2 targetValue(10.0f, 10.0f);
3838 Vector2 relativeValue(targetValue - startValue);
3840 animation.AnimateBy(Property(actor, index),
3842 AlphaFunction::LINEAR,
3843 TimePeriod(delay, durationSeconds - delay));
3845 // Start the animation
3848 bool signalReceived(false);
3849 AnimationFinishCheck finishCheck(signalReceived);
3850 animation.FinishedSignal().Connect(&application, finishCheck);
3852 application.SendNotification();
3853 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3855 // We didn't expect the animation to finish yet
3856 application.SendNotification();
3857 finishCheck.CheckSignalNotReceived();
3858 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3860 application.SendNotification();
3861 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3863 // We didn't expect the animation to finish yet
3864 application.SendNotification();
3865 finishCheck.CheckSignalNotReceived();
3866 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3868 application.SendNotification();
3869 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3871 // We did expect the animation to finish
3872 application.SendNotification();
3873 finishCheck.CheckSignalReceived();
3874 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3876 // Check that nothing has changed after a couple of buffer swaps
3877 application.Render(0);
3878 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3879 application.Render(0);
3880 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3884 int UtcDaliAnimationAnimateByVector3P(void)
3886 TestApplication application;
3888 Actor actor = Actor::New();
3890 // Register a Vector3 property
3891 Vector3 startValue(10.0f, 10.0f, 10.0f);
3892 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3893 Stage::GetCurrent().Add(actor);
3894 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3895 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3897 // Build the animation
3898 float durationSeconds(2.0f);
3899 Animation animation = Animation::New(durationSeconds);
3900 Vector3 targetValue(60.0f, 60.0f, 60.0f);
3901 Vector3 relativeValue(targetValue - startValue);
3902 animation.AnimateBy(Property(actor, index), relativeValue);
3904 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3906 // Start the animation
3909 // Target value should be retrievable straight away
3910 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3912 bool signalReceived(false);
3913 AnimationFinishCheck finishCheck(signalReceived);
3914 animation.FinishedSignal().Connect(&application, finishCheck);
3916 application.SendNotification();
3917 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3919 // We didn't expect the animation to finish yet
3920 application.SendNotification();
3921 finishCheck.CheckSignalNotReceived();
3922 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3924 application.SendNotification();
3925 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3927 // We did expect the animation to finish
3928 application.SendNotification();
3929 finishCheck.CheckSignalReceived();
3930 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3932 // Check that nothing has changed after a couple of buffer swaps
3933 application.Render(0);
3934 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3935 application.Render(0);
3936 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3940 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
3942 TestApplication application;
3944 Actor actor = Actor::New();
3946 // Register a Vector3 property
3947 Vector3 startValue(100.0f, 100.0f, 100.0f);
3948 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3949 Stage::GetCurrent().Add(actor);
3950 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3951 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3953 // Build the animation
3954 float durationSeconds(1.0f);
3955 Animation animation = Animation::New(durationSeconds);
3956 Vector3 targetValue(20.0f, 20.0f, 20.0f);
3957 Vector3 relativeValue(targetValue - startValue);
3958 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3960 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3962 // Start the animation
3965 bool signalReceived(false);
3966 AnimationFinishCheck finishCheck(signalReceived);
3967 animation.FinishedSignal().Connect(&application, finishCheck);
3969 application.SendNotification();
3970 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3972 // We didn't expect the animation to finish yet
3973 application.SendNotification();
3974 finishCheck.CheckSignalNotReceived();
3976 // The position should have moved more, than with a linear alpha function
3977 Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
3978 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3979 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3980 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3982 application.SendNotification();
3983 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3985 // We did expect the animation to finish
3986 application.SendNotification();
3987 finishCheck.CheckSignalReceived();
3988 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3990 // Check that nothing has changed after a couple of buffer swaps
3991 application.Render(0);
3992 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3993 application.Render(0);
3994 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3998 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
4000 TestApplication application;
4002 Actor actor = Actor::New();
4004 // Register a Vector3 property
4005 Vector3 startValue(10.0f, 10.0f, 10.0f);
4006 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4007 Stage::GetCurrent().Add(actor);
4008 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4009 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4011 // Build the animation
4012 float durationSeconds(1.0f);
4013 Animation animation = Animation::New(durationSeconds);
4014 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4015 Vector3 relativeValue(targetValue - startValue);
4017 animation.AnimateBy(Property(actor, index),
4019 TimePeriod(delay, durationSeconds - delay));
4021 // Start the animation
4024 bool signalReceived(false);
4025 AnimationFinishCheck finishCheck(signalReceived);
4026 animation.FinishedSignal().Connect(&application, finishCheck);
4028 application.SendNotification();
4029 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4031 // We didn't expect the animation to finish yet
4032 application.SendNotification();
4033 finishCheck.CheckSignalNotReceived();
4034 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4036 application.SendNotification();
4037 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4039 // We didn't expect the animation to finish yet
4040 application.SendNotification();
4041 finishCheck.CheckSignalNotReceived();
4042 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4044 application.SendNotification();
4045 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4047 // We did expect the animation to finish
4048 application.SendNotification();
4049 finishCheck.CheckSignalReceived();
4050 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4052 // Check that nothing has changed after a couple of buffer swaps
4053 application.Render(0);
4054 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4055 application.Render(0);
4056 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4060 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
4062 TestApplication application;
4064 Actor actor = Actor::New();
4066 // Register a Vector3 property
4067 Vector3 startValue(5.0f, 5.0f, 5.0f);
4068 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4069 Stage::GetCurrent().Add(actor);
4070 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4071 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4073 // Build the animation
4074 float durationSeconds(1.0f);
4075 Animation animation = Animation::New(durationSeconds);
4076 Vector3 targetValue(10.0f, 10.0f, 10.0f);
4077 Vector3 relativeValue(targetValue - startValue);
4079 animation.AnimateBy(Property(actor, index),
4081 AlphaFunction::LINEAR,
4082 TimePeriod(delay, durationSeconds - delay));
4084 // Start the animation
4087 bool signalReceived(false);
4088 AnimationFinishCheck finishCheck(signalReceived);
4089 animation.FinishedSignal().Connect(&application, finishCheck);
4091 application.SendNotification();
4092 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4094 // We didn't expect the animation to finish yet
4095 application.SendNotification();
4096 finishCheck.CheckSignalNotReceived();
4097 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4099 application.SendNotification();
4100 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4102 // We didn't expect the animation to finish yet
4103 application.SendNotification();
4104 finishCheck.CheckSignalNotReceived();
4105 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4107 application.SendNotification();
4108 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4110 // We did expect the animation to finish
4111 application.SendNotification();
4112 finishCheck.CheckSignalReceived();
4113 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4115 // Check that nothing has changed after a couple of buffer swaps
4116 application.Render(0);
4117 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4118 application.Render(0);
4119 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4123 int UtcDaliAnimationAnimateByVector4P(void)
4125 TestApplication application;
4127 Actor actor = Actor::New();
4129 // Register a Vector4 property
4130 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4131 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4132 Stage::GetCurrent().Add(actor);
4133 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4134 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4136 // Build the animation
4137 float durationSeconds(2.0f);
4138 Animation animation = Animation::New(durationSeconds);
4139 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4140 Vector4 relativeValue(targetValue - startValue);
4141 animation.AnimateBy(Property(actor, index), relativeValue);
4143 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4145 // Start the animation
4148 // Target value should be retrievable straight away
4149 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4151 bool signalReceived(false);
4152 AnimationFinishCheck finishCheck(signalReceived);
4153 animation.FinishedSignal().Connect(&application, finishCheck);
4155 application.SendNotification();
4156 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4158 // We didn't expect the animation to finish yet
4159 application.SendNotification();
4160 finishCheck.CheckSignalNotReceived();
4161 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4163 application.SendNotification();
4164 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4166 // We did expect the animation to finish
4167 application.SendNotification();
4168 finishCheck.CheckSignalReceived();
4169 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4171 // Check that nothing has changed after a couple of buffer swaps
4172 application.Render(0);
4173 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4174 application.Render(0);
4175 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4179 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4181 TestApplication application;
4183 Actor actor = Actor::New();
4185 // Register a Vector4 property
4186 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4187 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4188 Stage::GetCurrent().Add(actor);
4189 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4190 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4192 // Build the animation
4193 float durationSeconds(1.0f);
4194 Animation animation = Animation::New(durationSeconds);
4195 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4196 Vector4 relativeValue(targetValue - startValue);
4197 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4199 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4201 // Start the animation
4204 bool signalReceived(false);
4205 AnimationFinishCheck finishCheck(signalReceived);
4206 animation.FinishedSignal().Connect(&application, finishCheck);
4208 application.SendNotification();
4209 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4211 // We didn't expect the animation to finish yet
4212 application.SendNotification();
4213 finishCheck.CheckSignalNotReceived();
4215 // The position should have moved more, than with a linear alpha function
4216 Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4217 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4218 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4219 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4220 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4222 application.SendNotification();
4223 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4225 // We did expect the animation to finish
4226 application.SendNotification();
4227 finishCheck.CheckSignalReceived();
4228 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4230 // Check that nothing has changed after a couple of buffer swaps
4231 application.Render(0);
4232 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4233 application.Render(0);
4234 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4238 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4240 TestApplication application;
4242 Actor actor = Actor::New();
4244 // Register a Vector4 property
4245 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4246 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4247 Stage::GetCurrent().Add(actor);
4248 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4249 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4251 // Build the animation
4252 float durationSeconds(1.0f);
4253 Animation animation = Animation::New(durationSeconds);
4254 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4255 Vector4 relativeValue(targetValue - startValue);
4257 animation.AnimateBy(Property(actor, index),
4259 TimePeriod(delay, durationSeconds - delay));
4261 // Start the animation
4264 bool signalReceived(false);
4265 AnimationFinishCheck finishCheck(signalReceived);
4266 animation.FinishedSignal().Connect(&application, finishCheck);
4268 application.SendNotification();
4269 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4271 // We didn't expect the animation to finish yet
4272 application.SendNotification();
4273 finishCheck.CheckSignalNotReceived();
4274 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4276 application.SendNotification();
4277 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4279 // We didn't expect the animation to finish yet
4280 application.SendNotification();
4281 finishCheck.CheckSignalNotReceived();
4282 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4284 application.SendNotification();
4285 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4287 // We did expect the animation to finish
4288 application.SendNotification();
4289 finishCheck.CheckSignalReceived();
4290 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4292 // Check that nothing has changed after a couple of buffer swaps
4293 application.Render(0);
4294 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4295 application.Render(0);
4296 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4300 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4302 TestApplication application;
4304 Actor actor = Actor::New();
4306 // Register a Vector4 property
4307 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4308 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4309 Stage::GetCurrent().Add(actor);
4310 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4311 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4313 // Build the animation
4314 float durationSeconds(1.0f);
4315 Animation animation = Animation::New(durationSeconds);
4316 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4317 Vector4 relativeValue(targetValue - startValue);
4319 animation.AnimateBy(Property(actor, index),
4321 AlphaFunction::LINEAR,
4322 TimePeriod(delay, durationSeconds - delay));
4324 // Start the animation
4327 bool signalReceived(false);
4328 AnimationFinishCheck finishCheck(signalReceived);
4329 animation.FinishedSignal().Connect(&application, finishCheck);
4331 application.SendNotification();
4332 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4334 // We didn't expect the animation to finish yet
4335 application.SendNotification();
4336 finishCheck.CheckSignalNotReceived();
4337 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4339 application.SendNotification();
4340 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4342 // We didn't expect the animation to finish yet
4343 application.SendNotification();
4344 finishCheck.CheckSignalNotReceived();
4345 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4347 application.SendNotification();
4348 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4350 // We did expect the animation to finish
4351 application.SendNotification();
4352 finishCheck.CheckSignalReceived();
4353 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4355 // Check that nothing has changed after a couple of buffer swaps
4356 application.Render(0);
4357 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4358 application.Render(0);
4359 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4363 int UtcDaliAnimationAnimateByActorPositionP(void)
4365 TestApplication application;
4367 Actor actor = Actor::New();
4368 Vector3 startPosition(10.0f, 10.0f, 10.0f);
4369 actor.SetPosition(startPosition);
4370 Stage::GetCurrent().Add(actor);
4371 application.SendNotification();
4372 application.Render(0);
4373 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4375 // Build the animation
4376 float durationSeconds(1.0f);
4377 Animation animation = Animation::New(durationSeconds);
4378 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4379 Vector3 relativePosition(targetPosition - startPosition);
4380 animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4382 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4384 // Start the animation
4387 // Target value should be retrievable straight away
4388 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4390 bool signalReceived(false);
4391 AnimationFinishCheck finishCheck(signalReceived);
4392 animation.FinishedSignal().Connect(&application, finishCheck);
4394 application.SendNotification();
4395 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4397 // We didn't expect the animation to finish yet
4398 application.SendNotification();
4399 finishCheck.CheckSignalNotReceived();
4400 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4402 application.SendNotification();
4403 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4405 // We did expect the animation to finish
4406 application.SendNotification();
4407 finishCheck.CheckSignalReceived();
4408 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4410 // Check that nothing has changed after a couple of buffer swaps
4411 application.Render(0);
4412 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4413 application.Render(0);
4414 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4418 int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
4420 TestApplication application;
4422 Actor actor = Actor::New();
4423 Stage::GetCurrent().Add(actor);
4424 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4426 // Build the animation
4427 float durationSeconds(1.0f);
4428 Animation animation = Animation::New(durationSeconds);
4429 Vector3 targetPosition(200.0f, 300.0f, 400.0f);
4430 Vector3 relativePosition(targetPosition - Vector3::ZERO);
4431 animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
4432 animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
4433 animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
4435 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4436 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4438 // Start the animation
4441 // Target value should be retrievable straight away
4442 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4443 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
4444 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
4445 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
4447 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
4449 application.SendNotification();
4450 application.Render( 1000 ); // 1 second progress
4452 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4457 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4459 TestApplication application;
4461 Actor actor = Actor::New();
4462 Vector3 startPosition(10.0f, 10.0f, 10.0f);
4463 actor.SetPosition(startPosition);
4464 Stage::GetCurrent().Add(actor);
4465 application.SendNotification();
4466 application.Render(0);
4467 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4469 // Build the animation
4470 float durationSeconds(1.0f);
4471 Animation animation = Animation::New(durationSeconds);
4472 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4473 Vector3 relativePosition(targetPosition - startPosition);
4474 animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4476 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4478 // Start the animation
4481 bool signalReceived(false);
4482 AnimationFinishCheck finishCheck(signalReceived);
4483 animation.FinishedSignal().Connect(&application, finishCheck);
4485 application.SendNotification();
4486 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4488 // We didn't expect the animation to finish yet
4489 application.SendNotification();
4490 finishCheck.CheckSignalNotReceived();
4492 // The position should have moved more, than with a linear alpha function
4493 Vector3 current(actor.GetCurrentPosition());
4494 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4495 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4496 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4498 application.SendNotification();
4499 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4501 // We did expect the animation to finish
4502 application.SendNotification();
4503 finishCheck.CheckSignalReceived();
4504 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4506 // Check that nothing has changed after a couple of buffer swaps
4507 application.Render(0);
4508 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4509 application.Render(0);
4510 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4514 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4516 TestApplication application;
4518 Actor actor = Actor::New();
4519 Vector3 startPosition(10.0f, 10.0f, 10.0f);
4520 actor.SetPosition(startPosition);
4521 Stage::GetCurrent().Add(actor);
4522 application.SendNotification();
4523 application.Render(0);
4524 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4526 // Build the animation
4527 float durationSeconds(1.0f);
4528 Animation animation = Animation::New(durationSeconds);
4529 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4530 Vector3 relativePosition(targetPosition - startPosition);
4532 animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4534 TimePeriod(delay, durationSeconds - delay));
4536 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4538 // Start the animation
4541 bool signalReceived(false);
4542 AnimationFinishCheck finishCheck(signalReceived);
4543 animation.FinishedSignal().Connect(&application, finishCheck);
4545 application.SendNotification();
4546 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4548 // We didn't expect the animation to finish yet
4549 application.SendNotification();
4550 finishCheck.CheckSignalNotReceived();
4551 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4553 application.SendNotification();
4554 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4556 // We did expect the animation to finish
4557 application.SendNotification();
4558 finishCheck.CheckSignalReceived();
4559 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4561 // Check that nothing has changed after a couple of buffer swaps
4562 application.Render(0);
4563 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4564 application.Render(0);
4565 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4569 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4571 TestApplication application;
4573 Actor actor = Actor::New();
4574 Vector3 startPosition(10.0f, 10.0f, 10.0f);
4575 actor.SetPosition(startPosition);
4576 Stage::GetCurrent().Add(actor);
4577 application.SendNotification();
4578 application.Render(0);
4579 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4581 // Build the animation
4582 float durationSeconds(1.0f);
4583 Animation animation = Animation::New(durationSeconds);
4584 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4585 Vector3 relativePosition(targetPosition - startPosition);
4587 animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4589 AlphaFunction::LINEAR,
4590 TimePeriod(delay, durationSeconds - delay));
4592 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4594 // Start the animation
4597 bool signalReceived(false);
4598 AnimationFinishCheck finishCheck(signalReceived);
4599 animation.FinishedSignal().Connect(&application, finishCheck);
4601 application.SendNotification();
4602 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4604 // We didn't expect the animation to finish yet
4605 application.SendNotification();
4606 finishCheck.CheckSignalNotReceived();
4607 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4609 application.SendNotification();
4610 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4612 // We did expect the animation to finish
4613 application.SendNotification();
4614 finishCheck.CheckSignalReceived();
4615 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4617 // Check that nothing has changed after a couple of buffer swaps
4618 application.Render(0);
4619 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4620 application.Render(0);
4621 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4625 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4627 TestApplication application;
4629 Actor actor = Actor::New();
4630 actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4631 Stage::GetCurrent().Add(actor);
4632 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4634 // Build the animation
4635 float durationSeconds(1.0f);
4636 Animation animation = Animation::New(durationSeconds);
4637 Degree relativeRotationDegrees(360.0f);
4638 Radian relativeRotationRadians(relativeRotationDegrees);
4639 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4641 // Start the animation
4644 // Target value should be retrievable straight away
4645 DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
4647 bool signalReceived(false);
4648 AnimationFinishCheck finishCheck(signalReceived);
4649 animation.FinishedSignal().Connect(&application, finishCheck);
4651 application.SendNotification();
4652 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4654 // We didn't expect the animation to finish yet
4655 application.SendNotification();
4656 finishCheck.CheckSignalNotReceived();
4657 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4659 application.SendNotification();
4660 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4662 // We didn't expect the animation to finish yet
4663 application.SendNotification();
4664 finishCheck.CheckSignalNotReceived();
4665 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4667 application.SendNotification();
4668 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4670 // We didn't expect the animation to finish yet
4671 application.SendNotification();
4672 finishCheck.CheckSignalNotReceived();
4673 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4675 application.SendNotification();
4676 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4678 // We did expect the animation to finish
4679 application.SendNotification();
4680 finishCheck.CheckSignalReceived();
4681 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4685 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4687 TestApplication application;
4689 tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4691 Actor actor = Actor::New();
4692 actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4693 Stage::GetCurrent().Add(actor);
4694 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4696 // Build the animation
4697 float durationSeconds(1.0f);
4698 Animation animation = Animation::New(durationSeconds);
4699 Degree relativeRotationDegrees(710.0f);
4700 Radian relativeRotationRadians(relativeRotationDegrees);
4702 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4704 // Start the animation
4707 bool signalReceived(false);
4708 AnimationFinishCheck finishCheck(signalReceived);
4709 animation.FinishedSignal().Connect(&application, finishCheck);
4711 application.SendNotification();
4712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4714 // We didn't expect the animation to finish yet
4715 application.SendNotification();
4716 finishCheck.CheckSignalNotReceived();
4717 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4719 application.SendNotification();
4720 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4722 // We didn't expect the animation to finish yet
4723 application.SendNotification();
4724 finishCheck.CheckSignalNotReceived();
4725 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4727 application.SendNotification();
4728 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4730 // We didn't expect the animation to finish yet
4731 application.SendNotification();
4732 finishCheck.CheckSignalNotReceived();
4733 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4735 application.SendNotification();
4736 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4738 // We did expect the animation to finish
4739 application.SendNotification();
4740 finishCheck.CheckSignalReceived();
4741 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4746 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4748 TestApplication application;
4750 tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4752 Actor actor = Actor::New();
4753 actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4754 Stage::GetCurrent().Add(actor);
4755 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4757 // Build the animation
4758 float durationSeconds(1.0f);
4759 Animation animation = Animation::New(durationSeconds);
4760 Degree relativeRotationDegrees(730.0f);
4761 Radian relativeRotationRadians(relativeRotationDegrees);
4763 Radian actualRotationRadians( Degree(10.0f) );
4765 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4767 // Start the animation
4770 bool signalReceived(false);
4771 AnimationFinishCheck finishCheck(signalReceived);
4772 animation.FinishedSignal().Connect(&application, finishCheck);
4774 application.SendNotification();
4775 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4777 // We didn't expect the animation to finish yet
4778 application.SendNotification();
4779 finishCheck.CheckSignalNotReceived();
4780 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4782 application.SendNotification();
4783 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4785 // We didn't expect the animation to finish yet
4786 application.SendNotification();
4787 finishCheck.CheckSignalNotReceived();
4788 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4790 application.SendNotification();
4791 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4793 // We didn't expect the animation to finish yet
4794 application.SendNotification();
4795 finishCheck.CheckSignalNotReceived();
4796 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4798 application.SendNotification();
4799 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4801 // We did expect the animation to finish
4802 application.SendNotification();
4803 finishCheck.CheckSignalReceived();
4804 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4805 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4810 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4812 TestApplication application;
4814 Actor actor = Actor::New();
4815 actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4816 Stage::GetCurrent().Add(actor);
4817 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4819 // Build the animation
4820 float durationSeconds(1.0f);
4821 Animation animation = Animation::New(durationSeconds);
4822 Degree relativeRotationDegrees(360.0f);
4823 Radian relativeRotationRadians(relativeRotationDegrees);
4824 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4826 // Start the animation
4829 bool signalReceived(false);
4830 AnimationFinishCheck finishCheck(signalReceived);
4831 animation.FinishedSignal().Connect(&application, finishCheck);
4833 application.SendNotification();
4834 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4836 // We didn't expect the animation to finish yet
4837 application.SendNotification();
4838 finishCheck.CheckSignalNotReceived();
4839 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4841 application.SendNotification();
4842 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4844 // We didn't expect the animation to finish yet
4845 application.SendNotification();
4846 finishCheck.CheckSignalNotReceived();
4847 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4849 application.SendNotification();
4850 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4852 // We didn't expect the animation to finish yet
4853 application.SendNotification();
4854 finishCheck.CheckSignalNotReceived();
4855 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4857 application.SendNotification();
4858 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4860 // We did expect the animation to finish
4861 application.SendNotification();
4862 finishCheck.CheckSignalReceived();
4863 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4867 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4869 TestApplication application;
4871 Actor actor = Actor::New();
4872 actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4873 Stage::GetCurrent().Add(actor);
4874 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4876 // Build the animation
4877 float durationSeconds(1.0f);
4878 Animation animation = Animation::New(durationSeconds);
4879 Degree relativeRotationDegrees(360.0f);
4880 Radian relativeRotationRadians(relativeRotationDegrees);
4882 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4883 AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4885 // Start the animation
4888 bool signalReceived(false);
4889 AnimationFinishCheck finishCheck(signalReceived);
4890 animation.FinishedSignal().Connect(&application, finishCheck);
4892 application.SendNotification();
4893 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4895 // We didn't expect the animation to finish yet
4896 application.SendNotification();
4897 finishCheck.CheckSignalNotReceived();
4898 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4899 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4901 application.SendNotification();
4902 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4904 // We didn't expect the animation to finish yet
4905 application.SendNotification();
4906 finishCheck.CheckSignalNotReceived();
4907 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4908 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4910 application.SendNotification();
4911 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4913 // We didn't expect the animation to finish yet
4914 application.SendNotification();
4915 finishCheck.CheckSignalNotReceived();
4916 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4917 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4919 application.SendNotification();
4920 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4922 // We did expect the animation to finish
4923 application.SendNotification();
4924 finishCheck.CheckSignalReceived();
4925 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4929 int UtcDaliAnimationAnimateByActorScaleP(void)
4931 TestApplication application;
4933 Actor actor = Actor::New();
4934 Stage::GetCurrent().Add(actor);
4935 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4937 // Build the animation
4938 float durationSeconds(1.0f);
4939 Animation animation = Animation::New(durationSeconds);
4940 Vector3 targetScale(2.0f, 2.0f, 2.0f);
4941 Vector3 relativeScale(targetScale - Vector3::ONE);
4942 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4944 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4946 // Start the animation
4949 // Target value should be retrievable straight away
4950 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
4952 bool signalReceived(false);
4953 AnimationFinishCheck finishCheck(signalReceived);
4954 animation.FinishedSignal().Connect(&application, finishCheck);
4956 application.SendNotification();
4957 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4959 // We didn't expect the animation to finish yet
4960 application.SendNotification();
4961 finishCheck.CheckSignalNotReceived();
4962 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4964 application.SendNotification();
4965 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4967 // We did expect the animation to finish
4968 application.SendNotification();
4969 finishCheck.CheckSignalReceived();
4970 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4973 finishCheck.Reset();
4974 actor.SetScale(Vector3::ONE);
4975 application.SendNotification();
4976 application.Render(0);
4977 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4979 // Repeat with a different (ease-in) alpha function
4980 animation = Animation::New(durationSeconds);
4981 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4982 animation.FinishedSignal().Connect(&application, finishCheck);
4985 application.SendNotification();
4986 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4988 // We didn't expect the animation to finish yet
4989 application.SendNotification();
4990 finishCheck.CheckSignalNotReceived();
4992 // The scale should have grown less, than with a linear alpha function
4993 Vector3 current(actor.GetCurrentScale());
4994 DALI_TEST_CHECK( current.x > 1.0f );
4995 DALI_TEST_CHECK( current.y > 1.0f );
4996 DALI_TEST_CHECK( current.z > 1.0f );
4997 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4998 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4999 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5001 application.SendNotification();
5002 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5004 // We did expect the animation to finish
5005 application.SendNotification();
5006 finishCheck.CheckSignalReceived();
5007 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5010 finishCheck.Reset();
5011 actor.SetScale(Vector3::ONE);
5012 application.SendNotification();
5013 application.Render(0);
5014 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5016 // Repeat with a delay
5018 animation = Animation::New(durationSeconds);
5019 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
5020 animation.FinishedSignal().Connect(&application, finishCheck);
5023 application.SendNotification();
5024 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5026 // We didn't expect the animation to finish yet
5027 application.SendNotification();
5028 finishCheck.CheckSignalNotReceived();
5029 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5031 application.SendNotification();
5032 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5034 // We did expect the animation to finish
5035 application.SendNotification();
5036 finishCheck.CheckSignalReceived();
5037 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5041 int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
5043 TestApplication application;
5045 Actor actor = Actor::New();
5046 Stage::GetCurrent().Add(actor);
5047 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5049 // Build the animation
5050 float durationSeconds(1.0f);
5051 Animation animation = Animation::New(durationSeconds);
5052 Vector3 targetScale(2.0f, 3.0f, 4.0f);
5053 Vector3 relativeScale(targetScale - Vector3::ONE);
5054 animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
5055 animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
5056 animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
5058 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5059 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5061 // Start the animation
5064 // Target value should be retrievable straight away
5065 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5066 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
5067 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
5068 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
5070 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet
5072 application.SendNotification();
5073 application.Render( 1000 ); // 1 second progress
5075 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5080 int UtcDaliAnimationAnimateByActorColorP(void)
5082 TestApplication application;
5084 Actor actor = Actor::New();
5085 Stage::GetCurrent().Add(actor);
5086 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5088 // Build the animation
5089 float durationSeconds(1.0f);
5090 Animation animation = Animation::New(durationSeconds);
5091 Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5092 Vector4 relativeColor( targetColor - Color::WHITE );
5093 animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
5095 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5096 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5098 // Start the animation
5101 // Target value should be retrievable straight away
5102 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5103 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5104 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5105 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5106 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5108 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5110 application.SendNotification();
5111 application.Render( 1000 ); // 1 second progress
5113 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5118 int UtcDaliAnimationAnimateByActorColorComponentsP(void)
5120 TestApplication application;
5122 Actor actor = Actor::New();
5123 Stage::GetCurrent().Add(actor);
5124 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5126 // Build the animation
5127 float durationSeconds(1.0f);
5128 Animation animation = Animation::New(durationSeconds);
5129 Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5130 Vector4 relativeColor( targetColor - Color::WHITE );
5131 animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
5132 animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
5133 animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
5134 animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
5136 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5137 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5139 // Start the animation
5142 // Target value should be retrievable straight away
5143 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5144 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5145 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5146 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5147 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5149 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5151 application.SendNotification();
5152 application.Render( 1000 ); // 1 second progress
5154 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5159 int UtcDaliAnimationAnimateByActorSizeP(void)
5161 TestApplication application;
5163 Actor actor = Actor::New();
5164 Stage::GetCurrent().Add(actor);
5165 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5167 // Build the animation
5168 float durationSeconds(1.0f);
5169 Animation animation = Animation::New(durationSeconds);
5170 Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5171 Vector3 relativeSize( targetSize - Vector3::ZERO );
5172 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
5174 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5175 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5177 // Start the animation
5180 // Target value should be retrievable straight away
5181 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5182 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5183 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5184 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5186 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5188 application.SendNotification();
5189 application.Render( 1000 ); // 1 second progress
5191 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5196 int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
5198 TestApplication application;
5200 Actor actor = Actor::New();
5201 Stage::GetCurrent().Add(actor);
5202 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5204 // Build the animation
5205 float durationSeconds(1.0f);
5206 Animation animation = Animation::New(durationSeconds);
5207 Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5208 Vector3 relativeSize( targetSize - Vector3::ZERO );
5209 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
5210 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
5211 animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
5213 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5214 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5216 // Start the animation
5219 // Target value should be retrievable straight away
5220 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5221 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5222 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5223 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5225 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5227 application.SendNotification();
5228 application.Render( 1000 ); // 1 second progress
5230 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5235 int UtcDaliAnimationAnimateByActorVisibilityP(void)
5237 TestApplication application;
5239 Actor actor = Actor::New();
5240 Stage::GetCurrent().Add(actor);
5241 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5243 actor.SetVisible( false );
5245 application.SendNotification();
5246 application.Render();
5248 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
5250 // Build the animation
5251 float durationSeconds(1.0f);
5252 Animation animation = Animation::New(durationSeconds);
5253 bool targetVisibility( true );
5254 bool relativeVisibility( targetVisibility );
5255 animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
5257 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5259 // Start the animation
5262 // Target value should be retrievable straight away
5263 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
5264 DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet
5266 application.SendNotification();
5267 application.Render( 1000 ); // 1 second progress
5269 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5274 int UtcDaliAnimationAnimateToBooleanP(void)
5276 TestApplication application;
5278 Actor actor = Actor::New();
5280 // Register a boolean property
5281 const bool startValue(false);
5282 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5283 Stage::GetCurrent().Add(actor);
5284 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5285 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5287 // Build the animation
5288 float durationSeconds(2.0f);
5289 Animation animation = Animation::New(durationSeconds);
5290 const bool targetValue( !startValue );
5291 animation.AnimateTo(Property(actor, index), targetValue);
5293 // Start the animation
5296 bool signalReceived(false);
5297 AnimationFinishCheck finishCheck(signalReceived);
5298 animation.FinishedSignal().Connect(&application, finishCheck);
5300 application.SendNotification();
5301 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5303 // We didn't expect the animation to finish yet
5304 application.SendNotification();
5305 finishCheck.CheckSignalNotReceived();
5306 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5308 application.SendNotification();
5309 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5311 // We did expect the animation to finish
5312 application.SendNotification();
5313 finishCheck.CheckSignalReceived();
5314 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5316 // Check that nothing has changed after a couple of buffer swaps
5317 application.Render(0);
5318 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5319 application.Render(0);
5320 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5322 // Repeat with target value "false"
5323 animation = Animation::New(durationSeconds);
5324 const bool finalValue( !targetValue );
5325 animation.AnimateTo(Property(actor, index), finalValue);
5327 // Start the animation
5330 finishCheck.Reset();
5331 animation.FinishedSignal().Connect(&application, finishCheck);
5333 application.SendNotification();
5334 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5336 // We didn't expect the animation to finish yet
5337 application.SendNotification();
5338 finishCheck.CheckSignalNotReceived();
5339 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5341 application.SendNotification();
5342 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5344 // We did expect the animation to finish
5345 application.SendNotification();
5346 finishCheck.CheckSignalReceived();
5347 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5349 // Check that nothing has changed after a couple of buffer swaps
5350 application.Render(0);
5351 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5352 application.Render(0);
5353 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5357 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
5359 TestApplication application;
5361 Actor actor = Actor::New();
5363 // Register a boolean property
5364 const bool startValue(false);
5365 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5366 Stage::GetCurrent().Add(actor);
5367 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5368 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5370 // Build the animation
5371 float durationSeconds(2.0f);
5372 Animation animation = Animation::New(durationSeconds);
5373 const bool targetValue( !startValue );
5374 animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5376 // Start the animation
5379 bool signalReceived(false);
5380 AnimationFinishCheck finishCheck(signalReceived);
5381 animation.FinishedSignal().Connect(&application, finishCheck);
5383 application.SendNotification();
5384 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5386 // We didn't expect the animation to finish yet
5387 application.SendNotification();
5388 finishCheck.CheckSignalNotReceived();
5389 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5391 application.SendNotification();
5392 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5394 // We did expect the animation to finish
5395 application.SendNotification();
5396 finishCheck.CheckSignalReceived();
5397 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5399 // Check that nothing has changed after a couple of buffer swaps
5400 application.Render(0);
5401 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5402 application.Render(0);
5403 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5405 // Repeat with target value "false"
5406 animation = Animation::New(durationSeconds);
5407 const bool finalValue( !targetValue );
5408 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5410 // Start the animation
5413 finishCheck.Reset();
5414 animation.FinishedSignal().Connect(&application, finishCheck);
5416 application.SendNotification();
5417 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5419 // We didn't expect the animation to finish yet
5420 application.SendNotification();
5421 finishCheck.CheckSignalNotReceived();
5422 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5424 application.SendNotification();
5425 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5427 // We did expect the animation to finish
5428 application.SendNotification();
5429 finishCheck.CheckSignalReceived();
5430 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5432 // Check that nothing has changed after a couple of buffer swaps
5433 application.Render(0);
5434 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5435 application.Render(0);
5436 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5440 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5442 TestApplication application;
5444 Actor actor = Actor::New();
5446 // Register a boolean property
5447 bool startValue(false);
5448 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5449 Stage::GetCurrent().Add(actor);
5450 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5451 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5453 // Build the animation
5454 float durationSeconds(2.0f);
5455 Animation animation = Animation::New(durationSeconds);
5456 bool finalValue( !startValue );
5457 float animatorDurationSeconds(durationSeconds * 0.5f);
5458 animation.AnimateTo( Property(actor, index),
5460 TimePeriod( animatorDurationSeconds ) );
5462 // Start the animation
5465 bool signalReceived(false);
5466 AnimationFinishCheck finishCheck(signalReceived);
5467 animation.FinishedSignal().Connect(&application, finishCheck);
5469 application.SendNotification();
5470 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5472 // We didn't expect the animation to finish yet
5473 application.SendNotification();
5474 finishCheck.CheckSignalNotReceived();
5475 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5477 application.SendNotification();
5478 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5480 // We didn't expect the animation to finish yet...
5481 application.SendNotification();
5482 finishCheck.CheckSignalNotReceived();
5484 // ...however we should have reached the final value
5485 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5487 application.SendNotification();
5488 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5490 // We did expect the animation to finish
5491 application.SendNotification();
5492 finishCheck.CheckSignalReceived();
5493 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5495 // Check that nothing has changed after a couple of buffer swaps
5496 application.Render(0);
5497 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5498 application.Render(0);
5499 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5503 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5505 TestApplication application;
5507 Actor actor = Actor::New();
5509 // Register a boolean property
5510 bool startValue(false);
5511 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5512 Stage::GetCurrent().Add(actor);
5513 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5514 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5516 // Build the animation
5517 float durationSeconds(2.0f);
5518 Animation animation = Animation::New(durationSeconds);
5519 bool finalValue( !startValue );
5520 float animatorDurationSeconds(durationSeconds * 0.5f);
5521 animation.AnimateTo( Property(actor, index),
5523 AlphaFunction::LINEAR,
5524 TimePeriod( animatorDurationSeconds ) );
5526 // Start the animation
5529 bool signalReceived(false);
5530 AnimationFinishCheck finishCheck(signalReceived);
5531 animation.FinishedSignal().Connect(&application, finishCheck);
5533 application.SendNotification();
5534 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5536 // We didn't expect the animation to finish yet
5537 application.SendNotification();
5538 finishCheck.CheckSignalNotReceived();
5539 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5541 application.SendNotification();
5542 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5544 // We didn't expect the animation to finish yet...
5545 application.SendNotification();
5546 finishCheck.CheckSignalNotReceived();
5548 // ...however we should have reached the final value
5549 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5551 application.SendNotification();
5552 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5554 // We did expect the animation to finish
5555 application.SendNotification();
5556 finishCheck.CheckSignalReceived();
5557 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5559 // Check that nothing has changed after a couple of buffer swaps
5560 application.Render(0);
5561 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5562 application.Render(0);
5563 DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5567 int UtcDaliAnimationAnimateToFloatP(void)
5569 TestApplication application;
5571 Actor actor = Actor::New();
5573 // Register a float property
5574 float startValue(10.0f);
5575 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5576 Stage::GetCurrent().Add(actor);
5577 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5578 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5580 // Build the animation
5581 float durationSeconds(2.0f);
5582 Animation animation = Animation::New(durationSeconds);
5583 float targetValue(50.0f);
5584 float relativeValue(targetValue - startValue);
5585 animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5587 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5589 // Start the animation
5592 bool signalReceived(false);
5593 AnimationFinishCheck finishCheck(signalReceived);
5594 animation.FinishedSignal().Connect(&application, finishCheck);
5596 application.SendNotification();
5597 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5599 // We didn't expect the animation to finish yet
5600 application.SendNotification();
5601 finishCheck.CheckSignalNotReceived();
5602 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5604 application.SendNotification();
5605 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5607 // We did expect the animation to finish
5608 application.SendNotification();
5609 finishCheck.CheckSignalReceived();
5610 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5614 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5616 TestApplication application;
5618 Actor actor = Actor::New();
5620 // Register a float property
5621 float startValue(10.0f);
5622 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5623 Stage::GetCurrent().Add(actor);
5624 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5625 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5627 // Build the animation
5628 float durationSeconds(1.0f);
5629 Animation animation = Animation::New(durationSeconds);
5630 float targetValue(90.0f);
5631 float relativeValue(targetValue - startValue);
5632 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5634 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5636 // Start the animation
5639 bool signalReceived(false);
5640 AnimationFinishCheck finishCheck(signalReceived);
5641 animation.FinishedSignal().Connect(&application, finishCheck);
5643 application.SendNotification();
5644 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5646 // We didn't expect the animation to finish yet
5647 application.SendNotification();
5648 finishCheck.CheckSignalNotReceived();
5650 // The position should have moved more, than with a linear alpha function
5651 float current( actor.GetCurrentProperty< float >( index ) );
5652 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5654 application.SendNotification();
5655 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5657 // We did expect the animation to finish
5658 application.SendNotification();
5659 finishCheck.CheckSignalReceived();
5660 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5664 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5666 TestApplication application;
5668 Actor actor = Actor::New();
5670 // Register a float property
5671 float startValue(10.0f);
5672 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5673 Stage::GetCurrent().Add(actor);
5674 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5675 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5677 // Build the animation
5678 float durationSeconds(1.0f);
5679 Animation animation = Animation::New(durationSeconds);
5680 float targetValue(30.0f);
5681 float relativeValue(targetValue - startValue);
5683 animation.AnimateTo(Property(actor, index),
5685 TimePeriod(delay, durationSeconds - delay));
5687 // Start the animation
5690 bool signalReceived(false);
5691 AnimationFinishCheck finishCheck(signalReceived);
5692 animation.FinishedSignal().Connect(&application, finishCheck);
5694 application.SendNotification();
5695 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5697 // We didn't expect the animation to finish yet
5698 application.SendNotification();
5699 finishCheck.CheckSignalNotReceived();
5700 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5702 application.SendNotification();
5703 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5705 // We didn't expect the animation to finish yet
5706 application.SendNotification();
5707 finishCheck.CheckSignalNotReceived();
5708 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5710 application.SendNotification();
5711 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5713 // We did expect the animation to finish
5714 application.SendNotification();
5715 finishCheck.CheckSignalReceived();
5716 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5720 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5722 TestApplication application;
5724 Actor actor = Actor::New();
5726 // Register a float property
5727 float startValue(10.0f);
5728 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5729 Stage::GetCurrent().Add(actor);
5730 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5731 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5733 // Build the animation
5734 float durationSeconds(1.0f);
5735 Animation animation = Animation::New(durationSeconds);
5736 float targetValue(30.0f);
5737 float relativeValue(targetValue - startValue);
5739 animation.AnimateTo(Property(actor, index),
5741 AlphaFunction::LINEAR,
5742 TimePeriod(delay, durationSeconds - delay));
5744 // Start the animation
5747 bool signalReceived(false);
5748 AnimationFinishCheck finishCheck(signalReceived);
5749 animation.FinishedSignal().Connect(&application, finishCheck);
5751 application.SendNotification();
5752 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5754 // We didn't expect the animation to finish yet
5755 application.SendNotification();
5756 finishCheck.CheckSignalNotReceived();
5757 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5759 application.SendNotification();
5760 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5762 // We didn't expect the animation to finish yet
5763 application.SendNotification();
5764 finishCheck.CheckSignalNotReceived();
5765 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5767 application.SendNotification();
5768 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5770 // We did expect the animation to finish
5771 application.SendNotification();
5772 finishCheck.CheckSignalReceived();
5773 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5777 int UtcDaliAnimationAnimateToIntegerP(void)
5779 TestApplication application;
5781 Actor actor = Actor::New();
5783 // Register an integer property
5785 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5786 Stage::GetCurrent().Add(actor);
5787 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5788 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5790 // Build the animation
5791 float durationSeconds(2.0f);
5792 Animation animation = Animation::New(durationSeconds);
5793 int targetValue(50);
5794 int relativeValue(targetValue - startValue);
5795 animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5797 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5799 // Start the animation
5802 bool signalReceived(false);
5803 AnimationFinishCheck finishCheck(signalReceived);
5804 animation.FinishedSignal().Connect(&application, finishCheck);
5806 application.SendNotification();
5807 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5809 // We didn't expect the animation to finish yet
5810 application.SendNotification();
5811 finishCheck.CheckSignalNotReceived();
5812 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5814 application.SendNotification();
5815 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5817 // We did expect the animation to finish
5818 application.SendNotification();
5819 finishCheck.CheckSignalReceived();
5820 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5824 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5826 TestApplication application;
5828 Actor actor = Actor::New();
5830 // Register an integer property
5832 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5833 Stage::GetCurrent().Add(actor);
5834 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5835 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5837 // Build the animation
5838 float durationSeconds(1.0f);
5839 Animation animation = Animation::New(durationSeconds);
5840 int targetValue(90);
5841 int relativeValue(targetValue - startValue);
5842 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5844 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5846 // Start the animation
5849 bool signalReceived(false);
5850 AnimationFinishCheck finishCheck(signalReceived);
5851 animation.FinishedSignal().Connect(&application, finishCheck);
5853 application.SendNotification();
5854 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5856 // We didn't expect the animation to finish yet
5857 application.SendNotification();
5858 finishCheck.CheckSignalNotReceived();
5860 // The position should have moved more, than with a linear alpha function
5861 int current( actor.GetCurrentProperty< int >( index ) );
5862 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5864 application.SendNotification();
5865 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5867 // We did expect the animation to finish
5868 application.SendNotification();
5869 finishCheck.CheckSignalReceived();
5870 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5874 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5876 TestApplication application;
5878 Actor actor = Actor::New();
5880 // Register an integer property
5882 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5883 Stage::GetCurrent().Add(actor);
5884 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5885 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5887 // Build the animation
5888 float durationSeconds(1.0f);
5889 Animation animation = Animation::New(durationSeconds);
5890 int targetValue(30);
5891 int relativeValue(targetValue - startValue);
5893 animation.AnimateTo(Property(actor, index),
5895 TimePeriod(delay, durationSeconds - delay));
5897 // Start the animation
5900 bool signalReceived(false);
5901 AnimationFinishCheck finishCheck(signalReceived);
5902 animation.FinishedSignal().Connect(&application, finishCheck);
5904 application.SendNotification();
5905 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5907 // We didn't expect the animation to finish yet
5908 application.SendNotification();
5909 finishCheck.CheckSignalNotReceived();
5910 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5912 application.SendNotification();
5913 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5915 // We didn't expect the animation to finish yet
5916 application.SendNotification();
5917 finishCheck.CheckSignalNotReceived();
5918 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5920 application.SendNotification();
5921 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5923 // We did expect the animation to finish
5924 application.SendNotification();
5925 finishCheck.CheckSignalReceived();
5926 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5930 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5932 TestApplication application;
5934 Actor actor = Actor::New();
5936 // Register an integer property
5938 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5939 Stage::GetCurrent().Add(actor);
5940 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5941 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5943 // Build the animation
5944 float durationSeconds(1.0f);
5945 Animation animation = Animation::New(durationSeconds);
5946 int targetValue(30);
5947 int relativeValue(targetValue - startValue);
5949 animation.AnimateTo(Property(actor, index),
5951 AlphaFunction::LINEAR,
5952 TimePeriod(delay, durationSeconds - delay));
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*500.0f)/* 50% animation progress, 0% animator progress */);
5964 // We didn't expect the animation to finish yet
5965 application.SendNotification();
5966 finishCheck.CheckSignalNotReceived();
5967 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5969 application.SendNotification();
5970 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5972 // We didn't expect the animation to finish yet
5973 application.SendNotification();
5974 finishCheck.CheckSignalNotReceived();
5975 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5977 application.SendNotification();
5978 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5980 // We did expect the animation to finish
5981 application.SendNotification();
5982 finishCheck.CheckSignalReceived();
5983 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5987 int UtcDaliAnimationAnimateToVector2P(void)
5989 TestApplication application;
5991 Actor actor = Actor::New();
5993 // Register a Vector2 property
5994 Vector2 startValue(-50.0f, -50.0f);
5995 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
5996 Stage::GetCurrent().Add(actor);
5997 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5998 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6000 // Build the animation
6001 float durationSeconds(2.0f);
6002 Animation animation = Animation::New(durationSeconds);
6003 Vector2 targetValue(50.0f, 50.0f);
6004 Vector2 relativeValue(targetValue - startValue);
6005 animation.AnimateTo(Property(actor, index), targetValue);
6007 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6009 // Start the animation
6012 bool signalReceived(false);
6013 AnimationFinishCheck finishCheck(signalReceived);
6014 animation.FinishedSignal().Connect(&application, finishCheck);
6016 application.SendNotification();
6017 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6019 // We didn't expect the animation to finish yet
6020 application.SendNotification();
6021 finishCheck.CheckSignalNotReceived();
6022 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6024 application.SendNotification();
6025 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6027 // We did expect the animation to finish
6028 application.SendNotification();
6029 finishCheck.CheckSignalReceived();
6030 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6034 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
6036 TestApplication application;
6038 Actor actor = Actor::New();
6040 // Register a Vector2 property
6041 Vector2 startValue(1000.0f, 1000.0f);
6042 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6043 Stage::GetCurrent().Add(actor);
6044 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6045 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6047 // Build the animation
6048 float durationSeconds(1.0f);
6049 Animation animation = Animation::New(durationSeconds);
6050 Vector2 targetValue(9000.0f, 9000.0f);
6051 Vector2 relativeValue(targetValue - startValue);
6052 animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
6054 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6056 // Start the animation
6059 bool signalReceived(false);
6060 AnimationFinishCheck finishCheck(signalReceived);
6061 animation.FinishedSignal().Connect(&application, finishCheck);
6063 application.SendNotification();
6064 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6066 // We didn't expect the animation to finish yet
6067 application.SendNotification();
6068 finishCheck.CheckSignalNotReceived();
6070 // The position should have moved more, than with a linear alpha function
6071 Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
6072 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6073 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6075 application.SendNotification();
6076 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6078 // We did expect the animation to finish
6079 application.SendNotification();
6080 finishCheck.CheckSignalReceived();
6081 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6085 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
6087 TestApplication application;
6089 Actor actor = Actor::New();
6091 // Register a Vector2 property
6092 Vector2 startValue(10.0f, 10.0f);
6093 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6094 Stage::GetCurrent().Add(actor);
6095 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6096 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6098 // Build the animation
6099 float durationSeconds(1.0f);
6100 Animation animation = Animation::New(durationSeconds);
6101 Vector2 targetValue(-10.0f, 20.0f);
6102 Vector2 relativeValue(targetValue - startValue);
6104 animation.AnimateTo(Property(actor, index),
6106 TimePeriod(delay, durationSeconds - delay));
6108 // Start the animation
6111 bool signalReceived(false);
6112 AnimationFinishCheck finishCheck(signalReceived);
6113 animation.FinishedSignal().Connect(&application, finishCheck);
6115 application.SendNotification();
6116 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6118 // We didn't expect the animation to finish yet
6119 application.SendNotification();
6120 finishCheck.CheckSignalNotReceived();
6121 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6123 application.SendNotification();
6124 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6126 // We didn't expect the animation to finish yet
6127 application.SendNotification();
6128 finishCheck.CheckSignalNotReceived();
6129 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6131 application.SendNotification();
6132 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6134 // We did expect the animation to finish
6135 application.SendNotification();
6136 finishCheck.CheckSignalReceived();
6137 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6141 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
6143 TestApplication application;
6145 Actor actor = Actor::New();
6147 // Register a Vector2 property
6148 Vector2 startValue(10.0f, 10.0f);
6149 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6150 Stage::GetCurrent().Add(actor);
6151 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6152 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6154 // Build the animation
6155 float durationSeconds(1.0f);
6156 Animation animation = Animation::New(durationSeconds);
6157 Vector2 targetValue(30.0f, 30.0f);
6158 Vector2 relativeValue(targetValue - startValue);
6160 animation.AnimateTo(Property(actor, index),
6162 AlphaFunction::LINEAR,
6163 TimePeriod(delay, durationSeconds - delay));
6165 // Start the animation
6168 bool signalReceived(false);
6169 AnimationFinishCheck finishCheck(signalReceived);
6170 animation.FinishedSignal().Connect(&application, finishCheck);
6172 application.SendNotification();
6173 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6175 // We didn't expect the animation to finish yet, but cached value should be the final one
6176 application.SendNotification();
6177 finishCheck.CheckSignalNotReceived();
6178 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6179 DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
6181 application.SendNotification();
6182 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6184 // We didn't expect the animation to finish yet
6185 application.SendNotification();
6186 finishCheck.CheckSignalNotReceived();
6187 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6189 application.SendNotification();
6190 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6192 // We did expect the animation to finish
6193 application.SendNotification();
6194 finishCheck.CheckSignalReceived();
6195 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6196 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6200 int UtcDaliAnimationAnimateToVector3P(void)
6202 TestApplication application;
6204 Actor actor = Actor::New();
6206 // Register a Vector3 property
6207 Vector3 startValue(-50.0f, -50.0f, -50.0f);
6208 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6209 Stage::GetCurrent().Add(actor);
6210 DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
6211 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6213 // Build the animation
6214 float durationSeconds(2.0f);
6215 Animation animation = Animation::New(durationSeconds);
6216 Vector3 targetValue(50.0f, 50.0f, 50.0f);
6217 Vector3 relativeValue(targetValue - startValue);
6218 animation.AnimateTo(Property(actor, index), targetValue);
6220 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6222 // Start the animation
6225 bool signalReceived(false);
6226 AnimationFinishCheck finishCheck(signalReceived);
6227 animation.FinishedSignal().Connect(&application, finishCheck);
6229 application.SendNotification();
6230 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6232 // We didn't expect the animation to finish yet
6233 application.SendNotification();
6234 finishCheck.CheckSignalNotReceived();
6235 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6237 application.SendNotification();
6238 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6240 // We did expect the animation to finish
6241 application.SendNotification();
6242 finishCheck.CheckSignalReceived();
6243 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6247 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
6249 TestApplication application;
6251 Actor actor = Actor::New();
6253 // Register a Vector3 property
6254 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
6255 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6256 Stage::GetCurrent().Add(actor);
6257 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6258 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6260 // Build the animation
6261 float durationSeconds(1.0f);
6262 Animation animation = Animation::New(durationSeconds);
6263 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
6264 Vector3 relativeValue(targetValue - startValue);
6265 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6267 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6269 // Start the animation
6272 bool signalReceived(false);
6273 AnimationFinishCheck finishCheck(signalReceived);
6274 animation.FinishedSignal().Connect(&application, finishCheck);
6276 application.SendNotification();
6277 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6279 // We didn't expect the animation to finish yet
6280 application.SendNotification();
6281 finishCheck.CheckSignalNotReceived();
6283 // The position should have moved more, than with a linear alpha function
6284 Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
6285 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6286 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6287 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6289 application.SendNotification();
6290 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6292 // We did expect the animation to finish
6293 application.SendNotification();
6294 finishCheck.CheckSignalReceived();
6295 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6299 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
6301 TestApplication application;
6303 Actor actor = Actor::New();
6305 // Register a Vector3 property
6306 Vector3 startValue(10.0f, 10.0f, 10.0f);
6307 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6308 Stage::GetCurrent().Add(actor);
6309 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6310 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6312 // Build the animation
6313 float durationSeconds(1.0f);
6314 Animation animation = Animation::New(durationSeconds);
6315 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
6316 Vector3 relativeValue(targetValue - startValue);
6318 animation.AnimateTo(Property(actor, index),
6320 TimePeriod(delay, durationSeconds - delay));
6322 // Start the animation
6325 bool signalReceived(false);
6326 AnimationFinishCheck finishCheck(signalReceived);
6327 animation.FinishedSignal().Connect(&application, finishCheck);
6329 application.SendNotification();
6330 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6332 // We didn't expect the animation to finish yet
6333 application.SendNotification();
6334 finishCheck.CheckSignalNotReceived();
6335 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6337 application.SendNotification();
6338 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6340 // We didn't expect the animation to finish yet
6341 application.SendNotification();
6342 finishCheck.CheckSignalNotReceived();
6343 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6345 application.SendNotification();
6346 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6348 // We did expect the animation to finish
6349 application.SendNotification();
6350 finishCheck.CheckSignalReceived();
6351 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6355 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
6357 TestApplication application;
6359 Actor actor = Actor::New();
6361 // Register a Vector3 property
6362 Vector3 startValue(10.0f, 10.0f, 10.0f);
6363 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6364 Stage::GetCurrent().Add(actor);
6365 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6366 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6368 // Build the animation
6369 float durationSeconds(1.0f);
6370 Animation animation = Animation::New(durationSeconds);
6371 Vector3 targetValue(30.0f, 30.0f, 30.0f);
6372 Vector3 relativeValue(targetValue - startValue);
6374 animation.AnimateTo(Property(actor, "testProperty"),
6376 AlphaFunction::LINEAR,
6377 TimePeriod(delay, durationSeconds - delay));
6379 // Start the animation
6382 bool signalReceived(false);
6383 AnimationFinishCheck finishCheck(signalReceived);
6384 animation.FinishedSignal().Connect(&application, finishCheck);
6386 application.SendNotification();
6387 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6389 // We didn't expect the animation to finish yet
6390 application.SendNotification();
6391 finishCheck.CheckSignalNotReceived();
6392 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6394 application.SendNotification();
6395 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6397 // We didn't expect the animation to finish yet
6398 application.SendNotification();
6399 finishCheck.CheckSignalNotReceived();
6400 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6402 application.SendNotification();
6403 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6405 // We did expect the animation to finish
6406 application.SendNotification();
6407 finishCheck.CheckSignalReceived();
6408 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6412 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6414 TestApplication application;
6416 Actor actor = Actor::New();
6418 // Register a Vector3 property
6419 Vector3 startValue(10.0f, 10.0f, 10.0f);
6420 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6421 Stage::GetCurrent().Add(actor);
6422 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6423 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6425 // Build the animation
6426 float durationSeconds(1.0f);
6427 Animation animation = Animation::New(durationSeconds);
6428 Vector3 targetValue(30.0f, 30.0f, 10.0f);
6429 Vector3 relativeValue(targetValue - startValue);
6431 animation.AnimateTo(Property(actor, "testProperty", 0),
6433 AlphaFunction::LINEAR,
6434 TimePeriod(delay, durationSeconds - delay));
6435 animation.AnimateTo(Property(actor, index, 1),
6437 AlphaFunction::LINEAR,
6438 TimePeriod(delay, durationSeconds - delay));
6440 // Start the animation
6443 bool signalReceived(false);
6444 AnimationFinishCheck finishCheck(signalReceived);
6445 animation.FinishedSignal().Connect(&application, finishCheck);
6447 application.SendNotification();
6448 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6450 // We didn't expect the animation to finish yet
6451 application.SendNotification();
6452 finishCheck.CheckSignalNotReceived();
6453 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6455 application.SendNotification();
6456 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6458 // We didn't expect the animation to finish yet
6459 application.SendNotification();
6460 finishCheck.CheckSignalNotReceived();
6461 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6463 application.SendNotification();
6464 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6466 // We did expect the animation to finish
6467 application.SendNotification();
6468 finishCheck.CheckSignalReceived();
6469 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6473 int UtcDaliAnimationAnimateToVector4P(void)
6475 TestApplication application;
6477 Actor actor = Actor::New();
6479 // Register a Vector4 property
6480 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6481 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6482 Stage::GetCurrent().Add(actor);
6483 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6484 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6486 // Build the animation
6487 float durationSeconds(2.0f);
6488 Animation animation = Animation::New(durationSeconds);
6489 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6490 Vector4 relativeValue(targetValue - startValue);
6491 animation.AnimateTo(Property(actor, index), targetValue);
6493 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6495 // Start the animation
6498 bool signalReceived(false);
6499 AnimationFinishCheck finishCheck(signalReceived);
6500 animation.FinishedSignal().Connect(&application, finishCheck);
6502 application.SendNotification();
6503 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6505 // We didn't expect the animation to finish yet
6506 application.SendNotification();
6507 finishCheck.CheckSignalNotReceived();
6508 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6510 application.SendNotification();
6511 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6513 // We did expect the animation to finish
6514 application.SendNotification();
6515 finishCheck.CheckSignalReceived();
6516 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6520 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6522 TestApplication application;
6524 Actor actor = Actor::New();
6526 // Register a Vector4 property
6527 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6528 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6529 Stage::GetCurrent().Add(actor);
6530 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6531 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6533 // Build the animation
6534 float durationSeconds(1.0f);
6535 Animation animation = Animation::New(durationSeconds);
6536 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6537 Vector4 relativeValue(targetValue - startValue);
6538 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6540 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6542 // Start the animation
6545 bool signalReceived(false);
6546 AnimationFinishCheck finishCheck(signalReceived);
6547 animation.FinishedSignal().Connect(&application, finishCheck);
6549 application.SendNotification();
6550 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6552 // We didn't expect the animation to finish yet
6553 application.SendNotification();
6554 finishCheck.CheckSignalNotReceived();
6556 // The position should have moved more, than with a linear alpha function
6557 Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6558 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6559 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6560 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6561 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6563 application.SendNotification();
6564 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6566 // We did expect the animation to finish
6567 application.SendNotification();
6568 finishCheck.CheckSignalReceived();
6569 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6573 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6575 TestApplication application;
6577 Actor actor = Actor::New();
6579 // Register a Vector4 property
6580 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6581 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6582 Stage::GetCurrent().Add(actor);
6583 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6584 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6586 // Build the animation
6587 float durationSeconds(1.0f);
6588 Animation animation = Animation::New(durationSeconds);
6589 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6590 Vector4 relativeValue(targetValue - startValue);
6592 animation.AnimateTo(Property(actor, index),
6594 TimePeriod(delay, durationSeconds - delay));
6596 // Start the animation
6599 bool signalReceived(false);
6600 AnimationFinishCheck finishCheck(signalReceived);
6601 animation.FinishedSignal().Connect(&application, finishCheck);
6603 application.SendNotification();
6604 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6606 // We didn't expect the animation to finish yet
6607 application.SendNotification();
6608 finishCheck.CheckSignalNotReceived();
6609 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6611 application.SendNotification();
6612 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6614 // We didn't expect the animation to finish yet
6615 application.SendNotification();
6616 finishCheck.CheckSignalNotReceived();
6617 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6619 application.SendNotification();
6620 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6622 // We did expect the animation to finish
6623 application.SendNotification();
6624 finishCheck.CheckSignalReceived();
6625 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6629 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6631 TestApplication application;
6633 Actor actor = Actor::New();
6635 // Register a Vector4 property
6636 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6637 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
6638 Stage::GetCurrent().Add(actor);
6639 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6640 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6642 // Build the animation
6643 float durationSeconds(1.0f);
6644 Animation animation = Animation::New(durationSeconds);
6645 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6646 Vector4 relativeValue(targetValue - startValue);
6648 animation.AnimateTo(Property(actor, index),
6650 AlphaFunction::LINEAR,
6651 TimePeriod(delay, durationSeconds - delay));
6653 // Start the animation
6656 bool signalReceived(false);
6657 AnimationFinishCheck finishCheck(signalReceived);
6658 animation.FinishedSignal().Connect(&application, finishCheck);
6660 application.SendNotification();
6661 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6663 // We didn't expect the animation to finish yet
6664 application.SendNotification();
6665 finishCheck.CheckSignalNotReceived();
6666 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6668 application.SendNotification();
6669 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6671 // We didn't expect the animation to finish yet
6672 application.SendNotification();
6673 finishCheck.CheckSignalNotReceived();
6674 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6676 application.SendNotification();
6677 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6679 // We did expect the animation to finish
6680 application.SendNotification();
6681 finishCheck.CheckSignalReceived();
6682 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6686 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6688 TestApplication application;
6690 Actor actor = Actor::New();
6691 Stage::GetCurrent().Add(actor);
6692 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6694 // Build the animation
6695 float durationSeconds(1.0f);
6696 Animation animation = Animation::New(durationSeconds);
6697 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6699 DALI_TEST_ASSERTION(
6701 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6702 }, "IsPropertyAnimatable( index )" );
6707 int UtcDaliAnimationAnimateToActorParentOriginXN(void)
6709 TestApplication application;
6711 Actor actor = Actor::New();
6712 Stage::GetCurrent().Add(actor);
6713 float startValue(0.0f);
6714 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6715 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6717 // Build the animation
6718 float durationSeconds(1.0f);
6719 Animation animation = Animation::New(durationSeconds);
6720 float targetX(1.0f);
6722 DALI_TEST_ASSERTION(
6724 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6725 }, "IsPropertyAnimatable( index )" );
6730 int UtcDaliAnimationAnimateToActorParentOriginYN(void)
6732 TestApplication application;
6734 Actor actor = Actor::New();
6735 Stage::GetCurrent().Add(actor);
6736 float startValue(0.0f);
6737 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6738 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6740 // Build the animation
6741 float durationSeconds(1.0f);
6742 Animation animation = Animation::New(durationSeconds);
6743 float targetY(1.0f);
6745 DALI_TEST_ASSERTION(
6747 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6748 }, "IsPropertyAnimatable( index )" );
6753 int UtcDaliAnimationAnimateToActorParentOriginZN(void)
6755 TestApplication application;
6757 Actor actor = Actor::New();
6758 Stage::GetCurrent().Add(actor);
6759 float startValue(0.5f);
6760 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6761 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6763 // Build the animation
6764 float durationSeconds(1.0f);
6765 Animation animation = Animation::New(durationSeconds);
6766 float targetZ(1.0f);
6768 DALI_TEST_ASSERTION(
6770 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6771 }, "IsPropertyAnimatable( index )" );
6776 int UtcDaliAnimationAnimateToActorAnchorPointN(void)
6778 TestApplication application;
6780 Actor actor = Actor::New();
6781 Stage::GetCurrent().Add(actor);
6782 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6784 // Build the animation
6785 float durationSeconds(1.0f);
6786 Animation animation = Animation::New(durationSeconds);
6787 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6789 DALI_TEST_ASSERTION(
6791 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6792 }, "IsPropertyAnimatable( index )" );
6797 int UtcDaliAnimationAnimateToActorAnchorPointXN(void)
6799 TestApplication application;
6801 Actor actor = Actor::New();
6802 Stage::GetCurrent().Add(actor);
6803 float startValue(0.5f);
6804 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6807 // Build the animation
6808 float durationSeconds(1.0f);
6809 Animation animation = Animation::New(durationSeconds);
6810 float targetX(1.0f);
6812 DALI_TEST_ASSERTION(
6814 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6815 }, "IsPropertyAnimatable( index )" );
6820 int UtcDaliAnimationAnimateToActorAnchorPointYN(void)
6822 TestApplication application;
6824 Actor actor = Actor::New();
6825 Stage::GetCurrent().Add(actor);
6826 float startValue(0.5f);
6827 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6828 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6830 // Build the animation
6831 float durationSeconds(1.0f);
6832 Animation animation = Animation::New(durationSeconds);
6833 float targetY(0.0f);
6835 DALI_TEST_ASSERTION(
6837 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6838 }, "IsPropertyAnimatable( index )" );
6843 int UtcDaliAnimationAnimateToActorAnchorPointZN(void)
6845 TestApplication application;
6847 Actor actor = Actor::New();
6848 Stage::GetCurrent().Add(actor);
6849 float startValue(0.5f);
6850 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6851 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6853 // Build the animation
6854 float durationSeconds(1.0f);
6855 Animation animation = Animation::New(durationSeconds);
6856 float targetZ(100.0f);
6858 DALI_TEST_ASSERTION(
6860 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6861 }, "IsPropertyAnimatable( index )" );
6866 int UtcDaliAnimationAnimateToActorSizeP(void)
6868 TestApplication application;
6870 Actor actor = Actor::New();
6871 Stage::GetCurrent().Add(actor);
6872 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6874 // Build the animation
6875 float durationSeconds(1.0f);
6876 Animation animation = Animation::New(durationSeconds);
6877 Vector3 targetSize(100.0f, 100.0f, 100.0f);
6878 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6880 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6882 // Should return the initial properties before play
6883 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6884 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6885 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6886 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6888 // Start the animation
6891 // Should return the target property after play
6892 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6893 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6894 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6895 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6897 bool signalReceived(false);
6898 AnimationFinishCheck finishCheck(signalReceived);
6899 animation.FinishedSignal().Connect(&application, finishCheck);
6901 application.SendNotification();
6902 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6904 // We didn't expect the animation to finish yet
6905 application.SendNotification();
6906 finishCheck.CheckSignalNotReceived();
6907 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6909 application.SendNotification();
6910 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6912 // We did expect the animation to finish
6913 application.SendNotification();
6914 finishCheck.CheckSignalReceived();
6915 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6918 finishCheck.Reset();
6919 actor.SetSize(Vector3::ZERO);
6920 application.SendNotification();
6921 application.Render(0);
6922 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6924 // Repeat with a different (ease-in) alpha function
6925 animation = Animation::New(durationSeconds);
6926 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6927 animation.FinishedSignal().Connect(&application, finishCheck);
6930 application.SendNotification();
6931 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6933 // We didn't expect the animation to finish yet
6934 application.SendNotification();
6935 finishCheck.CheckSignalNotReceived();
6937 // The size should have travelled less, than with a linear alpha function
6938 Vector3 current(actor.GetCurrentSize());
6939 DALI_TEST_CHECK( current.x > 0.0f );
6940 DALI_TEST_CHECK( current.y > 0.0f );
6941 DALI_TEST_CHECK( current.z > 0.0f );
6942 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6943 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6944 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6946 application.SendNotification();
6947 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6949 // We did expect the animation to finish
6950 application.SendNotification();
6951 finishCheck.CheckSignalReceived();
6952 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6955 finishCheck.Reset();
6956 actor.SetSize(Vector3::ZERO);
6957 application.SendNotification();
6958 application.Render(0);
6959 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6961 // Repeat with a delay
6963 animation = Animation::New(durationSeconds);
6964 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6965 animation.FinishedSignal().Connect(&application, finishCheck);
6968 application.SendNotification();
6969 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6971 // We didn't expect the animation to finish yet
6972 application.SendNotification();
6973 finishCheck.CheckSignalNotReceived();
6974 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6976 application.SendNotification();
6977 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6979 // We did expect the animation to finish
6980 application.SendNotification();
6981 finishCheck.CheckSignalReceived();
6982 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6986 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6988 TestApplication application;
6990 Actor actor = Actor::New();
6991 Stage::GetCurrent().Add(actor);
6992 float startValue(0.0f);
6993 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6994 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6996 // Build the animation
6997 float durationSeconds(1.0f);
6998 Animation animation = Animation::New(durationSeconds);
6999 float targetWidth(10.0f);
7000 animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
7002 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
7004 // Should return the initial properties before play
7005 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7006 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
7008 // Start the animation
7011 // Should return the target property after play
7012 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
7013 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
7015 bool signalReceived(false);
7016 AnimationFinishCheck finishCheck(signalReceived);
7017 animation.FinishedSignal().Connect(&application, finishCheck);
7019 application.SendNotification();
7020 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7022 // We didn't expect the animation to finish yet
7023 application.SendNotification();
7024 finishCheck.CheckSignalNotReceived();
7025 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
7027 application.SendNotification();
7028 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7030 // We did expect the animation to finish
7031 application.SendNotification();
7032 finishCheck.CheckSignalReceived();
7033 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
7034 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7038 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7040 TestApplication application;
7042 Actor actor = Actor::New();
7043 Stage::GetCurrent().Add(actor);
7044 float startValue(0.0f);
7045 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
7046 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7048 // Build the animation
7049 float durationSeconds(1.0f);
7050 Animation animation = Animation::New(durationSeconds);
7051 float targetHeight(-10.0f);
7052 animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7054 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7056 // Should return the initial properties before play
7057 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7058 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7060 // Start the animation
7063 // Should return the target property after play
7064 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7065 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7067 bool signalReceived(false);
7068 AnimationFinishCheck finishCheck(signalReceived);
7069 animation.FinishedSignal().Connect(&application, finishCheck);
7071 application.SendNotification();
7072 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7074 // We didn't expect the animation to finish yet
7075 application.SendNotification();
7076 finishCheck.CheckSignalNotReceived();
7077 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
7079 application.SendNotification();
7080 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7082 // We did expect the animation to finish
7083 application.SendNotification();
7084 finishCheck.CheckSignalReceived();
7085 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
7086 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7090 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7092 TestApplication application;
7094 Actor actor = Actor::New();
7095 Stage::GetCurrent().Add(actor);
7096 float startValue(0.0f);
7097 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
7098 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7100 // Build the animation
7101 float durationSeconds(1.0f);
7102 Animation animation = Animation::New(durationSeconds);
7103 float targetDepth(-10.0f);
7104 animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7106 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7108 // Should return the initial properties before play
7109 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7110 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7112 // Start the animation
7115 // Should return the target property after play
7116 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7117 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7119 bool signalReceived(false);
7120 AnimationFinishCheck finishCheck(signalReceived);
7121 animation.FinishedSignal().Connect(&application, finishCheck);
7123 application.SendNotification();
7124 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7126 // We didn't expect the animation to finish yet
7127 application.SendNotification();
7128 finishCheck.CheckSignalNotReceived();
7129 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
7131 application.SendNotification();
7132 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7134 // We did expect the animation to finish
7135 application.SendNotification();
7136 finishCheck.CheckSignalReceived();
7137 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
7138 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7142 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7144 TestApplication application;
7146 Actor actor = Actor::New();
7147 Stage::GetCurrent().Add(actor);
7148 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7150 // Build the animation
7151 float durationSeconds(1.0f);
7152 Animation animation = Animation::New(durationSeconds);
7153 Vector3 targetSize(100.0f, 100.0f, 100.0f);
7154 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7156 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7158 // Start the animation
7161 bool signalReceived(false);
7162 AnimationFinishCheck finishCheck(signalReceived);
7163 animation.FinishedSignal().Connect(&application, finishCheck);
7165 application.SendNotification();
7166 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7168 // We didn't expect the animation to finish yet
7169 application.SendNotification();
7170 finishCheck.CheckSignalNotReceived();
7171 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
7173 application.SendNotification();
7174 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7176 // We did expect the animation to finish
7177 application.SendNotification();
7178 finishCheck.CheckSignalReceived();
7179 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7182 finishCheck.Reset();
7183 actor.SetSize(Vector3::ZERO);
7184 application.SendNotification();
7185 application.Render(0);
7186 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7188 // Repeat with a different (ease-in) alpha function
7189 animation = Animation::New(durationSeconds);
7190 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7191 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7192 animation.FinishedSignal().Connect(&application, finishCheck);
7195 application.SendNotification();
7196 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7198 // We didn't expect the animation to finish yet
7199 application.SendNotification();
7200 finishCheck.CheckSignalNotReceived();
7202 // The size should have travelled less, than with a linear alpha function
7203 Vector3 current(actor.GetCurrentSize());
7204 DALI_TEST_CHECK( current.x > 0.0f );
7205 DALI_TEST_CHECK( current.y > 0.0f );
7206 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7207 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7209 application.SendNotification();
7210 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7212 // We did expect the animation to finish
7213 application.SendNotification();
7214 finishCheck.CheckSignalReceived();
7215 DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7216 DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7219 finishCheck.Reset();
7220 actor.SetSize(Vector3::ZERO);
7221 application.SendNotification();
7222 application.Render(0);
7223 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7225 // Repeat with a delay
7227 animation = Animation::New(durationSeconds);
7228 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7229 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7230 animation.FinishedSignal().Connect(&application, finishCheck);
7233 application.SendNotification();
7234 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7236 // We didn't expect the animation to finish yet
7237 application.SendNotification();
7238 finishCheck.CheckSignalNotReceived();
7239 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7241 application.SendNotification();
7242 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7244 // We did expect the animation to finish
7245 application.SendNotification();
7246 finishCheck.CheckSignalReceived();
7247 DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7248 DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7252 int UtcDaliAnimationAnimateToActorPositionP(void)
7254 TestApplication application;
7256 Actor actor = Actor::New();
7257 Stage::GetCurrent().Add(actor);
7258 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7260 // Build the animation
7261 float durationSeconds(1.0f);
7262 Animation animation = Animation::New(durationSeconds);
7263 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7264 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7266 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7268 // Should return the initial properties before play
7269 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7270 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7271 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7272 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7274 // Start the animation
7277 // Should return the target property after play
7278 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7279 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7280 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7281 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
7283 bool signalReceived(false);
7284 AnimationFinishCheck finishCheck(signalReceived);
7285 animation.FinishedSignal().Connect(&application, finishCheck);
7287 application.SendNotification();
7288 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7290 // We didn't expect the animation to finish yet
7291 application.SendNotification();
7292 finishCheck.CheckSignalNotReceived();
7293 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7295 application.SendNotification();
7296 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7298 // We did expect the animation to finish
7299 application.SendNotification();
7300 finishCheck.CheckSignalReceived();
7301 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7305 int UtcDaliAnimationAnimateToActorPositionXP(void)
7307 TestApplication application;
7309 Actor actor = Actor::New();
7310 Stage::GetCurrent().Add(actor);
7311 float startValue(0.0f);
7312 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
7313 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7314 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7315 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7317 // Build the animation
7318 float durationSeconds(1.0f);
7319 Animation animation = Animation::New(durationSeconds);
7320 float targetX(1.0f);
7321 animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7323 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7325 // Should return the initial properties before play
7326 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7327 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7329 // Start the animation
7332 // Should return the target property after play
7333 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7334 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
7336 bool signalReceived(false);
7337 AnimationFinishCheck finishCheck(signalReceived);
7338 animation.FinishedSignal().Connect(&application, finishCheck);
7340 application.SendNotification();
7341 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7343 // We didn't expect the animation to finish yet
7344 application.SendNotification();
7345 finishCheck.CheckSignalNotReceived();
7346 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
7348 application.SendNotification();
7349 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7351 // We did expect the animation to finish
7352 application.SendNotification();
7353 finishCheck.CheckSignalReceived();
7354 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
7355 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7356 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7357 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7361 int UtcDaliAnimationAnimateToActorPositionYP(void)
7363 TestApplication application;
7365 Actor actor = Actor::New();
7366 Stage::GetCurrent().Add(actor);
7367 float startValue(0.0f);
7368 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7369 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7370 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7371 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7373 // Build the animation
7374 float durationSeconds(1.0f);
7375 Animation animation = Animation::New(durationSeconds);
7376 float targetY(10.0f);
7377 animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7379 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7381 // Should return the initial properties before play
7382 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7383 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7385 // Start the animation
7388 // Should return the target property after play
7389 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7390 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7392 bool signalReceived(false);
7393 AnimationFinishCheck finishCheck(signalReceived);
7394 animation.FinishedSignal().Connect(&application, finishCheck);
7396 application.SendNotification();
7397 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7399 // We didn't expect the animation to finish yet
7400 application.SendNotification();
7401 finishCheck.CheckSignalNotReceived();
7402 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7404 application.SendNotification();
7405 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7407 // We did expect the animation to finish
7408 application.SendNotification();
7409 finishCheck.CheckSignalReceived();
7410 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7411 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7412 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7413 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7417 int UtcDaliAnimationAnimateToActorPositionZP(void)
7419 TestApplication application;
7421 Actor actor = Actor::New();
7422 Stage::GetCurrent().Add(actor);
7423 float startValue(0.0f);
7424 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7425 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7426 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7427 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7429 // Build the animation
7430 float durationSeconds(1.0f);
7431 Animation animation = Animation::New(durationSeconds);
7432 float targetZ(-5.0f);
7433 animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7435 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7437 // Should return the initial properties before play
7438 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7439 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7441 // Start the animation
7444 // Should return the target property after play
7445 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7446 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7448 bool signalReceived(false);
7449 AnimationFinishCheck finishCheck(signalReceived);
7450 animation.FinishedSignal().Connect(&application, finishCheck);
7452 application.SendNotification();
7453 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7455 // We didn't expect the animation to finish yet
7456 application.SendNotification();
7457 finishCheck.CheckSignalNotReceived();
7458 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7460 application.SendNotification();
7461 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7463 // We did expect the animation to finish
7464 application.SendNotification();
7465 finishCheck.CheckSignalReceived();
7466 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7467 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7468 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7469 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7473 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7475 TestApplication application;
7477 Actor actor = Actor::New();
7478 Stage::GetCurrent().Add(actor);
7479 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7481 // Build the animation
7482 float durationSeconds(1.0f);
7483 Animation animation = Animation::New(durationSeconds);
7484 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7485 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7487 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7489 // Start the animation
7492 bool signalReceived(false);
7493 AnimationFinishCheck finishCheck(signalReceived);
7494 animation.FinishedSignal().Connect(&application, finishCheck);
7496 application.SendNotification();
7497 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7499 // We didn't expect the animation to finish yet
7500 application.SendNotification();
7501 finishCheck.CheckSignalNotReceived();
7503 // The position should have moved less, than with a linear alpha function
7504 Vector3 current(actor.GetCurrentPosition());
7505 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7506 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7507 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7508 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7509 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7510 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7512 application.SendNotification();
7513 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7515 // We did expect the animation to finish
7516 application.SendNotification();
7517 finishCheck.CheckSignalReceived();
7518 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7522 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7524 TestApplication application;
7526 Actor actor = Actor::New();
7527 Stage::GetCurrent().Add(actor);
7528 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7530 // Build the animation
7531 float durationSeconds(1.0f);
7532 Animation animation = Animation::New(durationSeconds);
7533 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7535 animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7537 TimePeriod( delay, durationSeconds - delay ) );
7539 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7541 // Start the animation
7544 bool signalReceived(false);
7545 AnimationFinishCheck finishCheck(signalReceived);
7546 animation.FinishedSignal().Connect(&application, finishCheck);
7548 application.SendNotification();
7549 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7551 // We didn't expect the animation to finish yet
7552 application.SendNotification();
7553 finishCheck.CheckSignalNotReceived();
7554 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7556 application.SendNotification();
7557 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7559 // We didn't expect the animation to finish yet
7560 application.SendNotification();
7561 finishCheck.CheckSignalNotReceived();
7562 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7564 application.SendNotification();
7565 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7567 // We did expect the animation to finish
7568 application.SendNotification();
7569 finishCheck.CheckSignalReceived();
7570 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7574 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7576 TestApplication application;
7578 Actor actor = Actor::New();
7579 Stage::GetCurrent().Add(actor);
7580 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7582 // Build the animation
7583 float durationSeconds(1.0f);
7584 Animation animation = Animation::New(durationSeconds);
7585 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7587 animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7589 AlphaFunction::LINEAR,
7590 TimePeriod( delay, durationSeconds - delay ) );
7592 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7594 // Start the animation
7597 bool signalReceived(false);
7598 AnimationFinishCheck finishCheck(signalReceived);
7599 animation.FinishedSignal().Connect(&application, finishCheck);
7601 application.SendNotification();
7602 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7604 // We didn't expect the animation to finish yet
7605 application.SendNotification();
7606 finishCheck.CheckSignalNotReceived();
7607 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7609 application.SendNotification();
7610 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7612 // We didn't expect the animation to finish yet
7613 application.SendNotification();
7614 finishCheck.CheckSignalNotReceived();
7615 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7617 application.SendNotification();
7618 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7620 // We did expect the animation to finish
7621 application.SendNotification();
7622 finishCheck.CheckSignalReceived();
7623 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7627 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7629 TestApplication application;
7631 Actor actor = Actor::New();
7632 actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7633 Stage::GetCurrent().Add(actor);
7634 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7636 // Build the animation
7637 float durationSeconds(1.0f);
7638 Animation animation = Animation::New(durationSeconds);
7639 Degree targetRotationDegrees(90.0f);
7640 Radian targetRotationRadians(targetRotationDegrees);
7641 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7643 // Start the animation
7646 // Target value should be retrievable straight away
7647 DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7649 bool signalReceived(false);
7650 AnimationFinishCheck finishCheck(signalReceived);
7651 animation.FinishedSignal().Connect(&application, finishCheck);
7653 application.SendNotification();
7654 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7656 // We didn't expect the animation to finish yet
7657 application.SendNotification();
7658 finishCheck.CheckSignalNotReceived();
7659 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7661 application.SendNotification();
7662 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7664 // We didn't expect the animation to finish yet
7665 application.SendNotification();
7666 finishCheck.CheckSignalNotReceived();
7667 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7669 application.SendNotification();
7670 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7672 // We didn't expect the animation to finish yet
7673 application.SendNotification();
7674 finishCheck.CheckSignalNotReceived();
7675 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7677 application.SendNotification();
7678 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7680 // We did expect the animation to finish
7681 application.SendNotification();
7682 finishCheck.CheckSignalReceived();
7683 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7687 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7689 TestApplication application;
7691 Actor actor = Actor::New();
7692 actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7693 Stage::GetCurrent().Add(actor);
7694 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7696 // Build the animation
7697 float durationSeconds(1.0f);
7698 Animation animation = Animation::New(durationSeconds);
7699 Degree targetRotationDegrees(90.0f);
7700 Radian targetRotationRadians(targetRotationDegrees);
7701 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7702 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7704 // Start the animation
7707 bool signalReceived(false);
7708 AnimationFinishCheck finishCheck(signalReceived);
7709 animation.FinishedSignal().Connect(&application, finishCheck);
7711 application.SendNotification();
7712 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7714 // We didn't expect the animation to finish yet
7715 application.SendNotification();
7716 finishCheck.CheckSignalNotReceived();
7717 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7719 application.SendNotification();
7720 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7722 // We didn't expect the animation to finish yet
7723 application.SendNotification();
7724 finishCheck.CheckSignalNotReceived();
7725 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7727 application.SendNotification();
7728 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7730 // We didn't expect the animation to finish yet
7731 application.SendNotification();
7732 finishCheck.CheckSignalNotReceived();
7733 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7735 application.SendNotification();
7736 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7738 // We did expect the animation to finish
7739 application.SendNotification();
7740 finishCheck.CheckSignalReceived();
7741 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7745 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7747 TestApplication application;
7749 Actor actor = Actor::New();
7750 actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7751 Stage::GetCurrent().Add(actor);
7752 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7754 // Build the animation
7755 float durationSeconds(1.0f);
7756 Animation animation = Animation::New(durationSeconds);
7757 Degree targetRotationDegrees(90.0f);
7758 Radian targetRotationRadians(targetRotationDegrees);
7759 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7761 // Start the animation
7764 bool signalReceived(false);
7765 AnimationFinishCheck finishCheck(signalReceived);
7766 animation.FinishedSignal().Connect(&application, finishCheck);
7768 application.SendNotification();
7769 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7771 // We didn't expect the animation to finish yet
7772 application.SendNotification();
7773 finishCheck.CheckSignalNotReceived();
7774 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7776 application.SendNotification();
7777 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7779 // We didn't expect the animation to finish yet
7780 application.SendNotification();
7781 finishCheck.CheckSignalNotReceived();
7782 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7784 application.SendNotification();
7785 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7787 // We didn't expect the animation to finish yet
7788 application.SendNotification();
7789 finishCheck.CheckSignalNotReceived();
7790 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7792 application.SendNotification();
7793 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7795 // We did expect the animation to finish
7796 application.SendNotification();
7797 finishCheck.CheckSignalReceived();
7798 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7802 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7804 TestApplication application;
7806 Actor actor = Actor::New();
7807 actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7808 Stage::GetCurrent().Add(actor);
7809 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7811 // Build the animation
7812 float durationSeconds(1.0f);
7813 Animation animation = Animation::New(durationSeconds);
7814 Degree targetRotationDegrees(90.0f);
7815 Radian targetRotationRadians(targetRotationDegrees);
7817 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7819 // Start the animation
7822 bool signalReceived(false);
7823 AnimationFinishCheck finishCheck(signalReceived);
7824 animation.FinishedSignal().Connect(&application, finishCheck);
7826 application.SendNotification();
7827 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7829 // We didn't expect the animation to finish yet
7830 application.SendNotification();
7831 finishCheck.CheckSignalNotReceived();
7832 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7833 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7835 application.SendNotification();
7836 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7838 // We didn't expect the animation to finish yet
7839 application.SendNotification();
7840 finishCheck.CheckSignalNotReceived();
7841 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7842 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7844 application.SendNotification();
7845 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7847 // We didn't expect the animation to finish yet
7848 application.SendNotification();
7849 finishCheck.CheckSignalNotReceived();
7850 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7851 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7853 application.SendNotification();
7854 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7856 // We did expect the animation to finish
7857 application.SendNotification();
7858 finishCheck.CheckSignalReceived();
7859 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7863 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7865 TestApplication application;
7867 Actor actor = Actor::New();
7868 actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7869 Stage::GetCurrent().Add(actor);
7870 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7872 // Build the animation
7873 float durationSeconds(1.0f);
7874 Animation animation = Animation::New(durationSeconds);
7875 Degree targetRotationDegrees(90.0f);
7876 Radian targetRotationRadians(targetRotationDegrees);
7878 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7880 // Start the animation
7883 bool signalReceived(false);
7884 AnimationFinishCheck finishCheck(signalReceived);
7885 animation.FinishedSignal().Connect(&application, finishCheck);
7887 application.SendNotification();
7888 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7890 // We didn't expect the animation to finish yet
7891 application.SendNotification();
7892 finishCheck.CheckSignalNotReceived();
7893 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7894 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7896 application.SendNotification();
7897 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7899 // We didn't expect the animation to finish yet
7900 application.SendNotification();
7901 finishCheck.CheckSignalNotReceived();
7902 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7903 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7905 application.SendNotification();
7906 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7908 // We didn't expect the animation to finish yet
7909 application.SendNotification();
7910 finishCheck.CheckSignalNotReceived();
7911 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7912 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7914 application.SendNotification();
7915 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7917 // We did expect the animation to finish
7918 application.SendNotification();
7919 finishCheck.CheckSignalReceived();
7920 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7924 int UtcDaliAnimationAnimateToActorScaleP(void)
7926 TestApplication application;
7928 Actor actor = Actor::New();
7929 Stage::GetCurrent().Add(actor);
7930 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7932 // Build the animation
7933 float durationSeconds(1.0f);
7934 Animation animation = Animation::New(durationSeconds);
7935 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7936 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7938 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7940 // Start the animation
7943 // Target value should be retrievable straight away
7944 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7945 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7946 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7947 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
7949 bool signalReceived(false);
7950 AnimationFinishCheck finishCheck(signalReceived);
7951 animation.FinishedSignal().Connect(&application, finishCheck);
7953 application.SendNotification();
7954 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7956 // We didn't expect the animation to finish yet
7957 application.SendNotification();
7958 finishCheck.CheckSignalNotReceived();
7959 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7961 application.SendNotification();
7962 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7964 // We did expect the animation to finish
7965 application.SendNotification();
7966 finishCheck.CheckSignalReceived();
7967 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7970 finishCheck.Reset();
7971 actor.SetScale(Vector3::ONE);
7972 application.SendNotification();
7973 application.Render(0);
7974 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7976 // Repeat with a different (ease-in) alpha function
7977 animation = Animation::New(durationSeconds);
7978 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7979 animation.FinishedSignal().Connect(&application, finishCheck);
7982 application.SendNotification();
7983 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7985 // We didn't expect the animation to finish yet
7986 application.SendNotification();
7987 finishCheck.CheckSignalNotReceived();
7989 // The scale should have grown less, than with a linear alpha function
7990 Vector3 current(actor.GetCurrentScale());
7991 DALI_TEST_CHECK( current.x > 1.0f );
7992 DALI_TEST_CHECK( current.y > 1.0f );
7993 DALI_TEST_CHECK( current.z > 1.0f );
7994 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7995 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7996 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7998 application.SendNotification();
7999 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8001 // We did expect the animation to finish
8002 application.SendNotification();
8003 finishCheck.CheckSignalReceived();
8004 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8007 finishCheck.Reset();
8008 actor.SetScale(Vector3::ONE);
8009 application.SendNotification();
8010 application.Render(0);
8011 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8013 // Repeat with a delay
8015 animation = Animation::New(durationSeconds);
8016 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
8017 animation.FinishedSignal().Connect(&application, finishCheck);
8020 application.SendNotification();
8021 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8023 // We didn't expect the animation to finish yet
8024 application.SendNotification();
8025 finishCheck.CheckSignalNotReceived();
8026 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8028 application.SendNotification();
8029 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8031 // We did expect the animation to finish
8032 application.SendNotification();
8033 finishCheck.CheckSignalReceived();
8034 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8038 int UtcDaliAnimationAnimateToActorScaleXP(void)
8040 TestApplication application;
8042 Actor actor = Actor::New();
8043 Stage::GetCurrent().Add(actor);
8044 float startValue(1.0f);
8045 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
8046 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8048 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8049 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8050 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8051 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8053 // Build the animation
8054 float durationSeconds(1.0f);
8055 Animation animation = Animation::New(durationSeconds);
8056 float targetX(10.0f);
8057 animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8059 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8061 // Start the animation
8064 // Target value should be retrievable straight away
8065 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8066 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8068 bool signalReceived(false);
8069 AnimationFinishCheck finishCheck(signalReceived);
8070 animation.FinishedSignal().Connect(&application, finishCheck);
8072 application.SendNotification();
8073 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8075 // We didn't expect the animation to finish yet
8076 application.SendNotification();
8077 finishCheck.CheckSignalNotReceived();
8078 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
8079 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8080 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8081 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8083 application.SendNotification();
8084 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8086 // We did expect the animation to finish
8087 application.SendNotification();
8088 finishCheck.CheckSignalReceived();
8089 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
8090 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8091 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8092 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8096 int UtcDaliAnimationAnimateToActorScaleYP(void)
8098 TestApplication application;
8100 Actor actor = Actor::New();
8101 Stage::GetCurrent().Add(actor);
8102 float startValue(1.0f);
8103 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
8104 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8105 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8106 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8107 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8108 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8109 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8111 // Build the animation
8112 float durationSeconds(1.0f);
8113 Animation animation = Animation::New(durationSeconds);
8114 float targetY(1000.0f);
8115 animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8117 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8119 // Start the animation
8122 // Target value should be retrievable straight away
8123 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8124 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8126 bool signalReceived(false);
8127 AnimationFinishCheck finishCheck(signalReceived);
8128 animation.FinishedSignal().Connect(&application, finishCheck);
8130 application.SendNotification();
8131 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8133 // We didn't expect the animation to finish yet
8134 application.SendNotification();
8135 finishCheck.CheckSignalNotReceived();
8136 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
8137 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8138 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8139 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8141 application.SendNotification();
8142 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8144 // We did expect the animation to finish
8145 application.SendNotification();
8146 finishCheck.CheckSignalReceived();
8147 DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
8148 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8149 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8150 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8154 int UtcDaliAnimationAnimateToActorScaleZP(void)
8156 TestApplication application;
8158 Actor actor = Actor::New();
8159 Stage::GetCurrent().Add(actor);
8160 float startValue(1.0f);
8161 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
8162 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8163 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8164 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8165 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8166 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8167 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8169 // Build the animation
8170 float durationSeconds(1.0f);
8171 Animation animation = Animation::New(durationSeconds);
8172 float targetZ(-1000.0f);
8173 animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8175 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8177 // Start the animation
8180 // Target value should be retrievable straight away
8181 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8182 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8184 bool signalReceived(false);
8185 AnimationFinishCheck finishCheck(signalReceived);
8186 animation.FinishedSignal().Connect(&application, finishCheck);
8188 application.SendNotification();
8189 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8191 // We didn't expect the animation to finish yet
8192 application.SendNotification();
8193 finishCheck.CheckSignalNotReceived();
8194 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
8195 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8196 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8197 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8199 application.SendNotification();
8200 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8202 // We did expect the animation to finish
8203 application.SendNotification();
8204 finishCheck.CheckSignalReceived();
8205 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
8206 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8207 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8208 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8212 int UtcDaliAnimationAnimateToActorColorP(void)
8214 TestApplication application;
8216 Actor actor = Actor::New();
8217 Stage::GetCurrent().Add(actor);
8218 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8220 // Build the animation
8221 float durationSeconds(1.0f);
8222 Animation animation = Animation::New(durationSeconds);
8223 Vector4 targetColor(Color::RED);
8224 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8226 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8227 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8229 // Start the animation
8232 // Target value should be retrievable straight away
8233 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8234 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8235 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8236 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8237 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8238 DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8240 bool signalReceived(false);
8241 AnimationFinishCheck finishCheck(signalReceived);
8242 animation.FinishedSignal().Connect(&application, finishCheck);
8244 application.SendNotification();
8245 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8247 // We didn't expect the animation to finish yet
8248 application.SendNotification();
8249 finishCheck.CheckSignalNotReceived();
8250 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8252 application.SendNotification();
8253 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8255 // We did expect the animation to finish
8256 application.SendNotification();
8257 finishCheck.CheckSignalReceived();
8258 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8261 finishCheck.Reset();
8262 actor.SetColor(Color::WHITE);
8263 application.SendNotification();
8264 application.Render(0);
8265 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8267 // Repeat with a different (ease-in) alpha function
8268 animation = Animation::New(durationSeconds);
8269 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8270 animation.FinishedSignal().Connect(&application, finishCheck);
8273 application.SendNotification();
8274 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8276 // We didn't expect the animation to finish yet
8277 application.SendNotification();
8278 finishCheck.CheckSignalNotReceived();
8280 // The color should have changed less, than with a linear alpha function
8281 Vector4 current(actor.GetCurrentColor());
8282 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8283 DALI_TEST_CHECK( current.y < 1.0f );
8284 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8285 DALI_TEST_CHECK( current.z < 1.0f );
8286 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8287 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8289 application.SendNotification();
8290 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8292 // We did expect the animation to finish
8293 application.SendNotification();
8294 finishCheck.CheckSignalReceived();
8295 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8298 finishCheck.Reset();
8299 actor.SetColor(Color::WHITE);
8300 application.SendNotification();
8301 application.Render(0);
8302 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8304 // Repeat with a shorter animator duration
8305 float animatorDuration = 0.5f;
8306 animation = Animation::New(durationSeconds);
8307 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8308 animation.FinishedSignal().Connect(&application, finishCheck);
8311 application.SendNotification();
8312 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8314 // We didn't expect the animation to finish yet
8315 application.SendNotification();
8316 finishCheck.CheckSignalNotReceived();
8317 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8319 application.SendNotification();
8320 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8322 // We didn't expect the animation to finish yet
8323 application.SendNotification();
8324 finishCheck.CheckSignalNotReceived();
8325 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8327 application.SendNotification();
8328 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8330 // We did expect the animation to finish
8331 application.SendNotification();
8332 finishCheck.CheckSignalReceived();
8333 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8337 int UtcDaliAnimationAnimateToActorColorRedP(void)
8339 TestApplication application;
8341 Actor actor = Actor::New();
8342 Stage::GetCurrent().Add(actor);
8343 float startValue(1.0f);
8344 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
8345 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8346 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8347 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8348 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8349 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8350 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8351 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8352 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8354 // Build the animation
8355 float durationSeconds(1.0f);
8356 Animation animation = Animation::New(durationSeconds);
8357 float targetRed(0.5f);
8358 animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8360 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8362 // Start the animation
8365 // Target value should be retrievable straight away
8366 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8367 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8369 bool signalReceived(false);
8370 AnimationFinishCheck finishCheck(signalReceived);
8371 animation.FinishedSignal().Connect(&application, finishCheck);
8373 application.SendNotification();
8374 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8376 // We didn't expect the animation to finish yet
8377 application.SendNotification();
8378 finishCheck.CheckSignalNotReceived();
8379 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8380 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
8381 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8382 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8383 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8385 application.SendNotification();
8386 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8388 // We did expect the animation to finish
8389 application.SendNotification();
8390 finishCheck.CheckSignalReceived();
8391 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8392 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), targetRed, TEST_LOCATION );
8393 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8394 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8395 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8399 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8401 TestApplication application;
8403 Actor actor = Actor::New();
8404 Stage::GetCurrent().Add(actor);
8405 float startValue(1.0f);
8406 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8407 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8408 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8409 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8410 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8411 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8412 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8413 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8414 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8416 // Build the animation
8417 float durationSeconds(1.0f);
8418 Animation animation = Animation::New(durationSeconds);
8419 float targetGreen(0.5f);
8420 animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8422 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8424 // Start the animation
8427 // Target value should be retrievable straight away
8428 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8429 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8431 bool signalReceived(false);
8432 AnimationFinishCheck finishCheck(signalReceived);
8433 animation.FinishedSignal().Connect(&application, finishCheck);
8435 application.SendNotification();
8436 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8438 // We didn't expect the animation to finish yet
8439 application.SendNotification();
8440 finishCheck.CheckSignalNotReceived();
8441 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8442 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8443 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8444 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8445 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8447 application.SendNotification();
8448 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8450 // We did expect the animation to finish
8451 application.SendNotification();
8452 finishCheck.CheckSignalReceived();
8453 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8454 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8455 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8456 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8457 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8461 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8463 TestApplication application;
8465 Actor actor = Actor::New();
8466 Stage::GetCurrent().Add(actor);
8467 float startValue(1.0f);
8468 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8469 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8470 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8471 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8472 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8473 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8474 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8475 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8476 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8478 // Build the animation
8479 float durationSeconds(1.0f);
8480 Animation animation = Animation::New(durationSeconds);
8481 float targetBlue(0.5f);
8482 animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8484 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8486 // Start the animation
8489 // Target value should be retrievable straight away
8490 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8491 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8493 bool signalReceived(false);
8494 AnimationFinishCheck finishCheck(signalReceived);
8495 animation.FinishedSignal().Connect(&application, finishCheck);
8497 application.SendNotification();
8498 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8500 // We didn't expect the animation to finish yet
8501 application.SendNotification();
8502 finishCheck.CheckSignalNotReceived();
8503 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8504 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8505 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8506 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), fiftyPercentProgress, TEST_LOCATION );
8507 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8509 application.SendNotification();
8510 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8512 // We did expect the animation to finish
8513 application.SendNotification();
8514 finishCheck.CheckSignalReceived();
8515 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8516 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8517 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8518 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8519 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8523 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8525 TestApplication application;
8527 Actor actor = Actor::New();
8528 Stage::GetCurrent().Add(actor);
8529 float startValue(1.0f);
8530 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8531 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8532 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8533 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8534 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8535 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8536 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8537 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8538 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8540 // Build the animation
8541 float durationSeconds(1.0f);
8542 Animation animation = Animation::New(durationSeconds);
8543 float targetAlpha(0.5f);
8544 animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8546 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8548 // Start the animation
8551 // Target value should be retrievable straight away
8552 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8553 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8554 DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8556 bool signalReceived(false);
8557 AnimationFinishCheck finishCheck(signalReceived);
8558 animation.FinishedSignal().Connect(&application, finishCheck);
8560 application.SendNotification();
8561 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8563 // We didn't expect the animation to finish yet
8564 application.SendNotification();
8565 finishCheck.CheckSignalNotReceived();
8566 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8567 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8568 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8569 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8570 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8572 application.SendNotification();
8573 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8575 // We did expect the animation to finish
8576 application.SendNotification();
8577 finishCheck.CheckSignalReceived();
8578 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8579 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8580 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8581 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8582 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8586 int UtcDaliAnimationKeyFrames01P(void)
8588 TestApplication application;
8590 KeyFrames keyFrames = KeyFrames::New();
8591 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8593 keyFrames.Add(0.0f, 0.1f);
8595 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8597 KeyFrames keyFrames2( keyFrames);
8598 DALI_TEST_CHECK( keyFrames2 );
8599 DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8601 KeyFrames keyFrames3 = KeyFrames::New();
8602 keyFrames3.Add(0.6f, true);
8603 DALI_TEST_CHECK( keyFrames3 );
8604 DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8606 keyFrames3 = keyFrames;
8607 DALI_TEST_CHECK( keyFrames3 );
8608 DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8613 int UtcDaliAnimationKeyFrames02N(void)
8615 TestApplication application;
8617 KeyFrames keyFrames = KeyFrames::New();
8618 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8620 keyFrames.Add(0.0f, 0.1f);
8621 keyFrames.Add(0.2f, 0.5f);
8622 keyFrames.Add(0.4f, 0.0f);
8623 keyFrames.Add(0.6f, 1.0f);
8624 keyFrames.Add(0.8f, 0.7f);
8625 keyFrames.Add(1.0f, 0.9f);
8627 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8629 DALI_TEST_ASSERTION(
8631 keyFrames.Add(1.9f, false);
8632 }, "mType == value.GetType()" );
8637 int UtcDaliAnimationKeyFrames03N(void)
8639 TestApplication application;
8641 KeyFrames keyFrames = KeyFrames::New();
8642 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8644 keyFrames.Add(0.0f, true);
8645 keyFrames.Add(0.2f, false);
8646 keyFrames.Add(0.4f, false);
8647 keyFrames.Add(0.6f, true);
8648 keyFrames.Add(0.8f, true);
8649 keyFrames.Add(1.0f, false);
8651 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8653 DALI_TEST_ASSERTION(
8655 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8656 }, "mType == value.GetType()" );
8661 int UtcDaliAnimationKeyFrames04N(void)
8663 TestApplication application;
8665 KeyFrames keyFrames = KeyFrames::New();
8666 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8668 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8669 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8670 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8671 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8672 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8673 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8675 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8677 DALI_TEST_ASSERTION(
8679 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8680 }, "mType == value.GetType()" );
8685 int UtcDaliAnimationKeyFrames05N(void)
8687 TestApplication application;
8689 KeyFrames keyFrames = KeyFrames::New();
8690 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8692 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8693 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8694 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8695 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8696 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8697 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8699 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8701 DALI_TEST_ASSERTION(
8703 keyFrames.Add(0.7f, 1.0f);
8704 }, "mType == value.GetType()" );
8709 int UtcDaliAnimationKeyFrames06N(void)
8711 TestApplication application;
8713 KeyFrames keyFrames = KeyFrames::New();
8714 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8716 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8717 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8718 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8719 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8720 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8721 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8723 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8725 DALI_TEST_ASSERTION(
8727 keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8728 }, "mType == value.GetType()" );
8733 int UtcDaliAnimationKeyFrames07N(void)
8735 TestApplication application;
8737 KeyFrames keyFrames = KeyFrames::New();
8738 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8740 keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8741 keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8742 keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8743 keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8744 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8745 keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8747 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8749 DALI_TEST_ASSERTION(
8751 keyFrames.Add(0.7f, 1.1f);
8752 }, "mType == value.GetType()" );
8757 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8759 TestApplication application;
8761 float startValue(1.0f);
8762 Actor actor = Actor::New();
8763 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8764 Stage::GetCurrent().Add(actor);
8766 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8767 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8771 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8772 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8773 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8774 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8776 // Build the animation
8777 float durationSeconds(1.0f);
8778 Animation animation = Animation::New(durationSeconds);
8780 KeyFrames keyFrames = KeyFrames::New();
8781 keyFrames.Add(0.0f, 0.1f);
8782 keyFrames.Add(0.2f, 0.5f);
8783 keyFrames.Add(0.4f, 0.0f);
8784 keyFrames.Add(0.6f, 1.0f);
8785 keyFrames.Add(0.8f, 0.7f);
8786 keyFrames.Add(1.0f, 0.9f);
8788 animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8790 // Start the animation
8793 // Final key frame value should be retrievable straight away
8794 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8796 bool signalReceived(false);
8797 AnimationFinishCheck finishCheck(signalReceived);
8798 animation.FinishedSignal().Connect(&application, finishCheck);
8799 application.SendNotification();
8800 application.Render(0);
8801 application.SendNotification();
8802 finishCheck.CheckSignalNotReceived();
8803 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8805 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8806 application.SendNotification();
8807 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8808 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8809 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8810 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8811 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8813 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8814 application.SendNotification();
8815 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8816 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8817 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8818 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8819 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8821 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8822 application.SendNotification();
8823 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8824 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8825 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8826 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8827 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8829 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8830 application.SendNotification();
8831 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8832 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8833 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8834 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8835 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8837 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8838 application.SendNotification();
8839 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8840 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8841 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8842 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8843 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8845 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8846 application.SendNotification();
8847 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8848 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8849 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8850 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8851 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8853 // We did expect the animation to finish
8855 finishCheck.CheckSignalReceived();
8859 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8861 TestApplication application;
8863 float startValue(1.0f);
8864 Actor actor = Actor::New();
8865 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8866 Stage::GetCurrent().Add(actor);
8868 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8869 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8870 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8871 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8872 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8873 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8874 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8875 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8876 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8878 // Build the animation
8879 float durationSeconds(1.0f);
8880 Animation animation = Animation::New(durationSeconds);
8882 KeyFrames keyFrames = KeyFrames::New();
8883 keyFrames.Add(0.0f, 0.1f);
8884 keyFrames.Add(0.2f, 0.5f);
8885 keyFrames.Add(0.4f, 0.0f);
8886 keyFrames.Add(0.6f, 1.0f);
8887 keyFrames.Add(0.8f, 0.7f);
8888 keyFrames.Add(1.0f, 0.9f);
8890 animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8892 // Start the animation
8895 bool signalReceived(false);
8896 AnimationFinishCheck finishCheck(signalReceived);
8897 animation.FinishedSignal().Connect(&application, finishCheck);
8898 application.SendNotification();
8899 application.Render(0);
8900 application.SendNotification();
8901 finishCheck.CheckSignalNotReceived();
8902 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8904 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8905 application.SendNotification();
8906 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8907 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8908 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8909 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8910 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8912 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8913 application.SendNotification();
8914 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8915 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8916 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8917 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8918 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8920 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8921 application.SendNotification();
8922 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8923 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8924 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8925 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8926 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8928 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8929 application.SendNotification();
8930 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8931 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8932 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8933 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8934 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8936 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8937 application.SendNotification();
8938 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8939 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8940 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8941 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8942 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8944 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8945 application.SendNotification();
8946 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8947 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8948 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8949 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
8950 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8952 // We did expect the animation to finish
8954 finishCheck.CheckSignalReceived();
8958 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8960 TestApplication application;
8962 float startValue(1.0f);
8963 Actor actor = Actor::New();
8964 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8965 Stage::GetCurrent().Add(actor);
8967 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8968 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8969 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8970 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8971 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8972 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
8973 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8974 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
8975 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8977 // Build the animation
8978 float durationSeconds(1.0f);
8979 Animation animation = Animation::New(durationSeconds);
8981 KeyFrames keyFrames = KeyFrames::New();
8982 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8983 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8984 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8986 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8988 // Start the animation
8991 bool signalReceived(false);
8992 AnimationFinishCheck finishCheck(signalReceived);
8993 animation.FinishedSignal().Connect(&application, finishCheck);
8994 application.SendNotification();
8995 application.Render(0);
8996 application.SendNotification();
8997 finishCheck.CheckSignalNotReceived();
8998 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
8999 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9000 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9001 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9003 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9004 application.SendNotification();
9005 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION );
9006 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9007 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION );
9008 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9010 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9011 application.SendNotification();
9012 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9013 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9014 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9015 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9017 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9018 application.SendNotification();
9019 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION );
9020 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9021 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION );
9022 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9024 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9025 application.SendNotification();
9026 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9027 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9028 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9029 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9031 // We did expect the animation to finish
9033 finishCheck.CheckSignalReceived();
9037 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9039 TestApplication application;
9041 float startValue(1.0f);
9042 Actor actor = Actor::New();
9043 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9044 Stage::GetCurrent().Add(actor);
9046 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9047 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9048 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9049 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9050 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9051 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9052 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9053 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9054 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9056 // Build the animation
9057 float durationSeconds(1.0f);
9058 Animation animation = Animation::New(durationSeconds);
9060 KeyFrames keyFrames = KeyFrames::New();
9061 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9062 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9063 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9065 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9067 // Start the animation
9070 bool signalReceived(false);
9071 AnimationFinishCheck finishCheck(signalReceived);
9072 animation.FinishedSignal().Connect(&application, finishCheck);
9073 application.SendNotification();
9074 application.Render(0);
9075 application.SendNotification();
9076 finishCheck.CheckSignalNotReceived();
9077 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9078 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9079 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9080 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9082 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9083 application.SendNotification();
9084 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION );
9085 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9086 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION );
9087 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9089 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9090 application.SendNotification();
9091 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9092 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9093 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9094 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9096 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9097 application.SendNotification();
9098 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION );
9099 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9100 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION );
9101 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9103 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9104 application.SendNotification();
9105 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9106 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9107 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9108 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9110 // We did expect the animation to finish
9112 finishCheck.CheckSignalReceived();
9116 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9118 TestApplication application;
9120 Actor actor = Actor::New();
9121 AngleAxis aa(Degree(90), Vector3::XAXIS);
9122 actor.SetOrientation(aa.angle, aa.axis);
9123 Stage::GetCurrent().Add(actor);
9125 application.SendNotification();
9126 application.Render(0);
9128 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9130 // Build the animation
9131 float durationSeconds(1.0f);
9132 Animation animation = Animation::New(durationSeconds);
9134 KeyFrames keyFrames = KeyFrames::New();
9135 keyFrames.Add(0.0f, false);
9136 keyFrames.Add(0.2f, true);
9137 keyFrames.Add(0.4f, true);
9138 keyFrames.Add(0.8f, false);
9139 keyFrames.Add(1.0f, true);
9141 animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9143 // Start the animation
9146 // Final key frame value should be retrievable straight away
9147 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9149 bool signalReceived(false);
9150 AnimationFinishCheck finishCheck(signalReceived);
9151 animation.FinishedSignal().Connect(&application, finishCheck);
9152 application.SendNotification();
9153 application.SendNotification();
9154 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9155 application.SendNotification();
9156 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9157 application.SendNotification();
9159 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9160 finishCheck.CheckSignalReceived();
9164 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9166 TestApplication application;
9168 Actor actor = Actor::New();
9169 AngleAxis aa(Degree(90), Vector3::XAXIS);
9170 actor.SetOrientation(aa.angle, aa.axis);
9171 Stage::GetCurrent().Add(actor);
9173 application.SendNotification();
9174 application.Render(0);
9176 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9178 // Build the animation
9179 float durationSeconds(1.0f);
9180 Animation animation = Animation::New(durationSeconds);
9182 KeyFrames keyFrames = KeyFrames::New();
9183 keyFrames.Add(0.0f, false);
9184 keyFrames.Add(0.2f, true);
9185 keyFrames.Add(0.4f, true);
9186 keyFrames.Add(0.8f, false);
9187 keyFrames.Add(1.0f, true);
9189 //Cubic interpolation for boolean values should be ignored
9190 animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9192 // Start the animation
9195 bool signalReceived(false);
9196 AnimationFinishCheck finishCheck(signalReceived);
9197 animation.FinishedSignal().Connect(&application, finishCheck);
9198 application.SendNotification();
9199 application.SendNotification();
9200 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9201 application.SendNotification();
9202 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9203 application.SendNotification();
9205 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9206 finishCheck.CheckSignalReceived();
9210 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9212 TestApplication application;
9214 Actor actor = Actor::New();
9215 AngleAxis aa(Degree(90), Vector3::XAXIS);
9216 actor.SetOrientation(aa.angle, aa.axis);
9217 Stage::GetCurrent().Add(actor);
9219 application.SendNotification();
9220 application.Render(0);
9221 Quaternion start(Radian(aa.angle), aa.axis);
9222 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9224 // Build the animation
9225 float durationSeconds(1.0f);
9226 Animation animation = Animation::New(durationSeconds);
9228 KeyFrames keyFrames = KeyFrames::New();
9229 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9231 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9233 // Start the animation
9236 // Final key frame value should be retrievable straight away
9237 DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9239 bool signalReceived(false);
9240 AnimationFinishCheck finishCheck(signalReceived);
9241 animation.FinishedSignal().Connect(&application, finishCheck);
9242 application.SendNotification();
9243 application.SendNotification();
9244 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9245 application.SendNotification();
9246 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9247 application.SendNotification();
9249 Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9251 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9252 finishCheck.CheckSignalReceived();
9256 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9258 TestApplication application;
9260 Actor actor = Actor::New();
9261 AngleAxis aa(Degree(90), Vector3::XAXIS);
9262 actor.SetOrientation(aa.angle, aa.axis);
9263 application.SendNotification();
9264 application.Render(0);
9265 Stage::GetCurrent().Add(actor);
9267 Quaternion start(Radian(aa.angle), aa.axis);
9268 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9270 // Build the animation
9271 float durationSeconds(1.0f);
9272 Animation animation = Animation::New(durationSeconds);
9274 KeyFrames keyFrames = KeyFrames::New();
9275 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9276 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9277 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9279 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9281 // Start the animation
9284 bool signalReceived(false);
9285 AnimationFinishCheck finishCheck(signalReceived);
9286 animation.FinishedSignal().Connect(&application, finishCheck);
9287 application.SendNotification();
9288 application.Render(0);
9289 application.SendNotification();
9290 finishCheck.CheckSignalNotReceived();
9292 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9293 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9295 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9296 application.SendNotification();
9297 check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9298 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9300 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9301 application.SendNotification();
9302 check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9303 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9305 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9306 application.SendNotification();
9307 check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9308 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9310 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9311 application.SendNotification();
9312 check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9313 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9315 // We did expect the animation to finish
9317 finishCheck.CheckSignalReceived();
9321 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9323 TestApplication application;
9325 Actor actor = Actor::New();
9326 AngleAxis aa(Degree(90), Vector3::XAXIS);
9327 actor.SetOrientation(aa.angle, aa.axis);
9328 Stage::GetCurrent().Add(actor);
9330 application.SendNotification();
9331 application.Render(0);
9332 Quaternion start(Radian(aa.angle), aa.axis);
9333 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9335 // Build the animation
9336 float durationSeconds(1.0f);
9337 Animation animation = Animation::New(durationSeconds);
9339 KeyFrames keyFrames = KeyFrames::New();
9340 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9342 //Cubic interpolation should be ignored for quaternions
9343 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9345 // Start the animation
9348 bool signalReceived(false);
9349 AnimationFinishCheck finishCheck(signalReceived);
9350 animation.FinishedSignal().Connect(&application, finishCheck);
9351 application.SendNotification();
9352 application.SendNotification();
9353 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9354 application.SendNotification();
9355 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9356 application.SendNotification();
9358 Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9360 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9361 finishCheck.CheckSignalReceived();
9365 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9367 TestApplication application;
9369 Actor actor = Actor::New();
9370 AngleAxis aa(Degree(90), Vector3::XAXIS);
9371 actor.SetOrientation(aa.angle, aa.axis);
9372 application.SendNotification();
9373 application.Render(0);
9374 Stage::GetCurrent().Add(actor);
9376 Quaternion start(Radian(aa.angle), aa.axis);
9377 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9379 // Build the animation
9380 float durationSeconds(1.0f);
9381 Animation animation = Animation::New(durationSeconds);
9383 KeyFrames keyFrames = KeyFrames::New();
9384 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9385 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9386 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9388 //Cubic interpolation should be ignored for quaternions
9389 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9391 // Start the animation
9394 bool signalReceived(false);
9395 AnimationFinishCheck finishCheck(signalReceived);
9396 animation.FinishedSignal().Connect(&application, finishCheck);
9397 application.SendNotification();
9398 application.Render(0);
9399 application.SendNotification();
9400 finishCheck.CheckSignalNotReceived();
9402 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9403 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9405 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9406 application.SendNotification();
9407 check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9408 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9410 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9411 application.SendNotification();
9412 check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9413 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9415 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9416 application.SendNotification();
9417 check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9418 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9420 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9421 application.SendNotification();
9422 check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9423 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9425 // We did expect the animation to finish
9427 finishCheck.CheckSignalReceived();
9431 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9433 TestApplication application;
9435 float startValue(1.0f);
9436 Actor actor = Actor::New();
9437 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9438 Stage::GetCurrent().Add(actor);
9440 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9441 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9442 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9443 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9444 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9445 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9446 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9447 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9448 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9450 // Build the animation
9451 float durationSeconds(1.0f);
9452 Animation animation = Animation::New(durationSeconds);
9454 KeyFrames keyFrames = KeyFrames::New();
9455 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9456 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9457 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9459 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9461 // Start the animation
9464 bool signalReceived(false);
9465 AnimationFinishCheck finishCheck(signalReceived);
9466 animation.FinishedSignal().Connect(&application, finishCheck);
9467 application.SendNotification();
9468 application.Render(0);
9469 application.SendNotification();
9470 finishCheck.CheckSignalNotReceived();
9471 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9472 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9473 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9474 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9476 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9477 application.SendNotification();
9478 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION );
9479 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9480 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION );
9481 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9483 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9484 application.SendNotification();
9485 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9486 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9487 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9488 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9490 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9491 application.SendNotification();
9492 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION );
9493 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9494 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION );
9495 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9497 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9498 application.SendNotification();
9499 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9500 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9501 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9502 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9504 // We did expect the animation to finish
9506 finishCheck.CheckSignalReceived();
9510 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9512 TestApplication application;
9514 float startValue(1.0f);
9515 Actor actor = Actor::New();
9516 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9517 Stage::GetCurrent().Add(actor);
9519 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9520 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9521 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9522 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9523 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9524 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9525 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9526 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9527 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9529 // Build the animation
9530 float durationSeconds(1.0f);
9531 Animation animation = Animation::New(durationSeconds);
9533 KeyFrames keyFrames = KeyFrames::New();
9534 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9535 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9536 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9538 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9540 // Start the animation
9543 bool signalReceived(false);
9544 AnimationFinishCheck finishCheck(signalReceived);
9545 animation.FinishedSignal().Connect(&application, finishCheck);
9546 application.SendNotification();
9547 application.Render(0);
9548 application.SendNotification();
9549 finishCheck.CheckSignalNotReceived();
9550 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9551 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9552 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9553 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9555 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9556 application.SendNotification();
9557 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION );
9558 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9559 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION );
9560 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9562 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9563 application.SendNotification();
9564 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9565 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9566 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9567 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9569 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9570 application.SendNotification();
9571 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION );
9572 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9573 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION );
9574 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9576 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9577 application.SendNotification();
9578 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9579 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9580 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9581 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9583 // We did expect the animation to finish
9585 finishCheck.CheckSignalReceived();
9589 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9591 TestApplication application;
9593 float startValue(1.0f);
9594 Actor actor = Actor::New();
9595 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9596 Stage::GetCurrent().Add(actor);
9598 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9599 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9600 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9601 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9602 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9603 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9604 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9605 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9606 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9608 // Build the animation
9609 float durationSeconds(1.0f);
9611 Animation animation = Animation::New(durationSeconds);
9613 KeyFrames keyFrames = KeyFrames::New();
9614 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9615 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9616 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9618 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9620 // Start the animation
9623 bool signalReceived(false);
9624 AnimationFinishCheck finishCheck(signalReceived);
9625 animation.FinishedSignal().Connect(&application, finishCheck);
9626 application.SendNotification();
9628 application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9629 application.SendNotification();
9630 finishCheck.CheckSignalNotReceived();
9631 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9632 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9633 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9634 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9636 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9637 application.SendNotification();
9638 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION );
9639 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9640 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION );
9641 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9643 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9644 application.SendNotification();
9645 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9646 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9647 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9648 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9650 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9651 application.SendNotification();
9652 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION );
9653 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9654 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION );
9655 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9657 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9658 application.SendNotification();
9659 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9660 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9661 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9662 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9664 // We did expect the animation to finish
9666 finishCheck.CheckSignalReceived();
9670 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9672 TestApplication application;
9674 float startValue(1.0f);
9675 Actor actor = Actor::New();
9676 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9677 Stage::GetCurrent().Add(actor);
9679 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9680 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9681 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9682 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9683 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9684 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9685 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9686 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9687 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9689 // Build the animation
9690 float durationSeconds(1.0f);
9692 Animation animation = Animation::New(durationSeconds);
9694 KeyFrames keyFrames = KeyFrames::New();
9695 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9696 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9697 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9699 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9701 // Start the animation
9704 bool signalReceived(false);
9705 AnimationFinishCheck finishCheck(signalReceived);
9706 animation.FinishedSignal().Connect(&application, finishCheck);
9707 application.SendNotification();
9709 application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9710 application.SendNotification();
9711 finishCheck.CheckSignalNotReceived();
9712 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9713 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9714 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9715 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9717 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9718 application.SendNotification();
9719 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION );
9720 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9721 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION );
9722 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9724 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9725 application.SendNotification();
9726 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9727 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9728 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9729 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9731 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9732 application.SendNotification();
9733 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION );
9734 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9735 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION );
9736 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9738 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9739 application.SendNotification();
9740 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9741 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9742 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9743 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9745 // We did expect the animation to finish
9747 finishCheck.CheckSignalReceived();
9751 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9753 TestApplication application;
9755 float startValue(1.0f);
9757 Actor actor = Actor::New();
9758 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9759 Stage::GetCurrent().Add(actor);
9761 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9762 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9763 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9764 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9766 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9767 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9768 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9769 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9771 // Build the animation
9772 float durationSeconds(1.0f);
9773 Animation animation = Animation::New(durationSeconds);
9775 KeyFrames keyFrames = KeyFrames::New();
9776 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9777 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9778 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9780 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9782 // Start the animation
9785 bool signalReceived(false);
9786 AnimationFinishCheck finishCheck(signalReceived);
9787 animation.FinishedSignal().Connect(&application, finishCheck);
9788 application.SendNotification();
9790 application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9791 application.SendNotification();
9792 finishCheck.CheckSignalNotReceived();
9793 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9794 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9795 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9796 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9798 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9799 application.SendNotification();
9800 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.5f, 0.01f, TEST_LOCATION );
9801 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9802 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.5f, 0.01f, TEST_LOCATION );
9803 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9805 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9806 application.SendNotification();
9807 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9808 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9809 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9810 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9812 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9813 application.SendNotification();
9814 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.95f, 0.01f, TEST_LOCATION );
9815 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9816 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85f, 0.01f, TEST_LOCATION );
9817 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9819 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9820 application.SendNotification();
9821 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9822 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9823 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9824 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9826 // We did expect the animation to finish
9828 finishCheck.CheckSignalReceived();
9832 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9834 TestApplication application;
9836 float startValue(1.0f);
9837 Actor actor = Actor::New();
9838 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9839 Stage::GetCurrent().Add(actor);
9841 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9842 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9843 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9844 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9845 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9846 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), startValue, TEST_LOCATION );
9847 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9848 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), startValue, TEST_LOCATION );
9849 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9852 // Build the animation
9853 float durationSeconds(1.0f);
9855 Animation animation = Animation::New(durationSeconds);
9857 KeyFrames keyFrames = KeyFrames::New();
9858 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9859 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9860 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9862 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9864 // Start the animation
9867 bool signalReceived(false);
9868 AnimationFinishCheck finishCheck(signalReceived);
9869 animation.FinishedSignal().Connect(&application, finishCheck);
9870 application.SendNotification();
9872 application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9873 application.SendNotification();
9874 finishCheck.CheckSignalNotReceived();
9875 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.1f, 0.01f, TEST_LOCATION );
9876 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9877 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.3f, 0.01f, TEST_LOCATION );
9878 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9880 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9881 application.SendNotification();
9882 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.55f, 0.01f, TEST_LOCATION );
9883 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9884 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.506f, 0.01f, TEST_LOCATION );
9885 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9887 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9888 application.SendNotification();
9889 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.9f, 0.01f, TEST_LOCATION );
9890 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9891 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.7f, 0.01f, TEST_LOCATION );
9892 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9894 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9895 application.SendNotification();
9896 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 0.99375f, 0.01f, TEST_LOCATION );
9897 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9898 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 0.85625f, 0.01f, TEST_LOCATION );
9899 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9901 application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9902 application.SendNotification();
9903 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), 1.0f, 0.01f, TEST_LOCATION );
9904 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9905 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), 1.0f, 0.01f, TEST_LOCATION );
9906 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9908 // We did expect the animation to finish
9910 finishCheck.CheckSignalReceived();
9914 int UtcDaliAnimationAnimateP(void)
9916 TestApplication application;
9918 Actor actor = Actor::New();
9919 Stage::GetCurrent().Add(actor);
9922 Vector3 position0( 30.0, 80.0, 0.0);
9923 Vector3 position1( 70.0, 120.0, 0.0);
9924 Vector3 position2( 100.0, 100.0, 0.0);
9926 Dali::Path path = Dali::Path::New();
9927 path.AddPoint(position0);
9928 path.AddPoint(position1);
9929 path.AddPoint(position2);
9931 //Control points for first segment
9932 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
9933 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9935 //Control points for second segment
9936 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9937 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9939 // Build the animation
9940 float durationSeconds( 1.0f );
9941 Animation animation = Animation::New(durationSeconds);
9942 animation.Animate(actor, path, Vector3::XAXIS);
9944 // Start the animation
9947 bool signalReceived(false);
9948 AnimationFinishCheck finishCheck(signalReceived);
9949 animation.FinishedSignal().Connect(&application, finishCheck);
9950 application.SendNotification();
9951 application.Render(0);
9952 application.SendNotification();
9953 finishCheck.CheckSignalNotReceived();
9954 Vector3 position, tangent;
9955 Quaternion rotation;
9956 path.Sample( 0.0f, position, tangent );
9957 rotation = Quaternion( Vector3::XAXIS, tangent );
9958 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9959 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9961 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9962 application.SendNotification();
9963 path.Sample( 0.25f, position, tangent );
9964 rotation = Quaternion( Vector3::XAXIS, tangent );
9965 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9966 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9968 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9969 application.SendNotification();
9970 path.Sample( 0.5f, position, tangent );
9971 rotation = Quaternion( Vector3::XAXIS, tangent );
9972 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9973 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9976 application.SendNotification();
9977 path.Sample( 0.75f, position, tangent );
9978 rotation = Quaternion( Vector3::XAXIS, tangent );
9979 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9980 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9982 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9983 application.SendNotification();
9984 path.Sample( 1.0f, position, tangent );
9985 rotation = Quaternion( Vector3::XAXIS, tangent );
9986 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9987 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9989 finishCheck.CheckSignalReceived();
9993 int UtcDaliAnimationAnimateAlphaFunctionP(void)
9995 TestApplication application;
9997 Actor actor = Actor::New();
9998 Stage::GetCurrent().Add(actor);
10001 Vector3 position0( 30.0, 80.0, 0.0);
10002 Vector3 position1( 70.0, 120.0, 0.0);
10003 Vector3 position2( 100.0, 100.0, 0.0);
10005 Dali::Path path = Dali::Path::New();
10006 path.AddPoint(position0);
10007 path.AddPoint(position1);
10008 path.AddPoint(position2);
10010 //Control points for first segment
10011 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
10012 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10014 //Control points for second segment
10015 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10016 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10018 // Build the animation
10019 float durationSeconds( 1.0f );
10020 Animation animation = Animation::New(durationSeconds);
10021 animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10023 // Start the animation
10026 bool signalReceived(false);
10027 AnimationFinishCheck finishCheck(signalReceived);
10028 animation.FinishedSignal().Connect(&application, finishCheck);
10029 application.SendNotification();
10030 application.Render(0);
10031 application.SendNotification();
10032 finishCheck.CheckSignalNotReceived();
10033 Vector3 position, tangent;
10034 Quaternion rotation;
10035 path.Sample( 0.0f, position, tangent );
10036 rotation = Quaternion( Vector3::XAXIS, tangent );
10037 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10038 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10040 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10041 application.SendNotification();
10042 path.Sample( 0.25f, position, tangent );
10043 rotation = Quaternion( Vector3::XAXIS, tangent );
10044 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10045 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10047 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10048 application.SendNotification();
10049 path.Sample( 0.5f, position, tangent );
10050 rotation = Quaternion( Vector3::XAXIS, tangent );
10051 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10052 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10054 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10055 application.SendNotification();
10056 path.Sample( 0.75f, position, tangent );
10057 rotation = Quaternion( Vector3::XAXIS, tangent );
10058 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10059 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10061 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10062 application.SendNotification();
10063 path.Sample( 1.0f, position, tangent );
10064 rotation = Quaternion( Vector3::XAXIS, tangent );
10065 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10066 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10068 finishCheck.CheckSignalReceived();
10072 int UtcDaliAnimationAnimateTimePeriodP(void)
10074 TestApplication application;
10076 Actor actor = Actor::New();
10077 Stage::GetCurrent().Add(actor);
10080 Vector3 position0( 30.0, 80.0, 0.0);
10081 Vector3 position1( 70.0, 120.0, 0.0);
10082 Vector3 position2( 100.0, 100.0, 0.0);
10084 Dali::Path path = Dali::Path::New();
10085 path.AddPoint(position0);
10086 path.AddPoint(position1);
10087 path.AddPoint(position2);
10089 //Control points for first segment
10090 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
10091 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10093 //Control points for second segment
10094 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10095 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10097 // Build the animation
10098 float durationSeconds( 1.0f );
10099 Animation animation = Animation::New(durationSeconds);
10100 animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10102 // Start the animation
10105 bool signalReceived(false);
10106 AnimationFinishCheck finishCheck(signalReceived);
10107 animation.FinishedSignal().Connect(&application, finishCheck);
10108 application.SendNotification();
10109 application.Render(0);
10110 application.SendNotification();
10111 finishCheck.CheckSignalNotReceived();
10112 Vector3 position, tangent;
10113 Quaternion rotation;
10114 path.Sample( 0.0f, position, tangent );
10115 rotation = Quaternion( Vector3::XAXIS, tangent );
10116 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10117 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10119 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10120 application.SendNotification();
10121 path.Sample( 0.25f, position, tangent );
10122 rotation = Quaternion( Vector3::XAXIS, tangent );
10123 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10124 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10126 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10127 application.SendNotification();
10128 path.Sample( 0.5f, position, tangent );
10129 rotation = Quaternion( Vector3::XAXIS, tangent );
10130 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10131 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10133 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10134 application.SendNotification();
10135 path.Sample( 0.75f, position, tangent );
10136 rotation = Quaternion( Vector3::XAXIS, tangent );
10137 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10138 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10140 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10141 application.SendNotification();
10142 path.Sample( 1.0f, position, tangent );
10143 rotation = Quaternion( Vector3::XAXIS, tangent );
10144 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10145 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10147 finishCheck.CheckSignalReceived();
10151 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10153 TestApplication application;
10155 Actor actor = Actor::New();
10156 Stage::GetCurrent().Add(actor);
10159 Vector3 position0( 30.0, 80.0, 0.0);
10160 Vector3 position1( 70.0, 120.0, 0.0);
10161 Vector3 position2( 100.0, 100.0, 0.0);
10163 Dali::Path path = Dali::Path::New();
10164 path.AddPoint(position0);
10165 path.AddPoint(position1);
10166 path.AddPoint(position2);
10168 //Control points for first segment
10169 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
10170 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10172 //Control points for second segment
10173 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10174 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10176 // Build the animation
10177 float durationSeconds( 1.0f );
10178 Animation animation = Animation::New(durationSeconds);
10179 animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10181 // Start the animation
10184 bool signalReceived(false);
10185 AnimationFinishCheck finishCheck(signalReceived);
10186 animation.FinishedSignal().Connect(&application, finishCheck);
10187 application.SendNotification();
10188 application.Render(0);
10189 application.SendNotification();
10190 finishCheck.CheckSignalNotReceived();
10191 Vector3 position, tangent;
10192 Quaternion rotation;
10193 path.Sample( 0.0f, position, tangent );
10194 rotation = Quaternion( Vector3::XAXIS, tangent );
10195 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10196 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10198 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10199 application.SendNotification();
10200 path.Sample( 0.25f, position, tangent );
10201 rotation = Quaternion( Vector3::XAXIS, tangent );
10202 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10203 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10205 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10206 application.SendNotification();
10207 path.Sample( 0.5f, position, tangent );
10208 rotation = Quaternion( Vector3::XAXIS, tangent );
10209 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10210 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10212 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10213 application.SendNotification();
10214 path.Sample( 0.75f, position, tangent );
10215 rotation = Quaternion( Vector3::XAXIS, tangent );
10216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10217 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10220 application.SendNotification();
10221 path.Sample( 1.0f, position, tangent );
10222 rotation = Quaternion( Vector3::XAXIS, tangent );
10223 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10224 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10226 finishCheck.CheckSignalReceived();
10230 int UtcDaliAnimationShowP(void)
10232 TestApplication application;
10234 Actor actor = Actor::New();
10235 actor.SetVisible(false);
10236 application.SendNotification();
10237 application.Render(0);
10238 DALI_TEST_CHECK( !actor.IsVisible() );
10239 Stage::GetCurrent().Add(actor);
10241 // Start the animation
10242 float durationSeconds(10.0f);
10243 Animation animation = Animation::New(durationSeconds);
10244 animation.Show(actor, durationSeconds*0.5f);
10247 bool signalReceived(false);
10248 AnimationFinishCheck finishCheck(signalReceived);
10249 animation.FinishedSignal().Connect(&application, finishCheck);
10251 application.SendNotification();
10252 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10254 // We didn't expect the animation to finish yet
10255 application.SendNotification();
10256 finishCheck.CheckSignalNotReceived();
10257 DALI_TEST_CHECK( !actor.IsVisible() );
10259 application.SendNotification();
10260 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10262 // We didn't expect the animation to finish yet
10263 application.SendNotification();
10264 finishCheck.CheckSignalNotReceived();
10265 DALI_TEST_CHECK( actor.IsVisible() );
10267 application.SendNotification();
10268 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10270 // We did expect the animation to finish
10271 application.SendNotification();
10272 finishCheck.CheckSignalReceived();
10273 DALI_TEST_CHECK( actor.IsVisible() );
10277 int UtcDaliAnimationHideP(void)
10279 TestApplication application;
10281 Actor actor = Actor::New();
10282 DALI_TEST_CHECK( actor.IsVisible() );
10283 Stage::GetCurrent().Add(actor);
10285 // Start the animation
10286 float durationSeconds(10.0f);
10287 Animation animation = Animation::New(durationSeconds);
10288 animation.Hide(actor, durationSeconds*0.5f);
10291 bool signalReceived(false);
10292 AnimationFinishCheck finishCheck(signalReceived);
10293 animation.FinishedSignal().Connect(&application, finishCheck);
10295 application.SendNotification();
10296 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10298 // We didn't expect the animation to finish yet
10299 application.SendNotification();
10300 finishCheck.CheckSignalNotReceived();
10301 DALI_TEST_CHECK( actor.IsVisible() );
10303 application.SendNotification();
10304 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10306 // We didn't expect the animation to finish yet
10307 application.SendNotification();
10308 finishCheck.CheckSignalNotReceived();
10309 DALI_TEST_CHECK( !actor.IsVisible() );
10311 application.SendNotification();
10312 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10314 // We did expect the animation to finish
10315 application.SendNotification();
10316 finishCheck.CheckSignalReceived();
10317 DALI_TEST_CHECK( !actor.IsVisible() );
10321 int UtcDaliAnimationShowHideAtEndP(void)
10323 // Test that show/hide delay can be the same as animation duration
10324 // i.e. to show/hide at the end of the animation
10326 TestApplication application;
10328 Actor actor = Actor::New();
10329 DALI_TEST_CHECK( actor.IsVisible() );
10330 Stage::GetCurrent().Add(actor);
10332 // Start Hide animation
10333 float durationSeconds(10.0f);
10334 Animation animation = Animation::New(durationSeconds);
10335 animation.Hide(actor, durationSeconds/*Hide at end*/);
10338 bool signalReceived(false);
10339 AnimationFinishCheck finishCheck(signalReceived);
10340 animation.FinishedSignal().Connect(&application, finishCheck);
10342 application.SendNotification();
10343 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10345 // We did expect the animation to finish
10346 application.SendNotification();
10347 finishCheck.CheckSignalReceived();
10348 DALI_TEST_CHECK( !actor.IsVisible() );
10350 // Start Show animation
10351 animation = Animation::New(durationSeconds);
10352 animation.Show(actor, durationSeconds/*Show at end*/);
10353 animation.FinishedSignal().Connect(&application, finishCheck);
10356 application.SendNotification();
10357 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10359 // We did expect the animation to finish
10360 application.SendNotification();
10361 finishCheck.CheckSignalReceived();
10362 DALI_TEST_CHECK( actor.IsVisible() );
10366 int UtcDaliKeyFramesCreateDestroyP(void)
10368 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10370 KeyFrames* keyFrames = new KeyFrames;
10372 DALI_TEST_CHECK( true );
10376 int UtcDaliKeyFramesDownCastP(void)
10378 TestApplication application;
10379 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10381 KeyFrames keyFrames = KeyFrames::New();
10382 BaseHandle object(keyFrames);
10384 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10385 DALI_TEST_CHECK(keyFrames2);
10387 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10388 DALI_TEST_CHECK(keyFrames3);
10390 BaseHandle unInitializedObject;
10391 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10392 DALI_TEST_CHECK(!keyFrames4);
10394 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10395 DALI_TEST_CHECK(!keyFrames5);
10399 int UtcDaliAnimationCreateDestroyP(void)
10401 TestApplication application;
10402 Animation* animation = new Animation;
10403 DALI_TEST_CHECK( animation );
10408 struct UpdateManagerTestConstraint
10410 UpdateManagerTestConstraint(TestApplication& application)
10411 : mApplication(application)
10415 void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10417 mApplication.SendNotification(); // Process events
10420 TestApplication& mApplication;
10423 int UtcDaliAnimationUpdateManagerP(void)
10425 TestApplication application;
10427 Actor actor = Actor::New();
10428 Stage::GetCurrent().Add( actor );
10430 // Build the animation
10431 Animation animation = Animation::New( 0.0f );
10433 bool signalReceived = false;
10434 AnimationFinishCheck finishCheck( signalReceived );
10435 animation.FinishedSignal().Connect( &application, finishCheck );
10437 Vector3 startValue(1.0f, 1.0f, 1.0f);
10438 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
10439 Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10440 constraint.Apply();
10442 // Apply animation to actor
10443 animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10444 animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10448 application.SendNotification();
10449 application.UpdateOnly( 16 );
10451 finishCheck.CheckSignalNotReceived();
10453 application.SendNotification(); // Process events
10455 finishCheck.CheckSignalReceived();
10460 int UtcDaliAnimationSignalOrderP(void)
10462 TestApplication application;
10464 Actor actor = Actor::New();
10465 Stage::GetCurrent().Add( actor );
10467 // Build the animations
10468 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10469 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10471 bool signal1Received = false;
10472 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10474 bool signal2Received = false;
10475 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10477 // Apply animations to actor
10478 animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10480 animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10483 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10484 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10486 application.SendNotification();
10487 application.UpdateOnly( 10 ); // 10ms progress
10489 // no notifications yet
10490 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10491 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10493 application.SendNotification();
10496 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10497 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10498 signal1Received = false;
10500 // 1st animation is complete now, do another update with no ProcessEvents in between
10501 application.UpdateOnly( 20 ); // 20ms progress
10504 application.SendNotification();
10506 // 2nd should complete now
10507 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10508 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10513 int UtcDaliAnimationExtendDurationP(void)
10515 TestApplication application;
10517 Actor actor = Actor::New();
10519 // Register a float property
10520 float startValue(10.0f);
10521 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
10522 Stage::GetCurrent().Add(actor);
10523 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10524 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10526 // Build the animation
10527 float initialDurationSeconds(1.0f);
10528 float animatorDelay = 5.0f;
10529 float animatorDurationSeconds(5.0f);
10530 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10531 Animation animation = Animation::New(initialDurationSeconds);
10532 float targetValue(30.0f);
10533 float relativeValue(targetValue - startValue);
10535 animation.AnimateTo(Property(actor, index),
10537 TimePeriod(animatorDelay, animatorDurationSeconds));
10539 // The duration should have been extended
10540 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10542 // Start the animation
10545 bool signalReceived(false);
10546 AnimationFinishCheck finishCheck(signalReceived);
10547 animation.FinishedSignal().Connect(&application, finishCheck);
10549 application.SendNotification();
10550 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10552 // We didn't expect the animation to finish yet, but cached value should be the final one
10553 application.SendNotification();
10554 finishCheck.CheckSignalNotReceived();
10555 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10556 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10558 application.SendNotification();
10559 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10561 // We didn't expect the animation to finish yet
10562 application.SendNotification();
10563 finishCheck.CheckSignalNotReceived();
10564 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10566 application.SendNotification();
10567 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10569 // We did expect the animation to finish
10570 application.SendNotification();
10571 finishCheck.CheckSignalReceived();
10572 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10573 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10577 int UtcDaliAnimationCustomIntProperty(void)
10579 TestApplication application;
10581 Actor actor = Actor::New();
10582 Stage::GetCurrent().Add(actor);
10583 int startValue(0u);
10585 Property::Index index = actor.RegisterProperty("anIndex", startValue);
10586 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10587 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10589 // Build the animation
10590 float durationSeconds(1.0f);
10591 Animation animation = Animation::New(durationSeconds);
10592 animation.AnimateTo( Property(actor, index), 20 );
10594 // Start the animation
10597 // Target value should be retrievable straight away
10598 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10600 bool signalReceived(false);
10601 AnimationFinishCheck finishCheck(signalReceived);
10602 animation.FinishedSignal().Connect(&application, finishCheck);
10604 application.SendNotification();
10605 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10607 // We didn't expect the animation to finish yet
10608 application.SendNotification();
10609 finishCheck.CheckSignalNotReceived();
10610 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10612 application.SendNotification();
10613 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10615 // We did expect the animation to finish
10616 application.SendNotification();
10617 finishCheck.CheckSignalReceived();
10618 DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10619 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10623 int UtcDaliAnimationDuration(void)
10625 TestApplication application;
10627 Actor actor = Actor::New();
10628 Stage::GetCurrent().Add(actor);
10630 Animation animation = Animation::New( 0.0f );
10631 DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10633 // The animation duration should automatically increase depending on the animator time period
10635 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10636 DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10638 animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10639 DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10644 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10646 TestApplication application;
10648 Actor actor = Actor::New();
10650 // Register an integer property
10652 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
10653 Stage::GetCurrent().Add(actor);
10654 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10656 DALI_TEST_ASSERTION(
10658 // Build the animation
10659 Animation animation = Animation::New( 2.0f );
10660 std::string relativeValue = "relative string";
10661 animation.AnimateBy( Property(actor, index), relativeValue );
10662 tet_result(TET_FAIL);
10663 }, "Target value is not animatable" );
10669 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10671 TestApplication application;
10673 Actor actor = Actor::New();
10675 // Register an integer property
10677 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
10678 Stage::GetCurrent().Add(actor);
10679 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10681 DALI_TEST_ASSERTION(
10683 // Build the animation
10684 Animation animation = Animation::New( 2.0f );
10685 std::string relativeValue = "relative string";
10686 animation.AnimateTo( Property(actor, index), relativeValue );
10687 }, "Target value is not animatable" );
10692 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10694 TestApplication application;
10696 Actor actor = Actor::New();
10698 // Register an integer property
10700 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
10701 Stage::GetCurrent().Add(actor);
10702 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10704 DALI_TEST_ASSERTION(
10706 // Build the animation
10707 KeyFrames keyFrames = KeyFrames::New();
10708 keyFrames.Add( 0.0f, std::string("relative string1") );
10709 keyFrames.Add( 1.0f, std::string("relative string2") );
10710 // no need to really create the animation as keyframes do the check
10711 }, "Property type is not animatable" );
10716 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10718 tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10720 TestApplication application;
10722 tet_infoline("Set initial position and set up animation to re-position actor");
10724 Actor actor = Actor::New();
10725 Stage::GetCurrent().Add(actor);
10726 Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10727 actor.SetProperty( Actor::Property::POSITION, initialPosition );
10729 // Build the animation
10730 Animation animation = Animation::New(2.0f);
10732 //Test GetCurrentProgress return 0.0 as the duration is 0.0
10733 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10734 DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10736 tet_infoline("Set target position in animation without intiating play");
10738 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10739 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10741 application.SendNotification();
10742 application.Render();
10744 tet_infoline("Ensure position of actor is still at intial value");
10746 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10747 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10748 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10750 tet_infoline("Play animation and ensure actor position is now target");
10753 application.SendNotification();
10754 application.Render(1000u);
10756 tet_infoline("Ensure position of actor is at target value when aninmation half way");
10758 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10759 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10760 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10762 tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10764 application.Render(2000u);
10766 tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10775 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10777 tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10779 TestApplication application;
10781 std::vector<Vector3> targetPositions;
10783 targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10784 targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10785 targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10787 tet_infoline("Set initial position and set up animation to re-position actor");
10789 Actor actor = Actor::New();
10790 Stage::GetCurrent().Add(actor);
10791 Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10792 actor.SetProperty( Actor::Property::POSITION, initialPosition );
10794 // Build the animation
10795 Animation animation = Animation::New(2.0f);
10797 //Test GetCurrentProgress return 0.0 as the duration is 0.0
10798 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10799 DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10801 tet_infoline("Set target position in animation without intiating play");
10803 for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10805 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10808 application.SendNotification();
10809 application.Render();
10811 tet_infoline("Ensure position of actor is still at intial value");
10813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10814 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10815 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10817 tet_infoline("Play animation and ensure actor position is now target");
10820 application.SendNotification();
10821 application.Render(1000u);
10823 tet_infoline("Ensure position of actor is at target value when aninmation half way");
10825 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10826 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10827 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10829 tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10831 application.Render(2000u);
10833 tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10835 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10836 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10837 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10842 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10844 tet_infoline("Setting up an animation should not effect it's size property until the animation plays even with mulitple animators of different Property Indexes");
10846 TestApplication application;
10848 std::vector<Vector3> targetSizes;
10849 std::vector<Vector3> targetPositions;
10851 targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10852 targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10854 targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10856 tet_infoline("Set initial position and set up animation to re-position actor");
10858 Actor actor = Actor::New();
10859 Stage::GetCurrent().Add(actor);
10860 Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10861 Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10863 actor.SetProperty( Actor::Property::SIZE, initialSize );
10864 actor.SetProperty( Actor::Property::POSITION, initialPosition );
10866 // Build the animation
10867 Animation animation = Animation::New(2.0f);
10869 tet_infoline("Set target size in animation without intiating play");
10870 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10871 tet_infoline("Set target position in animation without intiating play");
10872 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10873 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10875 application.SendNotification();
10876 application.Render();
10878 tet_infoline("Ensure position of actor is still at intial size and position");
10880 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10881 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10882 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10884 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10885 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10886 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10888 tet_infoline("Play animation and ensure actor position and size is now matches targets");
10891 application.SendNotification();
10892 application.Render(2000u);
10894 tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10896 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10897 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10898 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10900 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10901 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10902 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10907 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10909 tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10911 TestApplication application;
10913 std::vector<Vector3> targetSizes;
10914 std::vector<float> targetColors;
10916 targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10917 targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10919 targetColors.push_back( 1.0f );
10921 tet_infoline("Set initial position and set up animation to re-position actor");
10923 Actor actor = Actor::New();
10924 Stage::GetCurrent().Add(actor);
10925 Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10927 actor.SetProperty( Actor::Property::SIZE, initialSize );
10929 // Build the animation
10930 Animation animation = Animation::New(2.0f);
10932 tet_infoline("Set target size in animation without initiating play");
10933 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10934 tet_infoline("Set target position in animation without intiating play");
10935 animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
10936 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10938 application.SendNotification();
10939 application.Render();
10941 tet_infoline("Ensure position of actor is still at initial size and position");
10943 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10944 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10945 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10947 tet_infoline("Play animation and ensure actor position and size is now matches targets");
10950 application.SendNotification();
10951 application.Render(2000u);
10953 tet_infoline("Ensure position and size of actor is at target value when animation playing");
10955 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10956 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10957 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10959 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
10964 int UtcDaliAnimationTimePeriodOrder(void)
10966 tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
10968 TestApplication application;
10970 Actor actor = Actor::New();
10971 Stage::GetCurrent().Add( actor );
10973 application.SendNotification();
10974 application.Render();
10976 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10977 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10978 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10979 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10980 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10982 //////////////////////////////////////////////////////////////////////////////////
10984 tet_infoline( "With two AnimateTo calls" );
10986 Animation animation = Animation::New( 0.0f );
10987 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
10988 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
10991 tet_infoline( "The target position should change instantly" );
10992 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10993 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10995 application.SendNotification();
10996 application.Render(5000); // After the animation is complete
10998 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10999 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11000 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11002 //////////////////////////////////////////////////////////////////////////////////
11004 tet_infoline( "Same animation again but in a different order - should yield the same result" );
11006 actor.SetX( 0.0f );
11007 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11008 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11010 application.SendNotification();
11011 application.Render();
11013 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11014 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11015 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11017 animation = Animation::New( 0.0f );
11018 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11019 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11022 tet_infoline( "The target position should change instantly" );
11023 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11024 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11026 application.SendNotification();
11027 application.Render(5000); // After the animation is complete
11029 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11030 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11031 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11036 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11038 tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place with several AnimateTo calls" );
11040 TestApplication application;
11042 Actor actor = Actor::New();
11043 Stage::GetCurrent().Add( actor );
11045 application.SendNotification();
11046 application.Render();
11048 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11049 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11050 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11051 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11052 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11054 //////////////////////////////////////////////////////////////////////////////////
11056 tet_infoline( "" );
11058 Animation animation = Animation::New( 0.0f );
11059 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11060 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11061 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11062 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11063 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11064 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11067 tet_infoline( "The target position should change instantly" );
11068 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11069 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11071 application.SendNotification();
11072 application.Render(14000); // After the animation is complete
11074 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11075 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11076 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11078 //////////////////////////////////////////////////////////////////////////////////
11080 tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11082 actor.SetX( 0.0f );
11084 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11085 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11087 application.SendNotification();
11088 application.Render();
11090 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11091 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11092 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11094 animation = Animation::New( 0.0f );
11095 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11096 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11097 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11098 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11099 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11100 animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11103 tet_infoline( "The target position should change instantly" );
11104 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11105 DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11107 application.SendNotification();
11108 application.Render(14000); // After the animation is complete
11110 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11111 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11112 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11117 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11119 TestApplication application;
11122 Actor actor = Actor::New();
11123 const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11124 Stage::GetCurrent().Add(actor);
11126 application.Render();
11127 application.SendNotification();
11129 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11131 // Build the animation
11132 float durationSeconds(1.0f);
11133 Animation animation = Animation::New(durationSeconds);
11135 KeyFrames keyFrames = KeyFrames::New();
11136 keyFrames.Add(0.0f, 10);
11137 keyFrames.Add(0.2f, 20);
11138 keyFrames.Add(0.4f, 30);
11139 keyFrames.Add(0.6f, 40);
11140 keyFrames.Add(0.8f, 50);
11141 keyFrames.Add(1.0f, 60);
11143 animation.AnimateBetween( Property(actor, index ), keyFrames );
11145 // Start the animation
11148 // Target value should change to the last key-frame's value straight away
11149 DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11154 int UtcDaliAnimationAnimateBetweenVector2P(void)
11156 TestApplication application;
11158 Vector2 startValue( 10.0f, 20.0f );
11159 Actor actor = Actor::New();
11160 const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11161 Stage::GetCurrent().Add(actor);
11163 application.Render();
11164 application.SendNotification();
11166 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11168 // Build the animation
11169 float durationSeconds(1.0f);
11170 Animation animation = Animation::New(durationSeconds);
11172 KeyFrames keyFrames = KeyFrames::New();
11173 keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11174 keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11175 keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11176 keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11177 keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11178 keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11180 animation.AnimateBetween( Property(actor, index ), keyFrames );
11182 // Start the animation
11185 // Target value should change to the last key-frame's value straight away
11186 DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11191 int UtcDaliAnimationProgressCallbackP(void)
11193 TestApplication application;
11195 Actor actor = Actor::New();
11196 Stage::GetCurrent().Add(actor);
11198 // Build the animation
11199 Animation animation = Animation::New(0.0f);
11202 float durationSeconds(1.0f);
11203 animation.SetDuration(durationSeconds);
11205 bool finishedSignalReceived(false);
11206 bool progressSignalReceived(false);
11208 AnimationFinishCheck finishCheck(finishedSignalReceived);
11209 animation.FinishedSignal().Connect(&application, finishCheck);
11211 AnimationProgressCheck progressCheck(progressSignalReceived);
11212 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
11213 application.SendNotification();
11215 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11216 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
11218 tet_infoline( "Animation Progress notification set to 30%" );
11219 DevelAnimation::SetProgressNotification( animation, 0.3f );
11221 application.SendNotification();
11222 application.Render( );
11224 DALI_TEST_EQUALS( 0.3f, DevelAnimation::GetProgressNotification( animation ), TEST_LOCATION );
11226 progressCheck.CheckSignalNotReceived();
11228 // Start the animation from 10% progress
11229 animation.SetCurrentProgress( 0.1f );
11232 tet_infoline( "Animation Playing from 10%" );
11234 application.SendNotification();
11235 application.Render(0); // start animation
11236 application.Render(durationSeconds*100.0f ); // 20% progress
11238 tet_infoline( "Animation at 20%" );
11240 progressCheck.CheckSignalNotReceived();
11242 application.SendNotification();
11243 application.Render(durationSeconds*200.0f ); // 40% progress
11244 application.SendNotification();
11245 tet_infoline( "Animation at 40%" );
11246 DALI_TEST_EQUALS( 0.4f, animation.GetCurrentProgress(), TEST_LOCATION );
11248 progressCheck.CheckSignalReceived();
11250 tet_infoline( "Progress check reset" );
11251 progressCheck.Reset();
11253 application.Render(durationSeconds*100.0f ); // 50% progress
11254 tet_infoline( "Animation at 50%" );
11255 application.SendNotification();
11257 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
11259 progressCheck.CheckSignalNotReceived();
11261 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
11262 application.SendNotification();
11264 tet_infoline( "Animation at 60%" );
11266 finishCheck.CheckSignalNotReceived();
11268 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
11269 application.SendNotification();
11270 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
11271 tet_infoline( "Animation at 80%" );
11273 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
11274 // We did expect the animation to finish
11275 application.SendNotification();
11276 finishCheck.CheckSignalReceived();
11277 tet_infoline( "Animation finished" );
11278 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11283 int UtcDaliAnimationPlayAfterP(void)
11285 TestApplication application;
11287 tet_printf("Testing that playing after 2 seconds\n");
11290 Actor actor = Actor::New();
11291 Stage::GetCurrent().Add(actor);
11293 // Build the animation
11294 float durationSeconds(1.0f);
11295 Animation animation = Animation::New(durationSeconds);
11297 bool signalReceived( false );
11298 AnimationFinishCheck finishCheck( signalReceived );
11299 animation.FinishedSignal().Connect( &application, finishCheck );
11300 application.SendNotification();
11302 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11303 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11305 // Play animation after the initial delay time
11306 animation.PlayAfter( 0.2f );
11307 application.SendNotification();
11308 application.Render(0); // start animation
11310 application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11311 application.SendNotification();
11312 finishCheck.CheckSignalNotReceived();
11313 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11315 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11317 // We didn't expect the animation to finish yet
11318 application.SendNotification();
11319 finishCheck.CheckSignalNotReceived();
11320 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11322 application.SendNotification();
11323 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11325 application.SendNotification();
11326 finishCheck.CheckSignalNotReceived();
11327 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11329 application.SendNotification();
11330 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11332 // We did expect the animation to finish
11333 application.SendNotification();
11334 finishCheck.CheckSignalReceived();
11335 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11337 // Check that nothing has changed after a couple of buffer swaps
11338 application.Render(0);
11339 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11342 tet_printf("Testing that playing after 2 seconds with negative speedfactor\n");
11345 Actor actor = Actor::New();
11346 Stage::GetCurrent().Add(actor);
11348 // Build the animation
11349 float durationSeconds(1.0f);
11350 Animation animation = Animation::New(durationSeconds);
11351 animation.SetSpeedFactor( -1.0f ); // Set SpeedFactor as < 0
11353 bool signalReceived( false );
11354 AnimationFinishCheck finishCheck( signalReceived );
11355 animation.FinishedSignal().Connect( &application, finishCheck );
11356 application.SendNotification();
11358 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11359 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11361 // Play animation after the initial delay time
11362 animation.PlayAfter( 0.2f );
11363 application.SendNotification();
11364 application.Render(0); // start animation
11366 application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11367 application.SendNotification();
11368 finishCheck.CheckSignalNotReceived();
11369 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11371 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11373 // We didn't expect the animation to finish yet
11374 application.SendNotification();
11375 finishCheck.CheckSignalNotReceived();
11376 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11378 application.SendNotification();
11379 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11381 application.SendNotification();
11382 finishCheck.CheckSignalNotReceived();
11383 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11385 application.SendNotification();
11386 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) + 1u/*just beyond the animation duration*/ );
11388 // We did expect the animation to finish
11389 application.SendNotification();
11390 finishCheck.CheckSignalReceived();
11391 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of Timeperiod in seconds
11393 // Check that nothing has changed after a couple of buffer swaps
11394 application.Render(0);
11395 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11401 int UtcDaliAnimationPlayAfterP2(void)
11403 TestApplication application;
11405 tet_printf("Testing that playing after 2 seconds before looping\n");
11408 Actor actor = Actor::New();
11409 Stage::GetCurrent().Add(actor);
11411 // Build the animation
11412 float durationSeconds(1.0f);
11413 Animation animation = Animation::New(durationSeconds);
11414 animation.SetLooping( true );
11416 bool signalReceived( false );
11417 AnimationFinishCheck finishCheck( signalReceived );
11418 animation.FinishedSignal().Connect( &application, finishCheck );
11419 application.SendNotification();
11421 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11422 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11424 // Play animation after the initial delay time
11425 animation.PlayAfter( 0.2f );
11426 application.SendNotification();
11427 application.Render(0); // start animation
11429 for( int iterations = 0; iterations < 3; ++iterations )
11431 // The initial delay time of PlayAfter() applies only once in looping mode.
11432 if( iterations == 0 )
11434 application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11435 application.SendNotification();
11436 finishCheck.CheckSignalNotReceived();
11437 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11440 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11442 // We didn't expect the animation to finish yet
11443 application.SendNotification();
11444 finishCheck.CheckSignalNotReceived();
11445 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11447 application.SendNotification();
11448 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11450 application.SendNotification();
11451 finishCheck.CheckSignalNotReceived();
11452 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11454 application.SendNotification();
11455 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) /* 100% progress */ );
11457 // We did expect the animation to finish
11458 application.SendNotification();
11459 finishCheck.CheckSignalNotReceived();
11460 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11463 animation.SetLooping(false);
11464 application.SendNotification();
11465 application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11467 application.SendNotification();
11468 finishCheck.CheckSignalReceived();
11469 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11472 tet_printf("Testing that playing after 2 seconds before looping with negative speedfactor\n");
11475 Actor actor = Actor::New();
11476 Stage::GetCurrent().Add(actor);
11478 // Build the animation
11479 float durationSeconds(1.0f);
11480 Animation animation = Animation::New(durationSeconds);
11481 animation.SetLooping( true );
11482 animation.SetSpeedFactor( -1.0f ); //Set SpeedFactor as < 0
11484 bool signalReceived( false );
11485 AnimationFinishCheck finishCheck( signalReceived );
11486 animation.FinishedSignal().Connect( &application, finishCheck );
11487 application.SendNotification();
11489 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11490 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11492 // Play animation after the initial delay time
11493 animation.PlayAfter( 0.2f );
11494 application.SendNotification();
11495 application.Render(0); // start animation
11497 for( int iterations = 0; iterations < 3; ++iterations )
11499 // The initial delay time of PlayAfter() applies only once in looping mode.
11500 if( iterations == 0 )
11502 application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11503 application.SendNotification();
11504 finishCheck.CheckSignalNotReceived();
11505 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11508 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11510 // We didn't expect the animation to finish yet
11511 application.SendNotification();
11512 finishCheck.CheckSignalNotReceived();
11513 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11515 application.SendNotification();
11516 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11518 application.SendNotification();
11519 finishCheck.CheckSignalNotReceived();
11520 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11522 application.SendNotification();
11523 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) /* 100% progress */ );
11525 // We did expect the animation to finish
11526 application.SendNotification();
11527 finishCheck.CheckSignalNotReceived();
11528 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in second
11531 animation.SetLooping(false);
11532 application.SendNotification();
11533 application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11535 application.SendNotification();
11536 finishCheck.CheckSignalReceived();
11537 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11543 int UtcDaliAnimationPlayAfterP3(void)
11545 TestApplication application;
11547 tet_printf("Testing that PlayAfter with the negative delay seconds\n");
11549 Actor actor = Actor::New();
11550 Stage::GetCurrent().Add(actor);
11552 // Build the animation
11553 float durationSeconds(1.0f);
11554 Animation animation = Animation::New(durationSeconds);
11556 bool signalReceived( false );
11557 AnimationFinishCheck finishCheck( signalReceived );
11558 animation.FinishedSignal().Connect( &application, finishCheck );
11559 application.SendNotification();
11561 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11562 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11564 // When the delay time is negative value, it would treat as play immediately.
11565 animation.PlayAfter( -2.0f );
11566 application.SendNotification();
11567 application.Render(0); // start animation
11569 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11571 // We didn't expect the animation to finish yet
11572 application.SendNotification();
11573 finishCheck.CheckSignalNotReceived();
11574 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11576 application.SendNotification();
11577 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11579 application.SendNotification();
11580 finishCheck.CheckSignalNotReceived();
11581 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11583 application.SendNotification();
11584 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11586 // We did expect the animation to finish
11587 application.SendNotification();
11588 finishCheck.CheckSignalReceived();
11589 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11591 // Check that nothing has changed after a couple of buffer swaps
11592 application.Render(0);
11593 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11597 int UtcDaliAnimationPlayAfterP4(void)
11599 TestApplication application;
11601 tet_printf("Testing that PlayAfter with progress value\n");
11603 Actor actor = Actor::New();
11604 Stage::GetCurrent().Add(actor);
11606 // Build the animation
11607 float durationSeconds(1.0f);
11608 Animation animation = Animation::New(durationSeconds);
11610 bool signalReceived( false );
11611 AnimationFinishCheck finishCheck( signalReceived );
11612 animation.FinishedSignal().Connect( &application, finishCheck );
11613 application.SendNotification();
11615 Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11616 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11618 // Delay time is 0.3s. So after duration times, progress must be 70%. animation will finished at 1.3s.
11619 animation.PlayAfter( durationSeconds * 0.3f );
11620 application.SendNotification();
11621 application.Render(0); // start animation
11623 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 5/6 delay progress, 0% animation progress, 0% animator progress */ );
11625 // We didn't expect the animation to finish yet
11626 application.SendNotification();
11627 finishCheck.CheckSignalNotReceived();
11628 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of PlayAfter
11630 application.SendNotification();
11631 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 20% animation progress, 0% animator progress */ );
11633 application.SendNotification();
11634 finishCheck.CheckSignalNotReceived();
11635 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11637 application.SendNotification();
11638 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 45% animation progress, 0% animator progress */ );
11640 application.SendNotification();
11641 finishCheck.CheckSignalNotReceived();
11642 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11644 application.SendNotification();
11645 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 70% animation progress, 40% animator progress */ );
11647 application.SendNotification();
11648 finishCheck.CheckSignalNotReceived();
11649 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.4f ), TEST_LOCATION ); // 40% of animator progress
11651 application.SendNotification();
11652 application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 95% animation progress, 90% animator progress */ );
11654 application.SendNotification();
11655 finishCheck.CheckSignalNotReceived();
11656 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION ); // 90% of animator progress
11658 application.SendNotification();
11659 application.Render( static_cast< unsigned int >( durationSeconds * 50.0f ) + 1u/*just beyond the animation duration*/ );
11661 // We did expect the animation to finish
11662 application.SendNotification();
11663 finishCheck.CheckSignalReceived();
11664 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11666 // Check that nothing has changed after a couple of buffer swaps
11667 application.Render(0);
11668 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11672 int UtcDaliAnimationSetLoopingModeP(void)
11674 // Test Loop forever and Loop mode being set
11675 TestApplication application;
11676 Stage stage( Stage::GetCurrent() );
11678 // Default: LoopingMode::RESTART
11680 Actor actor = Actor::New();
11681 stage.Add( actor );
11683 float durationSeconds( 1.0f );
11684 Animation animation = Animation::New( durationSeconds );
11685 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
11687 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
11688 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11690 // Start the animation
11692 application.SendNotification();
11693 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
11697 application.SendNotification();
11698 application.Render();
11699 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11702 // LoopingMode::AUTO_REVERSE
11704 Actor actor = Actor::New();
11705 stage.Add( actor );
11707 float durationSeconds( 1.0f );
11708 Animation animation = Animation::New( durationSeconds );
11709 animation.SetLooping( true );
11711 bool signalReceived( false );
11712 AnimationFinishCheck finishCheck( signalReceived );
11713 animation.FinishedSignal().Connect( &application, finishCheck );
11714 application.SendNotification();
11716 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11717 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11719 animation.SetLoopingMode( Animation::LoopingMode::AUTO_REVERSE );
11720 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11722 // Start the animation
11724 application.SendNotification();
11725 application.Render(0);
11727 for( int iterations = 0; iterations < 3; ++iterations )
11729 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11730 application.SendNotification();
11731 finishCheck.CheckSignalNotReceived();
11733 // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11734 // and arrives at the beginning.
11735 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11737 application.SendNotification();
11738 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11740 // We did expect the animation to finish
11741 application.SendNotification();
11742 finishCheck.CheckSignalNotReceived();
11743 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11746 animation.SetLooping( false );
11747 application.SendNotification();
11748 application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11750 application.SendNotification();
11751 finishCheck.CheckSignalReceived();
11753 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11756 // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11758 Actor actor = Actor::New();
11759 stage.Add( actor );
11761 float durationSeconds( 1.0f );
11762 Animation animation = Animation::New( durationSeconds );
11763 animation.SetLooping( true );
11765 bool signalReceived( false );
11766 AnimationFinishCheck finishCheck( signalReceived );
11767 animation.FinishedSignal().Connect( &application, finishCheck );
11768 application.SendNotification();
11770 // Specify a negative multiplier to play the animation in reverse
11771 animation.SetSpeedFactor( -1.0f );
11773 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11774 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11776 animation.SetLoopingMode( Animation::AUTO_REVERSE );
11777 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11779 // Start the animation
11781 application.SendNotification();
11782 application.Render(0);
11784 for( int iterations = 0; iterations < 3; ++iterations )
11786 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11787 application.SendNotification();
11788 finishCheck.CheckSignalNotReceived();
11790 // Setting a negative speed factor is to play the animation in reverse.
11791 // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11792 // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11793 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11795 application.SendNotification();
11796 application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11798 // We did expect the animation to finish
11799 application.SendNotification();
11800 finishCheck.CheckSignalNotReceived();
11801 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11804 animation.SetLooping( false );
11805 application.SendNotification();
11806 application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11808 application.SendNotification();
11809 finishCheck.CheckSignalReceived();
11811 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11817 int UtcDaliAnimationSetLoopingModeP2(void)
11819 // Test Loop Count and Loop mode being set
11820 TestApplication application;
11821 Stage stage( Stage::GetCurrent() );
11823 // LoopingMode::AUTO_REVERSE
11825 Actor actor = Actor::New();
11826 stage.Add( actor );
11828 float durationSeconds( 1.0f );
11829 Animation animation = Animation::New( durationSeconds );
11830 animation.SetLoopCount(3);
11831 DALI_TEST_CHECK(animation.IsLooping());
11833 bool signalReceived( false );
11834 AnimationFinishCheck finishCheck( signalReceived );
11835 animation.FinishedSignal().Connect( &application, finishCheck );
11836 application.SendNotification();
11838 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11839 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11841 animation.SetLoopingMode( Animation::AUTO_REVERSE );
11842 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11844 // Start the animation
11847 application.Render(0);
11848 application.SendNotification();
11849 application.Render(0);
11850 application.SendNotification();
11851 application.Render(0);
11852 application.SendNotification();
11853 application.Render(0);
11854 application.SendNotification();
11857 float intervalSeconds = 3.0f;
11859 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11860 // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11861 // and arrives at the beginning.
11862 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11864 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11866 application.Render(0);
11867 application.SendNotification();
11868 application.Render(0);
11869 application.SendNotification();
11870 application.Render(0);
11871 application.SendNotification();
11872 application.Render(0);
11873 application.SendNotification();
11874 finishCheck.CheckSignalNotReceived();
11876 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11878 application.SendNotification();
11879 finishCheck.CheckSignalReceived();
11880 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11882 finishCheck.Reset();
11885 // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11887 Actor actor = Actor::New();
11888 stage.Add( actor );
11890 float durationSeconds( 1.0f );
11891 Animation animation = Animation::New( durationSeconds );
11892 animation.SetLoopCount(3);
11893 DALI_TEST_CHECK(animation.IsLooping());
11895 bool signalReceived( false );
11896 AnimationFinishCheck finishCheck( signalReceived );
11897 animation.FinishedSignal().Connect( &application, finishCheck );
11898 application.SendNotification();
11900 // Specify a negative multiplier to play the animation in reverse
11901 animation.SetSpeedFactor( -1.0f );
11903 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11904 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11906 animation.SetLoopingMode( Animation::AUTO_REVERSE );
11907 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11909 // Start the animation
11912 application.Render(0);
11913 application.SendNotification();
11914 application.Render(0);
11915 application.SendNotification();
11916 application.Render(0);
11917 application.SendNotification();
11918 application.Render(0);
11919 application.SendNotification();
11922 float intervalSeconds = 3.0f;
11924 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11925 // Setting a negative speed factor is to play the animation in reverse.
11926 // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11927 // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11928 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11930 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11932 application.Render(0);
11933 application.SendNotification();
11934 application.Render(0);
11935 application.SendNotification();
11936 application.Render(0);
11937 application.SendNotification();
11938 application.Render(0);
11939 application.SendNotification();
11940 finishCheck.CheckSignalNotReceived();
11942 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11944 application.SendNotification();
11945 finishCheck.CheckSignalReceived();
11946 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11948 finishCheck.Reset();
11954 int UtcDaliAnimationSetLoopingModeP3(void)
11956 // Test Loop Count is 1 (== default) and Loop mode being set
11957 TestApplication application;
11958 Stage stage( Stage::GetCurrent() );
11960 // LoopingMode::AUTO_REVERSE
11962 Actor actor = Actor::New();
11963 stage.Add( actor );
11965 float durationSeconds( 1.0f );
11966 Animation animation = Animation::New( durationSeconds );
11967 DALI_TEST_CHECK(1 == animation.GetLoopCount());
11969 bool signalReceived( false );
11970 AnimationFinishCheck finishCheck( signalReceived );
11971 animation.FinishedSignal().Connect( &application, finishCheck );
11972 application.SendNotification();
11974 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11975 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11977 animation.SetLoopingMode( Animation::AUTO_REVERSE );
11978 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11980 // Start the animation
11982 application.Render(0);
11983 application.SendNotification();
11985 application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
11986 application.SendNotification();
11987 finishCheck.CheckSignalNotReceived();
11989 // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11990 // and arrives at the beginning.
11991 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11993 application.SendNotification();
11994 application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
11996 application.SendNotification();
11997 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11999 application.SendNotification();
12000 application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12002 application.SendNotification();
12003 application.Render(0);
12004 application.SendNotification();
12005 finishCheck.CheckSignalReceived();
12007 // After all animation finished, arrives at the beginning.
12008 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12010 finishCheck.Reset();
12013 // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
12015 Actor actor = Actor::New();
12016 stage.Add( actor );
12018 float durationSeconds( 1.0f );
12019 Animation animation = Animation::New( durationSeconds );
12020 DALI_TEST_CHECK(1 == animation.GetLoopCount());
12022 bool signalReceived( false );
12023 AnimationFinishCheck finishCheck( signalReceived );
12024 animation.FinishedSignal().Connect( &application, finishCheck );
12025 application.SendNotification();
12027 // Specify a negative multiplier to play the animation in reverse
12028 animation.SetSpeedFactor( -1.0f );
12030 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12031 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12033 animation.SetLoopingMode( Animation::AUTO_REVERSE );
12034 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12036 // Start the animation
12038 application.Render(0);
12039 application.SendNotification();
12041 application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12042 application.SendNotification();
12043 finishCheck.CheckSignalNotReceived();
12045 // Setting a negative speed factor is to play the animation in reverse.
12046 // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12047 // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12048 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12050 application.SendNotification();
12051 application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12053 application.SendNotification();
12054 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12056 application.SendNotification();
12057 application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12059 application.SendNotification();
12060 application.Render(0);
12061 application.SendNotification();
12062 finishCheck.CheckSignalReceived();
12064 // After all animation finished, arrives at the target.
12065 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12067 finishCheck.Reset();
12073 int UtcDaliAnimationGetLoopingModeP(void)
12075 TestApplication application;
12077 Animation animation = Animation::New(1.0f);
12080 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
12082 animation.SetLoopingMode( Animation::AUTO_REVERSE );
12083 DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12088 int UtcDaliAnimationProgressSignalConnectionWithoutProgressMarkerP(void)
12090 TestApplication application;
12092 tet_infoline( "Connect to ProgressReachedSignal but do not set a required Progress marker" );
12094 Actor actor = Actor::New();
12095 Stage::GetCurrent().Add(actor);
12097 // Build the animation
12098 Animation animation = Animation::New(0.0f);
12101 float durationSeconds(1.0f);
12102 animation.SetDuration(durationSeconds);
12104 bool finishedSignalReceived(false);
12105 bool progressSignalReceived(false);
12107 AnimationFinishCheck finishCheck(finishedSignalReceived);
12108 animation.FinishedSignal().Connect(&application, finishCheck);
12110 AnimationProgressCheck progressCheck( progressSignalReceived );
12111 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12112 application.SendNotification();
12114 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12115 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12117 progressCheck.CheckSignalNotReceived();
12121 application.SendNotification();
12122 application.Render(0); // start animation
12123 application.Render(durationSeconds*100.0f ); // 10% progress
12124 application.SendNotification();
12126 tet_infoline( "Ensure after animation has started playing that ProgressReachedSignal not emitted" );
12127 progressCheck.CheckSignalNotReceived();
12129 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
12131 application.SendNotification();
12132 finishCheck.CheckSignalReceived();
12133 tet_infoline( "Animation finished" );
12134 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12139 int UtcDaliAnimationMultipleProgressSignalsP(void)
12141 tet_infoline( "Multiple animations with different progress markers" );
12143 TestApplication application;
12145 Actor actor = Actor::New();
12146 Stage::GetCurrent().Add(actor);
12148 // Build the animation
12149 Animation animationAlpha = Animation::New(0.0f);
12150 Animation animationBeta = Animation::New(0.0f);
12153 float durationSeconds(1.0f);
12154 animationAlpha.SetDuration(durationSeconds);
12155 animationBeta.SetDuration(durationSeconds);
12157 bool progressSignalReceivedAlpha(false);
12158 bool progressSignalReceivedBeta(false);
12160 AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12161 AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12163 DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12164 DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12165 application.SendNotification();
12167 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12168 animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12169 animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12171 tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12172 DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12174 tet_infoline( "AnimationBeta Progress notification set to 50%" );
12175 DevelAnimation::SetProgressNotification( animationBeta, 0.5f );
12177 application.SendNotification();
12178 application.Render( );
12180 progressCheckAlpha.CheckSignalNotReceived();
12181 progressCheckBeta.CheckSignalNotReceived();
12183 // Start the animations from 10% progress
12184 animationAlpha.SetCurrentProgress( 0.1f );
12185 animationBeta.SetCurrentProgress( 0.1f );
12186 animationAlpha.Play();
12187 animationBeta.Play();
12189 tet_infoline( "Animation Playing from 10%" );
12191 application.SendNotification();
12192 application.Render(0); // start animation
12193 application.Render(durationSeconds*100.0f ); // 20% progress
12195 tet_infoline( "Animation at 20% - No signals to be received" );
12197 progressCheckAlpha.CheckSignalNotReceived();
12198 progressCheckBeta.CheckSignalNotReceived();
12200 application.SendNotification();
12201 application.Render(durationSeconds*200.0f ); // 40% progress
12202 application.SendNotification();
12203 tet_infoline( "Animation at 40% - Alpha signal should be received" );
12204 DALI_TEST_EQUALS( 0.4f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12206 progressCheckAlpha.CheckSignalReceived();
12207 progressCheckBeta.CheckSignalNotReceived();
12209 tet_infoline( "Progress check reset" );
12210 progressCheckAlpha.Reset();
12211 progressCheckBeta.Reset();
12213 application.Render(durationSeconds*100.0f ); // 50% progress
12214 tet_infoline( "Animation at 50% - Beta should receive signal, Alpha should not" );
12215 application.SendNotification();
12217 DALI_TEST_EQUALS( 0.5f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12219 progressCheckAlpha.CheckSignalNotReceived();
12220 progressCheckBeta.CheckSignalReceived();
12221 tet_infoline( "Progress check reset" );
12222 progressCheckAlpha.Reset();
12223 progressCheckBeta.Reset();
12225 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
12226 application.SendNotification();
12228 tet_infoline( "Animation at 60%" );
12230 progressCheckAlpha.CheckSignalNotReceived();
12231 progressCheckBeta.CheckSignalNotReceived();
12233 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12234 application.SendNotification();
12235 tet_infoline( "Animation at 80%" );
12237 progressCheckAlpha.CheckSignalNotReceived();
12238 progressCheckBeta.CheckSignalNotReceived();
12240 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12241 // We did expect the animation to finish
12242 tet_infoline( "Animation finished" );
12247 int UtcDaliAnimationMultipleProgressSignalsP2(void)
12249 tet_infoline( "Multiple animations with different progress markers and big step time" );
12251 TestApplication application;
12253 Actor actor = Actor::New();
12254 Stage::GetCurrent().Add(actor);
12256 // Build the animation
12257 Animation animationAlpha = Animation::New(0.0f);
12258 Animation animationBeta = Animation::New(0.0f);
12261 const float durationSeconds(1.0f);
12262 animationAlpha.SetDuration(durationSeconds);
12263 animationBeta.SetDuration(durationSeconds);
12265 bool progressSignalReceivedAlpha(false);
12266 bool progressSignalReceivedBeta(false);
12268 AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12269 AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12271 DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12272 DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12273 application.SendNotification();
12275 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12276 animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12277 animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12279 tet_infoline( "AnimationAlpha Progress notification set to 1%" );
12280 DevelAnimation::SetProgressNotification( animationAlpha, 0.01f );
12282 tet_infoline( "AnimationBeta Progress notification set to 99%" );
12283 DevelAnimation::SetProgressNotification( animationBeta, 0.99f );
12285 application.SendNotification();
12286 application.Render( );
12288 progressCheckAlpha.CheckSignalNotReceived();
12289 progressCheckBeta.CheckSignalNotReceived();
12291 // Start the animations unlimited looping
12292 animationAlpha.SetLooping( true );
12293 animationBeta.SetLooping( true );
12294 animationAlpha.Play();
12295 animationBeta.Play();
12297 application.SendNotification();
12298 application.Render(0); // start animation
12299 application.Render(durationSeconds*20.0f ); // 2% progress
12300 application.SendNotification();
12301 DALI_TEST_EQUALS( 0.02f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12303 tet_infoline( "Animation at 2% - Alpha signals should be received, Beta should not." );
12305 progressCheckAlpha.CheckSignalReceived();
12306 progressCheckBeta.CheckSignalNotReceived();
12308 tet_infoline( "Progress check reset" );
12309 progressCheckAlpha.Reset();
12310 progressCheckBeta.Reset();
12312 application.SendNotification();
12313 application.Render(durationSeconds*960.0f ); // 98% progress
12314 application.SendNotification();
12315 tet_infoline( "Animation at 98% - No signal received" );
12316 DALI_TEST_EQUALS( 0.98f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12318 progressCheckAlpha.CheckSignalNotReceived();
12319 progressCheckBeta.CheckSignalNotReceived();
12321 application.SendNotification();
12322 application.Render(durationSeconds*40.0f ); // 2% progress
12323 application.SendNotification();
12324 tet_infoline( "Animation loop once and now 2% - Alpha and Beta should receive signal" );
12325 application.SendNotification();
12327 DALI_TEST_EQUALS( 0.02f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12329 progressCheckAlpha.CheckSignalReceived();
12330 progressCheckBeta.CheckSignalReceived();
12332 tet_infoline( "Progress check reset" );
12333 progressCheckAlpha.Reset();
12334 progressCheckBeta.Reset();
12336 application.SendNotification();
12337 application.Render(durationSeconds*980.0f ); // 100% progress
12338 application.SendNotification();
12339 tet_infoline( "Animation loop one more time. and now 100% - Beta should receive signal, Alhpa sholud not" );
12340 application.SendNotification();
12342 progressCheckAlpha.CheckSignalNotReceived();
12343 progressCheckBeta.CheckSignalReceived();
12345 tet_infoline( "Progress check reset" );
12346 progressCheckAlpha.Reset();
12347 progressCheckBeta.Reset();
12349 animationAlpha.SetLooping( false );
12350 animationBeta.SetLooping( false );
12352 application.SendNotification();
12353 application.Render(static_cast<unsigned int>(durationSeconds*2000.0f) + 1u/*just beyond the animation duration*/);
12354 application.SendNotification();
12356 // We did expect the animation to finish
12357 tet_infoline( "Animation finished" );
12362 int UtcDaliAnimationProgressSignalWithPlayAfterP(void)
12364 tet_infoline( "Multiple animations with different progress markers" );
12366 TestApplication application;
12368 Actor actor = Actor::New();
12369 Stage::GetCurrent().Add(actor);
12371 // Build the animation
12372 Animation animationAlpha = Animation::New(0.0f);
12373 Animation animationBeta = Animation::New(0.0f);
12376 float durationSeconds(1.0f);
12377 float delaySeconds(0.5f);
12378 animationAlpha.SetDuration(durationSeconds);
12379 animationBeta.SetDuration(durationSeconds);
12381 bool progressSignalReceivedAlpha(false);
12382 bool progressSignalReceivedBeta(false);
12384 AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12385 AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12387 DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12388 DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12389 application.SendNotification();
12391 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12392 animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12393 animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12395 tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12396 DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12398 tet_infoline( "AnimationBeta Progress notification set to ~0% (==Notify when delay is done)" );
12399 DevelAnimation::SetProgressNotification( animationBeta, Math::MACHINE_EPSILON_1 );
12401 application.SendNotification();
12402 application.Render( );
12404 progressCheckAlpha.CheckSignalNotReceived();
12405 progressCheckBeta.CheckSignalNotReceived();
12407 // Start the animations from 10% progress
12408 animationAlpha.PlayAfter(delaySeconds);
12409 animationBeta.PlayAfter(delaySeconds);
12411 application.SendNotification();
12412 application.Render(0); // start animation
12413 application.Render(delaySeconds * 500.0f ); // 50% wait progress
12415 tet_infoline( "Delay at 50% - No signals to be received" );
12417 progressCheckAlpha.CheckSignalNotReceived();
12418 progressCheckBeta.CheckSignalNotReceived();
12420 application.SendNotification();
12421 application.Render(delaySeconds * 500.0f + durationSeconds * 50.0f ); // 100% wait, 5% progress
12422 application.SendNotification();
12423 tet_infoline( "Delay at 100%, Animation at 5% - Beta signal should be received" );
12424 DALI_TEST_EQUALS( 0.05f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12426 progressCheckBeta.CheckSignalReceived();
12427 progressCheckAlpha.CheckSignalNotReceived();
12429 tet_infoline( "Progress check reset" );
12430 progressCheckAlpha.Reset();
12431 progressCheckBeta.Reset();
12433 application.Render(durationSeconds * 200.0f ); // 25% progress
12434 tet_infoline( "Animation at 25% - No signals to be received" );
12435 application.SendNotification();
12437 progressCheckAlpha.CheckSignalNotReceived();
12438 progressCheckBeta.CheckSignalNotReceived();
12440 application.Render(durationSeconds * 200.0f ); // 45% progress
12441 tet_infoline( "Animation at 45% - Alpha should receive signal, Beta should not" );
12442 application.SendNotification();
12444 DALI_TEST_EQUALS( 0.45f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12446 progressCheckAlpha.CheckSignalReceived();
12447 progressCheckBeta.CheckSignalNotReceived();
12449 tet_infoline( "Progress check reset" );
12450 progressCheckAlpha.Reset();
12451 progressCheckBeta.Reset();
12453 application.Render(static_cast<unsigned int>(durationSeconds*150.0f)/* 60% progress */);
12454 application.SendNotification();
12456 tet_infoline( "Animation at 60%" );
12458 progressCheckAlpha.CheckSignalNotReceived();
12459 progressCheckBeta.CheckSignalNotReceived();
12461 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12462 application.SendNotification();
12463 tet_infoline( "Animation at 80%" );
12465 progressCheckAlpha.CheckSignalNotReceived();
12466 progressCheckBeta.CheckSignalNotReceived();
12468 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12469 // We did expect the animation to finish
12470 tet_infoline( "Animation finished" );
12475 int UtcDaliAnimationProgressCallbackWithLoopingP(void)
12477 TestApplication application;
12479 Actor actor = Actor::New();
12480 Stage::GetCurrent().Add(actor);
12482 // Build the animation
12483 Animation animation = Animation::New(0.0f);
12486 const float durationSeconds(1.0f);
12487 animation.SetDuration(durationSeconds);
12489 // Set Looping Count
12490 const int loopCount( 4 );
12491 animation.SetLoopCount( loopCount );
12493 bool finishedSignalReceived(false);
12494 bool progressSignalReceived(false);
12496 AnimationFinishCheck finishCheck(finishedSignalReceived);
12497 animation.FinishedSignal().Connect(&application, finishCheck);
12499 AnimationProgressCheck progressCheck(progressSignalReceived);
12500 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12501 application.SendNotification();
12503 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12504 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12506 tet_infoline( "Animation Progress notification set to 50% with looping count 4" );
12507 DevelAnimation::SetProgressNotification( animation, 0.5f );
12509 application.SendNotification();
12510 application.Render( );
12512 progressCheck.CheckSignalNotReceived();
12516 for(int count = 0; count < loopCount; count++)
12518 application.SendNotification();
12519 application.Render(0); // start animation
12520 application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12521 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12523 tet_infoline( "Animation at 25%" );
12525 progressCheck.CheckSignalNotReceived();
12527 application.SendNotification();
12528 application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12529 application.SendNotification();
12530 tet_infoline( "Animation at 50%" );
12531 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12533 progressCheck.CheckSignalReceived();
12535 tet_infoline( "Progress check reset" );
12536 progressCheck.Reset();
12538 application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12539 tet_infoline( "Animation at 75%" );
12540 application.SendNotification();
12542 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12544 progressCheck.CheckSignalNotReceived();
12546 application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12547 tet_infoline( "Animation at 100%" );
12548 application.SendNotification();
12550 //Nothing check at 100% progress. cause It can be both 100% and 0%.
12551 application.SendNotification();
12553 application.Render(10u);
12554 application.SendNotification();
12555 application.Render(0u);
12556 application.SendNotification();
12558 finishCheck.CheckSignalReceived();
12563 int UtcDaliAnimationProgressCallbackWithLoopingP2(void)
12565 TestApplication application;
12567 Actor actor = Actor::New();
12568 Stage::GetCurrent().Add(actor);
12570 // Build the animation
12571 Animation animation = Animation::New(0.0f);
12574 const float durationSeconds(1.0f);
12575 animation.SetDuration(durationSeconds);
12577 // Set Looping Unlmited
12578 animation.SetLooping( true );
12580 bool finishedSignalReceived(false);
12581 bool progressSignalReceived(false);
12583 AnimationFinishCheck finishCheck(finishedSignalReceived);
12584 animation.FinishedSignal().Connect(&application, finishCheck);
12586 AnimationProgressCheck progressCheck(progressSignalReceived);
12587 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12588 application.SendNotification();
12590 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12591 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12593 tet_infoline( "Animation Progress notification set to 50% with unlimited looping" );
12594 DevelAnimation::SetProgressNotification( animation, 0.5f );
12596 application.SendNotification();
12597 application.Render( );
12599 progressCheck.CheckSignalNotReceived();
12603 for(int count = 0; count < 4; count++)
12605 application.SendNotification();
12606 application.Render(0); // start animation
12607 application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12608 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12610 tet_infoline( "Animation at 25%" );
12612 progressCheck.CheckSignalNotReceived();
12614 application.SendNotification();
12615 application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12616 application.SendNotification();
12617 tet_infoline( "Animation at 50%" );
12618 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12620 progressCheck.CheckSignalReceived();
12622 tet_infoline( "Progress check reset" );
12623 progressCheck.Reset();
12625 application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12626 tet_infoline( "Animation at 75%" );
12627 application.SendNotification();
12629 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12631 progressCheck.CheckSignalNotReceived();
12633 application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12634 tet_infoline( "Animation at 100%" );
12635 application.SendNotification();
12637 //Nothing check at 100% progress. cause It can be both 100% and 0%.
12638 finishCheck.CheckSignalNotReceived();
12639 application.SendNotification();
12641 finishCheck.CheckSignalNotReceived();
12643 animation.SetLooping( false );
12644 application.Render(0u);
12645 application.SendNotification();
12646 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 10u);
12647 application.SendNotification();
12648 application.Render(0u);
12649 application.SendNotification();
12651 finishCheck.CheckSignalReceived();
12656 int UtcDaliAnimationProgressCallbackNegativeSpeed(void)
12658 TestApplication application;
12660 Actor actor = Actor::New();
12661 Stage::GetCurrent().Add(actor);
12663 // Build the animation
12664 Animation animation = Animation::New(0.0f);
12667 const float durationSeconds(1.0f);
12668 animation.SetDuration(durationSeconds);
12670 //Set speed negative
12671 animation.SetSpeedFactor( -1.0f );
12673 // Set Looping Unlmited
12674 animation.SetLooping( true );
12676 bool finishedSignalReceived(false);
12677 bool progressSignalReceived(false);
12679 AnimationFinishCheck finishCheck(finishedSignalReceived);
12680 animation.FinishedSignal().Connect(&application, finishCheck);
12682 AnimationProgressCheck progressCheck(progressSignalReceived);
12683 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12684 application.SendNotification();
12686 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12687 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12689 tet_infoline( "Animation Progress notification set to 50%" );
12690 DevelAnimation::SetProgressNotification( animation, 0.5f );
12692 application.SendNotification();
12693 application.Render( );
12695 progressCheck.CheckSignalNotReceived();
12699 for(int count = 0; count < 4; count++)
12701 application.SendNotification();
12702 application.Render(0); // start animation
12703 progressCheck.CheckSignalNotReceived();
12705 application.SendNotification();
12706 application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12707 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12709 tet_infoline( "Animation at 25%" );
12711 progressCheck.CheckSignalNotReceived();
12713 application.SendNotification();
12714 application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12715 application.SendNotification();
12716 tet_infoline( "Animation at 50%" );
12717 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12719 progressCheck.CheckSignalReceived();
12721 tet_infoline( "Progress check reset" );
12722 progressCheck.Reset();
12724 application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12725 tet_infoline( "Animation at 75%" );
12726 application.SendNotification();
12728 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12730 progressCheck.CheckSignalNotReceived();
12732 application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12733 tet_infoline( "Animation at 100%" );
12734 application.SendNotification();
12736 //Nothing check at 100% progress. cause It can be both 100% and 0%.
12737 finishCheck.CheckSignalNotReceived();
12738 application.SendNotification();
12740 finishCheck.CheckSignalNotReceived();
12743 animation.SetLooping( false );
12744 animation.SetLoopCount( 4 );
12746 application.Render(0u);
12747 application.SendNotification();
12749 for(int count = 0; count < 4; count++)
12751 application.SendNotification();
12752 application.Render(0); // start animation
12753 progressCheck.CheckSignalNotReceived();
12755 application.SendNotification();
12756 application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12757 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12759 tet_infoline( "Animation at 25%" );
12761 progressCheck.CheckSignalNotReceived();
12763 application.SendNotification();
12764 application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12765 application.SendNotification();
12766 tet_infoline( "Animation at 50%" );
12767 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12769 progressCheck.CheckSignalReceived();
12771 tet_infoline( "Progress check reset" );
12772 progressCheck.Reset();
12774 application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12775 tet_infoline( "Animation at 75%" );
12776 application.SendNotification();
12778 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12780 progressCheck.CheckSignalNotReceived();
12782 application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12783 tet_infoline( "Animation at 100%" );
12784 application.SendNotification();
12786 //Nothing check at 100% progress. cause It can be both 100% and 0%.
12787 application.SendNotification();
12789 application.Render(10u);
12790 application.SendNotification();
12791 application.Render(0u);
12792 application.SendNotification();
12794 finishCheck.CheckSignalReceived();
12799 int UtcDaliAnimationProgressCallbackInvalidSignalN(void)
12801 TestApplication application;
12803 Actor actor = Actor::New();
12804 Stage::GetCurrent().Add(actor);
12806 // Build the animation
12807 Animation animation = Animation::New(0.0f);
12810 const float durationSeconds(1.0f);
12811 animation.SetDuration(durationSeconds);
12813 bool finishedSignalReceived(false);
12814 bool progressSignalReceived(false);
12816 AnimationFinishCheck finishCheck(finishedSignalReceived);
12817 animation.FinishedSignal().Connect(&application, finishCheck);
12819 AnimationProgressCheck progressCheck(progressSignalReceived);
12820 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12821 application.SendNotification();
12823 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12824 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12826 tet_infoline( "Animation Progress PlayRange as 10% ~ 90%" );
12827 animation.SetPlayRange( Vector2( 0.1f, 0.9f ) );
12829 tet_infoline( "Animation Progress notification set to >90% that never can notificated" );
12830 DevelAnimation::SetProgressNotification( animation, 0.9f + Math::MACHINE_EPSILON_1 );
12832 application.SendNotification();
12833 application.Render( );
12835 progressCheck.CheckSignalNotReceived();
12839 application.SendNotification();
12840 application.Render(0); // start animation
12841 application.Render(durationSeconds*0.25*1000.0f ); // 35% progress
12842 DALI_TEST_EQUALS( 0.35f, animation.GetCurrentProgress(), TEST_LOCATION );
12844 tet_infoline( "Animation at 35%" );
12846 progressCheck.CheckSignalNotReceived();
12848 application.SendNotification();
12849 application.Render(durationSeconds*0.25*1000.0f ); // 60% progress
12850 application.SendNotification();
12851 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
12853 tet_infoline( "Animation at 60%" );
12855 progressCheck.CheckSignalNotReceived();
12857 application.Render(durationSeconds*0.25*1000.0f ); // 85% progress
12858 tet_infoline( "Animation at 85%" );
12859 application.SendNotification();
12860 DALI_TEST_EQUALS( 0.85f, animation.GetCurrentProgress(), TEST_LOCATION );
12862 progressCheck.CheckSignalNotReceived();
12864 application.Render(durationSeconds*0.25*1000.0f ); // 90% progress
12865 tet_infoline( "Animation over 90%" );
12866 application.SendNotification();
12868 // progress never signaled because playrange is 90%
12869 progressCheck.CheckSignalNotReceived();
12874 int UtcDaliAnimationProgressCallbackLongDurationP(void)
12876 TestApplication application;
12878 Actor actor = Actor::New();
12879 Stage::GetCurrent().Add(actor);
12881 // Build the animation
12882 Animation animation = Animation::New(0.0f);
12885 float durationSeconds(5.0f);
12886 animation.SetDuration(durationSeconds);
12888 bool finishedSignalReceived(false);
12889 bool progressSignalReceived(false);
12891 AnimationFinishCheck finishCheck(finishedSignalReceived);
12892 animation.FinishedSignal().Connect(&application, finishCheck);
12894 AnimationProgressCheck progressCheck(progressSignalReceived);
12895 DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12896 application.SendNotification();
12898 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12899 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12901 tet_infoline( "Animation Progress notification set to 50%" );
12902 DevelAnimation::SetProgressNotification( animation, 0.5f );
12904 application.SendNotification();
12905 application.Render( );
12907 progressCheck.CheckSignalNotReceived();
12911 application.SendNotification();
12912 application.Render(0); // start animation
12913 application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12914 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12916 tet_infoline( "Animation at 25%" );
12918 progressCheck.CheckSignalNotReceived();
12920 application.SendNotification();
12921 application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12922 application.SendNotification();
12923 tet_infoline( "Animation at 50%" );
12924 DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12926 progressCheck.CheckSignalReceived();
12928 tet_infoline( "Progress check reset" );
12929 progressCheck.Reset();
12931 application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12932 tet_infoline( "Animation at 75%" );
12933 application.SendNotification();
12935 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12937 progressCheck.CheckSignalNotReceived();
12942 int UtcDaliAnimationAnimateByInvalidParameters(void)
12944 TestApplication application;
12946 Actor actor = Actor::New();
12947 Stage::GetCurrent().Add(actor);
12949 // Create the animation
12950 Animation animation = Animation::New(1.0f);
12952 DALI_TEST_ASSERTION(
12954 // non animateable property (STRING)
12955 animation.AnimateBy( Property( actor, Actor::Property::LAYOUT_DIRECTION ), Property::Value( "new direction" ) );
12956 }, "Property type is not animatable" );
12958 DALI_TEST_ASSERTION(
12960 // non animateable property (MATRIX)
12961 Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Dali::Matrix() ), Property::ANIMATABLE );
12962 animation.AnimateBy( Property( actor, index ), Property::Value( Property::MATRIX ) );
12963 }, "Property type is not animatable" );
12966 DALI_TEST_ASSERTION(
12968 // non animateable target (NONE)
12969 animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value() );
12970 }, "Target value is not animatable" );
12972 DALI_TEST_ASSERTION(
12974 // non animateable target (STRING)
12975 animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value("foo") );
12976 }, "Target value is not animatable" );
12978 DALI_TEST_ASSERTION(
12980 // not mathing properties (VECTOR3, FLOAT)
12981 animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( 10.f ) );
12982 }, "Property and target types don't match" );
12984 DALI_TEST_ASSERTION(
12986 // not mathing properties (VECTOR3.A, VECTOR2)
12987 animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), Property::Value( Property::VECTOR2 ) );
12988 }, "Property and target types don't match" );
12990 DALI_TEST_ASSERTION(
12992 // negative duration
12993 animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
12994 }, "Duration must be >=0" );
12999 int UtcDaliAnimationAnimateToInvalidParameters(void)
13001 TestApplication application;
13003 Actor actor = Actor::New();
13004 Stage::GetCurrent().Add(actor);
13006 // Create the animation
13007 Animation animation = Animation::New(1.0f);
13010 DALI_TEST_ASSERTION(
13012 // non animateable property (MAP)
13013 Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::MAP ), Property::ANIMATABLE );
13014 animation.AnimateTo( Property( actor, index ), Property::Value( Property::MAP ) );
13015 }, "Property type is not animatable" );
13017 DALI_TEST_ASSERTION(
13019 // non animateable target (NONE)
13020 animation.AnimateTo( Property( actor, Actor::Property::CLIPPING_MODE ), Property::Value() );
13021 }, "Property type is not animatable" );
13023 DALI_TEST_ASSERTION(
13025 // non animateable target (ARRAY)
13026 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Property::ARRAY ) );
13027 }, "Target value is not animatable" );
13029 DALI_TEST_ASSERTION(
13031 // non animateable target (RECTANGLE)
13032 animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Rect<int32_t>() ) );
13033 }, "Target value is not animatable" );
13035 DALI_TEST_ASSERTION(
13037 // not mathing properties (FLOAT, INT)
13038 animation.AnimateTo( Property( actor, Actor::Property::SCALE_Y ), Property::Value(10) );
13039 }, "Property and target types don't match" );
13041 DALI_TEST_ASSERTION(
13043 // not mathing properties (VECTOR3, VECTOR2)
13044 animation.AnimateTo( Property( actor, Actor::Property::COLOR ), Property::Value( Property::VECTOR2 ) );
13045 }, "Property and target types don't match" );
13047 DALI_TEST_ASSERTION(
13049 // negative duration
13050 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
13051 }, "Duration must be >=0" );
13056 int UtcDaliAnimationAnimateBetweenInvalidParameters(void)
13058 TestApplication application;
13060 Actor actor = Actor::New();
13061 Stage::GetCurrent().Add(actor);
13063 // Create the animation
13064 Animation animation = Animation::New(1.0f);
13067 DALI_TEST_ASSERTION(
13069 // non animateable property (ARRAY)
13070 Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::ARRAY ), Property::ANIMATABLE );
13071 KeyFrames keyframes = KeyFrames::New();
13072 keyframes.Add( 0.5f, Property::Value( Property::ARRAY ) );
13073 animation.AnimateBetween( Property( actor, index ), keyframes );
13074 }, "Property type is not animatable" );
13076 DALI_TEST_ASSERTION(
13078 // non animateable target (NONE)
13079 KeyFrames keyframes = KeyFrames::New();
13080 keyframes.Add( 0.5f, Property::Value() );
13081 animation.AnimateBetween( Property( actor, Actor::Property::CLIPPING_MODE ), keyframes );
13082 }, "Property type is not animatable" );
13084 DALI_TEST_ASSERTION(
13086 // non animateable target (EXTENTS)
13087 KeyFrames keyframes = KeyFrames::New();
13088 keyframes.Add( 0.5f, Property::Value( Property::EXTENTS ) ); // throws
13089 animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13090 }, "Property type is not animatable" );
13092 DALI_TEST_ASSERTION(
13094 // non animateable target (RECTANGLE)
13095 KeyFrames keyframes = KeyFrames::New();
13096 keyframes.Add( 0.5f, Property::Value( Property::MAP ) ); // throws
13097 animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13098 }, "Property type is not animatable" );
13100 DALI_TEST_ASSERTION(
13102 // not mathing properties (VECTOR2, VECTOR4)
13103 KeyFrames keyframes = KeyFrames::New();
13104 keyframes.Add( 0.5f, Property::Value( Vector4( 1, 2, 3, 4 ) ) );
13105 animation.AnimateBetween( Property( actor, Actor::Property::MAXIMUM_SIZE ), keyframes );
13106 }, "Property and target types don't match" );
13108 DALI_TEST_ASSERTION(
13110 // negative duration
13111 KeyFrames keyframes = KeyFrames::New();
13112 keyframes.Add( 0.5f, Property::Value(Vector3( 1, 2, 3 ) ) );
13113 animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes, TimePeriod(-1) );
13114 }, "Duration must be >=0" );