2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
28 void utc_dali_animation_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_animation_cleanup(void)
35 test_return_value = TET_PASS;
41 static const float ROTATION_EPSILON = 0.0001f;
42 static const float VECTOR4_EPSILON = 0.0001f;
44 // Functor to test whether a Finish signal is emitted
45 struct AnimationFinishCheck
47 AnimationFinishCheck(bool& signalReceived)
48 : mSignalReceived(signalReceived)
52 void operator()(Animation& animation)
54 mSignalReceived = true;
59 mSignalReceived = false;
62 void CheckSignalReceived()
66 tet_printf("Expected Finish signal was not received\n");
75 void CheckSignalNotReceived()
79 tet_printf("Unexpected Finish signal was received\n");
88 bool& mSignalReceived; // owned by individual tests
93 int UtcDaliAnimationNew01(void)
95 TestApplication application;
98 DALI_TEST_CHECK(!animation);
100 animation = Animation::New(1.0f);
102 DALI_TEST_CHECK(animation);
106 int UtcDaliAnimationNew02(void)
108 TestApplication application;
111 DALI_TEST_CHECK(!animation);
114 animation = Animation::New(0.0f);
116 catch (Dali::DaliException& e)
118 // Tests that a negative test of an assertion succeeds
119 DALI_TEST_PRINT_ASSERT( e );
120 DALI_TEST_EQUALS(e.condition, "durationSeconds > 0.0f", TEST_LOCATION);
125 int UtcDaliAnimationDownCast(void)
127 TestApplication application;
128 tet_infoline("Testing Dali::Animation::DownCast()");
130 float durationSeconds(1.0f);
131 Animation animation = Animation::New(durationSeconds);
133 BaseHandle object(animation);
135 Animation animation2 = Animation::DownCast(object);
136 DALI_TEST_CHECK(animation2);
138 Animation animation3 = DownCast< Animation >(object);
139 DALI_TEST_CHECK(animation3);
141 BaseHandle unInitializedObject;
142 Animation animation4 = Animation::DownCast(unInitializedObject);
143 DALI_TEST_CHECK(!animation4);
145 Animation animation5 = DownCast< Animation >(unInitializedObject);
146 DALI_TEST_CHECK(!animation5);
150 int UtcDaliAnimationSetDuration(void)
152 TestApplication application;
154 Actor actor = Actor::New();
155 Stage::GetCurrent().Add(actor);
157 // Build the animation
158 float durationSeconds(1.0f);
159 Animation animation = Animation::New(durationSeconds);
160 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
162 // Start the animation
163 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
164 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
167 bool signalReceived(false);
168 AnimationFinishCheck finishCheck(signalReceived);
169 animation.FinishedSignal().Connect(&application, finishCheck);
171 application.SendNotification();
172 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
174 // We didn't expect the animation to finish yet
175 application.SendNotification();
176 finishCheck.CheckSignalNotReceived();
178 application.Render(2u/*just beyond the animation duration*/);
180 // We did expect the animation to finish
181 application.SendNotification();
182 finishCheck.CheckSignalReceived();
183 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
185 // Restart the animation, with a different duration
187 actor.SetPosition(Vector3::ZERO);
188 durationSeconds = 3.5f;
189 animation.SetDuration(durationSeconds);
190 DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
193 application.SendNotification();
194 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
196 // We didn't expect the animation to finish yet
197 application.SendNotification();
198 finishCheck.CheckSignalNotReceived();
200 application.Render(2u/*just beyond the animation duration*/);
202 // We did expect the animation to finish
203 application.SendNotification();
204 finishCheck.CheckSignalReceived();
205 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
207 // Check that nothing has changed after a couple of buffer swaps
208 application.Render(0);
209 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
210 application.Render(0);
211 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
215 int UtcDaliAnimationGetDuration(void)
217 TestApplication application;
219 Animation animation = Animation::New(1.0f);
220 DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
222 animation.SetDuration(2.0f);
223 DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
227 int UtcDaliAnimationSetLooping(void)
229 TestApplication application;
231 Actor actor = Actor::New();
232 Stage::GetCurrent().Add(actor);
234 // Build the animation
235 float durationSeconds(1.0f);
236 Animation animation = Animation::New(durationSeconds);
237 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
238 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
240 // Start the animation
241 animation.SetLooping(true);
242 DALI_TEST_CHECK(animation.IsLooping());
245 bool signalReceived(false);
246 AnimationFinishCheck finishCheck(signalReceived);
247 animation.FinishedSignal().Connect(&application, finishCheck);
249 application.SendNotification();
252 float intervalSeconds = 0.25f;
253 float progress = 0.0f;
254 for (int iterations = 0; iterations < 5;)
256 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
258 progress += intervalSeconds;
259 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
261 if (progress >= 1.0f)
263 progress = progress - 1.0f;
268 // We didn't expect the animation to finish yet
269 application.SendNotification();
270 finishCheck.CheckSignalNotReceived();
272 animation.SetLooping(false);
273 DALI_TEST_CHECK(!animation.IsLooping());
275 application.SendNotification();
276 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
278 // We did expect the animation to finish
279 application.SendNotification();
280 finishCheck.CheckSignalReceived();
281 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
283 // Check that nothing has changed after a couple of buffer swaps
284 application.Render(0);
285 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
286 application.Render(0);
287 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
291 int UtcDaliAnimationIsLooping(void)
293 TestApplication application;
295 Animation animation = Animation::New(1.0f);
296 DALI_TEST_CHECK(!animation.IsLooping());
298 animation.SetLooping(true);
299 DALI_TEST_CHECK(animation.IsLooping());
303 int UtcDaliAnimationSetEndAction(void)
305 TestApplication application;
307 Actor actor = Actor::New();
308 Stage::GetCurrent().Add(actor);
310 // Build the animation
311 float durationSeconds(1.0f);
312 Animation animation = Animation::New(durationSeconds);
313 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
315 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
316 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
318 // Start the animation
321 bool signalReceived(false);
322 AnimationFinishCheck finishCheck(signalReceived);
323 animation.FinishedSignal().Connect(&application, finishCheck);
325 application.SendNotification();
326 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
328 // We did expect the animation to finish
329 application.SendNotification();
330 finishCheck.CheckSignalReceived();
331 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
333 // Go back to the start
334 actor.SetPosition(Vector3::ZERO);
335 application.SendNotification();
336 application.Render(0);
337 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
339 // Test BakeFinal, animate again, for half the duration
341 animation.SetEndAction(Animation::BakeFinal);
342 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
345 application.SendNotification();
346 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
348 // Stop the animation early
351 // We did NOT expect the animation to finish
352 application.SendNotification();
353 finishCheck.CheckSignalNotReceived();
354 DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
356 // Go back to the start
357 actor.SetPosition(Vector3::ZERO);
358 application.SendNotification();
359 application.Render(0);
360 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
362 // Test EndAction::Discard, animate again, but don't bake this time
364 animation.SetEndAction(Animation::Discard);
365 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
368 application.SendNotification();
369 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
371 // We did expect the animation to finish
372 application.SendNotification();
373 finishCheck.CheckSignalReceived();
374 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
376 // The position should be discarded in the next frame
377 application.Render(0);
378 DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
380 // Check that nothing has changed after a couple of buffer swaps
381 application.Render(0);
382 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
383 application.Render(0);
384 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
388 int UtcDaliAnimationGetEndAction(void)
390 TestApplication application;
392 Animation animation = Animation::New(1.0f);
393 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
395 animation.SetEndAction(Animation::Discard);
396 DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
398 animation.SetEndAction(Animation::BakeFinal);
399 DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
404 int UtcDaliAnimationSetDisconnectAction(void)
406 TestApplication application;
407 Stage stage( Stage::GetCurrent() );
409 // Default: BakeFinal
411 Actor actor = Actor::New();
414 // Build the animation
415 float durationSeconds(1.0f);
416 Animation animation = Animation::New(durationSeconds);
417 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
419 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
420 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
422 // Start the animation
425 application.SendNotification();
426 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
430 application.SendNotification();
431 application.Render();
433 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
438 Actor actor = Actor::New();
441 // Build the animation
442 float durationSeconds(1.0f);
443 Animation animation = Animation::New(durationSeconds);
444 animation.SetDisconnectAction( Animation::Bake );
446 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
447 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
449 // Start the animation
452 application.SendNotification();
453 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
457 application.SendNotification();
458 application.Render();
460 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
465 Actor actor = Actor::New();
468 // Build the animation
469 float durationSeconds(1.0f);
470 Animation animation = Animation::New(durationSeconds);
471 animation.SetDisconnectAction( Animation::Discard );
473 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
474 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
476 // Start the animation
479 application.SendNotification();
480 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
484 application.SendNotification();
485 application.Render();
487 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
490 // Don't play the animation: disconnect action should not be applied
492 Actor actor = Actor::New();
495 // Build the animation
496 float durationSeconds(1.0f);
497 Animation animation = Animation::New(durationSeconds);
499 Vector3 targetPosition(10.0f, 10.0f, 10.0f);
500 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
502 application.SendNotification();
503 application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
507 application.SendNotification();
508 application.Render();
510 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
516 int UtcDaliAnimationGetDisconnectAction(void)
518 TestApplication application;
519 Animation animation = Animation::New(1.0f);
520 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
522 animation.SetDisconnectAction(Animation::Discard);
523 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
525 animation.SetDisconnectAction(Animation::Bake);
526 DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
531 int UtcDaliAnimationSetDefaultAlphaFunction(void)
533 TestApplication application;
535 Animation animation = Animation::New(1.0f);
536 AlphaFunction func = animation.GetDefaultAlphaFunction();
537 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
539 animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
540 AlphaFunction func2 = animation.GetDefaultAlphaFunction();
541 DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
545 int UtcDaliAnimationGetDefaultAlphaFunction(void)
547 TestApplication application;
549 Animation animation = Animation::New(1.0f);
550 AlphaFunction func = animation.GetDefaultAlphaFunction();
552 // Test that the default is linear
553 DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
557 int UtcDaliAnimationPlay(void)
559 TestApplication application;
561 Actor actor = Actor::New();
562 Stage::GetCurrent().Add(actor);
564 // Build the animation
565 float durationSeconds(1.0f);
566 Animation animation = Animation::New(durationSeconds);
567 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
568 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
570 // Start the animation
573 bool signalReceived(false);
574 AnimationFinishCheck finishCheck(signalReceived);
575 animation.FinishedSignal().Connect(&application, finishCheck);
577 application.SendNotification();
578 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
580 // We didn't expect the animation to finish yet
581 application.SendNotification();
582 finishCheck.CheckSignalNotReceived();
583 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
585 animation.Play(); // Test that calling play has no effect, when animation is already playing
586 application.SendNotification();
587 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
589 // We didn't expect the animation to finish yet
590 application.SendNotification();
591 finishCheck.CheckSignalNotReceived();
592 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
594 animation.Play(); // Test that calling play has no effect, when animation is already playing
595 application.SendNotification();
596 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
598 // We didn't expect the animation to finish yet
599 application.SendNotification();
600 finishCheck.CheckSignalNotReceived();
601 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
603 animation.Play(); // Test that calling play has no effect, when animation is already playing
604 application.SendNotification();
605 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
607 // We didn't expect the animation to finish yet
608 application.SendNotification();
609 finishCheck.CheckSignalNotReceived();
610 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
612 animation.Play(); // Test that calling play has no effect, when animation is already playing
613 application.SendNotification();
614 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
616 // We did expect the animation to finish
617 application.SendNotification();
618 finishCheck.CheckSignalReceived();
619 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
621 // Check that nothing has changed after a couple of buffer swaps
622 application.Render(0);
623 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
624 application.Render(0);
625 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
629 int UtcDaliAnimationSetSpeedFactor(void)
631 TestApplication application;
633 Actor actor = Actor::New();
634 Stage::GetCurrent().Add(actor);
636 // Build the animation
637 float durationSeconds(1.0f);
638 Animation animation = Animation::New(durationSeconds);
640 const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
641 const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
643 KeyFrames keyframes = KeyFrames::New();
644 keyframes.Add( 0.0f, initialPosition);
645 keyframes.Add( 1.0f, targetPosition );
646 animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunctions::Linear);
649 animation.SetSpeedFactor(2.0f);
651 // Start the animation
654 bool signalReceived(false);
655 AnimationFinishCheck finishCheck(signalReceived);
656 animation.FinishedSignal().Connect(&application, finishCheck);
658 application.SendNotification();
659 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
661 // We didn't expect the animation to finish yet
662 application.SendNotification();
663 finishCheck.CheckSignalNotReceived();
664 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
666 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
668 // We didn't expect the animation to finish yet
669 application.SendNotification();
670 finishCheck.CheckSignalNotReceived();
671 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
673 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
675 // We did expect the animation to finish
676 application.SendNotification();
677 finishCheck.CheckSignalReceived();
678 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
680 // Check that nothing has changed after a couple of buffer swaps
681 application.Render(0);
682 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
683 application.Render(0);
684 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
688 //Test -1 speed factor. Animation will play in reverse at normal speed
689 animation.SetSpeedFactor( -1.0f );
691 // Start the animation
694 application.SendNotification();
695 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
697 // We didn't expect the animation to finish yet
698 application.SendNotification();
699 finishCheck.CheckSignalNotReceived();
700 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
702 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
704 // We didn't expect the animation to finish yet
705 application.SendNotification();
706 finishCheck.CheckSignalNotReceived();
707 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
709 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
711 // We didn't expect the animation to finish yet
712 application.SendNotification();
713 finishCheck.CheckSignalNotReceived();
714 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
716 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
718 // We didn't expect the animation to finish yet
719 application.SendNotification();
720 finishCheck.CheckSignalNotReceived();
721 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
723 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
725 // We did expect the animation to finish
726 application.SendNotification();
727 finishCheck.CheckSignalReceived();
728 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
730 // Check that nothing has changed after a couple of buffer swaps
731 application.Render(0);
732 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
733 application.Render(0);
734 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
737 //Test change speed factor on the fly
740 //Set speed to be half of normal speed
741 animation.SetSpeedFactor( 0.5f );
743 // Start the animation
746 application.SendNotification();
747 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
749 // We didn't expect the animation to finish yet
750 application.SendNotification();
751 finishCheck.CheckSignalNotReceived();
752 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
754 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
756 // We didn't expect the animation to finish yet
757 application.SendNotification();
758 finishCheck.CheckSignalNotReceived();
759 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
761 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
763 // We didn't expect the animation to finish yet
764 application.SendNotification();
765 finishCheck.CheckSignalNotReceived();
766 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
768 //Change speed factor while animation still playing.
769 animation.SetSpeedFactor(-1.0f);
770 application.SendNotification();
771 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
773 // We didn't expect the animation to finish yet
774 application.SendNotification();
775 finishCheck.CheckSignalNotReceived();
776 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
778 application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
780 // We did expect the animation to finish
781 application.SendNotification();
782 finishCheck.CheckSignalReceived();
783 DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
785 // Check that nothing has changed after a couple of buffer swaps
786 application.Render(0);
787 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
788 application.Render(0);
789 DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
793 int UtcDaliAnimationGetSpeedFactor(void)
795 TestApplication application;
797 Animation animation = Animation::New(1.0f);
798 animation.SetSpeedFactor(0.5f);
799 DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
801 animation.SetSpeedFactor(-2.5f);
802 DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
806 int UtcDaliAnimationPlayOffStage(void)
808 // Test that an animation can be played, when the actor is off-stage.
809 // When the actor is added to the stage, it should appear at the current position
810 // i.e. where it would have been anyway, if on-stage from the beginning.
812 TestApplication application;
814 Actor actor = Actor::New();
815 Vector3 basePosition(Vector3::ZERO);
816 DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
817 // Not added to the stage!
819 // Build the animation
820 float durationSeconds(1.0f);
821 Animation animation = Animation::New(durationSeconds);
822 animation.SetDisconnectAction( Animation::Discard );
823 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
824 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
826 // Start the animation
829 bool signalReceived(false);
830 AnimationFinishCheck finishCheck(signalReceived);
831 animation.FinishedSignal().Connect(&application, finishCheck);
833 application.SendNotification();
834 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
836 // We didn't expect the animation to finish yet
837 application.SendNotification();
838 finishCheck.CheckSignalNotReceived();
839 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
842 Stage::GetCurrent().Add(actor);
844 application.SendNotification();
845 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
847 // We didn't expect the animation to finish yet
848 application.SendNotification();
849 finishCheck.CheckSignalNotReceived();
850 Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
851 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
853 // Remove from the stage
854 Stage::GetCurrent().Remove(actor);
856 application.SendNotification();
857 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
859 // We didn't expect the animation to finish yet
860 application.SendNotification();
861 finishCheck.CheckSignalNotReceived();
862 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
865 Stage::GetCurrent().Add(actor);
867 application.SendNotification();
868 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
870 // We didn't expect the animation to finish yet
871 application.SendNotification();
872 finishCheck.CheckSignalNotReceived();
873 expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
874 DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
876 application.SendNotification();
877 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
879 // We did expect the animation to finish
880 application.SendNotification();
881 finishCheck.CheckSignalReceived();
882 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
884 // Check that nothing has changed after a couple of buffer swaps
885 application.Render(0);
886 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
887 application.Render(0);
888 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
892 int UtcDaliAnimationPlayDiscardHandle(void)
894 TestApplication application;
896 Actor actor = Actor::New();
897 Stage::GetCurrent().Add(actor);
899 // Build the animation
900 float durationSeconds(1.0f);
901 Animation animation = Animation::New(durationSeconds);
902 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
903 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
905 bool signalReceived(false);
906 AnimationFinishCheck finishCheck(signalReceived);
907 animation.FinishedSignal().Connect(&application, finishCheck);
909 // Start the animation
912 // This is a test of the "Fire and Forget" behaviour
913 // Discard the animation handle!
915 DALI_TEST_CHECK( !animation );
917 application.SendNotification();
918 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
920 // We didn't expect the animation to finish yet
921 application.SendNotification();
922 finishCheck.CheckSignalNotReceived();
923 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
925 application.SendNotification();
926 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
928 // We didn't expect the animation to finish yet
929 application.SendNotification();
930 finishCheck.CheckSignalNotReceived();
931 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
933 application.SendNotification();
934 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
936 // We didn't expect the animation to finish yet
937 application.SendNotification();
938 finishCheck.CheckSignalNotReceived();
939 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
941 application.SendNotification();
942 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
944 // We didn't expect the animation to finish yet
945 application.SendNotification();
946 finishCheck.CheckSignalNotReceived();
947 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
949 application.SendNotification();
950 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
952 // We did expect the animation to finish
953 application.SendNotification();
954 finishCheck.CheckSignalReceived();
955 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
957 // Check that nothing has changed after a couple of buffer swaps
958 application.Render(0);
959 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
960 application.Render(0);
961 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
965 int UtcDaliAnimationPlayStopDiscardHandle(void)
967 TestApplication application;
969 Actor actor = Actor::New();
970 Stage::GetCurrent().Add(actor);
972 // Build the animation
973 float durationSeconds(1.0f);
974 Animation animation = Animation::New(durationSeconds);
975 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
976 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
978 // Start the animation
981 bool signalReceived(false);
982 AnimationFinishCheck finishCheck(signalReceived);
983 animation.FinishedSignal().Connect(&application, finishCheck);
985 application.SendNotification();
986 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
988 // We didn't expect the animation to finish yet
989 application.SendNotification();
990 finishCheck.CheckSignalNotReceived();
991 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
993 // This is a test of the "Fire and Forget" behaviour
994 // Stop the animation, and Discard the animation handle!
997 DALI_TEST_CHECK( !animation );
999 application.SendNotification();
1000 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1002 // We expect the animation to finish at 20% progress
1003 application.SendNotification();
1004 finishCheck.CheckSignalReceived();
1005 finishCheck.Reset();
1006 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1008 application.SendNotification();
1009 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1011 // Check that nothing has changed
1012 application.SendNotification();
1013 finishCheck.CheckSignalNotReceived();
1014 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1016 application.SendNotification();
1017 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1019 // Check that nothing has changed
1020 application.SendNotification();
1021 finishCheck.CheckSignalNotReceived();
1022 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1024 application.SendNotification();
1025 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1027 // Check that nothing has changed
1028 application.SendNotification();
1029 finishCheck.CheckSignalNotReceived();
1030 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1034 int UtcDaliAnimationPlayFrom(void)
1036 TestApplication application;
1038 Actor actor = Actor::New();
1039 Stage::GetCurrent().Add(actor);
1041 // Build the animation
1042 float durationSeconds(1.0f);
1043 Animation animation = Animation::New(durationSeconds);
1044 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1045 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1047 //PlayFrom with an argument outside the range [0..1] will be ignored
1048 animation.PlayFrom(-1.0f);
1049 application.SendNotification();
1050 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1052 animation.PlayFrom(100.0f);
1053 application.SendNotification();
1054 DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1056 // Start the animation from 40% progress
1057 animation.PlayFrom( 0.4f );
1059 bool signalReceived(false);
1060 AnimationFinishCheck finishCheck(signalReceived);
1061 animation.FinishedSignal().Connect(&application, finishCheck);
1063 application.SendNotification();
1064 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1066 // We didn't expect the animation to finish yet
1067 application.SendNotification();
1068 finishCheck.CheckSignalNotReceived();
1069 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1071 animation.Play(); // Test that calling play has no effect, when animation is already playing
1072 application.SendNotification();
1073 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1075 // We didn't expect the animation to finish yet
1076 application.SendNotification();
1077 finishCheck.CheckSignalNotReceived();
1078 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1080 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1081 // We did expect the animation to finish
1082 application.SendNotification();
1083 finishCheck.CheckSignalReceived();
1084 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1086 // Check that nothing has changed after a couple of buffer swaps
1087 application.Render(0);
1088 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1089 application.Render(0);
1090 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1094 int UtcDaliAnimationSetCurrentProgress(void)
1096 TestApplication application;
1098 Actor actor = Actor::New();
1099 Stage::GetCurrent().Add(actor);
1101 // Build the animation
1102 Animation animation = Animation::New(0.0f);
1105 //Test GetCurrentProgress return 0.0 as the duration is 0.0
1106 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1108 animation.SetCurrentProgress( 0.5f );
1109 application.SendNotification();
1110 application.Render(static_cast<unsigned int>(100.0f));
1112 //Progress should still be 0.0
1113 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1116 float durationSeconds(1.0f);
1117 animation.SetDuration(durationSeconds);
1118 application.SendNotification();
1120 bool signalReceived(false);
1121 AnimationFinishCheck finishCheck(signalReceived);
1122 animation.FinishedSignal().Connect(&application, finishCheck);
1123 application.SendNotification();
1125 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1126 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1128 //Trying to set the current cursor outside the range [0..1] is ignored
1129 animation.SetCurrentProgress( -1.0f);
1130 application.SendNotification();
1131 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1133 animation.SetCurrentProgress( 100.0f);
1134 application.SendNotification();
1135 DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1137 // Start the animation from 40% progress
1138 animation.SetCurrentProgress( 0.4f );
1141 application.SendNotification();
1142 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1144 // We didn't expect the animation to finish yet
1145 application.SendNotification();
1146 finishCheck.CheckSignalNotReceived();
1147 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1148 DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1150 animation.Play(); // Test that calling play has no effect, when animation is already playing
1151 application.SendNotification();
1153 //Set the progress to 70%
1154 animation.SetCurrentProgress( 0.7f );
1155 application.SendNotification();
1156 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1157 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1160 application.SendNotification();
1161 finishCheck.CheckSignalNotReceived();
1162 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1163 DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1167 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1168 // We did expect the animation to finish
1169 application.SendNotification();
1170 finishCheck.CheckSignalReceived();
1171 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1173 // Check that nothing has changed after a couple of buffer swaps
1174 application.Render(0);
1175 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1176 application.Render(0);
1177 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1181 int UtcDaliAnimationPlayRange(void)
1183 TestApplication application;
1185 Actor actor = Actor::New();
1186 Stage::GetCurrent().Add(actor);
1188 // Build the animation
1189 float durationSeconds(1.0f);
1190 Animation animation = Animation::New(durationSeconds);
1191 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1192 KeyFrames keyframes = KeyFrames::New();
1193 keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1194 keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1196 animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
1198 // Set range between 0.4 and 0.8
1199 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1202 bool signalReceived(false);
1203 AnimationFinishCheck finishCheck(signalReceived);
1204 animation.FinishedSignal().Connect(&application, finishCheck);
1206 //Test that setting progress outside the range doesn't work
1207 animation.SetCurrentProgress( 0.9f );
1208 application.SendNotification();
1209 application.Render(0);
1210 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1211 animation.SetCurrentProgress( 0.2f );
1212 application.SendNotification();
1213 application.Render(0);
1214 DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1216 application.SendNotification();
1217 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1219 // We didn't expect the animation to finish yet
1220 application.SendNotification();
1221 finishCheck.CheckSignalNotReceived();
1222 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1224 animation.Play(); // Test that calling play has no effect, when animation is already playing
1225 application.SendNotification();
1226 application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1228 // We did expect the animation to finish
1229 application.SendNotification();
1230 finishCheck.CheckSignalReceived();
1231 DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1233 // Check that nothing has changed after a couple of buffer swaps
1234 application.Render(0);
1235 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1236 application.Render(0);
1237 DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1240 //Loop inside the range
1241 finishCheck.Reset();
1242 animation.SetLooping( true );
1244 application.SendNotification();
1245 float intervalSeconds = 0.1f;
1246 float progress = 0.4f;
1247 for (int iterations = 0; iterations < 10; ++iterations )
1249 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1251 progress += intervalSeconds;
1252 if (progress > 0.8f)
1254 progress = progress - 0.4f;
1257 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1260 // We didn't expect the animation to finish yet
1261 application.SendNotification();
1262 finishCheck.CheckSignalNotReceived();
1265 //Test change range on the fly
1266 animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1267 application.SendNotification();
1269 for (int iterations = 0; iterations < 10; ++iterations )
1271 application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1273 progress += intervalSeconds;
1274 if (progress > 0.9f)
1276 progress = progress - 0.7f;
1279 DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1285 int UtcDaliAnimationSetPlayRange(void)
1287 TestApplication application;
1289 Actor actor = Actor::New();
1290 Stage::GetCurrent().Add(actor);
1292 // Build the animation
1293 Animation animation = Animation::New(0);
1294 application.SendNotification();
1296 //If PlayRange not specified it should be 0.0-1.0 by default
1297 DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
1299 //PlayRange out of bounds
1300 animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1301 application.SendNotification();
1302 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1303 animation.SetPlayRange( Vector2(0.0f,2.0f) );
1304 application.SendNotification();
1305 DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1307 //If playRange is not in the correct order it has to be ordered
1308 animation.SetPlayRange( Vector2(0.8f,0.2f) );
1309 application.SendNotification();
1310 DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1312 // Set range between 0.4 and 0.8
1313 animation.SetPlayRange( Vector2(0.4f,0.8f) );
1314 application.SendNotification();
1315 DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1320 int UtcDaliAnimationPause(void)
1322 TestApplication application;
1324 Actor actor = Actor::New();
1325 Stage::GetCurrent().Add(actor);
1327 // Build the animation
1328 float durationSeconds(1.0f);
1329 Animation animation = Animation::New(durationSeconds);
1330 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1331 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1333 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1335 // Start the animation
1338 bool signalReceived(false);
1339 AnimationFinishCheck finishCheck(signalReceived);
1340 animation.FinishedSignal().Connect(&application, finishCheck);
1342 application.SendNotification();
1343 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1345 // We didn't expect the animation to finish yet
1346 application.SendNotification();
1347 finishCheck.CheckSignalNotReceived();
1348 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1350 // Pause the animation
1352 application.SendNotification();
1355 for (int i=0; i<5; ++i)
1357 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1359 // We didn't expect the animation to finish yet
1360 application.SendNotification();
1361 finishCheck.CheckSignalNotReceived();
1362 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1367 application.SendNotification();
1368 application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1370 // We didn't expect the animation to finish yet
1371 application.SendNotification();
1372 finishCheck.CheckSignalNotReceived();
1374 application.SendNotification();
1375 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1377 // We did expect the animation to finish
1378 application.SendNotification();
1379 finishCheck.CheckSignalReceived();
1380 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1382 // Check that nothing has changed after a couple of buffer swaps
1383 application.Render(0);
1384 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1385 application.Render(0);
1386 DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1390 int UtcDaliAnimationStop(void)
1392 TestApplication application;
1394 Actor actor = Actor::New();
1395 Stage::GetCurrent().Add(actor);
1397 // Build the animation
1398 float durationSeconds(1.0f);
1399 Animation animation = Animation::New(durationSeconds);
1400 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1401 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1403 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1405 // Start the animation
1408 bool signalReceived(false);
1409 AnimationFinishCheck finishCheck(signalReceived);
1410 animation.FinishedSignal().Connect(&application, finishCheck);
1412 application.SendNotification();
1413 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1415 // We didn't expect the animation to finish yet
1416 application.SendNotification();
1417 finishCheck.CheckSignalNotReceived();
1418 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1420 // Stop the animation
1422 application.SendNotification();
1425 for (int i=0; i<5; ++i)
1427 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1429 // We did expect the animation to finish
1430 application.SendNotification();
1431 finishCheck.CheckSignalReceived();
1432 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1437 int UtcDaliAnimationStopSetPosition(void)
1439 // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1440 // i.e. to check that the animation does not interfere with the position set.
1442 TestApplication application;
1444 Actor actor = Actor::New();
1445 Stage::GetCurrent().Add(actor);
1447 // Build the animation
1448 float durationSeconds(1.0f);
1449 Animation animation = Animation::New(durationSeconds);
1450 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1451 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1453 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1455 // Start the animation
1458 bool signalReceived(false);
1459 AnimationFinishCheck finishCheck(signalReceived);
1460 animation.FinishedSignal().Connect(&application, finishCheck);
1462 application.SendNotification();
1463 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1465 // We didn't expect the animation to finish yet
1466 application.SendNotification();
1467 finishCheck.CheckSignalNotReceived();
1468 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1470 // Stop the animation
1472 Vector3 positionSet(2.0f, 3.0f, 4.0f);
1473 actor.SetPosition(positionSet);
1474 application.SendNotification();
1477 for (int i=0; i<5; ++i)
1479 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1481 // We did expect the animation to finish
1482 application.SendNotification();
1483 finishCheck.CheckSignalReceived();
1484 DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1489 int UtcDaliAnimationClear(void)
1491 TestApplication application;
1493 Actor actor = Actor::New();
1494 Stage::GetCurrent().Add(actor);
1496 // Build the animation
1497 float durationSeconds(1.0f);
1498 Animation animation = Animation::New(durationSeconds);
1499 Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1500 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1502 Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1504 // Start the animation
1507 bool signalReceived(false);
1508 AnimationFinishCheck finishCheck(signalReceived);
1509 animation.FinishedSignal().Connect(&application, finishCheck);
1511 application.SendNotification();
1512 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1514 // We didn't expect the animation to finish yet
1515 application.SendNotification();
1516 finishCheck.CheckSignalNotReceived();
1517 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1519 // Clear the animation
1521 application.SendNotification();
1523 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1525 // We don't expect the animation to finish now
1526 application.SendNotification();
1527 finishCheck.CheckSignalNotReceived();
1528 DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1530 // Restart as a scale animation; this should not move the actor's position
1531 finishCheck.Reset();
1532 actor.SetPosition(Vector3::ZERO);
1533 Vector3 targetScale(3.0f, 3.0f, 3.0f);
1534 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1537 application.SendNotification();
1538 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1540 // We didn't expect the animation to finish yet
1541 application.SendNotification();
1542 finishCheck.CheckSignalNotReceived();
1543 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1544 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1546 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1548 // We did expect the animation to finish
1549 application.SendNotification();
1550 finishCheck.CheckSignalReceived();
1551 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1552 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1556 int UtcDaliAnimationSignalFinish(void)
1558 TestApplication application;
1560 // Start the empty animation
1561 float durationSeconds(1.0f);
1562 Animation animation = Animation::New(durationSeconds);
1565 bool signalReceived(false);
1566 AnimationFinishCheck finishCheck(signalReceived);
1567 animation.FinishedSignal().Connect(&application, finishCheck);
1569 application.SendNotification();
1570 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1572 // We did expect the animation to finish
1573 application.SendNotification();
1574 finishCheck.CheckSignalReceived();
1578 int UtcDaliAnimationAnimateByBoolean(void)
1580 TestApplication application;
1582 Actor actor = Actor::New();
1584 // Register a boolean property
1585 bool startValue(false);
1586 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1587 Stage::GetCurrent().Add(actor);
1588 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1590 // Build the animation
1591 float durationSeconds(2.0f);
1592 Animation animation = Animation::New(durationSeconds);
1593 const bool relativeValue(true);
1594 const bool finalValue( false || relativeValue );
1595 animation.AnimateBy(Property(actor, index), relativeValue);
1597 // Start the animation
1600 bool signalReceived(false);
1601 AnimationFinishCheck finishCheck(signalReceived);
1602 animation.FinishedSignal().Connect(&application, finishCheck);
1604 application.SendNotification();
1605 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1607 // We didn't expect the animation to finish yet
1608 application.SendNotification();
1609 finishCheck.CheckSignalNotReceived();
1610 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1612 application.SendNotification();
1613 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1615 // We did expect the animation to finish
1616 application.SendNotification();
1617 finishCheck.CheckSignalReceived();
1618 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1620 // Check that nothing has changed after a couple of buffer swaps
1621 application.Render(0);
1622 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1623 application.Render(0);
1624 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1626 // Repeat with relative value "false" - this should be an NOOP
1627 animation = Animation::New(durationSeconds);
1628 bool noOpValue(false);
1629 animation.AnimateBy(Property(actor, index), noOpValue);
1631 // Start the animation
1634 finishCheck.Reset();
1635 animation.FinishedSignal().Connect(&application, finishCheck);
1637 application.SendNotification();
1638 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1640 // We didn't expect the animation to finish yet
1641 application.SendNotification();
1642 finishCheck.CheckSignalNotReceived();
1643 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1645 application.SendNotification();
1646 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1648 // We did expect the animation to finish
1649 application.SendNotification();
1650 finishCheck.CheckSignalReceived();
1651 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1653 // Check that nothing has changed after a couple of buffer swaps
1654 application.Render(0);
1655 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1656 application.Render(0);
1657 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1661 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1663 TestApplication application;
1665 Actor actor = Actor::New();
1667 // Register a boolean property
1668 bool startValue(false);
1669 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1670 Stage::GetCurrent().Add(actor);
1671 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1673 // Build the animation
1674 float durationSeconds(2.0f);
1675 Animation animation = Animation::New(durationSeconds);
1676 bool relativeValue(true);
1677 bool finalValue( false || relativeValue );
1678 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1680 // Start the animation
1683 bool signalReceived(false);
1684 AnimationFinishCheck finishCheck(signalReceived);
1685 animation.FinishedSignal().Connect(&application, finishCheck);
1687 application.SendNotification();
1688 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1690 // We didn't expect the animation to finish yet
1691 application.SendNotification();
1692 finishCheck.CheckSignalNotReceived();
1693 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1695 application.SendNotification();
1696 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1698 // We did expect the animation to finish
1699 application.SendNotification();
1700 finishCheck.CheckSignalReceived();
1701 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1703 // Check that nothing has changed after a couple of buffer swaps
1704 application.Render(0);
1705 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1706 application.Render(0);
1707 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1709 // Repeat with relative value "false" - this should be an NOOP
1710 animation = Animation::New(durationSeconds);
1711 bool noOpValue(false);
1712 animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1714 // Start the animation
1717 finishCheck.Reset();
1718 animation.FinishedSignal().Connect(&application, finishCheck);
1720 application.SendNotification();
1721 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1723 // We didn't expect the animation to finish yet
1724 application.SendNotification();
1725 finishCheck.CheckSignalNotReceived();
1726 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1728 application.SendNotification();
1729 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1731 // We did expect the animation to finish
1732 application.SendNotification();
1733 finishCheck.CheckSignalReceived();
1734 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1738 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1740 TestApplication application;
1742 Actor actor = Actor::New();
1744 // Register a boolean property
1745 bool startValue(false);
1746 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1747 Stage::GetCurrent().Add(actor);
1748 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1750 // Build the animation
1751 float durationSeconds(2.0f);
1752 Animation animation = Animation::New(durationSeconds);
1753 bool relativeValue(true);
1754 bool finalValue( false || relativeValue );
1755 float animatorDurationSeconds(durationSeconds * 0.5f);
1756 animation.AnimateBy( Property(actor, index),
1758 TimePeriod( animatorDurationSeconds ) );
1760 // Start the animation
1763 bool signalReceived(false);
1764 AnimationFinishCheck finishCheck(signalReceived);
1765 animation.FinishedSignal().Connect(&application, finishCheck);
1767 application.SendNotification();
1768 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1770 // We didn't expect the animation to finish yet
1771 application.SendNotification();
1772 finishCheck.CheckSignalNotReceived();
1773 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1775 application.SendNotification();
1776 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1778 // We didn't expect the animation to finish yet...
1779 application.SendNotification();
1780 finishCheck.CheckSignalNotReceived();
1782 // ...however we should have reached the final value
1783 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1785 application.SendNotification();
1786 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1788 // We did expect the animation to finish
1789 application.SendNotification();
1790 finishCheck.CheckSignalReceived();
1791 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1793 // Check that nothing has changed after a couple of buffer swaps
1794 application.Render(0);
1795 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1796 application.Render(0);
1797 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1801 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 // Register a boolean property
1808 bool startValue(false);
1809 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1810 Stage::GetCurrent().Add(actor);
1811 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1813 // Build the animation
1814 float durationSeconds(2.0f);
1815 Animation animation = Animation::New(durationSeconds);
1816 bool relativeValue(true);
1817 bool finalValue( false || relativeValue );
1818 float animatorDurationSeconds(durationSeconds * 0.5f);
1819 animation.AnimateBy( Property(actor, index),
1821 AlphaFunctions::EaseInOut,
1822 TimePeriod( animatorDurationSeconds ) );
1824 // Start the animation
1827 bool signalReceived(false);
1828 AnimationFinishCheck finishCheck(signalReceived);
1829 animation.FinishedSignal().Connect(&application, finishCheck);
1831 application.SendNotification();
1832 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1834 // We didn't expect the animation to finish yet
1835 application.SendNotification();
1836 finishCheck.CheckSignalNotReceived();
1837 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1839 application.SendNotification();
1840 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1842 // We didn't expect the animation to finish yet...
1843 application.SendNotification();
1844 finishCheck.CheckSignalNotReceived();
1846 // ...however we should have reached the final value
1847 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1849 application.SendNotification();
1850 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1852 // We did expect the animation to finish
1853 application.SendNotification();
1854 finishCheck.CheckSignalReceived();
1855 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1857 // Check that nothing has changed after a couple of buffer swaps
1858 application.Render(0);
1859 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1860 application.Render(0);
1861 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1865 int UtcDaliAnimationAnimateByFloat(void)
1867 TestApplication application;
1869 Actor actor = Actor::New();
1871 // Register a float property
1872 float startValue(10.0f);
1873 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1874 Stage::GetCurrent().Add(actor);
1875 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1877 // Build the animation
1878 float durationSeconds(2.0f);
1879 Animation animation = Animation::New(durationSeconds);
1880 float targetValue(50.0f);
1881 float relativeValue(targetValue - startValue);
1882 animation.AnimateBy(Property(actor, index), relativeValue);
1884 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1886 // Start the animation
1889 bool signalReceived(false);
1890 AnimationFinishCheck finishCheck(signalReceived);
1891 animation.FinishedSignal().Connect(&application, finishCheck);
1893 application.SendNotification();
1894 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1896 // We didn't expect the animation to finish yet
1897 application.SendNotification();
1898 finishCheck.CheckSignalNotReceived();
1899 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
1901 application.SendNotification();
1902 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1904 // We did expect the animation to finish
1905 application.SendNotification();
1906 finishCheck.CheckSignalReceived();
1907 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1909 // Check that nothing has changed after a couple of buffer swaps
1910 application.Render(0);
1911 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1912 application.Render(0);
1913 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1917 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
1919 TestApplication application;
1921 Actor actor = Actor::New();
1923 // Register a float property
1924 float startValue(10.0f);
1925 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1926 Stage::GetCurrent().Add(actor);
1927 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1929 // Build the animation
1930 float durationSeconds(1.0f);
1931 Animation animation = Animation::New(durationSeconds);
1932 float targetValue(90.0f);
1933 float relativeValue(targetValue - startValue);
1934 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
1936 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
1938 // Start the animation
1941 bool signalReceived(false);
1942 AnimationFinishCheck finishCheck(signalReceived);
1943 animation.FinishedSignal().Connect(&application, finishCheck);
1945 application.SendNotification();
1946 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1948 // We didn't expect the animation to finish yet
1949 application.SendNotification();
1950 finishCheck.CheckSignalNotReceived();
1952 // The position should have moved more, than with a linear alpha function
1953 float current(actor.GetProperty<float>(index));
1954 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
1956 application.SendNotification();
1957 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1959 // We did expect the animation to finish
1960 application.SendNotification();
1961 finishCheck.CheckSignalReceived();
1962 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1964 // Check that nothing has changed after a couple of buffer swaps
1965 application.Render(0);
1966 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1967 application.Render(0);
1968 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
1972 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
1974 TestApplication application;
1976 Actor actor = Actor::New();
1978 // Register a float property
1979 float startValue(10.0f);
1980 Property::Index index = actor.RegisterProperty( "test-property", startValue );
1981 Stage::GetCurrent().Add(actor);
1982 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1984 // Build the animation
1985 float durationSeconds(1.0f);
1986 Animation animation = Animation::New(durationSeconds);
1987 float targetValue(30.0f);
1988 float relativeValue(targetValue - startValue);
1990 animation.AnimateBy(Property(actor, index),
1992 TimePeriod(delay, durationSeconds - delay));
1994 // Start the animation
1997 bool signalReceived(false);
1998 AnimationFinishCheck finishCheck(signalReceived);
1999 animation.FinishedSignal().Connect(&application, finishCheck);
2001 application.SendNotification();
2002 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2004 // We didn't expect the animation to finish yet
2005 application.SendNotification();
2006 finishCheck.CheckSignalNotReceived();
2007 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2009 application.SendNotification();
2010 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2012 // We didn't expect the animation to finish yet
2013 application.SendNotification();
2014 finishCheck.CheckSignalNotReceived();
2015 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2017 application.SendNotification();
2018 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2020 // We did expect the animation to finish
2021 application.SendNotification();
2022 finishCheck.CheckSignalReceived();
2023 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2025 // Check that nothing has changed after a couple of buffer swaps
2026 application.Render(0);
2027 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2028 application.Render(0);
2029 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2033 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
2035 TestApplication application;
2037 Actor actor = Actor::New();
2039 // Register a float property
2040 float startValue(10.0f);
2041 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2042 Stage::GetCurrent().Add(actor);
2043 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2045 // Build the animation
2046 float durationSeconds(1.0f);
2047 Animation animation = Animation::New(durationSeconds);
2048 float targetValue(30.0f);
2049 float relativeValue(targetValue - startValue);
2051 animation.AnimateBy(Property(actor, index),
2053 AlphaFunctions::Linear,
2054 TimePeriod(delay, durationSeconds - delay));
2056 // Start the animation
2059 bool signalReceived(false);
2060 AnimationFinishCheck finishCheck(signalReceived);
2061 animation.FinishedSignal().Connect(&application, finishCheck);
2063 application.SendNotification();
2064 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2066 // We didn't expect the animation to finish yet
2067 application.SendNotification();
2068 finishCheck.CheckSignalNotReceived();
2069 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2071 application.SendNotification();
2072 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2074 // We didn't expect the animation to finish yet
2075 application.SendNotification();
2076 finishCheck.CheckSignalNotReceived();
2077 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2079 application.SendNotification();
2080 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2082 // We did expect the animation to finish
2083 application.SendNotification();
2084 finishCheck.CheckSignalReceived();
2085 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2087 // Check that nothing has changed after a couple of buffer swaps
2088 application.Render(0);
2089 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2090 application.Render(0);
2091 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2095 int UtcDaliAnimationAnimateByInteger(void)
2097 TestApplication application;
2099 Actor actor = Actor::New();
2101 // Register an integer property
2103 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2104 Stage::GetCurrent().Add(actor);
2105 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2107 // Build the animation
2108 float durationSeconds(2.0f);
2109 Animation animation = Animation::New(durationSeconds);
2110 int targetValue(50);
2111 int relativeValue(targetValue - startValue);
2112 animation.AnimateBy(Property(actor, index), relativeValue);
2114 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2116 // Start the animation
2119 bool signalReceived(false);
2120 AnimationFinishCheck finishCheck(signalReceived);
2121 animation.FinishedSignal().Connect(&application, finishCheck);
2123 application.SendNotification();
2124 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2126 // We didn't expect the animation to finish yet
2127 application.SendNotification();
2128 finishCheck.CheckSignalNotReceived();
2129 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2131 application.SendNotification();
2132 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2134 // We did expect the animation to finish
2135 application.SendNotification();
2136 finishCheck.CheckSignalReceived();
2137 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2139 // Check that nothing has changed after a couple of buffer swaps
2140 application.Render(0);
2141 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2142 application.Render(0);
2143 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2147 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2149 TestApplication application;
2151 Actor actor = Actor::New();
2153 // Register an integer property
2155 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2156 Stage::GetCurrent().Add(actor);
2157 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2159 // Build the animation
2160 float durationSeconds(1.0f);
2161 Animation animation = Animation::New(durationSeconds);
2162 int targetValue(90);
2163 int relativeValue(targetValue - startValue);
2164 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2166 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2168 // Start the animation
2171 bool signalReceived(false);
2172 AnimationFinishCheck finishCheck(signalReceived);
2173 animation.FinishedSignal().Connect(&application, finishCheck);
2175 application.SendNotification();
2176 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2178 // We didn't expect the animation to finish yet
2179 application.SendNotification();
2180 finishCheck.CheckSignalNotReceived();
2182 // The position should have moved more, than with a linear alpha function
2183 int current(actor.GetProperty<int>(index));
2184 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2186 application.SendNotification();
2187 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2189 // We did expect the animation to finish
2190 application.SendNotification();
2191 finishCheck.CheckSignalReceived();
2192 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2194 // Check that nothing has changed after a couple of buffer swaps
2195 application.Render(0);
2196 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2197 application.Render(0);
2198 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2202 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2204 TestApplication application;
2206 Actor actor = Actor::New();
2208 // Register an integer property
2210 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2211 Stage::GetCurrent().Add(actor);
2212 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2214 // Build the animation
2215 float durationSeconds(1.0f);
2216 Animation animation = Animation::New(durationSeconds);
2217 int targetValue(30);
2218 int relativeValue(targetValue - startValue);
2220 animation.AnimateBy(Property(actor, index),
2222 TimePeriod(delay, durationSeconds - delay));
2224 // Start the animation
2227 bool signalReceived(false);
2228 AnimationFinishCheck finishCheck(signalReceived);
2229 animation.FinishedSignal().Connect(&application, finishCheck);
2231 application.SendNotification();
2232 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2234 // We didn't expect the animation to finish yet
2235 application.SendNotification();
2236 finishCheck.CheckSignalNotReceived();
2237 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2239 application.SendNotification();
2240 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2242 // We didn't expect the animation to finish yet
2243 application.SendNotification();
2244 finishCheck.CheckSignalNotReceived();
2245 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2247 application.SendNotification();
2248 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2250 // We did expect the animation to finish
2251 application.SendNotification();
2252 finishCheck.CheckSignalReceived();
2253 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2255 // Check that nothing has changed after a couple of buffer swaps
2256 application.Render(0);
2257 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2258 application.Render(0);
2259 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2263 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2265 TestApplication application;
2267 Actor actor = Actor::New();
2269 // Register an integer property
2271 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2272 Stage::GetCurrent().Add(actor);
2273 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2275 // Build the animation
2276 float durationSeconds(1.0f);
2277 Animation animation = Animation::New(durationSeconds);
2278 int targetValue(30);
2279 int relativeValue(targetValue - startValue);
2281 animation.AnimateBy(Property(actor, index),
2283 AlphaFunctions::Linear,
2284 TimePeriod(delay, durationSeconds - delay));
2286 // Start the animation
2289 bool signalReceived(false);
2290 AnimationFinishCheck finishCheck(signalReceived);
2291 animation.FinishedSignal().Connect(&application, finishCheck);
2293 application.SendNotification();
2294 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2296 // We didn't expect the animation to finish yet
2297 application.SendNotification();
2298 finishCheck.CheckSignalNotReceived();
2299 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2301 application.SendNotification();
2302 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2304 // We didn't expect the animation to finish yet
2305 application.SendNotification();
2306 finishCheck.CheckSignalNotReceived();
2307 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2309 application.SendNotification();
2310 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2312 // We did expect the animation to finish
2313 application.SendNotification();
2314 finishCheck.CheckSignalReceived();
2315 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2317 // Check that nothing has changed after a couple of buffer swaps
2318 application.Render(0);
2319 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2320 application.Render(0);
2321 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2325 int UtcDaliAnimationAnimateByVector2(void)
2327 TestApplication application;
2329 Actor actor = Actor::New();
2331 // Register a Vector2 property
2332 Vector2 startValue(10.0f, 10.0f);
2333 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2334 Stage::GetCurrent().Add(actor);
2335 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2337 // Build the animation
2338 float durationSeconds(2.0f);
2339 Animation animation = Animation::New(durationSeconds);
2340 Vector2 targetValue(60.0f, 60.0f);
2341 Vector2 relativeValue(targetValue - startValue);
2342 animation.AnimateBy(Property(actor, index), relativeValue);
2344 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2346 // Start the animation
2349 bool signalReceived(false);
2350 AnimationFinishCheck finishCheck(signalReceived);
2351 animation.FinishedSignal().Connect(&application, finishCheck);
2353 application.SendNotification();
2354 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2356 // We didn't expect the animation to finish yet
2357 application.SendNotification();
2358 finishCheck.CheckSignalNotReceived();
2359 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2361 application.SendNotification();
2362 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2364 // We did expect the animation to finish
2365 application.SendNotification();
2366 finishCheck.CheckSignalReceived();
2367 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2369 // Check that nothing has changed after a couple of buffer swaps
2370 application.Render(0);
2371 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2372 application.Render(0);
2373 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2377 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2379 TestApplication application;
2381 Actor actor = Actor::New();
2383 // Register a Vector2 property
2384 Vector2 startValue(100.0f, 100.0f);
2385 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2386 Stage::GetCurrent().Add(actor);
2387 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2389 // Build the animation
2390 float durationSeconds(1.0f);
2391 Animation animation = Animation::New(durationSeconds);
2392 Vector2 targetValue(20.0f, 20.0f);
2393 Vector2 relativeValue(targetValue - startValue);
2394 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2396 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2398 // Start the animation
2401 bool signalReceived(false);
2402 AnimationFinishCheck finishCheck(signalReceived);
2403 animation.FinishedSignal().Connect(&application, finishCheck);
2405 application.SendNotification();
2406 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2408 // We didn't expect the animation to finish yet
2409 application.SendNotification();
2410 finishCheck.CheckSignalNotReceived();
2412 // The position should have moved more, than with a linear alpha function
2413 Vector2 current(actor.GetProperty<Vector2>(index));
2414 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2415 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2417 application.SendNotification();
2418 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2420 // We did expect the animation to finish
2421 application.SendNotification();
2422 finishCheck.CheckSignalReceived();
2423 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2425 // Check that nothing has changed after a couple of buffer swaps
2426 application.Render(0);
2427 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2428 application.Render(0);
2429 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2433 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2435 TestApplication application;
2437 Actor actor = Actor::New();
2439 // Register a Vector2 property
2440 Vector2 startValue(10.0f, 10.0f);
2441 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2442 Stage::GetCurrent().Add(actor);
2443 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2445 // Build the animation
2446 float durationSeconds(1.0f);
2447 Animation animation = Animation::New(durationSeconds);
2448 Vector2 targetValue(30.0f, 30.0f);
2449 Vector2 relativeValue(targetValue - startValue);
2451 animation.AnimateBy(Property(actor, index),
2453 TimePeriod(delay, durationSeconds - delay));
2455 // Start the animation
2458 bool signalReceived(false);
2459 AnimationFinishCheck finishCheck(signalReceived);
2460 animation.FinishedSignal().Connect(&application, finishCheck);
2462 application.SendNotification();
2463 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2465 // We didn't expect the animation to finish yet
2466 application.SendNotification();
2467 finishCheck.CheckSignalNotReceived();
2468 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2470 application.SendNotification();
2471 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2473 // We didn't expect the animation to finish yet
2474 application.SendNotification();
2475 finishCheck.CheckSignalNotReceived();
2476 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2478 application.SendNotification();
2479 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2481 // We did expect the animation to finish
2482 application.SendNotification();
2483 finishCheck.CheckSignalReceived();
2484 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2486 // Check that nothing has changed after a couple of buffer swaps
2487 application.Render(0);
2488 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2489 application.Render(0);
2490 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2494 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2496 TestApplication application;
2498 Actor actor = Actor::New();
2500 // Register a Vector2 property
2501 Vector2 startValue(5.0f, 5.0f);
2502 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2503 Stage::GetCurrent().Add(actor);
2504 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2506 // Build the animation
2507 float durationSeconds(1.0f);
2508 Animation animation = Animation::New(durationSeconds);
2509 Vector2 targetValue(10.0f, 10.0f);
2510 Vector2 relativeValue(targetValue - startValue);
2512 animation.AnimateBy(Property(actor, index),
2514 AlphaFunctions::Linear,
2515 TimePeriod(delay, durationSeconds - delay));
2517 // Start the animation
2520 bool signalReceived(false);
2521 AnimationFinishCheck finishCheck(signalReceived);
2522 animation.FinishedSignal().Connect(&application, finishCheck);
2524 application.SendNotification();
2525 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2527 // We didn't expect the animation to finish yet
2528 application.SendNotification();
2529 finishCheck.CheckSignalNotReceived();
2530 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2532 application.SendNotification();
2533 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2535 // We didn't expect the animation to finish yet
2536 application.SendNotification();
2537 finishCheck.CheckSignalNotReceived();
2538 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2540 application.SendNotification();
2541 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2543 // We did expect the animation to finish
2544 application.SendNotification();
2545 finishCheck.CheckSignalReceived();
2546 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2548 // Check that nothing has changed after a couple of buffer swaps
2549 application.Render(0);
2550 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2551 application.Render(0);
2552 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2556 int UtcDaliAnimationAnimateByVector3(void)
2558 TestApplication application;
2560 Actor actor = Actor::New();
2562 // Register a Vector3 property
2563 Vector3 startValue(10.0f, 10.0f, 10.0f);
2564 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2565 Stage::GetCurrent().Add(actor);
2566 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2568 // Build the animation
2569 float durationSeconds(2.0f);
2570 Animation animation = Animation::New(durationSeconds);
2571 Vector3 targetValue(60.0f, 60.0f, 60.0f);
2572 Vector3 relativeValue(targetValue - startValue);
2573 animation.AnimateBy(Property(actor, index), relativeValue);
2575 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2577 // Start the animation
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*950.0f)/* 95% progress */);
2587 // We didn't expect the animation to finish yet
2588 application.SendNotification();
2589 finishCheck.CheckSignalNotReceived();
2590 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2592 application.SendNotification();
2593 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2595 // We did expect the animation to finish
2596 application.SendNotification();
2597 finishCheck.CheckSignalReceived();
2598 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2600 // Check that nothing has changed after a couple of buffer swaps
2601 application.Render(0);
2602 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2603 application.Render(0);
2604 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2608 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2610 TestApplication application;
2612 Actor actor = Actor::New();
2614 // Register a Vector3 property
2615 Vector3 startValue(100.0f, 100.0f, 100.0f);
2616 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2617 Stage::GetCurrent().Add(actor);
2618 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2620 // Build the animation
2621 float durationSeconds(1.0f);
2622 Animation animation = Animation::New(durationSeconds);
2623 Vector3 targetValue(20.0f, 20.0f, 20.0f);
2624 Vector3 relativeValue(targetValue - startValue);
2625 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2627 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2629 // Start the animation
2632 bool signalReceived(false);
2633 AnimationFinishCheck finishCheck(signalReceived);
2634 animation.FinishedSignal().Connect(&application, finishCheck);
2636 application.SendNotification();
2637 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2639 // We didn't expect the animation to finish yet
2640 application.SendNotification();
2641 finishCheck.CheckSignalNotReceived();
2643 // The position should have moved more, than with a linear alpha function
2644 Vector3 current(actor.GetProperty<Vector3>(index));
2645 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2646 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2647 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2649 application.SendNotification();
2650 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2652 // We did expect the animation to finish
2653 application.SendNotification();
2654 finishCheck.CheckSignalReceived();
2655 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2657 // Check that nothing has changed after a couple of buffer swaps
2658 application.Render(0);
2659 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2660 application.Render(0);
2661 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2665 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2667 TestApplication application;
2669 Actor actor = Actor::New();
2671 // Register a Vector3 property
2672 Vector3 startValue(10.0f, 10.0f, 10.0f);
2673 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2674 Stage::GetCurrent().Add(actor);
2675 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2677 // Build the animation
2678 float durationSeconds(1.0f);
2679 Animation animation = Animation::New(durationSeconds);
2680 Vector3 targetValue(30.0f, 30.0f, 30.0f);
2681 Vector3 relativeValue(targetValue - startValue);
2683 animation.AnimateBy(Property(actor, index),
2685 TimePeriod(delay, durationSeconds - delay));
2687 // Start the animation
2690 bool signalReceived(false);
2691 AnimationFinishCheck finishCheck(signalReceived);
2692 animation.FinishedSignal().Connect(&application, finishCheck);
2694 application.SendNotification();
2695 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2697 // We didn't expect the animation to finish yet
2698 application.SendNotification();
2699 finishCheck.CheckSignalNotReceived();
2700 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2702 application.SendNotification();
2703 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2705 // We didn't expect the animation to finish yet
2706 application.SendNotification();
2707 finishCheck.CheckSignalNotReceived();
2708 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2710 application.SendNotification();
2711 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2713 // We did expect the animation to finish
2714 application.SendNotification();
2715 finishCheck.CheckSignalReceived();
2716 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2718 // Check that nothing has changed after a couple of buffer swaps
2719 application.Render(0);
2720 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2721 application.Render(0);
2722 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2726 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2728 TestApplication application;
2730 Actor actor = Actor::New();
2732 // Register a Vector3 property
2733 Vector3 startValue(5.0f, 5.0f, 5.0f);
2734 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2735 Stage::GetCurrent().Add(actor);
2736 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2738 // Build the animation
2739 float durationSeconds(1.0f);
2740 Animation animation = Animation::New(durationSeconds);
2741 Vector3 targetValue(10.0f, 10.0f, 10.0f);
2742 Vector3 relativeValue(targetValue - startValue);
2744 animation.AnimateBy(Property(actor, index),
2746 AlphaFunctions::Linear,
2747 TimePeriod(delay, durationSeconds - delay));
2749 // Start the animation
2752 bool signalReceived(false);
2753 AnimationFinishCheck finishCheck(signalReceived);
2754 animation.FinishedSignal().Connect(&application, finishCheck);
2756 application.SendNotification();
2757 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2759 // We didn't expect the animation to finish yet
2760 application.SendNotification();
2761 finishCheck.CheckSignalNotReceived();
2762 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2764 application.SendNotification();
2765 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2767 // We didn't expect the animation to finish yet
2768 application.SendNotification();
2769 finishCheck.CheckSignalNotReceived();
2770 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2772 application.SendNotification();
2773 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2775 // We did expect the animation to finish
2776 application.SendNotification();
2777 finishCheck.CheckSignalReceived();
2778 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2780 // Check that nothing has changed after a couple of buffer swaps
2781 application.Render(0);
2782 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2783 application.Render(0);
2784 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2788 int UtcDaliAnimationAnimateByVector4(void)
2790 TestApplication application;
2792 Actor actor = Actor::New();
2794 // Register a Vector4 property
2795 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2796 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2797 Stage::GetCurrent().Add(actor);
2798 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2800 // Build the animation
2801 float durationSeconds(2.0f);
2802 Animation animation = Animation::New(durationSeconds);
2803 Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2804 Vector4 relativeValue(targetValue - startValue);
2805 animation.AnimateBy(Property(actor, index), relativeValue);
2807 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2809 // Start the animation
2812 bool signalReceived(false);
2813 AnimationFinishCheck finishCheck(signalReceived);
2814 animation.FinishedSignal().Connect(&application, finishCheck);
2816 application.SendNotification();
2817 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2819 // We didn't expect the animation to finish yet
2820 application.SendNotification();
2821 finishCheck.CheckSignalNotReceived();
2822 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2824 application.SendNotification();
2825 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2827 // We did expect the animation to finish
2828 application.SendNotification();
2829 finishCheck.CheckSignalReceived();
2830 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2832 // Check that nothing has changed after a couple of buffer swaps
2833 application.Render(0);
2834 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2835 application.Render(0);
2836 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2840 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2842 TestApplication application;
2844 Actor actor = Actor::New();
2846 // Register a Vector4 property
2847 Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2848 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2849 Stage::GetCurrent().Add(actor);
2850 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2852 // Build the animation
2853 float durationSeconds(1.0f);
2854 Animation animation = Animation::New(durationSeconds);
2855 Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2856 Vector4 relativeValue(targetValue - startValue);
2857 animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2859 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2861 // Start the animation
2864 bool signalReceived(false);
2865 AnimationFinishCheck finishCheck(signalReceived);
2866 animation.FinishedSignal().Connect(&application, finishCheck);
2868 application.SendNotification();
2869 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2871 // We didn't expect the animation to finish yet
2872 application.SendNotification();
2873 finishCheck.CheckSignalNotReceived();
2875 // The position should have moved more, than with a linear alpha function
2876 Vector4 current(actor.GetProperty<Vector4>(index));
2877 DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2878 DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2879 DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2880 DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
2882 application.SendNotification();
2883 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2885 // We did expect the animation to finish
2886 application.SendNotification();
2887 finishCheck.CheckSignalReceived();
2888 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2890 // Check that nothing has changed after a couple of buffer swaps
2891 application.Render(0);
2892 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2893 application.Render(0);
2894 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2898 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
2900 TestApplication application;
2902 Actor actor = Actor::New();
2904 // Register a Vector4 property
2905 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2906 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2907 Stage::GetCurrent().Add(actor);
2908 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2910 // Build the animation
2911 float durationSeconds(1.0f);
2912 Animation animation = Animation::New(durationSeconds);
2913 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
2914 Vector4 relativeValue(targetValue - startValue);
2916 animation.AnimateBy(Property(actor, index),
2918 TimePeriod(delay, durationSeconds - delay));
2920 // Start the animation
2923 bool signalReceived(false);
2924 AnimationFinishCheck finishCheck(signalReceived);
2925 animation.FinishedSignal().Connect(&application, finishCheck);
2927 application.SendNotification();
2928 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2930 // We didn't expect the animation to finish yet
2931 application.SendNotification();
2932 finishCheck.CheckSignalNotReceived();
2933 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2935 application.SendNotification();
2936 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2938 // We didn't expect the animation to finish yet
2939 application.SendNotification();
2940 finishCheck.CheckSignalNotReceived();
2941 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2943 application.SendNotification();
2944 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2946 // We did expect the animation to finish
2947 application.SendNotification();
2948 finishCheck.CheckSignalReceived();
2949 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2951 // Check that nothing has changed after a couple of buffer swaps
2952 application.Render(0);
2953 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2954 application.Render(0);
2955 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2959 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
2961 TestApplication application;
2963 Actor actor = Actor::New();
2965 // Register a Vector4 property
2966 Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
2967 Property::Index index = actor.RegisterProperty( "test-property", startValue );
2968 Stage::GetCurrent().Add(actor);
2969 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2971 // Build the animation
2972 float durationSeconds(1.0f);
2973 Animation animation = Animation::New(durationSeconds);
2974 Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
2975 Vector4 relativeValue(targetValue - startValue);
2977 animation.AnimateBy(Property(actor, index),
2979 AlphaFunctions::Linear,
2980 TimePeriod(delay, durationSeconds - delay));
2982 // Start the animation
2985 bool signalReceived(false);
2986 AnimationFinishCheck finishCheck(signalReceived);
2987 animation.FinishedSignal().Connect(&application, finishCheck);
2989 application.SendNotification();
2990 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2992 // We didn't expect the animation to finish yet
2993 application.SendNotification();
2994 finishCheck.CheckSignalNotReceived();
2995 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2997 application.SendNotification();
2998 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3000 // We didn't expect the animation to finish yet
3001 application.SendNotification();
3002 finishCheck.CheckSignalNotReceived();
3003 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3005 application.SendNotification();
3006 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3008 // We did expect the animation to finish
3009 application.SendNotification();
3010 finishCheck.CheckSignalReceived();
3011 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3013 // Check that nothing has changed after a couple of buffer swaps
3014 application.Render(0);
3015 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3016 application.Render(0);
3017 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3021 int UtcDaliAnimationAnimateByActorPosition(void)
3023 TestApplication application;
3025 Actor actor = Actor::New();
3026 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3027 actor.SetPosition(startPosition);
3028 Stage::GetCurrent().Add(actor);
3029 application.SendNotification();
3030 application.Render(0);
3031 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3033 // Build the animation
3034 float durationSeconds(1.0f);
3035 Animation animation = Animation::New(durationSeconds);
3036 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3037 Vector3 relativePosition(targetPosition - startPosition);
3038 animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
3040 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3042 // Start the animation
3045 bool signalReceived(false);
3046 AnimationFinishCheck finishCheck(signalReceived);
3047 animation.FinishedSignal().Connect(&application, finishCheck);
3049 application.SendNotification();
3050 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3052 // We didn't expect the animation to finish yet
3053 application.SendNotification();
3054 finishCheck.CheckSignalNotReceived();
3055 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3057 application.SendNotification();
3058 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3060 // We did expect the animation to finish
3061 application.SendNotification();
3062 finishCheck.CheckSignalReceived();
3063 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3065 // Check that nothing has changed after a couple of buffer swaps
3066 application.Render(0);
3067 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3068 application.Render(0);
3069 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3073 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
3075 TestApplication application;
3077 Actor actor = Actor::New();
3078 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3079 actor.SetPosition(startPosition);
3080 Stage::GetCurrent().Add(actor);
3081 application.SendNotification();
3082 application.Render(0);
3083 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3085 // Build the animation
3086 float durationSeconds(1.0f);
3087 Animation animation = Animation::New(durationSeconds);
3088 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3089 Vector3 relativePosition(targetPosition - startPosition);
3090 animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunctions::EaseOut);
3092 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3094 // Start the animation
3097 bool signalReceived(false);
3098 AnimationFinishCheck finishCheck(signalReceived);
3099 animation.FinishedSignal().Connect(&application, finishCheck);
3101 application.SendNotification();
3102 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3104 // We didn't expect the animation to finish yet
3105 application.SendNotification();
3106 finishCheck.CheckSignalNotReceived();
3108 // The position should have moved more, than with a linear alpha function
3109 Vector3 current(actor.GetCurrentPosition());
3110 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3111 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3112 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3114 application.SendNotification();
3115 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3117 // We did expect the animation to finish
3118 application.SendNotification();
3119 finishCheck.CheckSignalReceived();
3120 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3122 // Check that nothing has changed after a couple of buffer swaps
3123 application.Render(0);
3124 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3125 application.Render(0);
3126 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3130 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3132 TestApplication application;
3134 Actor actor = Actor::New();
3135 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3136 actor.SetPosition(startPosition);
3137 Stage::GetCurrent().Add(actor);
3138 application.SendNotification();
3139 application.Render(0);
3140 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3142 // Build the animation
3143 float durationSeconds(1.0f);
3144 Animation animation = Animation::New(durationSeconds);
3145 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3146 Vector3 relativePosition(targetPosition - startPosition);
3148 animation.AnimateBy(Property(actor, Actor::Property::POSITION),
3150 TimePeriod(delay, durationSeconds - delay));
3152 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3154 // Start the animation
3157 bool signalReceived(false);
3158 AnimationFinishCheck finishCheck(signalReceived);
3159 animation.FinishedSignal().Connect(&application, finishCheck);
3161 application.SendNotification();
3162 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3164 // We didn't expect the animation to finish yet
3165 application.SendNotification();
3166 finishCheck.CheckSignalNotReceived();
3167 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3169 application.SendNotification();
3170 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3172 // We did expect the animation to finish
3173 application.SendNotification();
3174 finishCheck.CheckSignalReceived();
3175 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3177 // Check that nothing has changed after a couple of buffer swaps
3178 application.Render(0);
3179 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3180 application.Render(0);
3181 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3185 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3187 TestApplication application;
3189 Actor actor = Actor::New();
3190 Vector3 startPosition(10.0f, 10.0f, 10.0f);
3191 actor.SetPosition(startPosition);
3192 Stage::GetCurrent().Add(actor);
3193 application.SendNotification();
3194 application.Render(0);
3195 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3197 // Build the animation
3198 float durationSeconds(1.0f);
3199 Animation animation = Animation::New(durationSeconds);
3200 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3201 Vector3 relativePosition(targetPosition - startPosition);
3203 animation.AnimateBy(Property(actor, Actor::Property::POSITION),
3205 AlphaFunctions::Linear,
3206 TimePeriod(delay, durationSeconds - delay));
3208 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3210 // Start the animation
3213 bool signalReceived(false);
3214 AnimationFinishCheck finishCheck(signalReceived);
3215 animation.FinishedSignal().Connect(&application, finishCheck);
3217 application.SendNotification();
3218 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3220 // We didn't expect the animation to finish yet
3221 application.SendNotification();
3222 finishCheck.CheckSignalNotReceived();
3223 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3225 application.SendNotification();
3226 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3228 // We did expect the animation to finish
3229 application.SendNotification();
3230 finishCheck.CheckSignalReceived();
3231 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3233 // Check that nothing has changed after a couple of buffer swaps
3234 application.Render(0);
3235 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3236 application.Render(0);
3237 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3241 int UtcDaliAnimationAnimateToBoolean(void)
3243 TestApplication application;
3245 Actor actor = Actor::New();
3247 // Register a boolean property
3248 const bool startValue(false);
3249 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3250 Stage::GetCurrent().Add(actor);
3251 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3253 // Build the animation
3254 float durationSeconds(2.0f);
3255 Animation animation = Animation::New(durationSeconds);
3256 const bool targetValue( !startValue );
3257 animation.AnimateTo(Property(actor, index), targetValue);
3259 // Start the animation
3262 bool signalReceived(false);
3263 AnimationFinishCheck finishCheck(signalReceived);
3264 animation.FinishedSignal().Connect(&application, finishCheck);
3266 application.SendNotification();
3267 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3269 // We didn't expect the animation to finish yet
3270 application.SendNotification();
3271 finishCheck.CheckSignalNotReceived();
3272 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3274 application.SendNotification();
3275 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3277 // We did expect the animation to finish
3278 application.SendNotification();
3279 finishCheck.CheckSignalReceived();
3280 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3282 // Check that nothing has changed after a couple of buffer swaps
3283 application.Render(0);
3284 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3285 application.Render(0);
3286 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3288 // Repeat with target value "false"
3289 animation = Animation::New(durationSeconds);
3290 const bool finalValue( !targetValue );
3291 animation.AnimateTo(Property(actor, index), finalValue);
3293 // Start the animation
3296 finishCheck.Reset();
3297 animation.FinishedSignal().Connect(&application, finishCheck);
3299 application.SendNotification();
3300 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3302 // We didn't expect the animation to finish yet
3303 application.SendNotification();
3304 finishCheck.CheckSignalNotReceived();
3305 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3307 application.SendNotification();
3308 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3310 // We did expect the animation to finish
3311 application.SendNotification();
3312 finishCheck.CheckSignalReceived();
3313 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3315 // Check that nothing has changed after a couple of buffer swaps
3316 application.Render(0);
3317 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3318 application.Render(0);
3319 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3323 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3325 TestApplication application;
3327 Actor actor = Actor::New();
3329 // Register a boolean property
3330 const bool startValue(false);
3331 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3332 Stage::GetCurrent().Add(actor);
3333 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3335 // Build the animation
3336 float durationSeconds(2.0f);
3337 Animation animation = Animation::New(durationSeconds);
3338 const bool targetValue( !startValue );
3339 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3341 // Start the animation
3344 bool signalReceived(false);
3345 AnimationFinishCheck finishCheck(signalReceived);
3346 animation.FinishedSignal().Connect(&application, finishCheck);
3348 application.SendNotification();
3349 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3351 // We didn't expect the animation to finish yet
3352 application.SendNotification();
3353 finishCheck.CheckSignalNotReceived();
3354 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3356 application.SendNotification();
3357 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3359 // We did expect the animation to finish
3360 application.SendNotification();
3361 finishCheck.CheckSignalReceived();
3362 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3364 // Check that nothing has changed after a couple of buffer swaps
3365 application.Render(0);
3366 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3367 application.Render(0);
3368 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3370 // Repeat with target value "false"
3371 animation = Animation::New(durationSeconds);
3372 const bool finalValue( !targetValue );
3373 animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3375 // Start the animation
3378 finishCheck.Reset();
3379 animation.FinishedSignal().Connect(&application, finishCheck);
3381 application.SendNotification();
3382 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3384 // We didn't expect the animation to finish yet
3385 application.SendNotification();
3386 finishCheck.CheckSignalNotReceived();
3387 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3389 application.SendNotification();
3390 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3392 // We did expect the animation to finish
3393 application.SendNotification();
3394 finishCheck.CheckSignalReceived();
3395 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3397 // Check that nothing has changed after a couple of buffer swaps
3398 application.Render(0);
3399 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3400 application.Render(0);
3401 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3405 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3407 TestApplication application;
3409 Actor actor = Actor::New();
3411 // Register a boolean property
3412 bool startValue(false);
3413 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3414 Stage::GetCurrent().Add(actor);
3415 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3417 // Build the animation
3418 float durationSeconds(2.0f);
3419 Animation animation = Animation::New(durationSeconds);
3420 bool finalValue( !startValue );
3421 float animatorDurationSeconds(durationSeconds * 0.5f);
3422 animation.AnimateTo( Property(actor, index),
3424 TimePeriod( animatorDurationSeconds ) );
3426 // Start the animation
3429 bool signalReceived(false);
3430 AnimationFinishCheck finishCheck(signalReceived);
3431 animation.FinishedSignal().Connect(&application, finishCheck);
3433 application.SendNotification();
3434 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3436 // We didn't expect the animation to finish yet
3437 application.SendNotification();
3438 finishCheck.CheckSignalNotReceived();
3439 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3441 application.SendNotification();
3442 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3444 // We didn't expect the animation to finish yet...
3445 application.SendNotification();
3446 finishCheck.CheckSignalNotReceived();
3448 // ...however we should have reached the final value
3449 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3451 application.SendNotification();
3452 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3454 // We did expect the animation to finish
3455 application.SendNotification();
3456 finishCheck.CheckSignalReceived();
3457 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3459 // Check that nothing has changed after a couple of buffer swaps
3460 application.Render(0);
3461 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3462 application.Render(0);
3463 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3467 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3469 TestApplication application;
3471 Actor actor = Actor::New();
3473 // Register a boolean property
3474 bool startValue(false);
3475 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3476 Stage::GetCurrent().Add(actor);
3477 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3479 // Build the animation
3480 float durationSeconds(2.0f);
3481 Animation animation = Animation::New(durationSeconds);
3482 bool finalValue( !startValue );
3483 float animatorDurationSeconds(durationSeconds * 0.5f);
3484 animation.AnimateTo( Property(actor, index),
3486 AlphaFunctions::Linear,
3487 TimePeriod( animatorDurationSeconds ) );
3489 // Start the animation
3492 bool signalReceived(false);
3493 AnimationFinishCheck finishCheck(signalReceived);
3494 animation.FinishedSignal().Connect(&application, finishCheck);
3496 application.SendNotification();
3497 application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3499 // We didn't expect the animation to finish yet
3500 application.SendNotification();
3501 finishCheck.CheckSignalNotReceived();
3502 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3504 application.SendNotification();
3505 application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3507 // We didn't expect the animation to finish yet...
3508 application.SendNotification();
3509 finishCheck.CheckSignalNotReceived();
3511 // ...however we should have reached the final value
3512 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3514 application.SendNotification();
3515 application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3517 // We did expect the animation to finish
3518 application.SendNotification();
3519 finishCheck.CheckSignalReceived();
3520 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3522 // Check that nothing has changed after a couple of buffer swaps
3523 application.Render(0);
3524 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3525 application.Render(0);
3526 DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3530 int UtcDaliAnimationAnimateToFloat(void)
3532 TestApplication application;
3534 Actor actor = Actor::New();
3536 // Register a float property
3537 float startValue(10.0f);
3538 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3539 Stage::GetCurrent().Add(actor);
3540 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3542 // Build the animation
3543 float durationSeconds(2.0f);
3544 Animation animation = Animation::New(durationSeconds);
3545 float targetValue(50.0f);
3546 float relativeValue(targetValue - startValue);
3547 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3549 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3551 // Start the animation
3554 bool signalReceived(false);
3555 AnimationFinishCheck finishCheck(signalReceived);
3556 animation.FinishedSignal().Connect(&application, finishCheck);
3558 application.SendNotification();
3559 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3561 // We didn't expect the animation to finish yet
3562 application.SendNotification();
3563 finishCheck.CheckSignalNotReceived();
3564 DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3566 application.SendNotification();
3567 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3569 // We did expect the animation to finish
3570 application.SendNotification();
3571 finishCheck.CheckSignalReceived();
3572 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3576 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3578 TestApplication application;
3580 Actor actor = Actor::New();
3582 // Register a float property
3583 float startValue(10.0f);
3584 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3585 Stage::GetCurrent().Add(actor);
3586 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3588 // Build the animation
3589 float durationSeconds(1.0f);
3590 Animation animation = Animation::New(durationSeconds);
3591 float targetValue(90.0f);
3592 float relativeValue(targetValue - startValue);
3593 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3595 float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3597 // Start the animation
3600 bool signalReceived(false);
3601 AnimationFinishCheck finishCheck(signalReceived);
3602 animation.FinishedSignal().Connect(&application, finishCheck);
3604 application.SendNotification();
3605 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3607 // We didn't expect the animation to finish yet
3608 application.SendNotification();
3609 finishCheck.CheckSignalNotReceived();
3611 // The position should have moved more, than with a linear alpha function
3612 float current(actor.GetProperty<float>(index));
3613 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3615 application.SendNotification();
3616 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3618 // We did expect the animation to finish
3619 application.SendNotification();
3620 finishCheck.CheckSignalReceived();
3621 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3625 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3627 TestApplication application;
3629 Actor actor = Actor::New();
3631 // Register a float property
3632 float startValue(10.0f);
3633 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3634 Stage::GetCurrent().Add(actor);
3635 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3637 // Build the animation
3638 float durationSeconds(1.0f);
3639 Animation animation = Animation::New(durationSeconds);
3640 float targetValue(30.0f);
3641 float relativeValue(targetValue - startValue);
3643 animation.AnimateTo(Property(actor, index),
3645 TimePeriod(delay, durationSeconds - delay));
3647 // Start the animation
3650 bool signalReceived(false);
3651 AnimationFinishCheck finishCheck(signalReceived);
3652 animation.FinishedSignal().Connect(&application, finishCheck);
3654 application.SendNotification();
3655 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3657 // We didn't expect the animation to finish yet
3658 application.SendNotification();
3659 finishCheck.CheckSignalNotReceived();
3660 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3662 application.SendNotification();
3663 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3665 // We didn't expect the animation to finish yet
3666 application.SendNotification();
3667 finishCheck.CheckSignalNotReceived();
3668 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3670 application.SendNotification();
3671 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3673 // We did expect the animation to finish
3674 application.SendNotification();
3675 finishCheck.CheckSignalReceived();
3676 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3680 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3682 TestApplication application;
3684 Actor actor = Actor::New();
3686 // Register a float property
3687 float startValue(10.0f);
3688 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3689 Stage::GetCurrent().Add(actor);
3690 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3692 // Build the animation
3693 float durationSeconds(1.0f);
3694 Animation animation = Animation::New(durationSeconds);
3695 float targetValue(30.0f);
3696 float relativeValue(targetValue - startValue);
3698 animation.AnimateTo(Property(actor, index),
3700 AlphaFunctions::Linear,
3701 TimePeriod(delay, durationSeconds - delay));
3703 // Start the animation
3706 bool signalReceived(false);
3707 AnimationFinishCheck finishCheck(signalReceived);
3708 animation.FinishedSignal().Connect(&application, finishCheck);
3710 application.SendNotification();
3711 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3713 // We didn't expect the animation to finish yet
3714 application.SendNotification();
3715 finishCheck.CheckSignalNotReceived();
3716 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3718 application.SendNotification();
3719 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3721 // We didn't expect the animation to finish yet
3722 application.SendNotification();
3723 finishCheck.CheckSignalNotReceived();
3724 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3726 application.SendNotification();
3727 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3729 // We did expect the animation to finish
3730 application.SendNotification();
3731 finishCheck.CheckSignalReceived();
3732 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3736 int UtcDaliAnimationAnimateToInteger(void)
3738 TestApplication application;
3740 Actor actor = Actor::New();
3742 // Register an integer property
3744 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3745 Stage::GetCurrent().Add(actor);
3746 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3748 // Build the animation
3749 float durationSeconds(2.0f);
3750 Animation animation = Animation::New(durationSeconds);
3751 int targetValue(50);
3752 int relativeValue(targetValue - startValue);
3753 animation.AnimateTo(Property(actor, "test-property"), targetValue);
3755 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3757 // Start the animation
3760 bool signalReceived(false);
3761 AnimationFinishCheck finishCheck(signalReceived);
3762 animation.FinishedSignal().Connect(&application, finishCheck);
3764 application.SendNotification();
3765 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3767 // We didn't expect the animation to finish yet
3768 application.SendNotification();
3769 finishCheck.CheckSignalNotReceived();
3770 DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3772 application.SendNotification();
3773 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3775 // We did expect the animation to finish
3776 application.SendNotification();
3777 finishCheck.CheckSignalReceived();
3778 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3782 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3784 TestApplication application;
3786 Actor actor = Actor::New();
3788 // Register an integer property
3790 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3791 Stage::GetCurrent().Add(actor);
3792 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3794 // Build the animation
3795 float durationSeconds(1.0f);
3796 Animation animation = Animation::New(durationSeconds);
3797 int targetValue(90);
3798 int relativeValue(targetValue - startValue);
3799 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3801 int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3803 // Start the animation
3806 bool signalReceived(false);
3807 AnimationFinishCheck finishCheck(signalReceived);
3808 animation.FinishedSignal().Connect(&application, finishCheck);
3810 application.SendNotification();
3811 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3813 // We didn't expect the animation to finish yet
3814 application.SendNotification();
3815 finishCheck.CheckSignalNotReceived();
3817 // The position should have moved more, than with a linear alpha function
3818 int current(actor.GetProperty<int>(index));
3819 DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3821 application.SendNotification();
3822 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3824 // We did expect the animation to finish
3825 application.SendNotification();
3826 finishCheck.CheckSignalReceived();
3827 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3831 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3833 TestApplication application;
3835 Actor actor = Actor::New();
3837 // Register an integer property
3839 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3840 Stage::GetCurrent().Add(actor);
3841 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3843 // Build the animation
3844 float durationSeconds(1.0f);
3845 Animation animation = Animation::New(durationSeconds);
3846 int targetValue(30);
3847 int relativeValue(targetValue - startValue);
3849 animation.AnimateTo(Property(actor, index),
3851 TimePeriod(delay, durationSeconds - delay));
3853 // Start the animation
3856 bool signalReceived(false);
3857 AnimationFinishCheck finishCheck(signalReceived);
3858 animation.FinishedSignal().Connect(&application, finishCheck);
3860 application.SendNotification();
3861 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3863 // We didn't expect the animation to finish yet
3864 application.SendNotification();
3865 finishCheck.CheckSignalNotReceived();
3866 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3868 application.SendNotification();
3869 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3871 // We didn't expect the animation to finish yet
3872 application.SendNotification();
3873 finishCheck.CheckSignalNotReceived();
3874 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3876 application.SendNotification();
3877 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3879 // We did expect the animation to finish
3880 application.SendNotification();
3881 finishCheck.CheckSignalReceived();
3882 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3886 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
3888 TestApplication application;
3890 Actor actor = Actor::New();
3892 // Register an integer property
3894 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3895 Stage::GetCurrent().Add(actor);
3896 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3898 // Build the animation
3899 float durationSeconds(1.0f);
3900 Animation animation = Animation::New(durationSeconds);
3901 int targetValue(30);
3902 int relativeValue(targetValue - startValue);
3904 animation.AnimateTo(Property(actor, index),
3906 AlphaFunctions::Linear,
3907 TimePeriod(delay, durationSeconds - delay));
3909 // Start the animation
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*500.0f)/* 50% animation progress, 0% animator progress */);
3919 // We didn't expect the animation to finish yet
3920 application.SendNotification();
3921 finishCheck.CheckSignalNotReceived();
3922 DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3924 application.SendNotification();
3925 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3927 // We didn't expect the animation to finish yet
3928 application.SendNotification();
3929 finishCheck.CheckSignalNotReceived();
3930 DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3932 application.SendNotification();
3933 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3935 // We did expect the animation to finish
3936 application.SendNotification();
3937 finishCheck.CheckSignalReceived();
3938 DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3942 int UtcDaliAnimationAnimateToVector2(void)
3944 TestApplication application;
3946 Actor actor = Actor::New();
3948 // Register a Vector2 property
3949 Vector2 startValue(-50.0f, -50.0f);
3950 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3951 Stage::GetCurrent().Add(actor);
3952 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3954 // Build the animation
3955 float durationSeconds(2.0f);
3956 Animation animation = Animation::New(durationSeconds);
3957 Vector2 targetValue(50.0f, 50.0f);
3958 Vector2 relativeValue(targetValue - startValue);
3959 animation.AnimateTo(Property(actor, index), targetValue);
3961 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3963 // Start the animation
3966 bool signalReceived(false);
3967 AnimationFinishCheck finishCheck(signalReceived);
3968 animation.FinishedSignal().Connect(&application, finishCheck);
3970 application.SendNotification();
3971 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3973 // We didn't expect the animation to finish yet
3974 application.SendNotification();
3975 finishCheck.CheckSignalNotReceived();
3976 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3978 application.SendNotification();
3979 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3981 // We did expect the animation to finish
3982 application.SendNotification();
3983 finishCheck.CheckSignalReceived();
3984 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3988 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
3990 TestApplication application;
3992 Actor actor = Actor::New();
3994 // Register a Vector2 property
3995 Vector2 startValue(1000.0f, 1000.0f);
3996 Property::Index index = actor.RegisterProperty( "test-property", startValue );
3997 Stage::GetCurrent().Add(actor);
3998 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4000 // Build the animation
4001 float durationSeconds(1.0f);
4002 Animation animation = Animation::New(durationSeconds);
4003 Vector2 targetValue(9000.0f, 9000.0f);
4004 Vector2 relativeValue(targetValue - startValue);
4005 animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
4007 Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4009 // Start the animation
4012 bool signalReceived(false);
4013 AnimationFinishCheck finishCheck(signalReceived);
4014 animation.FinishedSignal().Connect(&application, finishCheck);
4016 application.SendNotification();
4017 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4019 // We didn't expect the animation to finish yet
4020 application.SendNotification();
4021 finishCheck.CheckSignalNotReceived();
4023 // The position should have moved more, than with a linear alpha function
4024 Vector2 current(actor.GetProperty<Vector2>(index));
4025 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4026 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4028 application.SendNotification();
4029 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4031 // We did expect the animation to finish
4032 application.SendNotification();
4033 finishCheck.CheckSignalReceived();
4034 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4038 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
4040 TestApplication application;
4042 Actor actor = Actor::New();
4044 // Register a Vector2 property
4045 Vector2 startValue(10.0f, 10.0f);
4046 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4047 Stage::GetCurrent().Add(actor);
4048 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4050 // Build the animation
4051 float durationSeconds(1.0f);
4052 Animation animation = Animation::New(durationSeconds);
4053 Vector2 targetValue(-10.0f, 20.0f);
4054 Vector2 relativeValue(targetValue - startValue);
4056 animation.AnimateTo(Property(actor, index),
4058 TimePeriod(delay, durationSeconds - delay));
4060 // Start the animation
4063 bool signalReceived(false);
4064 AnimationFinishCheck finishCheck(signalReceived);
4065 animation.FinishedSignal().Connect(&application, finishCheck);
4067 application.SendNotification();
4068 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4070 // We didn't expect the animation to finish yet
4071 application.SendNotification();
4072 finishCheck.CheckSignalNotReceived();
4073 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4075 application.SendNotification();
4076 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4078 // We didn't expect the animation to finish yet
4079 application.SendNotification();
4080 finishCheck.CheckSignalNotReceived();
4081 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4083 application.SendNotification();
4084 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4086 // We did expect the animation to finish
4087 application.SendNotification();
4088 finishCheck.CheckSignalReceived();
4089 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4093 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
4095 TestApplication application;
4097 Actor actor = Actor::New();
4099 // Register a Vector2 property
4100 Vector2 startValue(10.0f, 10.0f);
4101 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4102 Stage::GetCurrent().Add(actor);
4103 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4105 // Build the animation
4106 float durationSeconds(1.0f);
4107 Animation animation = Animation::New(durationSeconds);
4108 Vector2 targetValue(30.0f, 30.0f);
4109 Vector2 relativeValue(targetValue - startValue);
4111 animation.AnimateTo(Property(actor, index),
4113 AlphaFunctions::Linear,
4114 TimePeriod(delay, durationSeconds - delay));
4116 // Start the animation
4119 bool signalReceived(false);
4120 AnimationFinishCheck finishCheck(signalReceived);
4121 animation.FinishedSignal().Connect(&application, finishCheck);
4123 application.SendNotification();
4124 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4126 // We didn't expect the animation to finish yet
4127 application.SendNotification();
4128 finishCheck.CheckSignalNotReceived();
4129 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4131 application.SendNotification();
4132 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4134 // We didn't expect the animation to finish yet
4135 application.SendNotification();
4136 finishCheck.CheckSignalNotReceived();
4137 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4139 application.SendNotification();
4140 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4142 // We did expect the animation to finish
4143 application.SendNotification();
4144 finishCheck.CheckSignalReceived();
4145 DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4149 int UtcDaliAnimationAnimateToVector3(void)
4151 TestApplication application;
4153 Actor actor = Actor::New();
4155 // Register a Vector3 property
4156 Vector3 startValue(-50.0f, -50.0f, -50.0f);
4157 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4158 Stage::GetCurrent().Add(actor);
4159 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4161 // Build the animation
4162 float durationSeconds(2.0f);
4163 Animation animation = Animation::New(durationSeconds);
4164 Vector3 targetValue(50.0f, 50.0f, 50.0f);
4165 Vector3 relativeValue(targetValue - startValue);
4166 animation.AnimateTo(Property(actor, index), targetValue);
4168 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4170 // Start the animation
4173 bool signalReceived(false);
4174 AnimationFinishCheck finishCheck(signalReceived);
4175 animation.FinishedSignal().Connect(&application, finishCheck);
4177 application.SendNotification();
4178 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4180 // We didn't expect the animation to finish yet
4181 application.SendNotification();
4182 finishCheck.CheckSignalNotReceived();
4183 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4185 application.SendNotification();
4186 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4188 // We did expect the animation to finish
4189 application.SendNotification();
4190 finishCheck.CheckSignalReceived();
4191 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4195 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4197 TestApplication application;
4199 Actor actor = Actor::New();
4201 // Register a Vector3 property
4202 Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4203 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4204 Stage::GetCurrent().Add(actor);
4205 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4207 // Build the animation
4208 float durationSeconds(1.0f);
4209 Animation animation = Animation::New(durationSeconds);
4210 Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4211 Vector3 relativeValue(targetValue - startValue);
4212 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4214 Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4216 // Start the animation
4219 bool signalReceived(false);
4220 AnimationFinishCheck finishCheck(signalReceived);
4221 animation.FinishedSignal().Connect(&application, finishCheck);
4223 application.SendNotification();
4224 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4226 // We didn't expect the animation to finish yet
4227 application.SendNotification();
4228 finishCheck.CheckSignalNotReceived();
4230 // The position should have moved more, than with a linear alpha function
4231 Vector3 current(actor.GetProperty<Vector3>(index));
4232 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4233 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4234 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4236 application.SendNotification();
4237 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4239 // We did expect the animation to finish
4240 application.SendNotification();
4241 finishCheck.CheckSignalReceived();
4242 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4246 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4248 TestApplication application;
4250 Actor actor = Actor::New();
4252 // Register a Vector3 property
4253 Vector3 startValue(10.0f, 10.0f, 10.0f);
4254 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4255 Stage::GetCurrent().Add(actor);
4256 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4258 // Build the animation
4259 float durationSeconds(1.0f);
4260 Animation animation = Animation::New(durationSeconds);
4261 Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4262 Vector3 relativeValue(targetValue - startValue);
4264 animation.AnimateTo(Property(actor, index),
4266 TimePeriod(delay, durationSeconds - delay));
4268 // Start the animation
4271 bool signalReceived(false);
4272 AnimationFinishCheck finishCheck(signalReceived);
4273 animation.FinishedSignal().Connect(&application, finishCheck);
4275 application.SendNotification();
4276 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4278 // We didn't expect the animation to finish yet
4279 application.SendNotification();
4280 finishCheck.CheckSignalNotReceived();
4281 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4283 application.SendNotification();
4284 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4286 // We didn't expect the animation to finish yet
4287 application.SendNotification();
4288 finishCheck.CheckSignalNotReceived();
4289 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4291 application.SendNotification();
4292 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4294 // We did expect the animation to finish
4295 application.SendNotification();
4296 finishCheck.CheckSignalReceived();
4297 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4301 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4303 TestApplication application;
4305 Actor actor = Actor::New();
4307 // Register a Vector3 property
4308 Vector3 startValue(10.0f, 10.0f, 10.0f);
4309 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4310 Stage::GetCurrent().Add(actor);
4311 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4313 // Build the animation
4314 float durationSeconds(1.0f);
4315 Animation animation = Animation::New(durationSeconds);
4316 Vector3 targetValue(30.0f, 30.0f, 30.0f);
4317 Vector3 relativeValue(targetValue - startValue);
4319 animation.AnimateTo(Property(actor, "test-property"),
4321 AlphaFunctions::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.GetProperty<Vector3>(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.GetProperty<Vector3>(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.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4357 int UtcDaliAnimationAnimateToVector3Component(void)
4359 TestApplication application;
4361 Actor actor = Actor::New();
4363 // Register a Vector3 property
4364 Vector3 startValue(10.0f, 10.0f, 10.0f);
4365 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4366 Stage::GetCurrent().Add(actor);
4367 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4369 // Build the animation
4370 float durationSeconds(1.0f);
4371 Animation animation = Animation::New(durationSeconds);
4372 Vector3 targetValue(30.0f, 30.0f, 10.0f);
4373 Vector3 relativeValue(targetValue - startValue);
4375 animation.AnimateTo(Property(actor, "test-property", 0),
4377 AlphaFunctions::Linear,
4378 TimePeriod(delay, durationSeconds - delay));
4379 animation.AnimateTo(Property(actor, index, 1),
4381 AlphaFunctions::Linear,
4382 TimePeriod(delay, durationSeconds - delay));
4384 // Start the animation
4387 bool signalReceived(false);
4388 AnimationFinishCheck finishCheck(signalReceived);
4389 animation.FinishedSignal().Connect(&application, finishCheck);
4391 application.SendNotification();
4392 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4394 // We didn't expect the animation to finish yet
4395 application.SendNotification();
4396 finishCheck.CheckSignalNotReceived();
4397 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4399 application.SendNotification();
4400 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4402 // We didn't expect the animation to finish yet
4403 application.SendNotification();
4404 finishCheck.CheckSignalNotReceived();
4405 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4407 application.SendNotification();
4408 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4410 // We did expect the animation to finish
4411 application.SendNotification();
4412 finishCheck.CheckSignalReceived();
4413 DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4417 int UtcDaliAnimationAnimateToVector4(void)
4419 TestApplication application;
4421 Actor actor = Actor::New();
4423 // Register a Vector4 property
4424 Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4425 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4426 Stage::GetCurrent().Add(actor);
4427 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4429 // Build the animation
4430 float durationSeconds(2.0f);
4431 Animation animation = Animation::New(durationSeconds);
4432 Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4433 Vector4 relativeValue(targetValue - startValue);
4434 animation.AnimateTo(Property(actor, index), targetValue);
4436 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4438 // Start the animation
4441 bool signalReceived(false);
4442 AnimationFinishCheck finishCheck(signalReceived);
4443 animation.FinishedSignal().Connect(&application, finishCheck);
4445 application.SendNotification();
4446 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4448 // We didn't expect the animation to finish yet
4449 application.SendNotification();
4450 finishCheck.CheckSignalNotReceived();
4451 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4453 application.SendNotification();
4454 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4456 // We did expect the animation to finish
4457 application.SendNotification();
4458 finishCheck.CheckSignalReceived();
4459 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4463 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4465 TestApplication application;
4467 Actor actor = Actor::New();
4469 // Register a Vector4 property
4470 Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4471 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4472 Stage::GetCurrent().Add(actor);
4473 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4475 // Build the animation
4476 float durationSeconds(1.0f);
4477 Animation animation = Animation::New(durationSeconds);
4478 Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4479 Vector4 relativeValue(targetValue - startValue);
4480 animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4482 Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4484 // Start the animation
4487 bool signalReceived(false);
4488 AnimationFinishCheck finishCheck(signalReceived);
4489 animation.FinishedSignal().Connect(&application, finishCheck);
4491 application.SendNotification();
4492 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4494 // We didn't expect the animation to finish yet
4495 application.SendNotification();
4496 finishCheck.CheckSignalNotReceived();
4498 // The position should have moved more, than with a linear alpha function
4499 Vector4 current(actor.GetProperty<Vector4>(index));
4500 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4501 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4502 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4503 DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4505 application.SendNotification();
4506 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4508 // We did expect the animation to finish
4509 application.SendNotification();
4510 finishCheck.CheckSignalReceived();
4511 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4515 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4517 TestApplication application;
4519 Actor actor = Actor::New();
4521 // Register a Vector4 property
4522 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4523 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4524 Stage::GetCurrent().Add(actor);
4525 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4527 // Build the animation
4528 float durationSeconds(1.0f);
4529 Animation animation = Animation::New(durationSeconds);
4530 Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4531 Vector4 relativeValue(targetValue - startValue);
4533 animation.AnimateTo(Property(actor, index),
4535 TimePeriod(delay, durationSeconds - delay));
4537 // Start the animation
4540 bool signalReceived(false);
4541 AnimationFinishCheck finishCheck(signalReceived);
4542 animation.FinishedSignal().Connect(&application, finishCheck);
4544 application.SendNotification();
4545 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4547 // We didn't expect the animation to finish yet
4548 application.SendNotification();
4549 finishCheck.CheckSignalNotReceived();
4550 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4552 application.SendNotification();
4553 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4555 // We didn't expect the animation to finish yet
4556 application.SendNotification();
4557 finishCheck.CheckSignalNotReceived();
4558 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4560 application.SendNotification();
4561 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4563 // We did expect the animation to finish
4564 application.SendNotification();
4565 finishCheck.CheckSignalReceived();
4566 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4570 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4572 TestApplication application;
4574 Actor actor = Actor::New();
4576 // Register a Vector4 property
4577 Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4578 Property::Index index = actor.RegisterProperty( "test-property", startValue );
4579 Stage::GetCurrent().Add(actor);
4580 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4582 // Build the animation
4583 float durationSeconds(1.0f);
4584 Animation animation = Animation::New(durationSeconds);
4585 Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4586 Vector4 relativeValue(targetValue - startValue);
4588 animation.AnimateTo(Property(actor, index),
4590 AlphaFunctions::Linear,
4591 TimePeriod(delay, durationSeconds - delay));
4593 // Start the animation
4596 bool signalReceived(false);
4597 AnimationFinishCheck finishCheck(signalReceived);
4598 animation.FinishedSignal().Connect(&application, finishCheck);
4600 application.SendNotification();
4601 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4603 // We didn't expect the animation to finish yet
4604 application.SendNotification();
4605 finishCheck.CheckSignalNotReceived();
4606 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4608 application.SendNotification();
4609 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4611 // We didn't expect the animation to finish yet
4612 application.SendNotification();
4613 finishCheck.CheckSignalNotReceived();
4614 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4616 application.SendNotification();
4617 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4619 // We did expect the animation to finish
4620 application.SendNotification();
4621 finishCheck.CheckSignalReceived();
4622 DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4626 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4628 TestApplication application;
4630 Actor actor = Actor::New();
4631 Stage::GetCurrent().Add(actor);
4632 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4634 // Build the animation
4635 float durationSeconds(1.0f);
4636 Animation animation = Animation::New(durationSeconds);
4637 Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4641 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
4643 catch (Dali::DaliException& e)
4645 DALI_TEST_PRINT_ASSERT( e );
4646 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4651 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4653 TestApplication application;
4655 Actor actor = Actor::New();
4656 Stage::GetCurrent().Add(actor);
4657 float startValue(0.0f);
4658 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4659 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4661 // Build the animation
4662 float durationSeconds(1.0f);
4663 Animation animation = Animation::New(durationSeconds);
4664 float targetX(1.0f);
4668 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
4670 catch (Dali::DaliException& e)
4672 DALI_TEST_PRINT_ASSERT( e );
4673 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4678 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4680 TestApplication application;
4682 Actor actor = Actor::New();
4683 Stage::GetCurrent().Add(actor);
4684 float startValue(0.0f);
4685 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4686 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4688 // Build the animation
4689 float durationSeconds(1.0f);
4690 Animation animation = Animation::New(durationSeconds);
4691 float targetY(1.0f);
4695 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
4697 catch (Dali::DaliException& e)
4699 DALI_TEST_PRINT_ASSERT( e );
4700 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4705 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4707 TestApplication application;
4709 Actor actor = Actor::New();
4710 Stage::GetCurrent().Add(actor);
4711 float startValue(0.5f);
4712 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4713 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4715 // Build the animation
4716 float durationSeconds(1.0f);
4717 Animation animation = Animation::New(durationSeconds);
4718 float targetZ(1.0f);
4722 animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
4724 catch (Dali::DaliException& e)
4726 DALI_TEST_PRINT_ASSERT( e );
4727 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4732 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4734 TestApplication application;
4736 Actor actor = Actor::New();
4737 Stage::GetCurrent().Add(actor);
4738 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4740 // Build the animation
4741 float durationSeconds(1.0f);
4742 Animation animation = Animation::New(durationSeconds);
4743 Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4747 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
4749 catch (Dali::DaliException& e)
4751 DALI_TEST_PRINT_ASSERT( e );
4752 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4757 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4759 TestApplication application;
4761 Actor actor = Actor::New();
4762 Stage::GetCurrent().Add(actor);
4763 float startValue(0.5f);
4764 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4767 // Build the animation
4768 float durationSeconds(1.0f);
4769 Animation animation = Animation::New(durationSeconds);
4770 float targetX(1.0f);
4774 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
4776 catch (Dali::DaliException& e)
4778 DALI_TEST_PRINT_ASSERT( e );
4779 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4784 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4786 TestApplication application;
4788 Actor actor = Actor::New();
4789 Stage::GetCurrent().Add(actor);
4790 float startValue(0.5f);
4791 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4794 // Build the animation
4795 float durationSeconds(1.0f);
4796 Animation animation = Animation::New(durationSeconds);
4797 float targetY(0.0f);
4801 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
4803 catch (Dali::DaliException& e)
4805 DALI_TEST_PRINT_ASSERT( e );
4806 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4811 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4813 TestApplication application;
4815 Actor actor = Actor::New();
4816 Stage::GetCurrent().Add(actor);
4817 float startValue(0.5f);
4818 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4821 // Build the animation
4822 float durationSeconds(1.0f);
4823 Animation animation = Animation::New(durationSeconds);
4824 float targetZ(100.0f);
4828 animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
4830 catch (Dali::DaliException& e)
4832 DALI_TEST_PRINT_ASSERT( e );
4833 DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4838 int UtcDaliAnimationAnimateToActorSize(void)
4840 TestApplication application;
4842 Actor actor = Actor::New();
4843 Stage::GetCurrent().Add(actor);
4844 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4846 // Build the animation
4847 float durationSeconds(1.0f);
4848 Animation animation = Animation::New(durationSeconds);
4849 Vector3 targetSize(100.0f, 100.0f, 100.0f);
4850 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
4852 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4854 // Start the animation
4857 bool signalReceived(false);
4858 AnimationFinishCheck finishCheck(signalReceived);
4859 animation.FinishedSignal().Connect(&application, finishCheck);
4861 application.SendNotification();
4862 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4864 // We didn't expect the animation to finish yet
4865 application.SendNotification();
4866 finishCheck.CheckSignalNotReceived();
4867 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4869 application.SendNotification();
4870 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4872 // We did expect the animation to finish
4873 application.SendNotification();
4874 finishCheck.CheckSignalReceived();
4875 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4878 finishCheck.Reset();
4879 actor.SetSize(Vector3::ZERO);
4880 application.SendNotification();
4881 application.Render(0);
4882 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4884 // Repeat with a different (ease-in) alpha function
4885 animation = Animation::New(durationSeconds);
4886 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunctions::EaseIn);
4887 animation.FinishedSignal().Connect(&application, finishCheck);
4890 application.SendNotification();
4891 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4893 // We didn't expect the animation to finish yet
4894 application.SendNotification();
4895 finishCheck.CheckSignalNotReceived();
4897 // The size should have travelled less, than with a linear alpha function
4898 Vector3 current(actor.GetCurrentSize());
4899 DALI_TEST_CHECK( current.x > 0.0f );
4900 DALI_TEST_CHECK( current.y > 0.0f );
4901 DALI_TEST_CHECK( current.z > 0.0f );
4902 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4903 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4904 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4906 application.SendNotification();
4907 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4909 // We did expect the animation to finish
4910 application.SendNotification();
4911 finishCheck.CheckSignalReceived();
4912 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4915 finishCheck.Reset();
4916 actor.SetSize(Vector3::ZERO);
4917 application.SendNotification();
4918 application.Render(0);
4919 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4921 // Repeat with a delay
4923 animation = Animation::New(durationSeconds);
4924 animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
4925 animation.FinishedSignal().Connect(&application, finishCheck);
4928 application.SendNotification();
4929 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4931 // We didn't expect the animation to finish yet
4932 application.SendNotification();
4933 finishCheck.CheckSignalNotReceived();
4934 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4936 application.SendNotification();
4937 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4939 // We did expect the animation to finish
4940 application.SendNotification();
4941 finishCheck.CheckSignalReceived();
4942 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
4946 int UtcDaliAnimationAnimateToActorSizeWidth(void)
4948 TestApplication application;
4950 Actor actor = Actor::New();
4951 Stage::GetCurrent().Add(actor);
4952 float startValue(0.0f);
4953 DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
4954 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
4956 // Build the animation
4957 float durationSeconds(1.0f);
4958 Animation animation = Animation::New(durationSeconds);
4959 float targetWidth(10.0f);
4960 animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
4962 float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
4964 // Start the animation
4967 bool signalReceived(false);
4968 AnimationFinishCheck finishCheck(signalReceived);
4969 animation.FinishedSignal().Connect(&application, finishCheck);
4971 application.SendNotification();
4972 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
4974 // We didn't expect the animation to finish yet
4975 application.SendNotification();
4976 finishCheck.CheckSignalNotReceived();
4977 DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
4978 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
4980 application.SendNotification();
4981 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4983 // We did expect the animation to finish
4984 application.SendNotification();
4985 finishCheck.CheckSignalReceived();
4986 DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
4987 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
4991 int UtcDaliAnimationAnimateToActorSizeHeight(void)
4993 TestApplication application;
4995 Actor actor = Actor::New();
4996 Stage::GetCurrent().Add(actor);
4997 float startValue(0.0f);
4998 DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
4999 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
5001 // Build the animation
5002 float durationSeconds(1.0f);
5003 Animation animation = Animation::New(durationSeconds);
5004 float targetHeight(-10.0f);
5005 animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
5007 float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5009 // Start the animation
5012 bool signalReceived(false);
5013 AnimationFinishCheck finishCheck(signalReceived);
5014 animation.FinishedSignal().Connect(&application, finishCheck);
5016 application.SendNotification();
5017 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5019 // We didn't expect the animation to finish yet
5020 application.SendNotification();
5021 finishCheck.CheckSignalNotReceived();
5022 DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5023 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5025 application.SendNotification();
5026 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5028 // We did expect the animation to finish
5029 application.SendNotification();
5030 finishCheck.CheckSignalReceived();
5031 DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5032 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5036 int UtcDaliAnimationAnimateToActorSizeDepth(void)
5038 TestApplication application;
5040 Actor actor = Actor::New();
5041 Stage::GetCurrent().Add(actor);
5042 float startValue(0.0f);
5043 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5044 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
5046 // Build the animation
5047 float durationSeconds(1.0f);
5048 Animation animation = Animation::New(durationSeconds);
5049 float targetDepth(-10.0f);
5050 animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
5052 float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5054 // Start the animation
5057 bool signalReceived(false);
5058 AnimationFinishCheck finishCheck(signalReceived);
5059 animation.FinishedSignal().Connect(&application, finishCheck);
5061 application.SendNotification();
5062 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5064 // We didn't expect the animation to finish yet
5065 application.SendNotification();
5066 finishCheck.CheckSignalNotReceived();
5067 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5068 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5070 application.SendNotification();
5071 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5073 // We did expect the animation to finish
5074 application.SendNotification();
5075 finishCheck.CheckSignalReceived();
5076 DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5077 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5081 int UtcDaliAnimationAnimateToActorPosition(void)
5083 TestApplication application;
5085 Actor actor = Actor::New();
5086 Stage::GetCurrent().Add(actor);
5087 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5089 // Build the animation
5090 float durationSeconds(1.0f);
5091 Animation animation = Animation::New(durationSeconds);
5092 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5093 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
5095 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5097 // Start the animation
5100 bool signalReceived(false);
5101 AnimationFinishCheck finishCheck(signalReceived);
5102 animation.FinishedSignal().Connect(&application, finishCheck);
5104 application.SendNotification();
5105 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5107 // We didn't expect the animation to finish yet
5108 application.SendNotification();
5109 finishCheck.CheckSignalNotReceived();
5110 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5112 application.SendNotification();
5113 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5115 // We did expect the animation to finish
5116 application.SendNotification();
5117 finishCheck.CheckSignalReceived();
5118 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5122 int UtcDaliAnimationAnimateToActorPositionX(void)
5124 TestApplication application;
5126 Actor actor = Actor::New();
5127 Stage::GetCurrent().Add(actor);
5128 float startValue(0.0f);
5129 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5130 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5131 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5132 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5134 // Build the animation
5135 float durationSeconds(1.0f);
5136 Animation animation = Animation::New(durationSeconds);
5137 float targetX(1.0f);
5138 animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
5140 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5142 // Start the animation
5145 bool signalReceived(false);
5146 AnimationFinishCheck finishCheck(signalReceived);
5147 animation.FinishedSignal().Connect(&application, finishCheck);
5149 application.SendNotification();
5150 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5152 // We didn't expect the animation to finish yet
5153 application.SendNotification();
5154 finishCheck.CheckSignalNotReceived();
5155 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5156 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5157 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5158 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5160 application.SendNotification();
5161 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5163 // We did expect the animation to finish
5164 application.SendNotification();
5165 finishCheck.CheckSignalReceived();
5166 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5167 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
5168 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5169 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5173 int UtcDaliAnimationAnimateToActorPositionY(void)
5175 TestApplication application;
5177 Actor actor = Actor::New();
5178 Stage::GetCurrent().Add(actor);
5179 float startValue(0.0f);
5180 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5181 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5182 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5183 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5185 // Build the animation
5186 float durationSeconds(1.0f);
5187 Animation animation = Animation::New(durationSeconds);
5188 float targetY(10.0f);
5189 animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
5191 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5193 // Start the animation
5196 bool signalReceived(false);
5197 AnimationFinishCheck finishCheck(signalReceived);
5198 animation.FinishedSignal().Connect(&application, finishCheck);
5200 application.SendNotification();
5201 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5203 // We didn't expect the animation to finish yet
5204 application.SendNotification();
5205 finishCheck.CheckSignalNotReceived();
5206 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5207 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5208 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5209 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5211 application.SendNotification();
5212 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5214 // We did expect the animation to finish
5215 application.SendNotification();
5216 finishCheck.CheckSignalReceived();
5217 DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5219 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
5220 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5224 int UtcDaliAnimationAnimateToActorPositionZ(void)
5226 TestApplication application;
5228 Actor actor = Actor::New();
5229 Stage::GetCurrent().Add(actor);
5230 float startValue(0.0f);
5231 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5232 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5233 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5234 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5236 // Build the animation
5237 float durationSeconds(1.0f);
5238 Animation animation = Animation::New(durationSeconds);
5239 float targetZ(-5.0f);
5240 animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
5242 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5244 // Start the animation
5247 bool signalReceived(false);
5248 AnimationFinishCheck finishCheck(signalReceived);
5249 animation.FinishedSignal().Connect(&application, finishCheck);
5251 application.SendNotification();
5252 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5254 // We didn't expect the animation to finish yet
5255 application.SendNotification();
5256 finishCheck.CheckSignalNotReceived();
5257 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5258 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5259 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5260 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5262 application.SendNotification();
5263 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5265 // We did expect the animation to finish
5266 application.SendNotification();
5267 finishCheck.CheckSignalReceived();
5268 DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5269 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5270 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
5275 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5277 TestApplication application;
5279 Actor actor = Actor::New();
5280 Stage::GetCurrent().Add(actor);
5281 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5283 // Build the animation
5284 float durationSeconds(1.0f);
5285 Animation animation = Animation::New(durationSeconds);
5286 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5287 animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::EaseIn);
5289 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5291 // Start the animation
5294 bool signalReceived(false);
5295 AnimationFinishCheck finishCheck(signalReceived);
5296 animation.FinishedSignal().Connect(&application, finishCheck);
5298 application.SendNotification();
5299 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5301 // We didn't expect the animation to finish yet
5302 application.SendNotification();
5303 finishCheck.CheckSignalNotReceived();
5305 // The position should have moved less, than with a linear alpha function
5306 Vector3 current(actor.GetCurrentPosition());
5307 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5308 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5309 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5310 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5311 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5312 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5314 application.SendNotification();
5315 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5317 // We did expect the animation to finish
5318 application.SendNotification();
5319 finishCheck.CheckSignalReceived();
5320 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5324 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5326 TestApplication application;
5328 Actor actor = Actor::New();
5329 Stage::GetCurrent().Add(actor);
5330 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5332 // Build the animation
5333 float durationSeconds(1.0f);
5334 Animation animation = Animation::New(durationSeconds);
5335 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5337 animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5339 TimePeriod( delay, durationSeconds - delay ) );
5341 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5343 // Start the animation
5346 bool signalReceived(false);
5347 AnimationFinishCheck finishCheck(signalReceived);
5348 animation.FinishedSignal().Connect(&application, finishCheck);
5350 application.SendNotification();
5351 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5353 // We didn't expect the animation to finish yet
5354 application.SendNotification();
5355 finishCheck.CheckSignalNotReceived();
5356 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5358 application.SendNotification();
5359 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5361 // We didn't expect the animation to finish yet
5362 application.SendNotification();
5363 finishCheck.CheckSignalNotReceived();
5364 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5366 application.SendNotification();
5367 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5369 // We did expect the animation to finish
5370 application.SendNotification();
5371 finishCheck.CheckSignalReceived();
5372 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5376 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5378 TestApplication application;
5380 Actor actor = Actor::New();
5381 Stage::GetCurrent().Add(actor);
5382 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5384 // Build the animation
5385 float durationSeconds(1.0f);
5386 Animation animation = Animation::New(durationSeconds);
5387 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5389 animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5391 AlphaFunctions::Linear,
5392 TimePeriod( delay, durationSeconds - delay ) );
5394 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5396 // Start the animation
5399 bool signalReceived(false);
5400 AnimationFinishCheck finishCheck(signalReceived);
5401 animation.FinishedSignal().Connect(&application, finishCheck);
5403 application.SendNotification();
5404 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5406 // We didn't expect the animation to finish yet
5407 application.SendNotification();
5408 finishCheck.CheckSignalNotReceived();
5409 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5411 application.SendNotification();
5412 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5414 // We didn't expect the animation to finish yet
5415 application.SendNotification();
5416 finishCheck.CheckSignalNotReceived();
5417 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5419 application.SendNotification();
5420 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5422 // We did expect the animation to finish
5423 application.SendNotification();
5424 finishCheck.CheckSignalReceived();
5425 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5429 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5431 TestApplication application;
5433 Actor actor = Actor::New();
5434 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
5435 Stage::GetCurrent().Add(actor);
5436 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5438 // Build the animation
5439 float durationSeconds(1.0f);
5440 Animation animation = Animation::New(durationSeconds);
5441 Degree targetRotationDegrees(90.0f);
5442 Radian targetRotationRadians(targetRotationDegrees);
5443 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5445 // Start the animation
5448 bool signalReceived(false);
5449 AnimationFinishCheck finishCheck(signalReceived);
5450 animation.FinishedSignal().Connect(&application, finishCheck);
5452 application.SendNotification();
5453 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5455 // We didn't expect the animation to finish yet
5456 application.SendNotification();
5457 finishCheck.CheckSignalNotReceived();
5458 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5460 application.SendNotification();
5461 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5463 // We didn't expect the animation to finish yet
5464 application.SendNotification();
5465 finishCheck.CheckSignalNotReceived();
5466 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5468 application.SendNotification();
5469 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5471 // We didn't expect the animation to finish yet
5472 application.SendNotification();
5473 finishCheck.CheckSignalNotReceived();
5474 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5476 application.SendNotification();
5477 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5479 // We did expect the animation to finish
5480 application.SendNotification();
5481 finishCheck.CheckSignalReceived();
5482 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5486 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5488 TestApplication application;
5490 Actor actor = Actor::New();
5491 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
5492 Stage::GetCurrent().Add(actor);
5493 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5495 // Build the animation
5496 float durationSeconds(1.0f);
5497 Animation animation = Animation::New(durationSeconds);
5498 Degree targetRotationDegrees(90.0f);
5499 Radian targetRotationRadians(targetRotationDegrees);
5500 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5501 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
5503 // Start the animation
5506 bool signalReceived(false);
5507 AnimationFinishCheck finishCheck(signalReceived);
5508 animation.FinishedSignal().Connect(&application, finishCheck);
5510 application.SendNotification();
5511 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5513 // We didn't expect the animation to finish yet
5514 application.SendNotification();
5515 finishCheck.CheckSignalNotReceived();
5516 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5518 application.SendNotification();
5519 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5521 // We didn't expect the animation to finish yet
5522 application.SendNotification();
5523 finishCheck.CheckSignalNotReceived();
5524 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5526 application.SendNotification();
5527 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5529 // We didn't expect the animation to finish yet
5530 application.SendNotification();
5531 finishCheck.CheckSignalNotReceived();
5532 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5534 application.SendNotification();
5535 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5537 // We did expect the animation to finish
5538 application.SendNotification();
5539 finishCheck.CheckSignalReceived();
5540 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5544 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5546 TestApplication application;
5548 Actor actor = Actor::New();
5549 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
5550 Stage::GetCurrent().Add(actor);
5551 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5553 // Build the animation
5554 float durationSeconds(1.0f);
5555 Animation animation = Animation::New(durationSeconds);
5556 Degree targetRotationDegrees(90.0f);
5557 Radian targetRotationRadians(targetRotationDegrees);
5558 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5560 // Start the animation
5563 bool signalReceived(false);
5564 AnimationFinishCheck finishCheck(signalReceived);
5565 animation.FinishedSignal().Connect(&application, finishCheck);
5567 application.SendNotification();
5568 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5570 // We didn't expect the animation to finish yet
5571 application.SendNotification();
5572 finishCheck.CheckSignalNotReceived();
5573 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5575 application.SendNotification();
5576 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5578 // We didn't expect the animation to finish yet
5579 application.SendNotification();
5580 finishCheck.CheckSignalNotReceived();
5581 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5583 application.SendNotification();
5584 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5586 // We didn't expect the animation to finish yet
5587 application.SendNotification();
5588 finishCheck.CheckSignalNotReceived();
5589 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5591 application.SendNotification();
5592 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5594 // We did expect the animation to finish
5595 application.SendNotification();
5596 finishCheck.CheckSignalReceived();
5597 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5601 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5603 TestApplication application;
5605 Actor actor = Actor::New();
5606 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
5607 Stage::GetCurrent().Add(actor);
5608 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5610 // Build the animation
5611 float durationSeconds(1.0f);
5612 Animation animation = Animation::New(durationSeconds);
5613 Degree targetRotationDegrees(90.0f);
5614 Radian targetRotationRadians(targetRotationDegrees);
5616 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5618 // Start the animation
5621 bool signalReceived(false);
5622 AnimationFinishCheck finishCheck(signalReceived);
5623 animation.FinishedSignal().Connect(&application, finishCheck);
5625 application.SendNotification();
5626 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5628 // We didn't expect the animation to finish yet
5629 application.SendNotification();
5630 finishCheck.CheckSignalNotReceived();
5631 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5632 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5634 application.SendNotification();
5635 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5637 // We didn't expect the animation to finish yet
5638 application.SendNotification();
5639 finishCheck.CheckSignalNotReceived();
5640 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5641 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5643 application.SendNotification();
5644 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5646 // We didn't expect the animation to finish yet
5647 application.SendNotification();
5648 finishCheck.CheckSignalNotReceived();
5649 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5650 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5652 application.SendNotification();
5653 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5655 // We did expect the animation to finish
5656 application.SendNotification();
5657 finishCheck.CheckSignalReceived();
5658 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5662 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5664 TestApplication application;
5666 Actor actor = Actor::New();
5667 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
5668 Stage::GetCurrent().Add(actor);
5669 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5671 // Build the animation
5672 float durationSeconds(1.0f);
5673 Animation animation = Animation::New(durationSeconds);
5674 Degree targetRotationDegrees(90.0f);
5675 Radian targetRotationRadians(targetRotationDegrees);
5677 animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5679 // Start the animation
5682 bool signalReceived(false);
5683 AnimationFinishCheck finishCheck(signalReceived);
5684 animation.FinishedSignal().Connect(&application, finishCheck);
5686 application.SendNotification();
5687 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5689 // We didn't expect the animation to finish yet
5690 application.SendNotification();
5691 finishCheck.CheckSignalNotReceived();
5692 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5693 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5695 application.SendNotification();
5696 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5698 // We didn't expect the animation to finish yet
5699 application.SendNotification();
5700 finishCheck.CheckSignalNotReceived();
5701 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5702 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5704 application.SendNotification();
5705 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5707 // We didn't expect the animation to finish yet
5708 application.SendNotification();
5709 finishCheck.CheckSignalNotReceived();
5710 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5711 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5713 application.SendNotification();
5714 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5716 // We did expect the animation to finish
5717 application.SendNotification();
5718 finishCheck.CheckSignalReceived();
5719 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5723 int UtcDaliAnimationAnimateToActorScale(void)
5725 TestApplication application;
5727 Actor actor = Actor::New();
5728 Stage::GetCurrent().Add(actor);
5729 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5731 // Build the animation
5732 float durationSeconds(1.0f);
5733 Animation animation = Animation::New(durationSeconds);
5734 Vector3 targetScale(2.0f, 2.0f, 2.0f);
5735 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
5737 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5739 // Start the animation
5742 bool signalReceived(false);
5743 AnimationFinishCheck finishCheck(signalReceived);
5744 animation.FinishedSignal().Connect(&application, finishCheck);
5746 application.SendNotification();
5747 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5749 // We didn't expect the animation to finish yet
5750 application.SendNotification();
5751 finishCheck.CheckSignalNotReceived();
5752 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5754 application.SendNotification();
5755 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5757 // We did expect the animation to finish
5758 application.SendNotification();
5759 finishCheck.CheckSignalReceived();
5760 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5763 finishCheck.Reset();
5764 actor.SetScale(Vector3::ONE);
5765 application.SendNotification();
5766 application.Render(0);
5767 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5769 // Repeat with a different (ease-in) alpha function
5770 animation = Animation::New(durationSeconds);
5771 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::EaseIn);
5772 animation.FinishedSignal().Connect(&application, finishCheck);
5775 application.SendNotification();
5776 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5778 // We didn't expect the animation to finish yet
5779 application.SendNotification();
5780 finishCheck.CheckSignalNotReceived();
5782 // The scale should have grown less, than with a linear alpha function
5783 Vector3 current(actor.GetCurrentScale());
5784 DALI_TEST_CHECK( current.x > 1.0f );
5785 DALI_TEST_CHECK( current.y > 1.0f );
5786 DALI_TEST_CHECK( current.z > 1.0f );
5787 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5788 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5789 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5791 application.SendNotification();
5792 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5794 // We did expect the animation to finish
5795 application.SendNotification();
5796 finishCheck.CheckSignalReceived();
5797 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5800 finishCheck.Reset();
5801 actor.SetScale(Vector3::ONE);
5802 application.SendNotification();
5803 application.Render(0);
5804 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5806 // Repeat with a delay
5808 animation = Animation::New(durationSeconds);
5809 animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5810 animation.FinishedSignal().Connect(&application, finishCheck);
5813 application.SendNotification();
5814 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5816 // We didn't expect the animation to finish yet
5817 application.SendNotification();
5818 finishCheck.CheckSignalNotReceived();
5819 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5821 application.SendNotification();
5822 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5824 // We did expect the animation to finish
5825 application.SendNotification();
5826 finishCheck.CheckSignalReceived();
5827 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5831 int UtcDaliAnimationAnimateToActorScaleX(void)
5833 TestApplication application;
5835 Actor actor = Actor::New();
5836 Stage::GetCurrent().Add(actor);
5837 float startValue(1.0f);
5838 DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5839 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5840 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5841 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5843 // Build the animation
5844 float durationSeconds(1.0f);
5845 Animation animation = Animation::New(durationSeconds);
5846 float targetX(10.0f);
5847 animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
5849 float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5851 // Start the animation
5854 bool signalReceived(false);
5855 AnimationFinishCheck finishCheck(signalReceived);
5856 animation.FinishedSignal().Connect(&application, finishCheck);
5858 application.SendNotification();
5859 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5861 // We didn't expect the animation to finish yet
5862 application.SendNotification();
5863 finishCheck.CheckSignalNotReceived();
5864 DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5865 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5866 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5867 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5869 application.SendNotification();
5870 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5872 // We did expect the animation to finish
5873 application.SendNotification();
5874 finishCheck.CheckSignalReceived();
5875 DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
5876 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), targetX, TEST_LOCATION );
5877 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5878 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5882 int UtcDaliAnimationAnimateToActorScaleY(void)
5884 TestApplication application;
5886 Actor actor = Actor::New();
5887 Stage::GetCurrent().Add(actor);
5888 float startValue(1.0f);
5889 DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
5890 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5891 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5892 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5894 // Build the animation
5895 float durationSeconds(1.0f);
5896 Animation animation = Animation::New(durationSeconds);
5897 float targetY(1000.0f);
5898 animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
5900 float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5902 // Start the animation
5905 bool signalReceived(false);
5906 AnimationFinishCheck finishCheck(signalReceived);
5907 animation.FinishedSignal().Connect(&application, finishCheck);
5909 application.SendNotification();
5910 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5912 // We didn't expect the animation to finish yet
5913 application.SendNotification();
5914 finishCheck.CheckSignalNotReceived();
5915 DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
5916 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5917 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
5918 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5920 application.SendNotification();
5921 application.Render(static_cast<unsigned int>(durationSeconds*500.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.GetCurrentScale().y, targetY, TEST_LOCATION );
5927 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5928 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), targetY, TEST_LOCATION );
5929 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5933 int UtcDaliAnimationAnimateToActorScaleZ(void)
5935 TestApplication application;
5937 Actor actor = Actor::New();
5938 Stage::GetCurrent().Add(actor);
5939 float startValue(1.0f);
5940 DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
5941 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5942 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5943 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
5945 // Build the animation
5946 float durationSeconds(1.0f);
5947 Animation animation = Animation::New(durationSeconds);
5948 float targetZ(-1000.0f);
5949 animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
5951 float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5953 // Start the animation
5956 bool signalReceived(false);
5957 AnimationFinishCheck finishCheck(signalReceived);
5958 animation.FinishedSignal().Connect(&application, finishCheck);
5960 application.SendNotification();
5961 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5963 // We didn't expect the animation to finish yet
5964 application.SendNotification();
5965 finishCheck.CheckSignalNotReceived();
5966 DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
5967 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5968 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5969 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
5971 application.SendNotification();
5972 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5974 // We did expect the animation to finish
5975 application.SendNotification();
5976 finishCheck.CheckSignalReceived();
5977 DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
5978 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
5979 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
5980 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), targetZ, TEST_LOCATION );
5984 int UtcDaliAnimationAnimateToActorColor(void)
5986 TestApplication application;
5988 Actor actor = Actor::New();
5989 Stage::GetCurrent().Add(actor);
5990 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5992 // Build the animation
5993 float durationSeconds(1.0f);
5994 Animation animation = Animation::New(durationSeconds);
5995 Vector4 targetColor(Color::RED);
5996 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
5998 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
5999 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6001 // Start the animation
6004 bool signalReceived(false);
6005 AnimationFinishCheck finishCheck(signalReceived);
6006 animation.FinishedSignal().Connect(&application, finishCheck);
6008 application.SendNotification();
6009 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6011 // We didn't expect the animation to finish yet
6012 application.SendNotification();
6013 finishCheck.CheckSignalNotReceived();
6014 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6016 application.SendNotification();
6017 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6019 // We did expect the animation to finish
6020 application.SendNotification();
6021 finishCheck.CheckSignalReceived();
6022 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6025 finishCheck.Reset();
6026 actor.SetColor(Color::WHITE);
6027 application.SendNotification();
6028 application.Render(0);
6029 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6031 // Repeat with a different (ease-in) alpha function
6032 animation = Animation::New(durationSeconds);
6033 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::EaseIn);
6034 animation.FinishedSignal().Connect(&application, finishCheck);
6037 application.SendNotification();
6038 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6040 // We didn't expect the animation to finish yet
6041 application.SendNotification();
6042 finishCheck.CheckSignalNotReceived();
6044 // The color should have changed less, than with a linear alpha function
6045 Vector4 current(actor.GetCurrentColor());
6046 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6047 DALI_TEST_CHECK( current.y < 1.0f );
6048 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6049 DALI_TEST_CHECK( current.z < 1.0f );
6050 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
6051 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6053 application.SendNotification();
6054 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6056 // We did expect the animation to finish
6057 application.SendNotification();
6058 finishCheck.CheckSignalReceived();
6059 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6062 finishCheck.Reset();
6063 actor.SetColor(Color::WHITE);
6064 application.SendNotification();
6065 application.Render(0);
6066 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6068 // Repeat with a shorter animator duration
6069 float animatorDuration = 0.5f;
6070 animation = Animation::New(durationSeconds);
6071 animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6072 animation.FinishedSignal().Connect(&application, finishCheck);
6075 application.SendNotification();
6076 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6078 // We didn't expect the animation to finish yet
6079 application.SendNotification();
6080 finishCheck.CheckSignalNotReceived();
6081 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6083 application.SendNotification();
6084 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6086 // We didn't expect the animation to finish yet
6087 application.SendNotification();
6088 finishCheck.CheckSignalNotReceived();
6089 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6091 application.SendNotification();
6092 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6094 // We did expect the animation to finish
6095 application.SendNotification();
6096 finishCheck.CheckSignalReceived();
6097 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6101 int UtcDaliAnimationAnimateToActorColorRed(void)
6103 TestApplication application;
6105 Actor actor = Actor::New();
6106 Stage::GetCurrent().Add(actor);
6107 float startValue(1.0f);
6108 DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6109 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6110 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6111 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6112 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6114 // Build the animation
6115 float durationSeconds(1.0f);
6116 Animation animation = Animation::New(durationSeconds);
6117 float targetRed(0.5f);
6118 animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
6120 float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6122 // Start the animation
6125 bool signalReceived(false);
6126 AnimationFinishCheck finishCheck(signalReceived);
6127 animation.FinishedSignal().Connect(&application, finishCheck);
6129 application.SendNotification();
6130 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6132 // We didn't expect the animation to finish yet
6133 application.SendNotification();
6134 finishCheck.CheckSignalNotReceived();
6135 DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6136 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), fiftyPercentProgress, TEST_LOCATION );
6137 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6138 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6139 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6141 application.SendNotification();
6142 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6144 // We did expect the animation to finish
6145 application.SendNotification();
6146 finishCheck.CheckSignalReceived();
6147 DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6148 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetRed, TEST_LOCATION );
6149 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6150 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6151 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6155 int UtcDaliAnimationAnimateToActorColorGreen(void)
6157 TestApplication application;
6159 Actor actor = Actor::New();
6160 Stage::GetCurrent().Add(actor);
6161 float startValue(1.0f);
6162 DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6163 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6164 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6165 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6166 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6168 // Build the animation
6169 float durationSeconds(1.0f);
6170 Animation animation = Animation::New(durationSeconds);
6171 float targetGreen(0.5f);
6172 animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
6174 float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6176 // Start the animation
6179 bool signalReceived(false);
6180 AnimationFinishCheck finishCheck(signalReceived);
6181 animation.FinishedSignal().Connect(&application, finishCheck);
6183 application.SendNotification();
6184 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6186 // We didn't expect the animation to finish yet
6187 application.SendNotification();
6188 finishCheck.CheckSignalNotReceived();
6189 DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6190 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6191 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6192 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6193 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6195 application.SendNotification();
6196 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6198 // We did expect the animation to finish
6199 application.SendNotification();
6200 finishCheck.CheckSignalReceived();
6201 DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6202 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6203 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
6204 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6205 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6209 int UtcDaliAnimationAnimateToActorColorBlue(void)
6211 TestApplication application;
6213 Actor actor = Actor::New();
6214 Stage::GetCurrent().Add(actor);
6215 float startValue(1.0f);
6216 DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6217 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6219 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6220 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6222 // Build the animation
6223 float durationSeconds(1.0f);
6224 Animation animation = Animation::New(durationSeconds);
6225 float targetBlue(0.5f);
6226 animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
6228 float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6230 // Start the animation
6233 bool signalReceived(false);
6234 AnimationFinishCheck finishCheck(signalReceived);
6235 animation.FinishedSignal().Connect(&application, finishCheck);
6237 application.SendNotification();
6238 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6240 // We didn't expect the animation to finish yet
6241 application.SendNotification();
6242 finishCheck.CheckSignalNotReceived();
6243 DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6244 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6245 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6246 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION );
6247 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6249 application.SendNotification();
6250 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6252 // We did expect the animation to finish
6253 application.SendNotification();
6254 finishCheck.CheckSignalReceived();
6255 DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6256 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6257 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6258 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), targetBlue, TEST_LOCATION );
6259 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6263 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6265 TestApplication application;
6267 Actor actor = Actor::New();
6268 Stage::GetCurrent().Add(actor);
6269 float startValue(1.0f);
6270 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6274 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6276 // Build the animation
6277 float durationSeconds(1.0f);
6278 Animation animation = Animation::New(durationSeconds);
6279 float targetAlpha(0.5f);
6280 animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
6282 float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6284 // Start the animation
6287 bool signalReceived(false);
6288 AnimationFinishCheck finishCheck(signalReceived);
6289 animation.FinishedSignal().Connect(&application, finishCheck);
6291 application.SendNotification();
6292 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6294 // We didn't expect the animation to finish yet
6295 application.SendNotification();
6296 finishCheck.CheckSignalNotReceived();
6297 DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6298 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6299 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6300 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6301 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6303 application.SendNotification();
6304 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6306 // We did expect the animation to finish
6307 application.SendNotification();
6308 finishCheck.CheckSignalReceived();
6309 DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6310 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6311 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6312 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6313 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6319 int UtcDaliAnimationKeyFrames01(void)
6321 TestApplication application;
6323 KeyFrames keyFrames = KeyFrames::New();
6324 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6326 keyFrames.Add(0.0f, 0.1f);
6327 keyFrames.Add(0.2f, 0.5f);
6328 keyFrames.Add(0.4f, 0.0f);
6329 keyFrames.Add(0.6f, 1.0f);
6330 keyFrames.Add(0.8f, 0.7f);
6331 keyFrames.Add(1.0f, 0.9f);
6333 DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6337 keyFrames.Add(1.9f, false);
6339 catch (Dali::DaliException& e)
6341 DALI_TEST_PRINT_ASSERT( e );
6342 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6347 int UtcDaliAnimationKeyFrames02(void)
6349 TestApplication application;
6351 KeyFrames keyFrames = KeyFrames::New();
6352 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6354 keyFrames.Add(0.0f, true);
6355 keyFrames.Add(0.2f, false);
6356 keyFrames.Add(0.4f, false);
6357 keyFrames.Add(0.6f, true);
6358 keyFrames.Add(0.8f, true);
6359 keyFrames.Add(1.0f, false);
6361 DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6365 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6367 catch (Dali::DaliException& e)
6369 DALI_TEST_PRINT_ASSERT( e );
6370 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6376 int UtcDaliAnimationKeyFrames03(void)
6378 TestApplication application;
6380 KeyFrames keyFrames = KeyFrames::New();
6381 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6383 keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6384 keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6385 keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6386 keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6387 keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6388 keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6390 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6394 keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6396 catch (Dali::DaliException& e)
6398 DALI_TEST_PRINT_ASSERT( e );
6399 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6405 int UtcDaliAnimationKeyFrames04(void)
6407 TestApplication application;
6409 KeyFrames keyFrames = KeyFrames::New();
6410 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6412 keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6413 keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6414 keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6415 keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6416 keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6417 keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6419 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6423 keyFrames.Add(0.7f, 1.0f);
6425 catch (Dali::DaliException& e)
6427 DALI_TEST_PRINT_ASSERT( e );
6428 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6433 int UtcDaliAnimationKeyFrames05(void)
6435 TestApplication application;
6437 KeyFrames keyFrames = KeyFrames::New();
6438 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6440 keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6441 keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6442 keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6443 keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6444 keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6445 keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6447 DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6451 keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6453 catch (Dali::DaliException& e)
6455 DALI_TEST_PRINT_ASSERT( e );
6456 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6462 int UtcDaliAnimationKeyFrames06(void)
6464 TestApplication application;
6466 KeyFrames keyFrames = KeyFrames::New();
6467 DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6469 keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6470 keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6471 keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6472 keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6473 keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6474 keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6476 DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6480 keyFrames.Add(0.7f, 1.1f);
6482 catch (Dali::DaliException& e)
6484 DALI_TEST_PRINT_ASSERT( e );
6485 DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6494 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6496 TestApplication application;
6498 float startValue(1.0f);
6499 Actor actor = Actor::New();
6500 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6501 Stage::GetCurrent().Add(actor);
6503 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6504 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6505 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6506 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6507 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6509 // Build the animation
6510 float durationSeconds(1.0f);
6511 Animation animation = Animation::New(durationSeconds);
6513 KeyFrames keyFrames = KeyFrames::New();
6514 keyFrames.Add(0.0f, 0.1f);
6515 keyFrames.Add(0.2f, 0.5f);
6516 keyFrames.Add(0.4f, 0.0f);
6517 keyFrames.Add(0.6f, 1.0f);
6518 keyFrames.Add(0.8f, 0.7f);
6519 keyFrames.Add(1.0f, 0.9f);
6521 animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
6523 // Start the animation
6526 bool signalReceived(false);
6527 AnimationFinishCheck finishCheck(signalReceived);
6528 animation.FinishedSignal().Connect(&application, finishCheck);
6529 application.SendNotification();
6530 application.Render(0);
6531 application.SendNotification();
6532 finishCheck.CheckSignalNotReceived();
6533 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6535 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6536 application.SendNotification();
6537 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6538 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6539 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6540 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6541 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6543 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6544 application.SendNotification();
6545 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6546 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6547 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6548 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6549 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6551 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6552 application.SendNotification();
6553 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6554 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6555 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6556 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6557 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6559 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6560 application.SendNotification();
6561 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6562 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6563 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6564 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6565 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6567 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6568 application.SendNotification();
6569 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6570 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6571 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6572 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6573 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6575 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6576 application.SendNotification();
6577 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6578 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6579 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6580 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6581 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6583 // We did expect the animation to finish
6585 finishCheck.CheckSignalReceived();
6589 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubic(void)
6591 TestApplication application;
6593 float startValue(1.0f);
6594 Actor actor = Actor::New();
6595 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6596 Stage::GetCurrent().Add(actor);
6598 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6599 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6600 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6601 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6602 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6604 // Build the animation
6605 float durationSeconds(1.0f);
6606 Animation animation = Animation::New(durationSeconds);
6608 KeyFrames keyFrames = KeyFrames::New();
6609 keyFrames.Add(0.0f, 0.1f);
6610 keyFrames.Add(0.2f, 0.5f);
6611 keyFrames.Add(0.4f, 0.0f);
6612 keyFrames.Add(0.6f, 1.0f);
6613 keyFrames.Add(0.8f, 0.7f);
6614 keyFrames.Add(1.0f, 0.9f);
6616 animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
6618 // Start the animation
6621 bool signalReceived(false);
6622 AnimationFinishCheck finishCheck(signalReceived);
6623 animation.FinishedSignal().Connect(&application, finishCheck);
6624 application.SendNotification();
6625 application.Render(0);
6626 application.SendNotification();
6627 finishCheck.CheckSignalNotReceived();
6628 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6630 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6631 application.SendNotification();
6632 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6633 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6634 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6635 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION );
6636 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
6638 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6639 application.SendNotification();
6640 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6641 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION );
6644 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
6646 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6647 application.SendNotification();
6648 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6649 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6650 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6651 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6652 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6654 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6655 application.SendNotification();
6656 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6657 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6658 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6659 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6660 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6662 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6663 application.SendNotification();
6664 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6665 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6666 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6667 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION );
6668 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
6670 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6671 application.SendNotification();
6672 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6673 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6674 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6675 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6676 DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6678 // We did expect the animation to finish
6680 finishCheck.CheckSignalReceived();
6684 int UtcDaliAnimationAnimateBetweenActorColor(void)
6686 TestApplication application;
6688 float startValue(1.0f);
6689 Actor actor = Actor::New();
6690 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6691 Stage::GetCurrent().Add(actor);
6693 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6694 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6695 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6696 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6697 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6699 // Build the animation
6700 float durationSeconds(1.0f);
6701 Animation animation = Animation::New(durationSeconds);
6703 KeyFrames keyFrames = KeyFrames::New();
6704 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6705 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6706 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6708 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
6710 // Start the animation
6713 bool signalReceived(false);
6714 AnimationFinishCheck finishCheck(signalReceived);
6715 animation.FinishedSignal().Connect(&application, finishCheck);
6716 application.SendNotification();
6717 application.Render(0);
6718 application.SendNotification();
6719 finishCheck.CheckSignalNotReceived();
6720 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6721 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6722 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6723 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6725 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6726 application.SendNotification();
6727 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
6728 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6729 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
6730 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6732 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6733 application.SendNotification();
6734 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6735 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6736 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6737 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6739 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6740 application.SendNotification();
6741 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
6742 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6743 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
6744 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6746 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6747 application.SendNotification();
6748 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6749 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6750 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6751 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6753 // We did expect the animation to finish
6755 finishCheck.CheckSignalReceived();
6759 int UtcDaliAnimationAnimateBetweenActorColorCubic(void)
6761 TestApplication application;
6763 float startValue(1.0f);
6764 Actor actor = Actor::New();
6765 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6766 Stage::GetCurrent().Add(actor);
6768 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6769 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
6770 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6771 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
6772 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6774 // Build the animation
6775 float durationSeconds(1.0f);
6776 Animation animation = Animation::New(durationSeconds);
6778 KeyFrames keyFrames = KeyFrames::New();
6779 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6780 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6781 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6783 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
6785 // Start the animation
6788 bool signalReceived(false);
6789 AnimationFinishCheck finishCheck(signalReceived);
6790 animation.FinishedSignal().Connect(&application, finishCheck);
6791 application.SendNotification();
6792 application.Render(0);
6793 application.SendNotification();
6794 finishCheck.CheckSignalNotReceived();
6795 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
6796 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6797 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
6798 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6800 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6801 application.SendNotification();
6802 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.55f, 0.01f, TEST_LOCATION );
6803 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
6804 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.506f, 0.01f, TEST_LOCATION );
6805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
6807 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6808 application.SendNotification();
6809 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
6810 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6811 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
6812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6814 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6815 application.SendNotification();
6816 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.99375f, 0.01f, TEST_LOCATION );
6817 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
6818 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85625f, 0.01f, TEST_LOCATION );
6819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
6821 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6822 application.SendNotification();
6823 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
6824 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6825 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
6826 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6828 // We did expect the animation to finish
6830 finishCheck.CheckSignalReceived();
6834 int UtcDaliAnimationAnimateBetweenActorVisible(void)
6836 TestApplication application;
6838 Actor actor = Actor::New();
6839 AngleAxis aa(Degree(90), Vector3::XAXIS);
6840 actor.SetOrientation(aa.angle, aa.axis);
6841 Stage::GetCurrent().Add(actor);
6843 application.SendNotification();
6844 application.Render(0);
6846 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6848 // Build the animation
6849 float durationSeconds(1.0f);
6850 Animation animation = Animation::New(durationSeconds);
6852 KeyFrames keyFrames = KeyFrames::New();
6853 keyFrames.Add(0.0f, false);
6854 keyFrames.Add(0.2f, true);
6855 keyFrames.Add(0.4f, true);
6856 keyFrames.Add(0.8f, false);
6857 keyFrames.Add(1.0f, true);
6859 animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
6861 // Start the animation
6864 bool signalReceived(false);
6865 AnimationFinishCheck finishCheck(signalReceived);
6866 animation.FinishedSignal().Connect(&application, finishCheck);
6867 application.SendNotification();
6868 application.SendNotification();
6869 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6870 application.SendNotification();
6871 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6872 application.SendNotification();
6874 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6875 finishCheck.CheckSignalReceived();
6879 int UtcDaliAnimationAnimateBetweenActorVisibleCubic(void)
6881 TestApplication application;
6883 Actor actor = Actor::New();
6884 AngleAxis aa(Degree(90), Vector3::XAXIS);
6885 actor.SetOrientation(aa.angle, aa.axis);
6886 Stage::GetCurrent().Add(actor);
6888 application.SendNotification();
6889 application.Render(0);
6891 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6893 // Build the animation
6894 float durationSeconds(1.0f);
6895 Animation animation = Animation::New(durationSeconds);
6897 KeyFrames keyFrames = KeyFrames::New();
6898 keyFrames.Add(0.0f, false);
6899 keyFrames.Add(0.2f, true);
6900 keyFrames.Add(0.4f, true);
6901 keyFrames.Add(0.8f, false);
6902 keyFrames.Add(1.0f, true);
6904 //Cubic interpolation for boolean values should be ignored
6905 animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
6907 // Start the animation
6910 bool signalReceived(false);
6911 AnimationFinishCheck finishCheck(signalReceived);
6912 animation.FinishedSignal().Connect(&application, finishCheck);
6913 application.SendNotification();
6914 application.SendNotification();
6915 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6916 application.SendNotification();
6917 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6918 application.SendNotification();
6920 DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6921 finishCheck.CheckSignalReceived();
6925 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6927 TestApplication application;
6929 Actor actor = Actor::New();
6930 AngleAxis aa(Degree(90), Vector3::XAXIS);
6931 actor.SetOrientation(aa.angle, aa.axis);
6932 Stage::GetCurrent().Add(actor);
6934 application.SendNotification();
6935 application.Render(0);
6936 Quaternion start(Radian(aa.angle), aa.axis);
6937 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
6939 // Build the animation
6940 float durationSeconds(1.0f);
6941 Animation animation = Animation::New(durationSeconds);
6943 KeyFrames keyFrames = KeyFrames::New();
6944 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6946 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
6948 // Start the animation
6951 bool signalReceived(false);
6952 AnimationFinishCheck finishCheck(signalReceived);
6953 animation.FinishedSignal().Connect(&application, finishCheck);
6954 application.SendNotification();
6955 application.SendNotification();
6956 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6957 application.SendNotification();
6958 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6959 application.SendNotification();
6961 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6963 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
6964 finishCheck.CheckSignalReceived();
6968 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6970 TestApplication application;
6972 Actor actor = Actor::New();
6973 AngleAxis aa(Degree(90), Vector3::XAXIS);
6974 actor.SetOrientation(aa.angle, aa.axis);
6975 application.SendNotification();
6976 application.Render(0);
6977 Stage::GetCurrent().Add(actor);
6979 Quaternion start(Radian(aa.angle), aa.axis);
6980 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
6982 // Build the animation
6983 float durationSeconds(1.0f);
6984 Animation animation = Animation::New(durationSeconds);
6986 KeyFrames keyFrames = KeyFrames::New();
6987 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6988 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6989 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6991 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
6993 // Start the animation
6996 bool signalReceived(false);
6997 AnimationFinishCheck finishCheck(signalReceived);
6998 animation.FinishedSignal().Connect(&application, finishCheck);
6999 application.SendNotification();
7000 application.Render(0);
7001 application.SendNotification();
7002 finishCheck.CheckSignalNotReceived();
7004 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7005 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7007 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7008 application.SendNotification();
7009 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
7010 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7012 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7013 application.SendNotification();
7014 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
7015 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7017 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7018 application.SendNotification();
7019 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
7020 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7022 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7023 application.SendNotification();
7024 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
7025 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7027 // We did expect the animation to finish
7029 finishCheck.CheckSignalReceived();
7033 int UtcDaliAnimationAnimateBetweenActorRotation01Cubic(void)
7035 TestApplication application;
7037 Actor actor = Actor::New();
7038 AngleAxis aa(Degree(90), Vector3::XAXIS);
7039 actor.SetOrientation(aa.angle, aa.axis);
7040 Stage::GetCurrent().Add(actor);
7042 application.SendNotification();
7043 application.Render(0);
7044 Quaternion start(Radian(aa.angle), aa.axis);
7045 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7047 // Build the animation
7048 float durationSeconds(1.0f);
7049 Animation animation = Animation::New(durationSeconds);
7051 KeyFrames keyFrames = KeyFrames::New();
7052 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
7054 //Cubic interpolation should be ignored for quaternions
7055 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7057 // Start the animation
7060 bool signalReceived(false);
7061 AnimationFinishCheck finishCheck(signalReceived);
7062 animation.FinishedSignal().Connect(&application, finishCheck);
7063 application.SendNotification();
7064 application.SendNotification();
7065 application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7066 application.SendNotification();
7067 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7068 application.SendNotification();
7070 Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
7072 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7073 finishCheck.CheckSignalReceived();
7077 int UtcDaliAnimationAnimateBetweenActorRotation02Cubic(void)
7079 TestApplication application;
7081 Actor actor = Actor::New();
7082 AngleAxis aa(Degree(90), Vector3::XAXIS);
7083 actor.SetOrientation(aa.angle, aa.axis);
7084 application.SendNotification();
7085 application.Render(0);
7086 Stage::GetCurrent().Add(actor);
7088 Quaternion start(Radian(aa.angle), aa.axis);
7089 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7091 // Build the animation
7092 float durationSeconds(1.0f);
7093 Animation animation = Animation::New(durationSeconds);
7095 KeyFrames keyFrames = KeyFrames::New();
7096 keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
7097 keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
7098 keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
7100 //Cubic interpolation should be ignored for quaternions
7101 animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7103 // Start the animation
7106 bool signalReceived(false);
7107 AnimationFinishCheck finishCheck(signalReceived);
7108 animation.FinishedSignal().Connect(&application, finishCheck);
7109 application.SendNotification();
7110 application.Render(0);
7111 application.SendNotification();
7112 finishCheck.CheckSignalNotReceived();
7114 Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7115 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7117 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7118 application.SendNotification();
7119 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
7120 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7122 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7123 application.SendNotification();
7124 check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
7125 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7127 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7128 application.SendNotification();
7129 check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
7130 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7132 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7133 application.SendNotification();
7134 check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
7135 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7137 // We did expect the animation to finish
7139 finishCheck.CheckSignalReceived();
7144 int UtcDaliAnimationMoveByFloat3(void)
7146 TestApplication application;
7148 Actor actor = Actor::New();
7149 Vector3 startPosition(10.0f, 10.0f, 10.0f);
7150 actor.SetPosition(startPosition);
7151 Stage::GetCurrent().Add(actor);
7152 application.SendNotification();
7153 application.Render(0);
7154 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7156 // Build the animation
7157 float durationSeconds(1.0f);
7158 Animation animation = Animation::New(durationSeconds);
7159 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7160 Vector3 relativePosition(targetPosition - startPosition);
7161 animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
7163 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7165 // Start the animation
7168 bool signalReceived(false);
7169 AnimationFinishCheck finishCheck(signalReceived);
7170 animation.FinishedSignal().Connect(&application, finishCheck);
7172 application.SendNotification();
7173 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
7175 // We didn't expect the animation to finish yet
7176 application.SendNotification();
7177 finishCheck.CheckSignalNotReceived();
7178 DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
7180 application.SendNotification();
7181 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
7183 // We did expect the animation to finish
7184 application.SendNotification();
7185 finishCheck.CheckSignalReceived();
7186 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7190 int UtcDaliAnimationMoveByVector3Alpha(void)
7192 TestApplication application;
7194 Actor actor = Actor::New();
7195 Vector3 startPosition(10.0f, 10.0f, 10.0f);
7196 actor.SetPosition(startPosition);
7197 Stage::GetCurrent().Add(actor);
7198 application.SendNotification();
7199 application.Render(0);
7200 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7202 // Build the animation
7203 float durationSeconds(1.0f);
7204 Animation animation = Animation::New(durationSeconds);
7205 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7206 Vector3 relativePosition(targetPosition - startPosition);
7207 animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
7209 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7211 // Start the animation
7214 bool signalReceived(false);
7215 AnimationFinishCheck finishCheck(signalReceived);
7216 animation.FinishedSignal().Connect(&application, finishCheck);
7218 application.SendNotification();
7219 application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
7221 // We didn't expect the animation to finish yet
7222 application.SendNotification();
7223 finishCheck.CheckSignalNotReceived();
7225 // The position should have moved more, than with a linear alpha function
7226 Vector3 current(actor.GetCurrentPosition());
7227 DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
7228 DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
7229 DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
7231 application.SendNotification();
7232 application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
7234 // We did expect the animation to finish
7235 application.SendNotification();
7236 finishCheck.CheckSignalReceived();
7237 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7241 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
7243 TestApplication application;
7245 Actor actor = Actor::New();
7246 Vector3 startPosition(10.0f, 10.0f, 10.0f);
7247 actor.SetPosition(startPosition);
7248 Stage::GetCurrent().Add(actor);
7249 application.SendNotification();
7250 application.Render(0);
7251 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7253 // Build the animation
7254 float durationSeconds(1.0f);
7255 Animation animation = Animation::New(durationSeconds);
7256 Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7257 Vector3 relativePosition(targetPosition - startPosition);
7259 animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7261 Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7263 // Start the animation
7266 bool signalReceived(false);
7267 AnimationFinishCheck finishCheck(signalReceived);
7268 animation.FinishedSignal().Connect(&application, finishCheck);
7270 application.SendNotification();
7271 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7273 // We didn't expect the animation to finish yet
7274 application.SendNotification();
7275 finishCheck.CheckSignalNotReceived();
7276 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7278 application.SendNotification();
7279 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7281 // We did expect the animation to finish
7282 application.SendNotification();
7283 finishCheck.CheckSignalReceived();
7284 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7288 int UtcDaliAnimationMoveToFloat3(void)
7290 TestApplication application;
7292 Actor actor = Actor::New();
7293 Stage::GetCurrent().Add(actor);
7294 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7296 // Build the animation
7297 float durationSeconds(1.0f);
7298 Animation animation = Animation::New(durationSeconds);
7299 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7300 animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
7302 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7304 // Start the animation
7307 bool signalReceived(false);
7308 AnimationFinishCheck finishCheck(signalReceived);
7309 animation.FinishedSignal().Connect(&application, finishCheck);
7311 application.SendNotification();
7312 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7314 // We didn't expect the animation to finish yet
7315 application.SendNotification();
7316 finishCheck.CheckSignalNotReceived();
7317 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7319 application.SendNotification();
7320 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7322 // We did expect the animation to finish
7323 application.SendNotification();
7324 finishCheck.CheckSignalReceived();
7325 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7329 int UtcDaliAnimationMoveToVector3Alpha(void)
7331 TestApplication application;
7333 Actor actor = Actor::New();
7334 Stage::GetCurrent().Add(actor);
7335 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7337 // Build the animation
7338 float durationSeconds(1.0f);
7339 Animation animation = Animation::New(durationSeconds);
7340 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7341 animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
7343 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7345 // Start the animation
7348 bool signalReceived(false);
7349 AnimationFinishCheck finishCheck(signalReceived);
7350 animation.FinishedSignal().Connect(&application, finishCheck);
7352 application.SendNotification();
7353 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7355 // We didn't expect the animation to finish yet
7356 application.SendNotification();
7357 finishCheck.CheckSignalNotReceived();
7359 // The position should have moved less, than with a linear alpha function
7360 Vector3 current(actor.GetCurrentPosition());
7361 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7362 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7363 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7364 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7365 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7366 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7368 application.SendNotification();
7369 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7371 // We did expect the animation to finish
7372 application.SendNotification();
7373 finishCheck.CheckSignalReceived();
7374 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7378 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
7380 TestApplication application;
7382 Actor actor = Actor::New();
7383 Stage::GetCurrent().Add(actor);
7384 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7386 // Build the animation
7387 float durationSeconds(1.0f);
7388 Animation animation = Animation::New(durationSeconds);
7389 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7391 animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7393 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7395 // Start the animation
7398 bool signalReceived(false);
7399 AnimationFinishCheck finishCheck(signalReceived);
7400 animation.FinishedSignal().Connect(&application, finishCheck);
7402 application.SendNotification();
7403 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7405 // We didn't expect the animation to finish yet
7406 application.SendNotification();
7407 finishCheck.CheckSignalNotReceived();
7408 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7410 application.SendNotification();
7411 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7413 // We didn't expect the animation to finish yet
7414 application.SendNotification();
7415 finishCheck.CheckSignalNotReceived();
7416 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7418 application.SendNotification();
7419 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7421 // We did expect the animation to finish
7422 application.SendNotification();
7423 finishCheck.CheckSignalReceived();
7424 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7428 int UtcDaliAnimationRotateByDegreeVector3(void)
7430 TestApplication application;
7432 Actor actor = Actor::New();
7433 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7434 Stage::GetCurrent().Add(actor);
7435 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7437 // Build the animation
7438 float durationSeconds(1.0f);
7439 Animation animation = Animation::New(durationSeconds);
7440 Degree relativeRotationDegrees(360.0f);
7441 Radian relativeRotationRadians(relativeRotationDegrees);
7442 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7444 // Start the animation
7447 bool signalReceived(false);
7448 AnimationFinishCheck finishCheck(signalReceived);
7449 animation.FinishedSignal().Connect(&application, finishCheck);
7451 application.SendNotification();
7452 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7454 // We didn't expect the animation to finish yet
7455 application.SendNotification();
7456 finishCheck.CheckSignalNotReceived();
7457 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7459 application.SendNotification();
7460 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7462 // We didn't expect the animation to finish yet
7463 application.SendNotification();
7464 finishCheck.CheckSignalNotReceived();
7465 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7467 application.SendNotification();
7468 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7470 // We didn't expect the animation to finish yet
7471 application.SendNotification();
7472 finishCheck.CheckSignalNotReceived();
7473 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7475 application.SendNotification();
7476 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7478 // We did expect the animation to finish
7479 application.SendNotification();
7480 finishCheck.CheckSignalReceived();
7481 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7485 int UtcDaliAnimationRotateByRadianVector3(void)
7487 TestApplication application;
7489 Actor actor = Actor::New();
7490 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7491 Stage::GetCurrent().Add(actor);
7492 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7494 // Build the animation
7495 float durationSeconds(1.0f);
7496 Animation animation = Animation::New(durationSeconds);
7497 Degree relativeRotationDegrees(360.0f);
7498 Radian relativeRotationRadians(relativeRotationDegrees);
7499 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7501 // Start the animation
7504 bool signalReceived(false);
7505 AnimationFinishCheck finishCheck(signalReceived);
7506 animation.FinishedSignal().Connect(&application, finishCheck);
7508 application.SendNotification();
7509 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7511 // We didn't expect the animation to finish yet
7512 application.SendNotification();
7513 finishCheck.CheckSignalNotReceived();
7514 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7516 application.SendNotification();
7517 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7519 // We didn't expect the animation to finish yet
7520 application.SendNotification();
7521 finishCheck.CheckSignalNotReceived();
7522 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7524 application.SendNotification();
7525 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7527 // We didn't expect the animation to finish yet
7528 application.SendNotification();
7529 finishCheck.CheckSignalNotReceived();
7530 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7532 application.SendNotification();
7533 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7535 // We did expect the animation to finish
7536 application.SendNotification();
7537 finishCheck.CheckSignalReceived();
7538 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7542 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7544 TestApplication application;
7546 Actor actor = Actor::New();
7547 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7548 Stage::GetCurrent().Add(actor);
7549 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7551 // Build the animation
7552 float durationSeconds(1.0f);
7553 Animation animation = Animation::New(durationSeconds);
7554 Degree relativeRotationDegrees(360.0f);
7555 Radian relativeRotationRadians(relativeRotationDegrees);
7556 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7558 // Start the animation
7561 bool signalReceived(false);
7562 AnimationFinishCheck finishCheck(signalReceived);
7563 animation.FinishedSignal().Connect(&application, finishCheck);
7565 application.SendNotification();
7566 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7568 // We didn't expect the animation to finish yet
7569 application.SendNotification();
7570 finishCheck.CheckSignalNotReceived();
7571 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7573 application.SendNotification();
7574 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7576 // We didn't expect the animation to finish yet
7577 application.SendNotification();
7578 finishCheck.CheckSignalNotReceived();
7579 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7581 application.SendNotification();
7582 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7584 // We didn't expect the animation to finish yet
7585 application.SendNotification();
7586 finishCheck.CheckSignalNotReceived();
7587 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7589 application.SendNotification();
7590 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7592 // We did expect the animation to finish
7593 application.SendNotification();
7594 finishCheck.CheckSignalReceived();
7595 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7599 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7601 TestApplication application;
7603 Actor actor = Actor::New();
7604 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7605 Stage::GetCurrent().Add(actor);
7606 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7608 // Build the animation
7609 float durationSeconds(1.0f);
7610 Animation animation = Animation::New(durationSeconds);
7611 Degree relativeRotationDegrees(360.0f);
7612 Radian relativeRotationRadians(relativeRotationDegrees);
7613 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7615 // Start the animation
7618 bool signalReceived(false);
7619 AnimationFinishCheck finishCheck(signalReceived);
7620 animation.FinishedSignal().Connect(&application, finishCheck);
7622 application.SendNotification();
7623 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7625 // We didn't expect the animation to finish yet
7626 application.SendNotification();
7627 finishCheck.CheckSignalNotReceived();
7628 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7630 application.SendNotification();
7631 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7633 // We didn't expect the animation to finish yet
7634 application.SendNotification();
7635 finishCheck.CheckSignalNotReceived();
7636 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7638 application.SendNotification();
7639 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7641 // We didn't expect the animation to finish yet
7642 application.SendNotification();
7643 finishCheck.CheckSignalNotReceived();
7644 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7646 application.SendNotification();
7647 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7649 // We did expect the animation to finish
7650 application.SendNotification();
7651 finishCheck.CheckSignalReceived();
7652 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7656 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7658 TestApplication application;
7660 Actor actor = Actor::New();
7661 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7662 Stage::GetCurrent().Add(actor);
7663 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7665 // Build the animation
7666 float durationSeconds(1.0f);
7667 Animation animation = Animation::New(durationSeconds);
7668 Degree relativeRotationDegrees(360.0f);
7669 Radian relativeRotationRadians(relativeRotationDegrees);
7671 animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7673 // Start the animation
7676 bool signalReceived(false);
7677 AnimationFinishCheck finishCheck(signalReceived);
7678 animation.FinishedSignal().Connect(&application, finishCheck);
7680 application.SendNotification();
7681 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7683 // We didn't expect the animation to finish yet
7684 application.SendNotification();
7685 finishCheck.CheckSignalNotReceived();
7686 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7687 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7689 application.SendNotification();
7690 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7692 // We didn't expect the animation to finish yet
7693 application.SendNotification();
7694 finishCheck.CheckSignalNotReceived();
7695 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7696 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7698 application.SendNotification();
7699 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7701 // We didn't expect the animation to finish yet
7702 application.SendNotification();
7703 finishCheck.CheckSignalNotReceived();
7704 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7705 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7707 application.SendNotification();
7708 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7710 // We did expect the animation to finish
7711 application.SendNotification();
7712 finishCheck.CheckSignalReceived();
7713 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7718 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7720 TestApplication application;
7722 Actor actor = Actor::New();
7723 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7724 Stage::GetCurrent().Add(actor);
7725 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7727 // Build the animation
7728 float durationSeconds(1.0f);
7729 Animation animation = Animation::New(durationSeconds);
7730 Degree relativeRotationDegrees(360.0f);
7731 Radian relativeRotationRadians(relativeRotationDegrees);
7733 animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7735 // Start the animation
7738 bool signalReceived(false);
7739 AnimationFinishCheck finishCheck(signalReceived);
7740 animation.FinishedSignal().Connect(&application, finishCheck);
7742 application.SendNotification();
7743 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7745 // We didn't expect the animation to finish yet
7746 application.SendNotification();
7747 finishCheck.CheckSignalNotReceived();
7748 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7749 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7751 application.SendNotification();
7752 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7754 // We didn't expect the animation to finish yet
7755 application.SendNotification();
7756 finishCheck.CheckSignalNotReceived();
7757 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7758 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7760 application.SendNotification();
7761 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7763 // We didn't expect the animation to finish yet
7764 application.SendNotification();
7765 finishCheck.CheckSignalNotReceived();
7766 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7767 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7769 application.SendNotification();
7770 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7772 // We did expect the animation to finish
7773 application.SendNotification();
7774 finishCheck.CheckSignalReceived();
7775 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7779 int UtcDaliAnimationRotateToDegreeVector3(void)
7781 TestApplication application;
7783 Actor actor = Actor::New();
7784 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7785 Stage::GetCurrent().Add(actor);
7786 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7788 // Build the animation
7789 float durationSeconds(1.0f);
7790 Animation animation = Animation::New(durationSeconds);
7791 Degree targetRotationDegrees(90.0f);
7792 Radian targetRotationRadians(targetRotationDegrees);
7793 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7795 // Start the animation
7798 bool signalReceived(false);
7799 AnimationFinishCheck finishCheck(signalReceived);
7800 animation.FinishedSignal().Connect(&application, finishCheck);
7802 application.SendNotification();
7803 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7805 // We didn't expect the animation to finish yet
7806 application.SendNotification();
7807 finishCheck.CheckSignalNotReceived();
7808 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7810 application.SendNotification();
7811 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7813 // We didn't expect the animation to finish yet
7814 application.SendNotification();
7815 finishCheck.CheckSignalNotReceived();
7816 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7818 application.SendNotification();
7819 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7821 // We didn't expect the animation to finish yet
7822 application.SendNotification();
7823 finishCheck.CheckSignalNotReceived();
7824 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7826 application.SendNotification();
7827 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7829 // We did expect the animation to finish
7830 application.SendNotification();
7831 finishCheck.CheckSignalReceived();
7832 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7836 int UtcDaliAnimationRotateToRadianVector3(void)
7838 TestApplication application;
7840 Actor actor = Actor::New();
7841 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7842 Stage::GetCurrent().Add(actor);
7843 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7845 // Build the animation
7846 float durationSeconds(1.0f);
7847 Animation animation = Animation::New(durationSeconds);
7848 Degree targetRotationDegrees(90.0f);
7849 Radian targetRotationRadians(targetRotationDegrees);
7850 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7852 // Start the animation
7855 bool signalReceived(false);
7856 AnimationFinishCheck finishCheck(signalReceived);
7857 animation.FinishedSignal().Connect(&application, finishCheck);
7859 application.SendNotification();
7860 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7862 // We didn't expect the animation to finish yet
7863 application.SendNotification();
7864 finishCheck.CheckSignalNotReceived();
7865 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7867 application.SendNotification();
7868 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7870 // We didn't expect the animation to finish yet
7871 application.SendNotification();
7872 finishCheck.CheckSignalNotReceived();
7873 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7875 application.SendNotification();
7876 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7878 // We didn't expect the animation to finish yet
7879 application.SendNotification();
7880 finishCheck.CheckSignalNotReceived();
7881 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7883 application.SendNotification();
7884 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7886 // We did expect the animation to finish
7887 application.SendNotification();
7888 finishCheck.CheckSignalReceived();
7889 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7893 int UtcDaliAnimationRotateToQuaternion(void)
7895 TestApplication application;
7897 Actor actor = Actor::New();
7898 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7899 Stage::GetCurrent().Add(actor);
7900 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7902 // Build the animation
7903 float durationSeconds(1.0f);
7904 Animation animation = Animation::New(durationSeconds);
7905 Degree targetRotationDegrees(90.0f);
7906 Radian targetRotationRadians(targetRotationDegrees);
7907 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7908 animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7910 // Start the animation
7913 bool signalReceived(false);
7914 AnimationFinishCheck finishCheck(signalReceived);
7915 animation.FinishedSignal().Connect(&application, finishCheck);
7917 application.SendNotification();
7918 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7920 // We didn't expect the animation to finish yet
7921 application.SendNotification();
7922 finishCheck.CheckSignalNotReceived();
7923 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7925 application.SendNotification();
7926 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7928 // We didn't expect the animation to finish yet
7929 application.SendNotification();
7930 finishCheck.CheckSignalNotReceived();
7931 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7933 application.SendNotification();
7934 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7936 // We didn't expect the animation to finish yet
7937 application.SendNotification();
7938 finishCheck.CheckSignalNotReceived();
7939 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7941 application.SendNotification();
7942 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7944 // We did expect the animation to finish
7945 application.SendNotification();
7946 finishCheck.CheckSignalReceived();
7947 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7951 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7953 TestApplication application;
7955 Actor actor = Actor::New();
7956 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7957 Stage::GetCurrent().Add(actor);
7958 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7960 // Build the animation
7961 float durationSeconds(1.0f);
7962 Animation animation = Animation::New(durationSeconds);
7963 Degree targetRotationDegrees(90.0f);
7964 Radian targetRotationRadians(targetRotationDegrees);
7965 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7967 // Start the animation
7970 bool signalReceived(false);
7971 AnimationFinishCheck finishCheck(signalReceived);
7972 animation.FinishedSignal().Connect(&application, finishCheck);
7974 application.SendNotification();
7975 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7977 // We didn't expect the animation to finish yet
7978 application.SendNotification();
7979 finishCheck.CheckSignalNotReceived();
7980 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7982 application.SendNotification();
7983 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7985 // We didn't expect the animation to finish yet
7986 application.SendNotification();
7987 finishCheck.CheckSignalNotReceived();
7988 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7990 application.SendNotification();
7991 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7993 // We didn't expect the animation to finish yet
7994 application.SendNotification();
7995 finishCheck.CheckSignalNotReceived();
7996 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7998 application.SendNotification();
7999 application.Render(static_cast<unsigned int>(durationSeconds*250.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.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8008 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
8010 TestApplication application;
8012 Actor actor = Actor::New();
8013 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
8014 Stage::GetCurrent().Add(actor);
8015 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8017 // Build the animation
8018 float durationSeconds(1.0f);
8019 Animation animation = Animation::New(durationSeconds);
8020 Degree targetRotationDegrees(90.0f);
8021 Radian targetRotationRadians(targetRotationDegrees);
8022 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
8024 // Start the animation
8027 bool signalReceived(false);
8028 AnimationFinishCheck finishCheck(signalReceived);
8029 animation.FinishedSignal().Connect(&application, finishCheck);
8031 application.SendNotification();
8032 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8034 // We didn't expect the animation to finish yet
8035 application.SendNotification();
8036 finishCheck.CheckSignalNotReceived();
8037 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8039 application.SendNotification();
8040 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8042 // We didn't expect the animation to finish yet
8043 application.SendNotification();
8044 finishCheck.CheckSignalNotReceived();
8045 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8047 application.SendNotification();
8048 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8050 // We didn't expect the animation to finish yet
8051 application.SendNotification();
8052 finishCheck.CheckSignalNotReceived();
8053 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8055 application.SendNotification();
8056 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8058 // We did expect the animation to finish
8059 application.SendNotification();
8060 finishCheck.CheckSignalReceived();
8061 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8065 int UtcDaliAnimationRotateToQuaternionAlpha(void)
8067 TestApplication application;
8069 Actor actor = Actor::New();
8070 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
8071 Stage::GetCurrent().Add(actor);
8072 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8074 // Build the animation
8075 float durationSeconds(1.0f);
8076 Animation animation = Animation::New(durationSeconds);
8077 Degree targetRotationDegrees(90.0f);
8078 Radian targetRotationRadians(targetRotationDegrees);
8079 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8080 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
8082 // Start the animation
8085 bool signalReceived(false);
8086 AnimationFinishCheck finishCheck(signalReceived);
8087 animation.FinishedSignal().Connect(&application, finishCheck);
8089 application.SendNotification();
8090 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8092 // We didn't expect the animation to finish yet
8093 application.SendNotification();
8094 finishCheck.CheckSignalNotReceived();
8095 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8097 application.SendNotification();
8098 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8100 // We didn't expect the animation to finish yet
8101 application.SendNotification();
8102 finishCheck.CheckSignalNotReceived();
8103 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8105 application.SendNotification();
8106 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8108 // We didn't expect the animation to finish yet
8109 application.SendNotification();
8110 finishCheck.CheckSignalNotReceived();
8111 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8113 application.SendNotification();
8114 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8116 // We did expect the animation to finish
8117 application.SendNotification();
8118 finishCheck.CheckSignalReceived();
8119 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8123 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
8125 TestApplication application;
8127 Actor actor = Actor::New();
8128 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
8129 Stage::GetCurrent().Add(actor);
8130 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8132 // Build the animation
8133 float durationSeconds(1.0f);
8134 Animation animation = Animation::New(durationSeconds);
8135 Degree targetRotationDegrees(90.0f);
8136 Radian targetRotationRadians(targetRotationDegrees);
8138 animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8140 // Start the animation
8143 bool signalReceived(false);
8144 AnimationFinishCheck finishCheck(signalReceived);
8145 animation.FinishedSignal().Connect(&application, finishCheck);
8147 application.SendNotification();
8148 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8150 // We didn't expect the animation to finish yet
8151 application.SendNotification();
8152 finishCheck.CheckSignalNotReceived();
8153 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8154 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8156 application.SendNotification();
8157 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8159 // We didn't expect the animation to finish yet
8160 application.SendNotification();
8161 finishCheck.CheckSignalNotReceived();
8162 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8163 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8165 application.SendNotification();
8166 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8168 // We didn't expect the animation to finish yet
8169 application.SendNotification();
8170 finishCheck.CheckSignalNotReceived();
8171 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8172 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8174 application.SendNotification();
8175 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8177 // We did expect the animation to finish
8178 application.SendNotification();
8179 finishCheck.CheckSignalReceived();
8180 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8184 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
8186 TestApplication application;
8188 Actor actor = Actor::New();
8189 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
8190 Stage::GetCurrent().Add(actor);
8191 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8193 // Build the animation
8194 float durationSeconds(1.0f);
8195 Animation animation = Animation::New(durationSeconds);
8196 Degree targetRotationDegrees(90.0f);
8197 Radian targetRotationRadians(targetRotationDegrees);
8199 animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8201 // Start the animation
8204 bool signalReceived(false);
8205 AnimationFinishCheck finishCheck(signalReceived);
8206 animation.FinishedSignal().Connect(&application, finishCheck);
8208 application.SendNotification();
8209 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8211 // We didn't expect the animation to finish yet
8212 application.SendNotification();
8213 finishCheck.CheckSignalNotReceived();
8214 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8215 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8217 application.SendNotification();
8218 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8220 // We didn't expect the animation to finish yet
8221 application.SendNotification();
8222 finishCheck.CheckSignalNotReceived();
8223 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8224 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8226 application.SendNotification();
8227 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8229 // We didn't expect the animation to finish yet
8230 application.SendNotification();
8231 finishCheck.CheckSignalNotReceived();
8232 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8233 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8235 application.SendNotification();
8236 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8238 // We did expect the animation to finish
8239 application.SendNotification();
8240 finishCheck.CheckSignalReceived();
8241 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8245 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
8247 TestApplication application;
8249 Actor actor = Actor::New();
8250 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
8251 Stage::GetCurrent().Add(actor);
8252 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8254 // Build the animation
8255 float durationSeconds(1.0f);
8256 Animation animation = Animation::New(durationSeconds);
8257 Degree targetRotationDegrees(90.0f);
8258 Radian targetRotationRadians(targetRotationDegrees);
8260 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8261 animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8263 // Start the animation
8266 bool signalReceived(false);
8267 AnimationFinishCheck finishCheck(signalReceived);
8268 animation.FinishedSignal().Connect(&application, finishCheck);
8270 application.SendNotification();
8271 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8273 // We didn't expect the animation to finish yet
8274 application.SendNotification();
8275 finishCheck.CheckSignalNotReceived();
8276 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8277 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8279 application.SendNotification();
8280 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8282 // We didn't expect the animation to finish yet
8283 application.SendNotification();
8284 finishCheck.CheckSignalNotReceived();
8285 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8286 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8288 application.SendNotification();
8289 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8291 // We didn't expect the animation to finish yet
8292 application.SendNotification();
8293 finishCheck.CheckSignalNotReceived();
8294 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8295 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8297 application.SendNotification();
8298 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8300 // We did expect the animation to finish
8301 application.SendNotification();
8302 finishCheck.CheckSignalReceived();
8303 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8307 int UtcDaliAnimationScaleBy(void)
8309 TestApplication application;
8311 Actor actor = Actor::New();
8312 Stage::GetCurrent().Add(actor);
8313 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8315 // Build the animation
8316 float durationSeconds(1.0f);
8317 Animation animation = Animation::New(durationSeconds);
8318 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8319 Vector3 relativeScale(targetScale - Vector3::ONE);
8320 animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
8322 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
8324 // Start the animation
8327 bool signalReceived(false);
8328 AnimationFinishCheck finishCheck(signalReceived);
8329 animation.FinishedSignal().Connect(&application, finishCheck);
8331 application.SendNotification();
8332 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8334 // We didn't expect the animation to finish yet
8335 application.SendNotification();
8336 finishCheck.CheckSignalNotReceived();
8337 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8339 application.SendNotification();
8340 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8342 // We did expect the animation to finish
8343 application.SendNotification();
8344 finishCheck.CheckSignalReceived();
8345 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8348 finishCheck.Reset();
8349 actor.SetScale(Vector3::ONE);
8350 application.SendNotification();
8351 application.Render(0);
8352 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8354 // Repeat with a different (ease-in) alpha function
8355 animation = Animation::New(durationSeconds);
8356 animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8357 animation.FinishedSignal().Connect(&application, finishCheck);
8360 application.SendNotification();
8361 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8363 // We didn't expect the animation to finish yet
8364 application.SendNotification();
8365 finishCheck.CheckSignalNotReceived();
8367 // The scale should have grown less, than with a linear alpha function
8368 Vector3 current(actor.GetCurrentScale());
8369 DALI_TEST_CHECK( current.x > 1.0f );
8370 DALI_TEST_CHECK( current.y > 1.0f );
8371 DALI_TEST_CHECK( current.z > 1.0f );
8372 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8373 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8374 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8376 application.SendNotification();
8377 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8379 // We did expect the animation to finish
8380 application.SendNotification();
8381 finishCheck.CheckSignalReceived();
8382 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8385 finishCheck.Reset();
8386 actor.SetScale(Vector3::ONE);
8387 application.SendNotification();
8388 application.Render(0);
8389 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8391 // Repeat with a delay
8393 animation = Animation::New(durationSeconds);
8394 animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8395 animation.FinishedSignal().Connect(&application, finishCheck);
8398 application.SendNotification();
8399 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8401 // We didn't expect the animation to finish yet
8402 application.SendNotification();
8403 finishCheck.CheckSignalNotReceived();
8404 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8406 application.SendNotification();
8407 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8409 // We did expect the animation to finish
8410 application.SendNotification();
8411 finishCheck.CheckSignalReceived();
8412 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8416 int UtcDaliAnimationScaleTo(void)
8418 TestApplication application;
8420 Actor actor = Actor::New();
8421 Stage::GetCurrent().Add(actor);
8422 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8424 // Build the animation
8425 float durationSeconds(1.0f);
8426 Animation animation = Animation::New(durationSeconds);
8427 Vector3 targetScale(2.0f, 2.0f, 2.0f);
8428 animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8430 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8432 // Start the animation
8435 bool signalReceived(false);
8436 AnimationFinishCheck finishCheck(signalReceived);
8437 animation.FinishedSignal().Connect(&application, finishCheck);
8439 application.SendNotification();
8440 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8442 // We didn't expect the animation to finish yet
8443 application.SendNotification();
8444 finishCheck.CheckSignalNotReceived();
8445 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8447 application.SendNotification();
8448 application.Render(static_cast<unsigned int>(durationSeconds*10.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.GetCurrentScale(), targetScale, TEST_LOCATION );
8456 finishCheck.Reset();
8457 actor.SetScale(Vector3::ONE);
8458 application.SendNotification();
8459 application.Render(0);
8460 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8462 // Repeat with a different (ease-in) alpha function
8463 animation = Animation::New(durationSeconds);
8464 animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8465 animation.FinishedSignal().Connect(&application, finishCheck);
8468 application.SendNotification();
8469 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8471 // We didn't expect the animation to finish yet
8472 application.SendNotification();
8473 finishCheck.CheckSignalNotReceived();
8475 // The scale should have grown less, than with a linear alpha function
8476 Vector3 current(actor.GetCurrentScale());
8477 DALI_TEST_CHECK( current.x > 1.0f );
8478 DALI_TEST_CHECK( current.y > 1.0f );
8479 DALI_TEST_CHECK( current.z > 1.0f );
8480 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8481 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8482 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8484 application.SendNotification();
8485 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8487 // We did expect the animation to finish
8488 application.SendNotification();
8489 finishCheck.CheckSignalReceived();
8490 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8493 finishCheck.Reset();
8494 actor.SetScale(Vector3::ONE);
8495 application.SendNotification();
8496 application.Render(0);
8497 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8499 // Repeat with a delay
8501 animation = Animation::New(durationSeconds);
8502 animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8503 animation.FinishedSignal().Connect(&application, finishCheck);
8506 application.SendNotification();
8507 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8509 // We didn't expect the animation to finish yet
8510 application.SendNotification();
8511 finishCheck.CheckSignalNotReceived();
8512 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8514 application.SendNotification();
8515 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8517 // We did expect the animation to finish
8518 application.SendNotification();
8519 finishCheck.CheckSignalReceived();
8520 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8524 int UtcDaliAnimationShow(void)
8526 TestApplication application;
8528 Actor actor = Actor::New();
8529 actor.SetVisible(false);
8530 application.SendNotification();
8531 application.Render(0);
8532 DALI_TEST_CHECK( !actor.IsVisible() );
8533 Stage::GetCurrent().Add(actor);
8535 // Start the animation
8536 float durationSeconds(10.0f);
8537 Animation animation = Animation::New(durationSeconds);
8538 animation.Show(actor, durationSeconds*0.5f);
8541 bool signalReceived(false);
8542 AnimationFinishCheck finishCheck(signalReceived);
8543 animation.FinishedSignal().Connect(&application, finishCheck);
8545 application.SendNotification();
8546 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8548 // We didn't expect the animation to finish yet
8549 application.SendNotification();
8550 finishCheck.CheckSignalNotReceived();
8551 DALI_TEST_CHECK( !actor.IsVisible() );
8553 application.SendNotification();
8554 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8556 // We didn't expect the animation to finish yet
8557 application.SendNotification();
8558 finishCheck.CheckSignalNotReceived();
8559 DALI_TEST_CHECK( actor.IsVisible() );
8561 application.SendNotification();
8562 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8564 // We did expect the animation to finish
8565 application.SendNotification();
8566 finishCheck.CheckSignalReceived();
8567 DALI_TEST_CHECK( actor.IsVisible() );
8571 int UtcDaliAnimationHide(void)
8573 TestApplication application;
8575 Actor actor = Actor::New();
8576 DALI_TEST_CHECK( actor.IsVisible() );
8577 Stage::GetCurrent().Add(actor);
8579 // Start the animation
8580 float durationSeconds(10.0f);
8581 Animation animation = Animation::New(durationSeconds);
8582 animation.Hide(actor, durationSeconds*0.5f);
8585 bool signalReceived(false);
8586 AnimationFinishCheck finishCheck(signalReceived);
8587 animation.FinishedSignal().Connect(&application, finishCheck);
8589 application.SendNotification();
8590 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8592 // We didn't expect the animation to finish yet
8593 application.SendNotification();
8594 finishCheck.CheckSignalNotReceived();
8595 DALI_TEST_CHECK( actor.IsVisible() );
8597 application.SendNotification();
8598 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8600 // We didn't expect the animation to finish yet
8601 application.SendNotification();
8602 finishCheck.CheckSignalNotReceived();
8603 DALI_TEST_CHECK( !actor.IsVisible() );
8605 application.SendNotification();
8606 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8608 // We did expect the animation to finish
8609 application.SendNotification();
8610 finishCheck.CheckSignalReceived();
8611 DALI_TEST_CHECK( !actor.IsVisible() );
8615 int UtcDaliAnimationShowHideAtEnd(void)
8617 // Test that show/hide delay can be the same as animation duration
8618 // i.e. to show/hide at the end of the animation
8620 TestApplication application;
8622 Actor actor = Actor::New();
8623 DALI_TEST_CHECK( actor.IsVisible() );
8624 Stage::GetCurrent().Add(actor);
8626 // Start Hide animation
8627 float durationSeconds(10.0f);
8628 Animation animation = Animation::New(durationSeconds);
8629 animation.Hide(actor, durationSeconds/*Hide at end*/);
8632 bool signalReceived(false);
8633 AnimationFinishCheck finishCheck(signalReceived);
8634 animation.FinishedSignal().Connect(&application, finishCheck);
8636 application.SendNotification();
8637 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8639 // We did expect the animation to finish
8640 application.SendNotification();
8641 finishCheck.CheckSignalReceived();
8642 DALI_TEST_CHECK( !actor.IsVisible() );
8644 // Start Show animation
8645 animation = Animation::New(durationSeconds);
8646 animation.Show(actor, durationSeconds/*Show at end*/);
8647 animation.FinishedSignal().Connect(&application, finishCheck);
8650 application.SendNotification();
8651 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8653 // We did expect the animation to finish
8654 application.SendNotification();
8655 finishCheck.CheckSignalReceived();
8656 DALI_TEST_CHECK( actor.IsVisible() );
8660 int UtcDaliAnimationOpacityTo(void)
8662 TestApplication application;
8664 Actor actor = Actor::New();
8665 Stage::GetCurrent().Add(actor);
8666 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8668 // Build the animation
8669 float durationSeconds(1.0f);
8670 Animation animation = Animation::New(durationSeconds);
8671 float targetOpacity(0.0f);
8672 animation.OpacityTo(actor, targetOpacity);
8674 float ninetyNinePercentProgress(0.01f);
8676 // Start the animation
8679 bool signalReceived(false);
8680 AnimationFinishCheck finishCheck(signalReceived);
8681 animation.FinishedSignal().Connect(&application, finishCheck);
8683 application.SendNotification();
8684 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8686 // We didn't expect the animation to finish yet
8687 application.SendNotification();
8688 finishCheck.CheckSignalNotReceived();
8689 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8691 application.SendNotification();
8692 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8694 // We did expect the animation to finish
8695 application.SendNotification();
8696 finishCheck.CheckSignalReceived();
8697 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8700 finishCheck.Reset();
8701 actor.SetOpacity(1.0f);
8702 application.SendNotification();
8703 application.Render(0);
8704 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8706 // Repeat with a different (ease-in) alpha function
8707 animation = Animation::New(durationSeconds);
8708 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8709 animation.FinishedSignal().Connect(&application, finishCheck);
8712 application.SendNotification();
8713 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8715 // We didn't expect the animation to finish yet
8716 application.SendNotification();
8717 finishCheck.CheckSignalNotReceived();
8719 // The opacity should reduce less, than with a linear alpha function
8720 float current(actor.GetCurrentOpacity());
8721 DALI_TEST_CHECK( current < 1.0f );
8722 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8724 application.SendNotification();
8725 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8727 // We did expect the animation to finish
8728 application.SendNotification();
8729 finishCheck.CheckSignalReceived();
8730 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8733 finishCheck.Reset();
8734 actor.SetOpacity(1.0f);
8735 application.SendNotification();
8736 application.Render(0);
8737 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8739 // Repeat with a delay
8741 animation = Animation::New(durationSeconds);
8742 animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8743 animation.FinishedSignal().Connect(&application, finishCheck);
8746 application.SendNotification();
8747 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8749 // We didn't expect the animation to finish yet
8750 application.SendNotification();
8751 finishCheck.CheckSignalNotReceived();
8752 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8754 application.SendNotification();
8755 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8757 // We did expect the animation to finish
8758 application.SendNotification();
8759 finishCheck.CheckSignalReceived();
8760 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8764 int UtcDaliAnimationColorTo(void)
8766 TestApplication application;
8768 Actor actor = Actor::New();
8769 Stage::GetCurrent().Add(actor);
8770 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8772 // Build the animation
8773 float durationSeconds(1.0f);
8774 Animation animation = Animation::New(durationSeconds);
8775 Vector4 targetColor(Color::RED);
8776 animation.ColorTo(actor, targetColor);
8778 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8779 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8781 // Start the animation
8784 bool signalReceived(false);
8785 AnimationFinishCheck finishCheck(signalReceived);
8786 animation.FinishedSignal().Connect(&application, finishCheck);
8788 application.SendNotification();
8789 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8791 // We didn't expect the animation to finish yet
8792 application.SendNotification();
8793 finishCheck.CheckSignalNotReceived();
8794 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8796 application.SendNotification();
8797 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8799 // We did expect the animation to finish
8800 application.SendNotification();
8801 finishCheck.CheckSignalReceived();
8802 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8805 finishCheck.Reset();
8806 actor.SetColor(Color::WHITE);
8807 application.SendNotification();
8808 application.Render(0);
8809 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8811 // Repeat with a different (ease-in) alpha function
8812 animation = Animation::New(durationSeconds);
8813 animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8814 animation.FinishedSignal().Connect(&application, finishCheck);
8817 application.SendNotification();
8818 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8820 // We didn't expect the animation to finish yet
8821 application.SendNotification();
8822 finishCheck.CheckSignalNotReceived();
8824 // The color should have changed less, than with a linear alpha function
8825 Vector4 current(actor.GetCurrentColor());
8826 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8827 DALI_TEST_CHECK( current.y < 1.0f );
8828 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8829 DALI_TEST_CHECK( current.z < 1.0f );
8830 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8831 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8833 application.SendNotification();
8834 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8836 // We did expect the animation to finish
8837 application.SendNotification();
8838 finishCheck.CheckSignalReceived();
8839 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8842 finishCheck.Reset();
8843 actor.SetColor(Color::WHITE);
8844 application.SendNotification();
8845 application.Render(0);
8846 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8848 // Repeat with a shorter animator duration
8849 float animatorDuration = 0.5f;
8850 animation = Animation::New(durationSeconds);
8851 animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
8852 animation.FinishedSignal().Connect(&application, finishCheck);
8855 application.SendNotification();
8856 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8858 // We didn't expect the animation to finish yet
8859 application.SendNotification();
8860 finishCheck.CheckSignalNotReceived();
8861 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8863 application.SendNotification();
8864 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8866 // We didn't expect the animation to finish yet
8867 application.SendNotification();
8868 finishCheck.CheckSignalNotReceived();
8869 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8871 application.SendNotification();
8872 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8874 // We did expect the animation to finish
8875 application.SendNotification();
8876 finishCheck.CheckSignalReceived();
8877 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8881 int UtcDaliAnimationResize(void)
8883 TestApplication application;
8885 Actor actor = Actor::New();
8886 Stage::GetCurrent().Add(actor);
8887 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8889 // Build the animation
8890 float durationSeconds(1.0f);
8891 Animation animation = Animation::New(durationSeconds);
8892 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8893 animation.Resize(actor, targetSize);
8895 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8897 // Start the animation
8900 bool signalReceived(false);
8901 AnimationFinishCheck finishCheck(signalReceived);
8902 animation.FinishedSignal().Connect(&application, finishCheck);
8904 application.SendNotification();
8905 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8907 // We didn't expect the animation to finish yet
8908 application.SendNotification();
8909 finishCheck.CheckSignalNotReceived();
8910 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8912 application.SendNotification();
8913 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8915 // We did expect the animation to finish
8916 application.SendNotification();
8917 finishCheck.CheckSignalReceived();
8918 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8921 finishCheck.Reset();
8922 actor.SetSize(Vector3::ZERO);
8923 application.SendNotification();
8924 application.Render(0);
8925 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8927 // Repeat with a different (ease-in) alpha function
8928 animation = Animation::New(durationSeconds);
8929 animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
8930 animation.FinishedSignal().Connect(&application, finishCheck);
8933 application.SendNotification();
8934 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8936 // We didn't expect the animation to finish yet
8937 application.SendNotification();
8938 finishCheck.CheckSignalNotReceived();
8940 // The size should have travelled less, than with a linear alpha function
8941 Vector3 current(actor.GetCurrentSize());
8942 DALI_TEST_CHECK( current.x > 0.0f );
8943 DALI_TEST_CHECK( current.y > 0.0f );
8944 DALI_TEST_CHECK( current.z > 0.0f );
8945 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8946 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8947 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8949 application.SendNotification();
8950 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8952 // We did expect the animation to finish
8953 application.SendNotification();
8954 finishCheck.CheckSignalReceived();
8955 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8958 finishCheck.Reset();
8959 actor.SetSize(Vector3::ZERO);
8960 application.SendNotification();
8961 application.Render(0);
8962 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8964 // Repeat with a delay
8966 animation = Animation::New(durationSeconds);
8967 animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
8968 animation.FinishedSignal().Connect(&application, finishCheck);
8971 application.SendNotification();
8972 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8974 // We didn't expect the animation to finish yet
8975 application.SendNotification();
8976 finishCheck.CheckSignalNotReceived();
8977 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8979 application.SendNotification();
8980 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8982 // We did expect the animation to finish
8983 application.SendNotification();
8984 finishCheck.CheckSignalReceived();
8985 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8989 int UtcDaliKeyFramesCreateDestroy(void)
8991 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8993 KeyFrames* keyFrames = new KeyFrames;
8995 DALI_TEST_CHECK( true );
8999 int UtcDaliKeyFramesDownCast(void)
9001 TestApplication application;
9002 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9004 KeyFrames keyFrames = KeyFrames::New();
9005 BaseHandle object(keyFrames);
9007 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9008 DALI_TEST_CHECK(keyFrames2);
9010 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9011 DALI_TEST_CHECK(keyFrames3);
9013 BaseHandle unInitializedObject;
9014 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9015 DALI_TEST_CHECK(!keyFrames4);
9017 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9018 DALI_TEST_CHECK(!keyFrames5);
9022 int UtcDaliAnimationResizeByXY(void)
9024 TestApplication application;
9026 Actor actor = Actor::New();
9027 Stage::GetCurrent().Add(actor);
9028 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9030 // Build the animation
9031 float durationSeconds(1.0f);
9032 Animation animation = Animation::New(durationSeconds);
9033 Vector3 targetSize(100.0f, 100.0f, 100.0f);
9034 animation.Resize(actor, targetSize);
9036 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9038 // Start the animation
9041 bool signalReceived(false);
9042 AnimationFinishCheck finishCheck(signalReceived);
9043 animation.FinishedSignal().Connect(&application, finishCheck);
9045 application.SendNotification();
9046 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9048 // We didn't expect the animation to finish yet
9049 application.SendNotification();
9050 finishCheck.CheckSignalNotReceived();
9051 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9053 application.SendNotification();
9054 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9056 // We did expect the animation to finish
9057 application.SendNotification();
9058 finishCheck.CheckSignalReceived();
9059 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9062 finishCheck.Reset();
9063 actor.SetSize(Vector3::ZERO);
9064 application.SendNotification();
9065 application.Render(0);
9066 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9068 // Repeat with a different (ease-in) alpha function
9069 animation = Animation::New(durationSeconds);
9070 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9071 animation.FinishedSignal().Connect(&application, finishCheck);
9074 application.SendNotification();
9075 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9077 // We didn't expect the animation to finish yet
9078 application.SendNotification();
9079 finishCheck.CheckSignalNotReceived();
9081 // The size should have travelled less, than with a linear alpha function
9082 Vector3 current(actor.GetCurrentSize());
9083 DALI_TEST_CHECK( current.x > 0.0f );
9084 DALI_TEST_CHECK( current.y > 0.0f );
9085 DALI_TEST_CHECK( current.z > 0.0f );
9086 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9087 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9088 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9090 application.SendNotification();
9091 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9093 // We did expect the animation to finish
9094 application.SendNotification();
9095 finishCheck.CheckSignalReceived();
9096 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9099 finishCheck.Reset();
9100 actor.SetSize(Vector3::ZERO);
9101 application.SendNotification();
9102 application.Render(0);
9103 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9105 // Repeat with a delay
9107 animation = Animation::New(durationSeconds);
9108 animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9109 animation.FinishedSignal().Connect(&application, finishCheck);
9112 application.SendNotification();
9113 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9115 // We didn't expect the animation to finish yet
9116 application.SendNotification();
9117 finishCheck.CheckSignalNotReceived();
9118 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9120 application.SendNotification();
9121 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9123 // We did expect the animation to finish
9124 application.SendNotification();
9125 finishCheck.CheckSignalReceived();
9126 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9131 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9133 TestApplication application;
9135 float startValue(1.0f);
9136 Actor actor = Actor::New();
9137 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9138 Stage::GetCurrent().Add(actor);
9140 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9141 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9142 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9143 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9144 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9146 // Build the animation
9147 float durationSeconds(1.0f);
9148 Animation animation = Animation::New(durationSeconds);
9150 KeyFrames keyFrames = KeyFrames::New();
9151 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9152 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9153 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9155 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( 1.0f) );
9157 // Start the animation
9160 bool signalReceived(false);
9161 AnimationFinishCheck finishCheck(signalReceived);
9162 animation.FinishedSignal().Connect(&application, finishCheck);
9163 application.SendNotification();
9164 application.Render(0);
9165 application.SendNotification();
9166 finishCheck.CheckSignalNotReceived();
9167 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9168 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9169 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9170 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9172 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9173 application.SendNotification();
9174 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9175 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9176 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9177 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9179 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9180 application.SendNotification();
9181 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9182 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9183 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9184 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9186 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9187 application.SendNotification();
9188 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9189 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9190 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9191 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9193 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9194 application.SendNotification();
9195 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9196 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9197 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9198 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9200 // We did expect the animation to finish
9202 finishCheck.CheckSignalReceived();
9206 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9208 TestApplication application;
9210 float startValue(1.0f);
9211 Actor actor = Actor::New();
9212 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9213 Stage::GetCurrent().Add(actor);
9215 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9216 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9217 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9218 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9219 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9221 // Build the animation
9222 float durationSeconds(1.0f);
9223 Animation animation = Animation::New(durationSeconds);
9225 KeyFrames keyFrames = KeyFrames::New();
9226 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9227 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9228 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9230 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear );
9232 // Start the animation
9235 bool signalReceived(false);
9236 AnimationFinishCheck finishCheck(signalReceived);
9237 animation.FinishedSignal().Connect(&application, finishCheck);
9238 application.SendNotification();
9239 application.Render(0);
9240 application.SendNotification();
9241 finishCheck.CheckSignalNotReceived();
9242 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9243 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9244 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9245 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9247 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9248 application.SendNotification();
9249 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9250 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9251 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9252 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9254 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9255 application.SendNotification();
9256 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9257 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9258 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9259 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9261 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9262 application.SendNotification();
9263 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9264 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9265 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9266 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9268 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9269 application.SendNotification();
9270 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9271 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9272 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9273 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9275 // We did expect the animation to finish
9277 finishCheck.CheckSignalReceived();
9281 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9283 TestApplication application;
9285 float startValue(1.0f);
9286 Actor actor = Actor::New();
9287 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9288 Stage::GetCurrent().Add(actor);
9290 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9291 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
9292 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9293 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
9294 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9296 // Build the animation
9297 float durationSeconds(1.0f);
9298 Animation animation = Animation::New(durationSeconds);
9300 KeyFrames keyFrames = KeyFrames::New();
9301 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9302 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9303 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9305 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9307 // Start the animation
9310 bool signalReceived(false);
9311 AnimationFinishCheck finishCheck(signalReceived);
9312 animation.FinishedSignal().Connect(&application, finishCheck);
9313 application.SendNotification();
9314 application.Render(0);
9315 application.SendNotification();
9316 finishCheck.CheckSignalNotReceived();
9317 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
9318 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9319 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
9320 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9322 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9323 application.SendNotification();
9324 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
9325 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9326 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
9327 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9329 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9330 application.SendNotification();
9331 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
9332 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9333 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
9334 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9336 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9337 application.SendNotification();
9338 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
9339 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9340 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
9341 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9343 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9344 application.SendNotification();
9345 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
9346 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9347 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
9348 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9350 // We did expect the animation to finish
9352 finishCheck.CheckSignalReceived();
9356 int UtcDaliAnimationCreateDestroy(void)
9358 TestApplication application;
9359 Animation* animation = new Animation;
9360 DALI_TEST_CHECK( animation );
9365 struct UpdateManagerTestConstraint
9367 UpdateManagerTestConstraint(TestApplication& application)
9368 : mApplication(application)
9372 Vector3 operator()(const Vector3& current)
9374 mApplication.SendNotification(); // Process events
9378 TestApplication& mApplication;
9381 int UtcDaliAnimationUpdateManager(void)
9383 TestApplication application;
9385 Actor actor = Actor::New();
9386 Stage::GetCurrent().Add( actor );
9388 // Build the animation
9389 Animation animation = Animation::New( 0.0f );
9391 bool signalReceived = false;
9392 AnimationFinishCheck finishCheck( signalReceived );
9393 animation.FinishedSignal().Connect( &application, finishCheck );
9395 Vector3 startValue(1.0f, 1.0f, 1.0f);
9396 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9397 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
9398 actor.ApplyConstraint( constraint );
9400 // Apply animation to actor
9401 animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear );
9405 application.SendNotification();
9406 application.UpdateOnly( 16 );
9408 finishCheck.CheckSignalNotReceived();
9410 application.SendNotification(); // Process events
9412 finishCheck.CheckSignalReceived();
9417 int UtcDaliAnimationSignalOrder(void)
9419 TestApplication application;
9421 Actor actor = Actor::New();
9422 Stage::GetCurrent().Add( actor );
9424 // Build the animations
9425 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9426 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9428 bool signal1Received = false;
9429 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9431 bool signal2Received = false;
9432 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9434 // Apply animations to actor
9435 animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
9437 animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
9440 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9441 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9443 application.SendNotification();
9444 application.UpdateOnly( 10 ); // 10ms progress
9446 // no notifications yet
9447 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9448 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9450 application.SendNotification();
9453 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9454 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9455 signal1Received = false;
9457 // 1st animation is complete now, do another update with no ProcessEvents in between
9458 application.UpdateOnly( 20 ); // 20ms progress
9461 application.SendNotification();
9463 // 2nd should complete now
9464 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9465 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
9470 int UtcDaliAnimationExtendDuration(void)
9472 TestApplication application;
9474 Actor actor = Actor::New();
9476 // Register a float property
9477 float startValue(10.0f);
9478 Property::Index index = actor.RegisterProperty( "test-property", startValue );
9479 Stage::GetCurrent().Add(actor);
9480 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9482 // Build the animation
9483 float initialDurationSeconds(1.0f);
9484 float animatorDelay = 5.0f;
9485 float animatorDurationSeconds(5.0f);
9486 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
9487 Animation animation = Animation::New(initialDurationSeconds);
9488 float targetValue(30.0f);
9489 float relativeValue(targetValue - startValue);
9491 animation.AnimateTo(Property(actor, index),
9493 TimePeriod(animatorDelay, animatorDurationSeconds));
9495 // The duration should have been extended
9496 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
9498 // Start the animation
9501 bool signalReceived(false);
9502 AnimationFinishCheck finishCheck(signalReceived);
9503 animation.FinishedSignal().Connect(&application, finishCheck);
9505 application.SendNotification();
9506 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9508 // We didn't expect the animation to finish yet
9509 application.SendNotification();
9510 finishCheck.CheckSignalNotReceived();
9511 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9513 application.SendNotification();
9514 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
9516 // We didn't expect the animation to finish yet
9517 application.SendNotification();
9518 finishCheck.CheckSignalNotReceived();
9519 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
9521 application.SendNotification();
9522 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9524 // We did expect the animation to finish
9525 application.SendNotification();
9526 finishCheck.CheckSignalReceived();
9527 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
9531 int UtcDaliAnimationPath(void)
9533 TestApplication application;
9535 Actor actor = Actor::New();
9536 Stage::GetCurrent().Add(actor);
9539 Vector3 position0( 30.0, 80.0, 0.0);
9540 Vector3 position1( 70.0, 120.0, 0.0);
9541 Vector3 position2( 100.0, 100.0, 0.0);
9543 Dali::Path path = Dali::Path::New();
9544 path.AddPoint(position0);
9545 path.AddPoint(position1);
9546 path.AddPoint(position2);
9548 //Control points for first segment
9549 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
9550 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9552 //Control points for second segment
9553 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9554 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9556 // Build the animation
9557 float durationSeconds( 1.0f );
9558 Animation animation = Animation::New(durationSeconds);
9559 animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f ));
9561 // Start the animation
9564 bool signalReceived(false);
9565 AnimationFinishCheck finishCheck(signalReceived);
9566 animation.FinishedSignal().Connect(&application, finishCheck);
9567 application.SendNotification();
9568 application.Render(0);
9569 application.SendNotification();
9570 finishCheck.CheckSignalNotReceived();
9571 Vector3 position, tangent;
9572 Quaternion rotation;
9573 path.Sample( 0.0f, position, tangent );
9574 rotation = Quaternion( Vector3::XAXIS, tangent );
9575 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9576 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9578 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9579 application.SendNotification();
9580 path.Sample( 0.25f, position, tangent );
9581 rotation = Quaternion( Vector3::XAXIS, tangent );
9582 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9583 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9585 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9586 application.SendNotification();
9587 path.Sample( 0.5f, position, tangent );
9588 rotation = Quaternion( Vector3::XAXIS, tangent );
9589 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9590 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9592 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9593 application.SendNotification();
9594 path.Sample( 0.75f, position, tangent );
9595 rotation = Quaternion( Vector3::XAXIS, tangent );
9596 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9597 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9599 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9600 application.SendNotification();
9601 path.Sample( 1.0f, position, tangent );
9602 rotation = Quaternion( Vector3::XAXIS, tangent );
9603 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9604 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9606 finishCheck.CheckSignalReceived();