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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo(Property(actor, Actor::Property::POSITION), 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.AnimateTo( Property( actor, Actor::Property::SCALE ), 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 UtcDaliAnimationAnimateByPropertyPositionVector3(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.AnimateBy( Property( actor, Actor::Property::POSITION ), Vector3( 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 UtcDaliAnimationAnimateByPropertyPositionVector3Alpha(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.AnimateBy( Property( actor, Actor::Property::POSITION ), 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 UtcDaliAnimationAnimateByPropertyPositionVector3AlphaTimePeriod(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.AnimateBy( Property( actor, Actor::Property::POSITION ), relativePosition, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
7261 // Start the animation
7264 bool signalReceived(false);
7265 AnimationFinishCheck finishCheck(signalReceived);
7266 animation.FinishedSignal().Connect(&application, finishCheck);
7268 application.SendNotification();
7269 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7271 // We didn't expect the animation to finish yet
7272 application.SendNotification();
7273 finishCheck.CheckSignalNotReceived();
7274 DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7276 application.SendNotification();
7277 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7279 // We did expect the animation to finish
7280 application.SendNotification();
7281 finishCheck.CheckSignalReceived();
7282 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7286 int UtcDaliAnimationAnimateToPropertyPositionVector3(void)
7288 TestApplication application;
7290 Actor actor = Actor::New();
7291 Stage::GetCurrent().Add(actor);
7292 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7294 // Build the animation
7295 float durationSeconds(1.0f);
7296 Animation animation = Animation::New(durationSeconds);
7297 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7298 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( targetPosition.x, targetPosition.y, targetPosition.z ) );
7300 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7302 // Start the animation
7305 bool signalReceived(false);
7306 AnimationFinishCheck finishCheck(signalReceived);
7307 animation.FinishedSignal().Connect(&application, finishCheck);
7309 application.SendNotification();
7310 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7312 // We didn't expect the animation to finish yet
7313 application.SendNotification();
7314 finishCheck.CheckSignalNotReceived();
7315 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7317 application.SendNotification();
7318 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7320 // We did expect the animation to finish
7321 application.SendNotification();
7322 finishCheck.CheckSignalReceived();
7323 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7327 int UtcDaliAnimationAnimateToPropertyPositionVector3Alpha(void)
7329 TestApplication application;
7331 Actor actor = Actor::New();
7332 Stage::GetCurrent().Add(actor);
7333 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7335 // Build the animation
7336 float durationSeconds(1.0f);
7337 Animation animation = Animation::New(durationSeconds);
7338 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7339 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunctions::EaseIn );
7341 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7343 // Start the animation
7346 bool signalReceived(false);
7347 AnimationFinishCheck finishCheck(signalReceived);
7348 animation.FinishedSignal().Connect(&application, finishCheck);
7350 application.SendNotification();
7351 application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7353 // We didn't expect the animation to finish yet
7354 application.SendNotification();
7355 finishCheck.CheckSignalNotReceived();
7357 // The position should have moved less, than with a linear alpha function
7358 Vector3 current(actor.GetCurrentPosition());
7359 DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7360 DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7361 DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7362 DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7363 DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7364 DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7366 application.SendNotification();
7367 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7369 // We did expect the animation to finish
7370 application.SendNotification();
7371 finishCheck.CheckSignalReceived();
7372 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7376 int UtcDaliAnimationAnimateToPropertyPositionVector3AlphaTimePeriod(void)
7378 TestApplication application;
7380 Actor actor = Actor::New();
7381 Stage::GetCurrent().Add(actor);
7382 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7384 // Build the animation
7385 float durationSeconds(1.0f);
7386 Animation animation = Animation::New(durationSeconds);
7387 Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7389 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
7391 Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7393 // Start the animation
7396 bool signalReceived(false);
7397 AnimationFinishCheck finishCheck(signalReceived);
7398 animation.FinishedSignal().Connect(&application, finishCheck);
7400 application.SendNotification();
7401 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7403 // We didn't expect the animation to finish yet
7404 application.SendNotification();
7405 finishCheck.CheckSignalNotReceived();
7406 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7408 application.SendNotification();
7409 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7411 // We didn't expect the animation to finish yet
7412 application.SendNotification();
7413 finishCheck.CheckSignalNotReceived();
7414 DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7416 application.SendNotification();
7417 application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7419 // We did expect the animation to finish
7420 application.SendNotification();
7421 finishCheck.CheckSignalReceived();
7422 DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7426 int UtcDaliAnimationAnimateByPropertyOrientationQuaternion(void)
7428 TestApplication application;
7430 Actor actor = Actor::New();
7431 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7432 Stage::GetCurrent().Add(actor);
7433 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7435 // Build the animation
7436 float durationSeconds(1.0f);
7437 Animation animation = Animation::New(durationSeconds);
7438 Degree relativeRotationDegrees(360.0f);
7439 Radian relativeRotationRadians(relativeRotationDegrees);
7440 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
7442 // Start the animation
7445 bool signalReceived(false);
7446 AnimationFinishCheck finishCheck(signalReceived);
7447 animation.FinishedSignal().Connect(&application, finishCheck);
7449 application.SendNotification();
7450 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7452 // We didn't expect the animation to finish yet
7453 application.SendNotification();
7454 finishCheck.CheckSignalNotReceived();
7455 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7457 application.SendNotification();
7458 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7460 // We didn't expect the animation to finish yet
7461 application.SendNotification();
7462 finishCheck.CheckSignalNotReceived();
7463 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7465 application.SendNotification();
7466 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7468 // We didn't expect the animation to finish yet
7469 application.SendNotification();
7470 finishCheck.CheckSignalNotReceived();
7471 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7473 application.SendNotification();
7474 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7476 // We did expect the animation to finish
7477 application.SendNotification();
7478 finishCheck.CheckSignalReceived();
7479 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7483 int UtcDaliAnimationAnimateByPropertyOrientationQuaternionAlpha(void)
7485 TestApplication application;
7487 Actor actor = Actor::New();
7488 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7489 Stage::GetCurrent().Add(actor);
7490 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7492 // Build the animation
7493 float durationSeconds(1.0f);
7494 Animation animation = Animation::New(durationSeconds);
7495 Degree relativeRotationDegrees(360.0f);
7496 Radian relativeRotationRadians(relativeRotationDegrees);
7497 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunctions::EaseIn );
7499 // Start the animation
7502 bool signalReceived(false);
7503 AnimationFinishCheck finishCheck(signalReceived);
7504 animation.FinishedSignal().Connect(&application, finishCheck);
7506 application.SendNotification();
7507 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7509 // We didn't expect the animation to finish yet
7510 application.SendNotification();
7511 finishCheck.CheckSignalNotReceived();
7512 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7514 application.SendNotification();
7515 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7517 // We didn't expect the animation to finish yet
7518 application.SendNotification();
7519 finishCheck.CheckSignalNotReceived();
7520 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7522 application.SendNotification();
7523 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7525 // We didn't expect the animation to finish yet
7526 application.SendNotification();
7527 finishCheck.CheckSignalNotReceived();
7528 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7530 application.SendNotification();
7531 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7533 // We did expect the animation to finish
7534 application.SendNotification();
7535 finishCheck.CheckSignalReceived();
7536 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7540 int UtcDaliAnimationAnimateByPropertyOrientationQuaternionAlphaTimePeriod(void)
7542 TestApplication application;
7544 Actor actor = Actor::New();
7545 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7546 Stage::GetCurrent().Add(actor);
7547 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7549 // Build the animation
7550 float durationSeconds(1.0f);
7551 Animation animation = Animation::New(durationSeconds);
7552 Degree relativeRotationDegrees(360.0f);
7553 Radian relativeRotationRadians(relativeRotationDegrees);
7555 animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
7556 AlphaFunctions::EaseIn, TimePeriod( delay, durationSeconds - delay ) );
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 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7572 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7574 application.SendNotification();
7575 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7577 // We didn't expect the animation to finish yet
7578 application.SendNotification();
7579 finishCheck.CheckSignalNotReceived();
7580 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7581 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7583 application.SendNotification();
7584 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7586 // We didn't expect the animation to finish yet
7587 application.SendNotification();
7588 finishCheck.CheckSignalNotReceived();
7589 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7590 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7592 application.SendNotification();
7593 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7595 // We did expect the animation to finish
7596 application.SendNotification();
7597 finishCheck.CheckSignalReceived();
7598 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7602 int UtcDaliAnimationAnimateToPropertyOrientationQuaternion(void)
7604 TestApplication application;
7606 Actor actor = Actor::New();
7607 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7608 Stage::GetCurrent().Add(actor);
7609 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7611 // Build the animation
7612 float durationSeconds(1.0f);
7613 Animation animation = Animation::New(durationSeconds);
7614 Degree targetRotationDegrees(90.0f);
7615 Radian targetRotationRadians(targetRotationDegrees);
7616 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7617 animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), targetRotation );
7619 // Start the animation
7622 bool signalReceived(false);
7623 AnimationFinishCheck finishCheck(signalReceived);
7624 animation.FinishedSignal().Connect(&application, finishCheck);
7626 application.SendNotification();
7627 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7629 // We didn't expect the animation to finish yet
7630 application.SendNotification();
7631 finishCheck.CheckSignalNotReceived();
7632 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7634 application.SendNotification();
7635 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7637 // We didn't expect the animation to finish yet
7638 application.SendNotification();
7639 finishCheck.CheckSignalNotReceived();
7640 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7642 application.SendNotification();
7643 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7645 // We didn't expect the animation to finish yet
7646 application.SendNotification();
7647 finishCheck.CheckSignalNotReceived();
7648 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7650 application.SendNotification();
7651 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7653 // We did expect the animation to finish
7654 application.SendNotification();
7655 finishCheck.CheckSignalReceived();
7656 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7660 int UtcDaliAnimationAnimateToPropertyOrientationQuaternionAlpha(void)
7662 TestApplication application;
7664 Actor actor = Actor::New();
7665 actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
7666 Stage::GetCurrent().Add(actor);
7667 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7669 // Build the animation
7670 float durationSeconds(1.0f);
7671 Animation animation = Animation::New(durationSeconds);
7672 Degree targetRotationDegrees(90.0f);
7673 Radian targetRotationRadians(targetRotationDegrees);
7674 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7675 animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), targetRotation, AlphaFunctions::EaseIn );
7677 // Start the animation
7680 bool signalReceived(false);
7681 AnimationFinishCheck finishCheck(signalReceived);
7682 animation.FinishedSignal().Connect(&application, finishCheck);
7684 application.SendNotification();
7685 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7687 // We didn't expect the animation to finish yet
7688 application.SendNotification();
7689 finishCheck.CheckSignalNotReceived();
7690 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7692 application.SendNotification();
7693 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7695 // We didn't expect the animation to finish yet
7696 application.SendNotification();
7697 finishCheck.CheckSignalNotReceived();
7698 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7700 application.SendNotification();
7701 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7703 // We didn't expect the animation to finish yet
7704 application.SendNotification();
7705 finishCheck.CheckSignalNotReceived();
7706 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7708 application.SendNotification();
7709 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7711 // We did expect the animation to finish
7712 application.SendNotification();
7713 finishCheck.CheckSignalReceived();
7714 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7718 int UtcDaliAnimationAnimateToPropertyOrientationQuaternionAlphaTimePeriod(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 targetRotationDegrees(90.0f);
7731 Radian targetRotationRadians(targetRotationDegrees);
7733 Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7734 animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), targetRotation, AlphaFunctions::EaseIn, TimePeriod( delay, durationSeconds - delay ) );
7736 // Start the animation
7739 bool signalReceived(false);
7740 AnimationFinishCheck finishCheck(signalReceived);
7741 animation.FinishedSignal().Connect(&application, finishCheck);
7743 application.SendNotification();
7744 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7746 // We didn't expect the animation to finish yet
7747 application.SendNotification();
7748 finishCheck.CheckSignalNotReceived();
7749 float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7750 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7752 application.SendNotification();
7753 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7755 // We didn't expect the animation to finish yet
7756 application.SendNotification();
7757 finishCheck.CheckSignalNotReceived();
7758 progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7759 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7761 application.SendNotification();
7762 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7764 // We didn't expect the animation to finish yet
7765 application.SendNotification();
7766 finishCheck.CheckSignalNotReceived();
7767 progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7768 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7770 application.SendNotification();
7771 application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7773 // We did expect the animation to finish
7774 application.SendNotification();
7775 finishCheck.CheckSignalReceived();
7776 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7780 int UtcDaliAnimationAnimateByPropertyScale(void)
7782 TestApplication application;
7784 Actor actor = Actor::New();
7785 Stage::GetCurrent().Add(actor);
7786 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7788 // Build the animation
7789 float durationSeconds(1.0f);
7790 Animation animation = Animation::New(durationSeconds);
7791 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7792 Vector3 relativeScale(targetScale - Vector3::ONE);
7793 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
7795 Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
7797 // Start the animation
7800 bool signalReceived(false);
7801 AnimationFinishCheck finishCheck(signalReceived);
7802 animation.FinishedSignal().Connect(&application, finishCheck);
7804 application.SendNotification();
7805 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7807 // We didn't expect the animation to finish yet
7808 application.SendNotification();
7809 finishCheck.CheckSignalNotReceived();
7810 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7812 application.SendNotification();
7813 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7815 // We did expect the animation to finish
7816 application.SendNotification();
7817 finishCheck.CheckSignalReceived();
7818 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7821 finishCheck.Reset();
7822 actor.SetScale(Vector3::ONE);
7823 application.SendNotification();
7824 application.Render(0);
7825 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7827 // Repeat with a different (ease-in) alpha function
7828 animation = Animation::New(durationSeconds);
7829 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunctions::EaseIn );
7830 animation.FinishedSignal().Connect(&application, finishCheck);
7833 application.SendNotification();
7834 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7836 // We didn't expect the animation to finish yet
7837 application.SendNotification();
7838 finishCheck.CheckSignalNotReceived();
7840 // The scale should have grown less, than with a linear alpha function
7841 Vector3 current(actor.GetCurrentScale());
7842 DALI_TEST_CHECK( current.x > 1.0f );
7843 DALI_TEST_CHECK( current.y > 1.0f );
7844 DALI_TEST_CHECK( current.z > 1.0f );
7845 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7846 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7847 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7849 application.SendNotification();
7850 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7852 // We did expect the animation to finish
7853 application.SendNotification();
7854 finishCheck.CheckSignalReceived();
7855 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7858 finishCheck.Reset();
7859 actor.SetScale(Vector3::ONE);
7860 application.SendNotification();
7861 application.Render(0);
7862 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7864 // Repeat with a delay
7866 animation = Animation::New(durationSeconds);
7867 animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
7868 animation.FinishedSignal().Connect(&application, finishCheck);
7871 application.SendNotification();
7872 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7874 // We didn't expect the animation to finish yet
7875 application.SendNotification();
7876 finishCheck.CheckSignalNotReceived();
7877 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7879 application.SendNotification();
7880 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7882 // We did expect the animation to finish
7883 application.SendNotification();
7884 finishCheck.CheckSignalReceived();
7885 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7889 int UtcDaliAnimationAnimateToPropertyScale(void)
7891 TestApplication application;
7893 Actor actor = Actor::New();
7894 Stage::GetCurrent().Add(actor);
7895 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7897 // Build the animation
7898 float durationSeconds(1.0f);
7899 Animation animation = Animation::New(durationSeconds);
7900 Vector3 targetScale(2.0f, 2.0f, 2.0f);
7901 animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale );
7903 Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7905 // Start the animation
7908 bool signalReceived(false);
7909 AnimationFinishCheck finishCheck(signalReceived);
7910 animation.FinishedSignal().Connect(&application, finishCheck);
7912 application.SendNotification();
7913 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7915 // We didn't expect the animation to finish yet
7916 application.SendNotification();
7917 finishCheck.CheckSignalNotReceived();
7918 DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7920 application.SendNotification();
7921 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7923 // We did expect the animation to finish
7924 application.SendNotification();
7925 finishCheck.CheckSignalReceived();
7926 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7929 finishCheck.Reset();
7930 actor.SetScale(Vector3::ONE);
7931 application.SendNotification();
7932 application.Render(0);
7933 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7935 // Repeat with a different (ease-in) alpha function
7936 animation = Animation::New(durationSeconds);
7937 animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunctions::EaseIn );
7938 animation.FinishedSignal().Connect(&application, finishCheck);
7941 application.SendNotification();
7942 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7944 // We didn't expect the animation to finish yet
7945 application.SendNotification();
7946 finishCheck.CheckSignalNotReceived();
7948 // The scale should have grown less, than with a linear alpha function
7949 Vector3 current(actor.GetCurrentScale());
7950 DALI_TEST_CHECK( current.x > 1.0f );
7951 DALI_TEST_CHECK( current.y > 1.0f );
7952 DALI_TEST_CHECK( current.z > 1.0f );
7953 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7954 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7955 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7957 application.SendNotification();
7958 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7960 // We did expect the animation to finish
7961 application.SendNotification();
7962 finishCheck.CheckSignalReceived();
7963 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7966 finishCheck.Reset();
7967 actor.SetScale(Vector3::ONE);
7968 application.SendNotification();
7969 application.Render(0);
7970 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7972 // Repeat with a delay
7974 animation = Animation::New(durationSeconds);
7975 animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
7976 animation.FinishedSignal().Connect(&application, finishCheck);
7979 application.SendNotification();
7980 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7982 // We didn't expect the animation to finish yet
7983 application.SendNotification();
7984 finishCheck.CheckSignalNotReceived();
7985 DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7987 application.SendNotification();
7988 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7990 // We did expect the animation to finish
7991 application.SendNotification();
7992 finishCheck.CheckSignalReceived();
7993 DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7997 int UtcDaliAnimationShow(void)
7999 TestApplication application;
8001 Actor actor = Actor::New();
8002 actor.SetVisible(false);
8003 application.SendNotification();
8004 application.Render(0);
8005 DALI_TEST_CHECK( !actor.IsVisible() );
8006 Stage::GetCurrent().Add(actor);
8008 // Start the animation
8009 float durationSeconds(10.0f);
8010 Animation animation = Animation::New(durationSeconds);
8011 animation.Show(actor, durationSeconds*0.5f);
8014 bool signalReceived(false);
8015 AnimationFinishCheck finishCheck(signalReceived);
8016 animation.FinishedSignal().Connect(&application, finishCheck);
8018 application.SendNotification();
8019 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8021 // We didn't expect the animation to finish yet
8022 application.SendNotification();
8023 finishCheck.CheckSignalNotReceived();
8024 DALI_TEST_CHECK( !actor.IsVisible() );
8026 application.SendNotification();
8027 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8029 // We didn't expect the animation to finish yet
8030 application.SendNotification();
8031 finishCheck.CheckSignalNotReceived();
8032 DALI_TEST_CHECK( actor.IsVisible() );
8034 application.SendNotification();
8035 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8037 // We did expect the animation to finish
8038 application.SendNotification();
8039 finishCheck.CheckSignalReceived();
8040 DALI_TEST_CHECK( actor.IsVisible() );
8044 int UtcDaliAnimationHide(void)
8046 TestApplication application;
8048 Actor actor = Actor::New();
8049 DALI_TEST_CHECK( actor.IsVisible() );
8050 Stage::GetCurrent().Add(actor);
8052 // Start the animation
8053 float durationSeconds(10.0f);
8054 Animation animation = Animation::New(durationSeconds);
8055 animation.Hide(actor, durationSeconds*0.5f);
8058 bool signalReceived(false);
8059 AnimationFinishCheck finishCheck(signalReceived);
8060 animation.FinishedSignal().Connect(&application, finishCheck);
8062 application.SendNotification();
8063 application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8065 // We didn't expect the animation to finish yet
8066 application.SendNotification();
8067 finishCheck.CheckSignalNotReceived();
8068 DALI_TEST_CHECK( actor.IsVisible() );
8070 application.SendNotification();
8071 application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8073 // We didn't expect the animation to finish yet
8074 application.SendNotification();
8075 finishCheck.CheckSignalNotReceived();
8076 DALI_TEST_CHECK( !actor.IsVisible() );
8078 application.SendNotification();
8079 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8081 // We did expect the animation to finish
8082 application.SendNotification();
8083 finishCheck.CheckSignalReceived();
8084 DALI_TEST_CHECK( !actor.IsVisible() );
8088 int UtcDaliAnimationShowHideAtEnd(void)
8090 // Test that show/hide delay can be the same as animation duration
8091 // i.e. to show/hide at the end of the animation
8093 TestApplication application;
8095 Actor actor = Actor::New();
8096 DALI_TEST_CHECK( actor.IsVisible() );
8097 Stage::GetCurrent().Add(actor);
8099 // Start Hide animation
8100 float durationSeconds(10.0f);
8101 Animation animation = Animation::New(durationSeconds);
8102 animation.Hide(actor, durationSeconds/*Hide at end*/);
8105 bool signalReceived(false);
8106 AnimationFinishCheck finishCheck(signalReceived);
8107 animation.FinishedSignal().Connect(&application, finishCheck);
8109 application.SendNotification();
8110 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8112 // We did expect the animation to finish
8113 application.SendNotification();
8114 finishCheck.CheckSignalReceived();
8115 DALI_TEST_CHECK( !actor.IsVisible() );
8117 // Start Show animation
8118 animation = Animation::New(durationSeconds);
8119 animation.Show(actor, durationSeconds/*Show at end*/);
8120 animation.FinishedSignal().Connect(&application, finishCheck);
8123 application.SendNotification();
8124 application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8126 // We did expect the animation to finish
8127 application.SendNotification();
8128 finishCheck.CheckSignalReceived();
8129 DALI_TEST_CHECK( actor.IsVisible() );
8133 int UtcDaliAnimationAnimateToPropertyColorAlpha(void)
8135 TestApplication application;
8137 Actor actor = Actor::New();
8138 Stage::GetCurrent().Add(actor);
8139 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8141 // Build the animation
8142 float durationSeconds(1.0f);
8143 Animation animation = Animation::New(durationSeconds);
8144 float targetOpacity(0.0f);
8145 animation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), targetOpacity );
8147 float ninetyNinePercentProgress(0.01f);
8149 // Start the animation
8152 bool signalReceived(false);
8153 AnimationFinishCheck finishCheck(signalReceived);
8154 animation.FinishedSignal().Connect(&application, finishCheck);
8156 application.SendNotification();
8157 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8159 // We didn't expect the animation to finish yet
8160 application.SendNotification();
8161 finishCheck.CheckSignalNotReceived();
8162 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8164 application.SendNotification();
8165 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8167 // We did expect the animation to finish
8168 application.SendNotification();
8169 finishCheck.CheckSignalReceived();
8170 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8173 finishCheck.Reset();
8174 actor.SetOpacity(1.0f);
8175 application.SendNotification();
8176 application.Render(0);
8177 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8179 // Repeat with a different (ease-in) alpha function
8180 animation = Animation::New(durationSeconds);
8181 animation.AnimateTo(Property( actor, Actor::Property::COLOR_ALPHA ), targetOpacity, AlphaFunctions::EaseIn );
8182 animation.FinishedSignal().Connect(&application, finishCheck);
8185 application.SendNotification();
8186 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8188 // We didn't expect the animation to finish yet
8189 application.SendNotification();
8190 finishCheck.CheckSignalNotReceived();
8192 // The opacity should reduce less, than with a linear alpha function
8193 float current(actor.GetCurrentOpacity());
8194 DALI_TEST_CHECK( current < 1.0f );
8195 DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8197 application.SendNotification();
8198 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8200 // We did expect the animation to finish
8201 application.SendNotification();
8202 finishCheck.CheckSignalReceived();
8203 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8206 finishCheck.Reset();
8207 actor.SetOpacity(1.0f);
8208 application.SendNotification();
8209 application.Render(0);
8210 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8212 // Repeat with a delay
8214 animation = Animation::New(durationSeconds);
8215 animation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), targetOpacity, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
8216 animation.FinishedSignal().Connect(&application, finishCheck);
8219 application.SendNotification();
8220 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8222 // We didn't expect the animation to finish yet
8223 application.SendNotification();
8224 finishCheck.CheckSignalNotReceived();
8225 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8227 application.SendNotification();
8228 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8230 // We did expect the animation to finish
8231 application.SendNotification();
8232 finishCheck.CheckSignalReceived();
8233 DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8237 int UtcDaliAnimationAnimateToPropertyColor(void)
8239 TestApplication application;
8241 Actor actor = Actor::New();
8242 Stage::GetCurrent().Add(actor);
8243 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8245 // Build the animation
8246 float durationSeconds(1.0f);
8247 Animation animation = Animation::New(durationSeconds);
8248 Vector4 targetColor(Color::RED);
8249 animation.AnimateTo( Property( actor, Actor::Property::COLOR ), targetColor );
8251 Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8252 Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8254 // Start the animation
8257 bool signalReceived(false);
8258 AnimationFinishCheck finishCheck(signalReceived);
8259 animation.FinishedSignal().Connect(&application, finishCheck);
8261 application.SendNotification();
8262 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8264 // We didn't expect the animation to finish yet
8265 application.SendNotification();
8266 finishCheck.CheckSignalNotReceived();
8267 DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8269 application.SendNotification();
8270 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8272 // We did expect the animation to finish
8273 application.SendNotification();
8274 finishCheck.CheckSignalReceived();
8275 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8278 finishCheck.Reset();
8279 actor.SetColor(Color::WHITE);
8280 application.SendNotification();
8281 application.Render(0);
8282 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8284 // Repeat with a different (ease-in) alpha function
8285 animation = Animation::New(durationSeconds);
8286 animation.AnimateTo( Property( actor, Actor::Property::COLOR ), targetColor, AlphaFunctions::EaseIn );
8287 animation.FinishedSignal().Connect(&application, finishCheck);
8290 application.SendNotification();
8291 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8293 // We didn't expect the animation to finish yet
8294 application.SendNotification();
8295 finishCheck.CheckSignalNotReceived();
8297 // The color should have changed less, than with a linear alpha function
8298 Vector4 current(actor.GetCurrentColor());
8299 DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8300 DALI_TEST_CHECK( current.y < 1.0f );
8301 DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8302 DALI_TEST_CHECK( current.z < 1.0f );
8303 DALI_TEST_CHECK( current.z > tenPercentProgress.z );
8304 DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8306 application.SendNotification();
8307 application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8309 // We did expect the animation to finish
8310 application.SendNotification();
8311 finishCheck.CheckSignalReceived();
8312 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8315 finishCheck.Reset();
8316 actor.SetColor(Color::WHITE);
8317 application.SendNotification();
8318 application.Render(0);
8319 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8321 // Repeat with a shorter animator duration
8322 float animatorDuration = 0.5f;
8323 animation = Animation::New(durationSeconds);
8324 animation.AnimateTo( Property( actor, Actor::Property::COLOR ), targetColor, AlphaFunctions::Linear, TimePeriod( 0, animatorDuration ) );
8325 animation.FinishedSignal().Connect(&application, finishCheck);
8328 application.SendNotification();
8329 application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8331 // We didn't expect the animation to finish yet
8332 application.SendNotification();
8333 finishCheck.CheckSignalNotReceived();
8334 DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8336 application.SendNotification();
8337 application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8339 // We didn't expect the animation to finish yet
8340 application.SendNotification();
8341 finishCheck.CheckSignalNotReceived();
8342 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8344 application.SendNotification();
8345 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8347 // We did expect the animation to finish
8348 application.SendNotification();
8349 finishCheck.CheckSignalReceived();
8350 DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8354 int UtcDaliAnimationAnimateToPropertySize(void)
8356 TestApplication application;
8358 Actor actor = Actor::New();
8359 Stage::GetCurrent().Add(actor);
8360 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8362 // Build the animation
8363 float durationSeconds(1.0f);
8364 Animation animation = Animation::New(durationSeconds);
8365 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8366 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize);
8368 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8370 // Start the animation
8373 bool signalReceived(false);
8374 AnimationFinishCheck finishCheck(signalReceived);
8375 animation.FinishedSignal().Connect(&application, finishCheck);
8377 application.SendNotification();
8378 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8380 // We didn't expect the animation to finish yet
8381 application.SendNotification();
8382 finishCheck.CheckSignalNotReceived();
8383 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8385 application.SendNotification();
8386 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8388 // We did expect the animation to finish
8389 application.SendNotification();
8390 finishCheck.CheckSignalReceived();
8391 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8394 finishCheck.Reset();
8395 actor.SetSize(Vector3::ZERO);
8396 application.SendNotification();
8397 application.Render(0);
8398 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8400 // Repeat with a different (ease-in) alpha function
8401 animation = Animation::New(durationSeconds);
8402 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn );
8403 animation.FinishedSignal().Connect(&application, finishCheck);
8406 application.SendNotification();
8407 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8409 // We didn't expect the animation to finish yet
8410 application.SendNotification();
8411 finishCheck.CheckSignalNotReceived();
8413 // The size should have travelled less, than with a linear alpha function
8414 Vector3 current(actor.GetCurrentSize());
8415 DALI_TEST_CHECK( current.x > 0.0f );
8416 DALI_TEST_CHECK( current.y > 0.0f );
8417 DALI_TEST_CHECK( current.z > 0.0f );
8418 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8419 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8420 DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8422 application.SendNotification();
8423 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8425 // We did expect the animation to finish
8426 application.SendNotification();
8427 finishCheck.CheckSignalReceived();
8428 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8431 finishCheck.Reset();
8432 actor.SetSize(Vector3::ZERO);
8433 application.SendNotification();
8434 application.Render(0);
8435 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8437 // Repeat with a delay
8439 animation = Animation::New(durationSeconds);
8440 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
8441 animation.FinishedSignal().Connect(&application, finishCheck);
8444 application.SendNotification();
8445 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8447 // We didn't expect the animation to finish yet
8448 application.SendNotification();
8449 finishCheck.CheckSignalNotReceived();
8450 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8452 application.SendNotification();
8453 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8455 // We did expect the animation to finish
8456 application.SendNotification();
8457 finishCheck.CheckSignalReceived();
8458 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8462 int UtcDaliKeyFramesCreateDestroy(void)
8464 tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8466 KeyFrames* keyFrames = new KeyFrames;
8468 DALI_TEST_CHECK( true );
8472 int UtcDaliKeyFramesDownCast(void)
8474 TestApplication application;
8475 tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
8477 KeyFrames keyFrames = KeyFrames::New();
8478 BaseHandle object(keyFrames);
8480 KeyFrames keyFrames2 = KeyFrames::DownCast(object);
8481 DALI_TEST_CHECK(keyFrames2);
8483 KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
8484 DALI_TEST_CHECK(keyFrames3);
8486 BaseHandle unInitializedObject;
8487 KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
8488 DALI_TEST_CHECK(!keyFrames4);
8490 KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
8491 DALI_TEST_CHECK(!keyFrames5);
8495 int UtcDaliAnimationAnimateToPropertySizeByXY(void)
8497 TestApplication application;
8499 Actor actor = Actor::New();
8500 Stage::GetCurrent().Add(actor);
8501 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8503 // Build the animation
8504 float durationSeconds(1.0f);
8505 Animation animation = Animation::New(durationSeconds);
8506 Vector3 targetSize(100.0f, 100.0f, 100.0f);
8507 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
8509 Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
8511 // Start the animation
8514 bool signalReceived(false);
8515 AnimationFinishCheck finishCheck(signalReceived);
8516 animation.FinishedSignal().Connect(&application, finishCheck);
8518 application.SendNotification();
8519 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8521 // We didn't expect the animation to finish yet
8522 application.SendNotification();
8523 finishCheck.CheckSignalNotReceived();
8524 DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
8526 application.SendNotification();
8527 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8529 // We did expect the animation to finish
8530 application.SendNotification();
8531 finishCheck.CheckSignalReceived();
8532 DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
8535 finishCheck.Reset();
8536 actor.SetSize(Vector3::ZERO);
8537 application.SendNotification();
8538 application.Render(0);
8539 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8541 // Repeat with a different (ease-in) alpha function
8542 animation = Animation::New(durationSeconds);
8543 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::EaseIn );
8544 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::EaseIn );
8545 animation.FinishedSignal().Connect(&application, finishCheck);
8548 application.SendNotification();
8549 application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8551 // We didn't expect the animation to finish yet
8552 application.SendNotification();
8553 finishCheck.CheckSignalNotReceived();
8555 // The size should have travelled less, than with a linear alpha function
8556 Vector3 current(actor.GetCurrentSize());
8557 DALI_TEST_CHECK( current.x > 0.0f );
8558 DALI_TEST_CHECK( current.y > 0.0f );
8559 DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8560 DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8562 application.SendNotification();
8563 application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8565 // We did expect the animation to finish
8566 application.SendNotification();
8567 finishCheck.CheckSignalReceived();
8568 DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
8569 DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
8572 finishCheck.Reset();
8573 actor.SetSize(Vector3::ZERO);
8574 application.SendNotification();
8575 application.Render(0);
8576 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8578 // Repeat with a delay
8580 animation = Animation::New(durationSeconds);
8581 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
8582 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
8583 animation.FinishedSignal().Connect(&application, finishCheck);
8586 application.SendNotification();
8587 application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8589 // We didn't expect the animation to finish yet
8590 application.SendNotification();
8591 finishCheck.CheckSignalNotReceived();
8592 DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
8594 application.SendNotification();
8595 application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8597 // We did expect the animation to finish
8598 application.SendNotification();
8599 finishCheck.CheckSignalReceived();
8600 DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
8601 DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
8605 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
8607 TestApplication application;
8609 float startValue(1.0f);
8610 Actor actor = Actor::New();
8611 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8612 Stage::GetCurrent().Add(actor);
8614 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8615 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8616 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8617 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8618 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8620 // Build the animation
8621 float durationSeconds(1.0f);
8622 Animation animation = Animation::New(durationSeconds);
8624 KeyFrames keyFrames = KeyFrames::New();
8625 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8626 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8627 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8629 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( 1.0f) );
8631 // Start the animation
8634 bool signalReceived(false);
8635 AnimationFinishCheck finishCheck(signalReceived);
8636 animation.FinishedSignal().Connect(&application, finishCheck);
8637 application.SendNotification();
8638 application.Render(0);
8639 application.SendNotification();
8640 finishCheck.CheckSignalNotReceived();
8641 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8642 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8643 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8644 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8646 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8647 application.SendNotification();
8648 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8649 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8650 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8651 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8653 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8654 application.SendNotification();
8655 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8656 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8657 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8658 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8660 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8661 application.SendNotification();
8662 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8663 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8664 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8665 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8667 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8668 application.SendNotification();
8669 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8670 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8671 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8672 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8674 // We did expect the animation to finish
8676 finishCheck.CheckSignalReceived();
8680 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
8682 TestApplication application;
8684 float startValue(1.0f);
8685 Actor actor = Actor::New();
8686 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8687 Stage::GetCurrent().Add(actor);
8689 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8690 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8691 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8692 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8693 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8695 // Build the animation
8696 float durationSeconds(1.0f);
8697 Animation animation = Animation::New(durationSeconds);
8699 KeyFrames keyFrames = KeyFrames::New();
8700 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8701 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8702 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8704 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear );
8706 // Start the animation
8709 bool signalReceived(false);
8710 AnimationFinishCheck finishCheck(signalReceived);
8711 animation.FinishedSignal().Connect(&application, finishCheck);
8712 application.SendNotification();
8713 application.Render(0);
8714 application.SendNotification();
8715 finishCheck.CheckSignalNotReceived();
8716 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8717 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8718 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8719 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8721 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8722 application.SendNotification();
8723 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8724 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8725 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8726 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8728 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8729 application.SendNotification();
8730 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8731 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8732 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8733 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8735 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8736 application.SendNotification();
8737 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8738 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8739 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8740 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8742 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8743 application.SendNotification();
8744 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8745 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8746 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8747 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8749 // We did expect the animation to finish
8751 finishCheck.CheckSignalReceived();
8755 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
8757 TestApplication application;
8759 float startValue(1.0f);
8760 Actor actor = Actor::New();
8761 actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8762 Stage::GetCurrent().Add(actor);
8764 DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8765 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), startValue, TEST_LOCATION );
8766 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8767 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), startValue, TEST_LOCATION );
8768 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8770 // Build the animation
8771 float durationSeconds(1.0f);
8772 Animation animation = Animation::New(durationSeconds);
8774 KeyFrames keyFrames = KeyFrames::New();
8775 keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8776 keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8777 keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8779 animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
8781 // Start the animation
8784 bool signalReceived(false);
8785 AnimationFinishCheck finishCheck(signalReceived);
8786 animation.FinishedSignal().Connect(&application, finishCheck);
8787 application.SendNotification();
8788 application.Render(0);
8789 application.SendNotification();
8790 finishCheck.CheckSignalNotReceived();
8791 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION );
8792 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8793 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION );
8794 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8796 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8797 application.SendNotification();
8798 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION );
8799 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8800 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION );
8801 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8803 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8804 application.SendNotification();
8805 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION );
8806 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8807 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION );
8808 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8810 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8811 application.SendNotification();
8812 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION );
8813 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8814 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION );
8815 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8817 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8818 application.SendNotification();
8819 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION );
8820 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8821 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION );
8822 DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8824 // We did expect the animation to finish
8826 finishCheck.CheckSignalReceived();
8830 int UtcDaliAnimationCreateDestroy(void)
8832 TestApplication application;
8833 Animation* animation = new Animation;
8834 DALI_TEST_CHECK( animation );
8839 struct UpdateManagerTestConstraint
8841 UpdateManagerTestConstraint(TestApplication& application)
8842 : mApplication(application)
8846 Vector3 operator()(const Vector3& current)
8848 mApplication.SendNotification(); // Process events
8852 TestApplication& mApplication;
8855 int UtcDaliAnimationUpdateManager(void)
8857 TestApplication application;
8859 Actor actor = Actor::New();
8860 Stage::GetCurrent().Add( actor );
8862 // Build the animation
8863 Animation animation = Animation::New( 0.0f );
8865 bool signalReceived = false;
8866 AnimationFinishCheck finishCheck( signalReceived );
8867 animation.FinishedSignal().Connect( &application, finishCheck );
8869 Vector3 startValue(1.0f, 1.0f, 1.0f);
8870 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8871 Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
8872 actor.ApplyConstraint( constraint );
8874 // Apply animation to actor
8875 animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear );
8879 application.SendNotification();
8880 application.UpdateOnly( 16 );
8882 finishCheck.CheckSignalNotReceived();
8884 application.SendNotification(); // Process events
8886 finishCheck.CheckSignalReceived();
8891 int UtcDaliAnimationSignalOrder(void)
8893 TestApplication application;
8895 Actor actor = Actor::New();
8896 Stage::GetCurrent().Add( actor );
8898 // Build the animations
8899 Animation animation1 = Animation::New( 0.0f ); // finishes first frame
8900 Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
8902 bool signal1Received = false;
8903 animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
8905 bool signal2Received = false;
8906 animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
8908 // Apply animations to actor
8909 animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
8911 animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
8914 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8915 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8917 application.SendNotification();
8918 application.UpdateOnly( 10 ); // 10ms progress
8920 // no notifications yet
8921 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8922 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8924 application.SendNotification();
8927 DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
8928 DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8929 signal1Received = false;
8931 // 1st animation is complete now, do another update with no ProcessEvents in between
8932 application.UpdateOnly( 20 ); // 20ms progress
8935 application.SendNotification();
8937 // 2nd should complete now
8938 DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8939 DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
8944 int UtcDaliAnimationExtendDuration(void)
8946 TestApplication application;
8948 Actor actor = Actor::New();
8950 // Register a float property
8951 float startValue(10.0f);
8952 Property::Index index = actor.RegisterProperty( "test-property", startValue );
8953 Stage::GetCurrent().Add(actor);
8954 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8956 // Build the animation
8957 float initialDurationSeconds(1.0f);
8958 float animatorDelay = 5.0f;
8959 float animatorDurationSeconds(5.0f);
8960 float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
8961 Animation animation = Animation::New(initialDurationSeconds);
8962 float targetValue(30.0f);
8963 float relativeValue(targetValue - startValue);
8965 animation.AnimateTo(Property(actor, index),
8967 TimePeriod(animatorDelay, animatorDurationSeconds));
8969 // The duration should have been extended
8970 DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
8972 // Start the animation
8975 bool signalReceived(false);
8976 AnimationFinishCheck finishCheck(signalReceived);
8977 animation.FinishedSignal().Connect(&application, finishCheck);
8979 application.SendNotification();
8980 application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8982 // We didn't expect the animation to finish yet
8983 application.SendNotification();
8984 finishCheck.CheckSignalNotReceived();
8985 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8987 application.SendNotification();
8988 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
8990 // We didn't expect the animation to finish yet
8991 application.SendNotification();
8992 finishCheck.CheckSignalNotReceived();
8993 DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
8995 application.SendNotification();
8996 application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8998 // We did expect the animation to finish
8999 application.SendNotification();
9000 finishCheck.CheckSignalReceived();
9001 DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
9005 int UtcDaliAnimationPath(void)
9007 TestApplication application;
9009 Actor actor = Actor::New();
9010 Stage::GetCurrent().Add(actor);
9013 Vector3 position0( 30.0, 80.0, 0.0);
9014 Vector3 position1( 70.0, 120.0, 0.0);
9015 Vector3 position2( 100.0, 100.0, 0.0);
9017 Dali::Path path = Dali::Path::New();
9018 path.AddPoint(position0);
9019 path.AddPoint(position1);
9020 path.AddPoint(position2);
9022 //Control points for first segment
9023 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
9024 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9026 //Control points for second segment
9027 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9028 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9030 // Build the animation
9031 float durationSeconds( 1.0f );
9032 Animation animation = Animation::New(durationSeconds);
9033 animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f ));
9035 // Start the animation
9038 bool signalReceived(false);
9039 AnimationFinishCheck finishCheck(signalReceived);
9040 animation.FinishedSignal().Connect(&application, finishCheck);
9041 application.SendNotification();
9042 application.Render(0);
9043 application.SendNotification();
9044 finishCheck.CheckSignalNotReceived();
9045 Vector3 position, tangent;
9046 Quaternion rotation;
9047 path.Sample( 0.0f, position, tangent );
9048 rotation = Quaternion( Vector3::XAXIS, tangent );
9049 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9050 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9052 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9053 application.SendNotification();
9054 path.Sample( 0.25f, position, tangent );
9055 rotation = Quaternion( Vector3::XAXIS, tangent );
9056 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9057 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9059 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9060 application.SendNotification();
9061 path.Sample( 0.5f, position, tangent );
9062 rotation = Quaternion( Vector3::XAXIS, tangent );
9063 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9064 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9066 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9067 application.SendNotification();
9068 path.Sample( 0.75f, position, tangent );
9069 rotation = Quaternion( Vector3::XAXIS, tangent );
9070 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9071 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9073 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9074 application.SendNotification();
9075 path.Sample( 1.0f, position, tangent );
9076 rotation = Quaternion( Vector3::XAXIS, tangent );
9077 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9078 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9080 finishCheck.CheckSignalReceived();