Merge "(Animation) Ensure animator has been activated before performing the disconnec...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <algorithm>
20
21 #include <stdlib.h>
22 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
24
25 using std::max;
26 using namespace Dali;
27
28 void utc_dali_animation_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void utc_dali_animation_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40
41 static const float ROTATION_EPSILON = 0.0001f;
42 static const float VECTOR4_EPSILON = 0.0001f;
43
44 // Functor to test whether a Finish signal is emitted
45 struct AnimationFinishCheck
46 {
47   AnimationFinishCheck(bool& signalReceived)
48   : mSignalReceived(signalReceived)
49   {
50   }
51
52   void operator()(Animation& animation)
53   {
54     mSignalReceived = true;
55   }
56
57   void Reset()
58   {
59     mSignalReceived = false;
60   }
61
62   void CheckSignalReceived()
63   {
64     if (!mSignalReceived)
65     {
66       tet_printf("Expected Finish signal was not received\n");
67       tet_result(TET_FAIL);
68     }
69     else
70     {
71       tet_result(TET_PASS);
72     }
73   }
74
75   void CheckSignalNotReceived()
76   {
77     if (mSignalReceived)
78     {
79       tet_printf("Unexpected Finish signal was received\n");
80       tet_result(TET_FAIL);
81     }
82     else
83     {
84       tet_result(TET_PASS);
85     }
86   }
87
88   bool& mSignalReceived; // owned by individual tests
89 };
90
91 static bool ReturnFalseAfterProgressOne( float alpha, const bool& current )
92 {
93   return alpha < 1.0f;
94 }
95
96 struct AnimateFloatTestFunctor
97 {
98   AnimateFloatTestFunctor( float start, float end )
99   : mStart( start ),
100     mEnd( end )
101   {
102   }
103
104   float operator()( float alpha, const float& current )
105   {
106     return mStart + ((mEnd - mStart) * alpha );
107   }
108
109   float mStart;
110   float mEnd;
111 };
112
113 struct AnimateIntegerTestFunctor
114 {
115   AnimateIntegerTestFunctor( int start, int end )
116   : mStart( start ),
117     mEnd( end )
118   {
119   }
120
121   int operator()( float alpha, const int& current )
122   {
123     return static_cast<int>( mStart + ((mEnd - mStart) * alpha ) + 0.5f );
124   }
125
126   int mStart;
127   int mEnd;
128 };
129
130 struct AnimateVector2TestFunctor
131 {
132   AnimateVector2TestFunctor( Vector2 start, Vector2 end )
133   : mStart( start ),
134     mEnd( end )
135   {
136   }
137
138   Vector2 operator()( float alpha, const Vector2& current )
139   {
140     return mStart + ((mEnd - mStart) * alpha );
141   }
142
143   Vector2 mStart;
144   Vector2 mEnd;
145 };
146
147 struct AnimateVector4TestFunctor
148 {
149   AnimateVector4TestFunctor( Vector4 start, Vector4 end )
150   : mStart( start ),
151     mEnd( end )
152   {
153   }
154
155   Vector4 operator()( float alpha, const Vector4& current )
156   {
157     return mStart + ((mEnd - mStart) * alpha );
158   }
159
160   Vector4 mStart;
161   Vector4 mEnd;
162 };
163
164 struct AnimateQuaternionTestFunctor
165 {
166   AnimateQuaternionTestFunctor( Quaternion start, Quaternion end )
167   : mStart( start ),
168     mEnd( end )
169   {
170   }
171
172   Quaternion operator()( float alpha, const Quaternion& current )
173   {
174     return Quaternion::Slerp(mStart, mEnd, alpha);
175   }
176
177   Quaternion mStart;
178   Quaternion mEnd;
179 };
180
181 struct BounceFunc
182 {
183   BounceFunc(float x, float y, float z)
184   : mDistance(Vector3(x, y, z))
185   {
186   }
187   Vector3 operator()(float alpha, const Vector3& current)
188   {
189     if (alpha>0.001f && alpha<1.0f)
190     {
191       const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f;
192       Vector3 newTranslation(current);
193       newTranslation += mDistance * flip;
194       return newTranslation;
195     }
196     return current;
197   }
198   Vector3 mDistance;
199 };
200
201
202 struct TumbleFunc
203 {
204   TumbleFunc(Vector3 axis) : tumbleAxis(axis){}
205   Quaternion operator()(float alpha, const Quaternion& current)
206   {
207     if (alpha>0.001f && alpha<1.0f)
208     {
209       Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis);
210       return tumbleRotation * current;
211     }
212     return current;
213   }
214   Vector3 tumbleAxis;
215 };
216
217 } // anon namespace
218
219 int UtcDaliAnimationNew01(void)
220 {
221   TestApplication application;
222
223   Animation animation;
224   DALI_TEST_CHECK(!animation);
225
226   animation = Animation::New(1.0f);
227
228   DALI_TEST_CHECK(animation);
229   END_TEST;
230 }
231
232 int UtcDaliAnimationNew02(void)
233 {
234   TestApplication application;
235
236   Animation animation;
237   DALI_TEST_CHECK(!animation);
238   try
239   {
240     animation = Animation::New(0.0f);
241   }
242   catch (Dali::DaliException& e)
243   {
244     // TODO: Determine why catch doesn't.
245     //
246
247     // Tests that a negative test of an assertion succeeds
248     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
249     DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION);
250   }
251   END_TEST;
252 }
253
254 int UtcDaliAnimationDownCast(void)
255 {
256   TestApplication application;
257   tet_infoline("Testing Dali::Animation::DownCast()");
258
259   float durationSeconds(1.0f);
260   Animation animation = Animation::New(durationSeconds);
261
262   BaseHandle object(animation);
263
264   Animation animation2 = Animation::DownCast(object);
265   DALI_TEST_CHECK(animation2);
266
267   Animation animation3 = DownCast< Animation >(object);
268   DALI_TEST_CHECK(animation3);
269
270   BaseHandle unInitializedObject;
271   Animation animation4 = Animation::DownCast(unInitializedObject);
272   DALI_TEST_CHECK(!animation4);
273
274   Animation animation5 = DownCast< Animation >(unInitializedObject);
275   DALI_TEST_CHECK(!animation5);
276   END_TEST;
277 }
278
279 int UtcDaliAnimationSetDuration(void)
280 {
281   TestApplication application;
282
283   Actor actor = Actor::New();
284   Stage::GetCurrent().Add(actor);
285
286   // Build the animation
287   float durationSeconds(1.0f);
288   Animation animation = Animation::New(durationSeconds);
289   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
290
291   // Start the animation
292   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
293   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
294   animation.Play();
295
296   bool signalReceived(false);
297   AnimationFinishCheck finishCheck(signalReceived);
298   animation.FinishedSignal().Connect(&application, finishCheck);
299
300   application.SendNotification();
301   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
302
303   // We didn't expect the animation to finish yet
304   application.SendNotification();
305   finishCheck.CheckSignalNotReceived();
306
307   application.Render(2u/*just beyond the animation duration*/);
308
309   // We did expect the animation to finish
310   application.SendNotification();
311   finishCheck.CheckSignalReceived();
312   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
313
314   // Restart the animation, with a different duration
315   finishCheck.Reset();
316   actor.SetPosition(Vector3::ZERO);
317   durationSeconds = 3.5f;
318   animation.SetDuration(durationSeconds);
319   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
320   animation.Play();
321
322   application.SendNotification();
323   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
324
325   // We didn't expect the animation to finish yet
326   application.SendNotification();
327   finishCheck.CheckSignalNotReceived();
328
329   application.Render(2u/*just beyond the animation duration*/);
330
331   // We did expect the animation to finish
332   application.SendNotification();
333   finishCheck.CheckSignalReceived();
334   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
335
336   // Check that nothing has changed after a couple of buffer swaps
337   application.Render(0);
338   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
339   application.Render(0);
340   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
341   END_TEST;
342 }
343
344 int UtcDaliAnimationGetDuration(void)
345 {
346   TestApplication application;
347
348   Animation animation = Animation::New(1.0f);
349   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
350
351   animation.SetDuration(2.0f);
352   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
353   END_TEST;
354 }
355
356 int UtcDaliAnimationSetLooping(void)
357 {
358   TestApplication application;
359
360   Actor actor = Actor::New();
361   Stage::GetCurrent().Add(actor);
362
363   // Build the animation
364   float durationSeconds(1.0f);
365   Animation animation = Animation::New(durationSeconds);
366   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
367   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
368
369   // Start the animation
370   animation.SetLooping(true);
371   DALI_TEST_CHECK(animation.IsLooping());
372   animation.Play();
373
374   bool signalReceived(false);
375   AnimationFinishCheck finishCheck(signalReceived);
376   animation.FinishedSignal().Connect(&application, finishCheck);
377
378   application.SendNotification();
379
380   // Loop 5 times
381   float intervalSeconds = 0.25f;
382   float progress = 0.0f;
383   for (int iterations = 0; iterations < 5;)
384   {
385     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
386
387     progress += intervalSeconds;
388     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
389
390     if (progress >= 1.0f)
391     {
392       progress = progress - 1.0f;
393       ++iterations;
394     }
395   }
396
397   // We didn't expect the animation to finish yet
398   application.SendNotification();
399   finishCheck.CheckSignalNotReceived();
400
401   animation.SetLooping(false);
402   DALI_TEST_CHECK(!animation.IsLooping());
403
404   application.SendNotification();
405   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
406
407   // We did expect the animation to finish
408   application.SendNotification();
409   finishCheck.CheckSignalReceived();
410   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
411
412   // Check that nothing has changed after a couple of buffer swaps
413   application.Render(0);
414   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
415   application.Render(0);
416   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
417   END_TEST;
418 }
419
420 int UtcDaliAnimationIsLooping(void)
421 {
422   TestApplication application;
423
424   Animation animation = Animation::New(1.0f);
425   DALI_TEST_CHECK(!animation.IsLooping());
426
427   animation.SetLooping(true);
428   DALI_TEST_CHECK(animation.IsLooping());
429   END_TEST;
430 }
431
432 int UtcDaliAnimationSetEndAction(void)
433 {
434   TestApplication application;
435
436   Actor actor = Actor::New();
437   Stage::GetCurrent().Add(actor);
438
439   // Build the animation
440   float durationSeconds(1.0f);
441   Animation animation = Animation::New(durationSeconds);
442   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
443
444   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
445   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
446
447   // Start the animation
448   animation.Play();
449
450   bool signalReceived(false);
451   AnimationFinishCheck finishCheck(signalReceived);
452   animation.FinishedSignal().Connect(&application, finishCheck);
453
454   application.SendNotification();
455   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
456
457   // We did expect the animation to finish
458   application.SendNotification();
459   finishCheck.CheckSignalReceived();
460   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
461
462   // Go back to the start
463   actor.SetPosition(Vector3::ZERO);
464   application.SendNotification();
465   application.Render(0);
466   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
467
468   // Test BakeFinal, animate again, for half the duration
469   finishCheck.Reset();
470   animation.SetEndAction(Animation::BakeFinal);
471   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
472   animation.Play();
473
474   application.SendNotification();
475   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
476
477   // Stop the animation early
478   animation.Stop();
479
480   // We did NOT expect the animation to finish
481   application.SendNotification();
482   finishCheck.CheckSignalNotReceived();
483   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
484
485   // Go back to the start
486   actor.SetPosition(Vector3::ZERO);
487   application.SendNotification();
488   application.Render(0);
489   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
490
491   // Test EndAction::Discard, animate again, but don't bake this time
492   finishCheck.Reset();
493   animation.SetEndAction(Animation::Discard);
494   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
495   animation.Play();
496
497   application.SendNotification();
498   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
499
500   // We did expect the animation to finish
501   application.SendNotification();
502   finishCheck.CheckSignalReceived();
503   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
504
505   // The position should be discarded in the next frame
506   application.Render(0);
507   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
508
509   // Check that nothing has changed after a couple of buffer swaps
510   application.Render(0);
511   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
512   application.Render(0);
513   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
514   END_TEST;
515 }
516
517 int UtcDaliAnimationGetEndAction(void)
518 {
519   TestApplication application;
520
521   Animation animation = Animation::New(1.0f);
522   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
523
524   animation.SetEndAction(Animation::Discard);
525   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
526
527   animation.SetEndAction(Animation::BakeFinal);
528   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
529
530   END_TEST;
531 }
532
533 int UtcDaliAnimationSetDisconnectAction(void)
534 {
535   TestApplication application;
536   Stage stage( Stage::GetCurrent() );
537
538   // Default: BakeFinal
539   {
540     Actor actor = Actor::New();
541     stage.Add(actor);
542
543     // Build the animation
544     float durationSeconds(1.0f);
545     Animation animation = Animation::New(durationSeconds);
546     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
547
548     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
549     animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
550
551     // Start the animation
552     animation.Play();
553
554     application.SendNotification();
555     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
556
557     actor.Unparent();
558
559     application.SendNotification();
560     application.Render();
561
562     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
563   }
564
565   // Bake
566   {
567     Actor actor = Actor::New();
568     stage.Add(actor);
569
570     // Build the animation
571     float durationSeconds(1.0f);
572     Animation animation = Animation::New(durationSeconds);
573     animation.SetDisconnectAction( Animation::Bake );
574
575     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
576     animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
577
578     // Start the animation
579     animation.Play();
580
581     application.SendNotification();
582     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
583
584     actor.Unparent();
585
586     application.SendNotification();
587     application.Render();
588
589     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
590   }
591
592   // Discard
593   {
594     Actor actor = Actor::New();
595     stage.Add(actor);
596
597     // Build the animation
598     float durationSeconds(1.0f);
599     Animation animation = Animation::New(durationSeconds);
600     animation.SetDisconnectAction( Animation::Discard );
601
602     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
603     animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
604
605     // Start the animation
606     animation.Play();
607
608     application.SendNotification();
609     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
610
611     actor.Unparent();
612
613     application.SendNotification();
614     application.Render();
615
616     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
617   }
618
619   // Don't play the animation: disconnect action should not be applied
620   {
621     Actor actor = Actor::New();
622     stage.Add(actor);
623
624     // Build the animation
625     float durationSeconds(1.0f);
626     Animation animation = Animation::New(durationSeconds);
627
628     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
629     animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
630
631     application.SendNotification();
632     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
633
634     actor.Unparent();
635
636     application.SendNotification();
637     application.Render();
638
639     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
640   }
641
642   END_TEST;
643 }
644
645 int UtcDaliAnimationGetDisconnectAction(void)
646 {
647   TestApplication application;
648   Animation animation = Animation::New(1.0f);
649   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
650
651   animation.SetDisconnectAction(Animation::Discard);
652   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
653
654   animation.SetDisconnectAction(Animation::Bake);
655   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
656
657   END_TEST;
658 }
659
660 int UtcDaliAnimationSetDefaultAlphaFunction(void)
661 {
662   TestApplication application;
663
664   Animation animation = Animation::New(1.0f);
665   AlphaFunction func = animation.GetDefaultAlphaFunction();
666   DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
667
668   animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
669   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
670   DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
671   END_TEST;
672 }
673
674 int UtcDaliAnimationGetDefaultAlphaFunction(void)
675 {
676   TestApplication application;
677
678   Animation animation = Animation::New(1.0f);
679   AlphaFunction func = animation.GetDefaultAlphaFunction();
680
681   // Test that the default is linear
682   DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
683   END_TEST;
684 }
685
686 int UtcDaliAnimationPlay(void)
687 {
688   TestApplication application;
689
690   Actor actor = Actor::New();
691   Stage::GetCurrent().Add(actor);
692
693   // Build the animation
694   float durationSeconds(1.0f);
695   Animation animation = Animation::New(durationSeconds);
696   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
697   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
698
699   // Start the animation
700   animation.Play();
701
702   bool signalReceived(false);
703   AnimationFinishCheck finishCheck(signalReceived);
704   animation.FinishedSignal().Connect(&application, finishCheck);
705
706   application.SendNotification();
707   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
708
709   // We didn't expect the animation to finish yet
710   application.SendNotification();
711   finishCheck.CheckSignalNotReceived();
712   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
713
714   animation.Play(); // Test that calling play has no effect, when animation is already playing
715   application.SendNotification();
716   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
717
718   // We didn't expect the animation to finish yet
719   application.SendNotification();
720   finishCheck.CheckSignalNotReceived();
721   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
722
723   animation.Play(); // Test that calling play has no effect, when animation is already playing
724   application.SendNotification();
725   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
726
727   // We didn't expect the animation to finish yet
728   application.SendNotification();
729   finishCheck.CheckSignalNotReceived();
730   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
731
732   animation.Play(); // Test that calling play has no effect, when animation is already playing
733   application.SendNotification();
734   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
735
736   // We didn't expect the animation to finish yet
737   application.SendNotification();
738   finishCheck.CheckSignalNotReceived();
739   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
740
741   animation.Play(); // Test that calling play has no effect, when animation is already playing
742   application.SendNotification();
743   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
744
745   // We did expect the animation to finish
746   application.SendNotification();
747   finishCheck.CheckSignalReceived();
748   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
749
750   // Check that nothing has changed after a couple of buffer swaps
751   application.Render(0);
752   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
753   application.Render(0);
754   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
755   END_TEST;
756 }
757
758 int UtcDaliAnimationSetSpeedFactor(void)
759 {
760   TestApplication application;
761
762   Actor actor = Actor::New();
763   Stage::GetCurrent().Add(actor);
764
765   // Build the animation
766   float durationSeconds(1.0f);
767   Animation animation = Animation::New(durationSeconds);
768
769   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
770   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
771
772   KeyFrames keyframes = KeyFrames::New();
773   keyframes.Add( 0.0f, initialPosition);
774   keyframes.Add( 1.0f, targetPosition );
775   animation.AnimateBetween( Property(actor, Actor::POSITION), keyframes, AlphaFunctions::Linear);
776
777   //Set speed to be x2
778   animation.SetSpeedFactor(2.0f);
779
780   // Start the animation
781   animation.Play();
782
783   bool signalReceived(false);
784   AnimationFinishCheck finishCheck(signalReceived);
785   animation.FinishedSignal().Connect(&application, finishCheck);
786
787   application.SendNotification();
788   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
789
790   // We didn't expect the animation to finish yet
791   application.SendNotification();
792   finishCheck.CheckSignalNotReceived();
793   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
794
795   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
796
797   // We didn't expect the animation to finish yet
798   application.SendNotification();
799   finishCheck.CheckSignalNotReceived();
800   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
801
802   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
803
804   // We did expect the animation to finish
805   application.SendNotification();
806   finishCheck.CheckSignalReceived();
807   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
808
809   // Check that nothing has changed after a couple of buffer swaps
810   application.Render(0);
811   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
812   application.Render(0);
813   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
814
815   finishCheck.Reset();
816
817   //Test -1 speed factor. Animation will play in reverse at normal speed
818   animation.SetSpeedFactor( -1.0f );
819
820   // Start the animation
821   animation.Play();
822
823   application.SendNotification();
824   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
825
826   // We didn't expect the animation to finish yet
827   application.SendNotification();
828   finishCheck.CheckSignalNotReceived();
829   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
830
831   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
832
833   // We didn't expect the animation to finish yet
834   application.SendNotification();
835   finishCheck.CheckSignalNotReceived();
836   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
837
838   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
839
840   // We didn't expect the animation to finish yet
841   application.SendNotification();
842   finishCheck.CheckSignalNotReceived();
843   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
844
845   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
846
847   // We didn't expect the animation to finish yet
848   application.SendNotification();
849   finishCheck.CheckSignalNotReceived();
850   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
851
852   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
853
854   // We did expect the animation to finish
855   application.SendNotification();
856   finishCheck.CheckSignalReceived();
857   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
858
859   // Check that nothing has changed after a couple of buffer swaps
860   application.Render(0);
861   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
862   application.Render(0);
863   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
864
865
866   //Test change speed factor on the fly
867   finishCheck.Reset();
868
869   //Set speed to be half of normal speed
870   animation.SetSpeedFactor( 0.5f );
871
872   // Start the animation
873   animation.Play();
874
875   application.SendNotification();
876   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
877
878   // We didn't expect the animation to finish yet
879   application.SendNotification();
880   finishCheck.CheckSignalNotReceived();
881   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
882
883   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
884
885   // We didn't expect the animation to finish yet
886   application.SendNotification();
887   finishCheck.CheckSignalNotReceived();
888   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
889
890   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
891
892   // We didn't expect the animation to finish yet
893   application.SendNotification();
894   finishCheck.CheckSignalNotReceived();
895   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
896
897   //Change speed factor while animation still playing.
898   animation.SetSpeedFactor(-1.0f);
899   application.SendNotification();
900   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
901
902   // We didn't expect the animation to finish yet
903   application.SendNotification();
904   finishCheck.CheckSignalNotReceived();
905   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
906
907   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
908
909   // We did expect the animation to finish
910   application.SendNotification();
911   finishCheck.CheckSignalReceived();
912   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
913
914   // Check that nothing has changed after a couple of buffer swaps
915   application.Render(0);
916   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
917   application.Render(0);
918   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
919   END_TEST;
920 }
921
922 int UtcDaliAnimationGetSpeedFactor(void)
923 {
924   TestApplication application;
925
926   Animation animation = Animation::New(1.0f);
927   animation.SetSpeedFactor(0.5f);
928   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
929
930   animation.SetSpeedFactor(-2.5f);
931   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
932   END_TEST;
933 }
934
935 int UtcDaliAnimationPlayOffStage(void)
936 {
937   // Test that an animation can be played, when the actor is off-stage.
938   // When the actor is added to the stage, it should appear at the current position
939   // i.e. where it would have been anyway, if on-stage from the beginning.
940
941   TestApplication application;
942
943   Actor actor = Actor::New();
944   Vector3 basePosition(Vector3::ZERO);
945   DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
946   // Not added to the stage!
947
948   // Build the animation
949   float durationSeconds(1.0f);
950   Animation animation = Animation::New(durationSeconds);
951   animation.SetDisconnectAction( Animation::Discard );
952   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
953   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
954
955   // Start the animation
956   animation.Play();
957
958   bool signalReceived(false);
959   AnimationFinishCheck finishCheck(signalReceived);
960   animation.FinishedSignal().Connect(&application, finishCheck);
961
962   application.SendNotification();
963   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
964
965   // We didn't expect the animation to finish yet
966   application.SendNotification();
967   finishCheck.CheckSignalNotReceived();
968   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
969
970   // Add to the stage
971   Stage::GetCurrent().Add(actor);
972
973   application.SendNotification();
974   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
975
976   // We didn't expect the animation to finish yet
977   application.SendNotification();
978   finishCheck.CheckSignalNotReceived();
979   Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
980   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
981
982   // Remove from the stage
983   Stage::GetCurrent().Remove(actor);
984
985   application.SendNotification();
986   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
987
988   // We didn't expect the animation to finish yet
989   application.SendNotification();
990   finishCheck.CheckSignalNotReceived();
991   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
992
993   // Add to the stage
994   Stage::GetCurrent().Add(actor);
995
996   application.SendNotification();
997   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
998
999   // We didn't expect the animation to finish yet
1000   application.SendNotification();
1001   finishCheck.CheckSignalNotReceived();
1002   expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
1003   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
1004
1005   application.SendNotification();
1006   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1007
1008   // We did expect the animation to finish
1009   application.SendNotification();
1010   finishCheck.CheckSignalReceived();
1011   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1012
1013   // Check that nothing has changed after a couple of buffer swaps
1014   application.Render(0);
1015   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1016   application.Render(0);
1017   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1018   END_TEST;
1019 }
1020
1021 int UtcDaliAnimationPlayDiscardHandle(void)
1022 {
1023   TestApplication application;
1024
1025   Actor actor = Actor::New();
1026   Stage::GetCurrent().Add(actor);
1027
1028   // Build the animation
1029   float durationSeconds(1.0f);
1030   Animation animation = Animation::New(durationSeconds);
1031   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1032   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1033
1034   bool signalReceived(false);
1035   AnimationFinishCheck finishCheck(signalReceived);
1036   animation.FinishedSignal().Connect(&application, finishCheck);
1037
1038   // Start the animation
1039   animation.Play();
1040
1041   // This is a test of the "Fire and Forget" behaviour
1042   // Discard the animation handle!
1043   animation.Reset();
1044   DALI_TEST_CHECK( !animation );
1045
1046   application.SendNotification();
1047   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1048
1049   // We didn't expect the animation to finish yet
1050   application.SendNotification();
1051   finishCheck.CheckSignalNotReceived();
1052   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1053
1054   application.SendNotification();
1055   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1056
1057   // We didn't expect the animation to finish yet
1058   application.SendNotification();
1059   finishCheck.CheckSignalNotReceived();
1060   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1061
1062   application.SendNotification();
1063   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1064
1065   // We didn't expect the animation to finish yet
1066   application.SendNotification();
1067   finishCheck.CheckSignalNotReceived();
1068   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1069
1070   application.SendNotification();
1071   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1072
1073   // We didn't expect the animation to finish yet
1074   application.SendNotification();
1075   finishCheck.CheckSignalNotReceived();
1076   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1077
1078   application.SendNotification();
1079   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1080
1081   // We did expect the animation to finish
1082   application.SendNotification();
1083   finishCheck.CheckSignalReceived();
1084   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1085
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 );
1091   END_TEST;
1092 }
1093
1094 int UtcDaliAnimationPlayStopDiscardHandle(void)
1095 {
1096   TestApplication application;
1097
1098   Actor actor = Actor::New();
1099   Stage::GetCurrent().Add(actor);
1100
1101   // Build the animation
1102   float durationSeconds(1.0f);
1103   Animation animation = Animation::New(durationSeconds);
1104   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1105   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1106
1107   // Start the animation
1108   animation.Play();
1109
1110   bool signalReceived(false);
1111   AnimationFinishCheck finishCheck(signalReceived);
1112   animation.FinishedSignal().Connect(&application, finishCheck);
1113
1114   application.SendNotification();
1115   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1116
1117   // We didn't expect the animation to finish yet
1118   application.SendNotification();
1119   finishCheck.CheckSignalNotReceived();
1120   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1121
1122   // This is a test of the "Fire and Forget" behaviour
1123   // Stop the animation, and Discard the animation handle!
1124   animation.Stop();
1125   animation.Reset();
1126   DALI_TEST_CHECK( !animation );
1127
1128   application.SendNotification();
1129   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1130
1131   // We expect the animation to finish at 20% progress
1132   application.SendNotification();
1133   finishCheck.CheckSignalReceived();
1134   finishCheck.Reset();
1135   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1136
1137   application.SendNotification();
1138   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1139
1140   // Check that nothing has changed
1141   application.SendNotification();
1142   finishCheck.CheckSignalNotReceived();
1143   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1144
1145   application.SendNotification();
1146   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1147
1148   // Check that nothing has changed
1149   application.SendNotification();
1150   finishCheck.CheckSignalNotReceived();
1151   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1152
1153   application.SendNotification();
1154   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1155
1156   // Check that nothing has changed
1157   application.SendNotification();
1158   finishCheck.CheckSignalNotReceived();
1159   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1160   END_TEST;
1161 }
1162
1163 int UtcDaliAnimationPlayFrom(void)
1164 {
1165   TestApplication application;
1166
1167   Actor actor = Actor::New();
1168   Stage::GetCurrent().Add(actor);
1169
1170   // Build the animation
1171   float durationSeconds(1.0f);
1172   Animation animation = Animation::New(durationSeconds);
1173   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1174   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1175
1176   //PlayFrom with an argument outside the range [0..1] will be ignored
1177   animation.PlayFrom(-1.0f);
1178   application.SendNotification();
1179   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1180
1181   animation.PlayFrom(100.0f);
1182   application.SendNotification();
1183   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1184
1185   // Start the animation from 40% progress
1186   animation.PlayFrom( 0.4f );
1187
1188   bool signalReceived(false);
1189   AnimationFinishCheck finishCheck(signalReceived);
1190   animation.FinishedSignal().Connect(&application, finishCheck);
1191
1192   application.SendNotification();
1193   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1194
1195   // We didn't expect the animation to finish yet
1196   application.SendNotification();
1197   finishCheck.CheckSignalNotReceived();
1198   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1199
1200   animation.Play(); // Test that calling play has no effect, when animation is already playing
1201   application.SendNotification();
1202   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1203
1204   // We didn't expect the animation to finish yet
1205   application.SendNotification();
1206   finishCheck.CheckSignalNotReceived();
1207   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1208
1209   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1210   // We did expect the animation to finish
1211   application.SendNotification();
1212   finishCheck.CheckSignalReceived();
1213   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1214
1215   // Check that nothing has changed after a couple of buffer swaps
1216   application.Render(0);
1217   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1218   application.Render(0);
1219   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1220   END_TEST;
1221 }
1222
1223 int UtcDaliAnimationSetCurrentProgress(void)
1224 {
1225   TestApplication application;
1226
1227   Actor actor = Actor::New();
1228   Stage::GetCurrent().Add(actor);
1229
1230   // Build the animation
1231   Animation animation = Animation::New(0.0f);
1232   animation.Play();
1233
1234   //Test GetCurrentProgress return 0.0 as the duration is 0.0
1235   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1236
1237   animation.SetCurrentProgress( 0.5f );
1238   application.SendNotification();
1239   application.Render(static_cast<unsigned int>(100.0f));
1240
1241   //Progress should still be 0.0
1242   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1243
1244   //Set duration
1245   float durationSeconds(1.0f);
1246   animation.SetDuration(durationSeconds);
1247   application.SendNotification();
1248
1249   bool signalReceived(false);
1250   AnimationFinishCheck finishCheck(signalReceived);
1251   animation.FinishedSignal().Connect(&application, finishCheck);
1252   application.SendNotification();
1253
1254   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1255   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1256
1257   //Trying to set the current cursor outside the range [0..1] is ignored
1258   animation.SetCurrentProgress( -1.0f);
1259   application.SendNotification();
1260   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1261
1262   animation.SetCurrentProgress( 100.0f);
1263   application.SendNotification();
1264   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1265
1266   // Start the animation from 40% progress
1267   animation.SetCurrentProgress( 0.4f );
1268   animation.Play();
1269
1270   application.SendNotification();
1271   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1272
1273   // We didn't expect the animation to finish yet
1274   application.SendNotification();
1275   finishCheck.CheckSignalNotReceived();
1276   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1277   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1278
1279   animation.Play(); // Test that calling play has no effect, when animation is already playing
1280   application.SendNotification();
1281
1282   //Set the progress to 70%
1283   animation.SetCurrentProgress( 0.7f );
1284   application.SendNotification();
1285   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1286   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1287
1288
1289   application.SendNotification();
1290   finishCheck.CheckSignalNotReceived();
1291   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1292   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1293
1294   //
1295
1296   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1297   // We did expect the animation to finish
1298   application.SendNotification();
1299   finishCheck.CheckSignalReceived();
1300   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1301
1302   // Check that nothing has changed after a couple of buffer swaps
1303   application.Render(0);
1304   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1305   application.Render(0);
1306   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1307   END_TEST;
1308 }
1309
1310 int UtcDaliAnimationPlayRange(void)
1311 {
1312   TestApplication application;
1313
1314   Actor actor = Actor::New();
1315   Stage::GetCurrent().Add(actor);
1316
1317   // Build the animation
1318   float durationSeconds(1.0f);
1319   Animation animation = Animation::New(durationSeconds);
1320   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1321   KeyFrames keyframes = KeyFrames::New();
1322   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1323   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1324
1325   animation.AnimateBetween( Property( actor, Actor::POSITION), keyframes );
1326
1327   // Set range between 0.4 and 0.8
1328   animation.SetPlayRange( Vector2(0.4f,0.8f) );
1329   animation.Play();
1330
1331   bool signalReceived(false);
1332   AnimationFinishCheck finishCheck(signalReceived);
1333   animation.FinishedSignal().Connect(&application, finishCheck);
1334
1335   //Test that setting progress outside the range doesn't work
1336   animation.SetCurrentProgress( 0.9f );
1337   application.SendNotification();
1338   application.Render(0);
1339   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1340   animation.SetCurrentProgress( 0.2f );
1341   application.SendNotification();
1342   application.Render(0);
1343   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1344
1345   application.SendNotification();
1346   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1347
1348   // We didn't expect the animation to finish yet
1349   application.SendNotification();
1350   finishCheck.CheckSignalNotReceived();
1351   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1352
1353   animation.Play(); // Test that calling play has no effect, when animation is already playing
1354   application.SendNotification();
1355   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1356
1357   // We did expect the animation to finish
1358   application.SendNotification();
1359   finishCheck.CheckSignalReceived();
1360   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1361
1362   // Check that nothing has changed after a couple of buffer swaps
1363   application.Render(0);
1364   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1365   application.Render(0);
1366   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1367
1368
1369   //Loop inside the range
1370   finishCheck.Reset();
1371   animation.SetLooping( true );
1372   animation.Play();
1373   application.SendNotification();
1374   float intervalSeconds = 0.1f;
1375   float progress = 0.4f;
1376   for (int iterations = 0; iterations < 10; ++iterations )
1377   {
1378     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1379
1380     progress += intervalSeconds;
1381     if (progress > 0.8f)
1382     {
1383       progress = progress - 0.4f;
1384     }
1385
1386     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1387   }
1388
1389   // We didn't expect the animation to finish yet
1390   application.SendNotification();
1391   finishCheck.CheckSignalNotReceived();
1392
1393
1394   //Test change range on the fly
1395   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1396   application.SendNotification();
1397
1398   for (int iterations = 0; iterations < 10; ++iterations )
1399   {
1400     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1401
1402     progress += intervalSeconds;
1403     if (progress > 0.9f)
1404     {
1405       progress = progress - 0.7f;
1406     }
1407
1408     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1409   }
1410
1411   END_TEST;
1412 }
1413
1414 int UtcDaliAnimationSetPlayRange(void)
1415 {
1416   TestApplication application;
1417
1418   Actor actor = Actor::New();
1419   Stage::GetCurrent().Add(actor);
1420
1421   // Build the animation
1422   Animation animation = Animation::New(0);
1423   application.SendNotification();
1424
1425   //If PlayRange not specified it should be 0.0-1.0 by default
1426   DALI_TEST_EQUALS( Vector2(0.0,1.0), animation.GetPlayRange(), TEST_LOCATION );
1427
1428   //PlayRange out of bounds
1429   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1430   application.SendNotification();
1431   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1432   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1433   application.SendNotification();
1434   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1435
1436   //If playRange is not in the correct order it has to be ordered
1437   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1438   application.SendNotification();
1439   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1440
1441   // Set range between 0.4 and 0.8
1442   animation.SetPlayRange( Vector2(0.4f,0.8f) );
1443   application.SendNotification();
1444   DALI_TEST_EQUALS( Vector2(0.4f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1445
1446   END_TEST;
1447 }
1448
1449 int UtcDaliAnimationPause(void)
1450 {
1451   TestApplication application;
1452
1453   Actor actor = Actor::New();
1454   Stage::GetCurrent().Add(actor);
1455
1456   // Build the animation
1457   float durationSeconds(1.0f);
1458   Animation animation = Animation::New(durationSeconds);
1459   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1460   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1461
1462   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1463
1464   // Start the animation
1465   animation.Play();
1466
1467   bool signalReceived(false);
1468   AnimationFinishCheck finishCheck(signalReceived);
1469   animation.FinishedSignal().Connect(&application, finishCheck);
1470
1471   application.SendNotification();
1472   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1473
1474   // We didn't expect the animation to finish yet
1475   application.SendNotification();
1476   finishCheck.CheckSignalNotReceived();
1477   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1478
1479   // Pause the animation
1480   animation.Pause();
1481   application.SendNotification();
1482
1483   // Loop 5 times
1484   for (int i=0; i<5; ++i)
1485   {
1486     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1487
1488     // We didn't expect the animation to finish yet
1489     application.SendNotification();
1490     finishCheck.CheckSignalNotReceived();
1491     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1492   }
1493
1494   // Keep going
1495   animation.Play();
1496   application.SendNotification();
1497   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1498
1499   // We didn't expect the animation to finish yet
1500   application.SendNotification();
1501   finishCheck.CheckSignalNotReceived();
1502
1503   application.SendNotification();
1504   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1505
1506   // We did expect the animation to finish
1507   application.SendNotification();
1508   finishCheck.CheckSignalReceived();
1509   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1510
1511   // Check that nothing has changed after a couple of buffer swaps
1512   application.Render(0);
1513   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1514   application.Render(0);
1515   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1516   END_TEST;
1517 }
1518
1519 int UtcDaliAnimationStop(void)
1520 {
1521   TestApplication application;
1522
1523   Actor actor = Actor::New();
1524   Stage::GetCurrent().Add(actor);
1525
1526   // Build the animation
1527   float durationSeconds(1.0f);
1528   Animation animation = Animation::New(durationSeconds);
1529   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1530   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1531
1532   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1533
1534   // Start the animation
1535   animation.Play();
1536
1537   bool signalReceived(false);
1538   AnimationFinishCheck finishCheck(signalReceived);
1539   animation.FinishedSignal().Connect(&application, finishCheck);
1540
1541   application.SendNotification();
1542   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1543
1544   // We didn't expect the animation to finish yet
1545   application.SendNotification();
1546   finishCheck.CheckSignalNotReceived();
1547   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1548
1549   // Stop the animation
1550   animation.Stop();
1551   application.SendNotification();
1552
1553   // Loop 5 times
1554   for (int i=0; i<5; ++i)
1555   {
1556     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1557
1558     // We did expect the animation to finish
1559     application.SendNotification();
1560     finishCheck.CheckSignalReceived();
1561     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1562   }
1563   END_TEST;
1564 }
1565
1566 int UtcDaliAnimationStopSetPosition(void)
1567 {
1568   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1569   // i.e. to check that the animation does not interfere with the position set.
1570
1571   TestApplication application;
1572
1573   Actor actor = Actor::New();
1574   Stage::GetCurrent().Add(actor);
1575
1576   // Build the animation
1577   float durationSeconds(1.0f);
1578   Animation animation = Animation::New(durationSeconds);
1579   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1580   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1581
1582   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1583
1584   // Start the animation
1585   animation.Play();
1586
1587   bool signalReceived(false);
1588   AnimationFinishCheck finishCheck(signalReceived);
1589   animation.FinishedSignal().Connect(&application, finishCheck);
1590
1591   application.SendNotification();
1592   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1593
1594   // We didn't expect the animation to finish yet
1595   application.SendNotification();
1596   finishCheck.CheckSignalNotReceived();
1597   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1598
1599   // Stop the animation
1600   animation.Stop();
1601   Vector3 positionSet(2.0f, 3.0f, 4.0f);
1602   actor.SetPosition(positionSet);
1603   application.SendNotification();
1604
1605   // Loop 5 times
1606   for (int i=0; i<5; ++i)
1607   {
1608     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1609
1610     // We did expect the animation to finish
1611     application.SendNotification();
1612     finishCheck.CheckSignalReceived();
1613     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1614   }
1615   END_TEST;
1616 }
1617
1618 int UtcDaliAnimationClear(void)
1619 {
1620   TestApplication application;
1621
1622   Actor actor = Actor::New();
1623   Stage::GetCurrent().Add(actor);
1624
1625   // Build the animation
1626   float durationSeconds(1.0f);
1627   Animation animation = Animation::New(durationSeconds);
1628   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1629   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
1630
1631   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1632
1633   // Start the animation
1634   animation.Play();
1635
1636   bool signalReceived(false);
1637   AnimationFinishCheck finishCheck(signalReceived);
1638   animation.FinishedSignal().Connect(&application, finishCheck);
1639
1640   application.SendNotification();
1641   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1642
1643   // We didn't expect the animation to finish yet
1644   application.SendNotification();
1645   finishCheck.CheckSignalNotReceived();
1646   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1647
1648   // Clear the animation
1649   animation.Clear();
1650   application.SendNotification();
1651
1652   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1653
1654   // We don't expect the animation to finish now
1655   application.SendNotification();
1656   finishCheck.CheckSignalNotReceived();
1657   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1658
1659   // Restart as a scale animation; this should not move the actor's position
1660   finishCheck.Reset();
1661   actor.SetPosition(Vector3::ZERO);
1662   Vector3 targetScale(3.0f, 3.0f, 3.0f);
1663   animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear);
1664   animation.Play();
1665
1666   application.SendNotification();
1667   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1668
1669   // We didn't expect the animation to finish yet
1670   application.SendNotification();
1671   finishCheck.CheckSignalNotReceived();
1672   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1673   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1674
1675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1676
1677   // We did expect the animation to finish
1678   application.SendNotification();
1679   finishCheck.CheckSignalReceived();
1680   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1681   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1682   END_TEST;
1683 }
1684
1685 int UtcDaliAnimationSignalFinish(void)
1686 {
1687   TestApplication application;
1688
1689   // Start the empty animation
1690   float durationSeconds(1.0f);
1691   Animation animation = Animation::New(durationSeconds);
1692   animation.Play();
1693
1694   bool signalReceived(false);
1695   AnimationFinishCheck finishCheck(signalReceived);
1696   animation.FinishedSignal().Connect(&application, finishCheck);
1697
1698   application.SendNotification();
1699   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1700
1701   // We did expect the animation to finish
1702   application.SendNotification();
1703   finishCheck.CheckSignalReceived();
1704   END_TEST;
1705 }
1706
1707 int UtcDaliAnimationAnimateByBoolean(void)
1708 {
1709   TestApplication application;
1710
1711   Actor actor = Actor::New();
1712
1713   // Register a boolean property
1714   bool startValue(false);
1715   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1716   Stage::GetCurrent().Add(actor);
1717   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1718
1719   // Build the animation
1720   float durationSeconds(2.0f);
1721   Animation animation = Animation::New(durationSeconds);
1722   const bool relativeValue(true);
1723   const bool finalValue( false || relativeValue );
1724   animation.AnimateBy(Property(actor, index), relativeValue);
1725
1726   // Start the animation
1727   animation.Play();
1728
1729   bool signalReceived(false);
1730   AnimationFinishCheck finishCheck(signalReceived);
1731   animation.FinishedSignal().Connect(&application, finishCheck);
1732
1733   application.SendNotification();
1734   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1735
1736   // We didn't expect the animation to finish yet
1737   application.SendNotification();
1738   finishCheck.CheckSignalNotReceived();
1739   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1740
1741   application.SendNotification();
1742   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1743
1744   // We did expect the animation to finish
1745   application.SendNotification();
1746   finishCheck.CheckSignalReceived();
1747   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1748
1749   // Check that nothing has changed after a couple of buffer swaps
1750   application.Render(0);
1751   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1752   application.Render(0);
1753   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1754
1755   // Repeat with relative value "false" - this should be an NOOP
1756   animation = Animation::New(durationSeconds);
1757   bool noOpValue(false);
1758   animation.AnimateBy(Property(actor, index), noOpValue);
1759
1760   // Start the animation
1761   animation.Play();
1762
1763   finishCheck.Reset();
1764   animation.FinishedSignal().Connect(&application, finishCheck);
1765
1766   application.SendNotification();
1767   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1768
1769   // We didn't expect the animation to finish yet
1770   application.SendNotification();
1771   finishCheck.CheckSignalNotReceived();
1772   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1773
1774   application.SendNotification();
1775   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1776
1777   // We did expect the animation to finish
1778   application.SendNotification();
1779   finishCheck.CheckSignalReceived();
1780   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1781
1782   // Check that nothing has changed after a couple of buffer swaps
1783   application.Render(0);
1784   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1785   application.Render(0);
1786   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1787   END_TEST;
1788 }
1789
1790 int UtcDaliAnimationAnimateByBooleanAlphaFunction(void)
1791 {
1792   TestApplication application;
1793
1794   Actor actor = Actor::New();
1795
1796   // Register a boolean property
1797   bool startValue(false);
1798   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1799   Stage::GetCurrent().Add(actor);
1800   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1801
1802   // Build the animation
1803   float durationSeconds(2.0f);
1804   Animation animation = Animation::New(durationSeconds);
1805   bool relativeValue(true);
1806   bool finalValue( false || relativeValue );
1807   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn);
1808
1809   // Start the animation
1810   animation.Play();
1811
1812   bool signalReceived(false);
1813   AnimationFinishCheck finishCheck(signalReceived);
1814   animation.FinishedSignal().Connect(&application, finishCheck);
1815
1816   application.SendNotification();
1817   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1818
1819   // We didn't expect the animation to finish yet
1820   application.SendNotification();
1821   finishCheck.CheckSignalNotReceived();
1822   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1823
1824   application.SendNotification();
1825   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1826
1827   // We did expect the animation to finish
1828   application.SendNotification();
1829   finishCheck.CheckSignalReceived();
1830   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1831
1832   // Check that nothing has changed after a couple of buffer swaps
1833   application.Render(0);
1834   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1835   application.Render(0);
1836   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1837
1838   // Repeat with relative value "false" - this should be an NOOP
1839   animation = Animation::New(durationSeconds);
1840   bool noOpValue(false);
1841   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn);
1842
1843   // Start the animation
1844   animation.Play();
1845
1846   finishCheck.Reset();
1847   animation.FinishedSignal().Connect(&application, finishCheck);
1848
1849   application.SendNotification();
1850   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1851
1852   // We didn't expect the animation to finish yet
1853   application.SendNotification();
1854   finishCheck.CheckSignalNotReceived();
1855   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1856
1857   application.SendNotification();
1858   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1859
1860   // We did expect the animation to finish
1861   application.SendNotification();
1862   finishCheck.CheckSignalReceived();
1863   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1864   END_TEST;
1865 }
1866
1867 int UtcDaliAnimationAnimateByBooleanTimePeriod(void)
1868 {
1869   TestApplication application;
1870
1871   Actor actor = Actor::New();
1872
1873   // Register a boolean property
1874   bool startValue(false);
1875   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1876   Stage::GetCurrent().Add(actor);
1877   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1878
1879   // Build the animation
1880   float durationSeconds(2.0f);
1881   Animation animation = Animation::New(durationSeconds);
1882   bool relativeValue(true);
1883   bool finalValue( false || relativeValue );
1884   float animatorDurationSeconds(durationSeconds * 0.5f);
1885   animation.AnimateBy( Property(actor, index),
1886                        relativeValue,
1887                        TimePeriod( animatorDurationSeconds ) );
1888
1889   // Start the animation
1890   animation.Play();
1891
1892   bool signalReceived(false);
1893   AnimationFinishCheck finishCheck(signalReceived);
1894   animation.FinishedSignal().Connect(&application, finishCheck);
1895
1896   application.SendNotification();
1897   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1898
1899   // We didn't expect the animation to finish yet
1900   application.SendNotification();
1901   finishCheck.CheckSignalNotReceived();
1902   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1903
1904   application.SendNotification();
1905   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1906
1907   // We didn't expect the animation to finish yet...
1908   application.SendNotification();
1909   finishCheck.CheckSignalNotReceived();
1910
1911   // ...however we should have reached the final value
1912   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1913
1914   application.SendNotification();
1915   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1916
1917   // We did expect the animation to finish
1918   application.SendNotification();
1919   finishCheck.CheckSignalReceived();
1920   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1921
1922   // Check that nothing has changed after a couple of buffer swaps
1923   application.Render(0);
1924   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1925   application.Render(0);
1926   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1927   END_TEST;
1928 }
1929
1930 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void)
1931 {
1932   TestApplication application;
1933
1934   Actor actor = Actor::New();
1935
1936   // Register a boolean property
1937   bool startValue(false);
1938   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1939   Stage::GetCurrent().Add(actor);
1940   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1941
1942   // Build the animation
1943   float durationSeconds(2.0f);
1944   Animation animation = Animation::New(durationSeconds);
1945   bool relativeValue(true);
1946   bool finalValue( false || relativeValue );
1947   float animatorDurationSeconds(durationSeconds * 0.5f);
1948   animation.AnimateBy( Property(actor, index),
1949                        relativeValue,
1950                        AlphaFunctions::EaseInOut,
1951                        TimePeriod( animatorDurationSeconds ) );
1952
1953   // Start the animation
1954   animation.Play();
1955
1956   bool signalReceived(false);
1957   AnimationFinishCheck finishCheck(signalReceived);
1958   animation.FinishedSignal().Connect(&application, finishCheck);
1959
1960   application.SendNotification();
1961   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1962
1963   // We didn't expect the animation to finish yet
1964   application.SendNotification();
1965   finishCheck.CheckSignalNotReceived();
1966   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1967
1968   application.SendNotification();
1969   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1970
1971   // We didn't expect the animation to finish yet...
1972   application.SendNotification();
1973   finishCheck.CheckSignalNotReceived();
1974
1975   // ...however we should have reached the final value
1976   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1977
1978   application.SendNotification();
1979   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1980
1981   // We did expect the animation to finish
1982   application.SendNotification();
1983   finishCheck.CheckSignalReceived();
1984   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1985
1986   // Check that nothing has changed after a couple of buffer swaps
1987   application.Render(0);
1988   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1989   application.Render(0);
1990   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1991   END_TEST;
1992 }
1993
1994 int UtcDaliAnimationAnimateByFloat(void)
1995 {
1996   TestApplication application;
1997
1998   Actor actor = Actor::New();
1999
2000   // Register a float property
2001   float startValue(10.0f);
2002   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2003   Stage::GetCurrent().Add(actor);
2004   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2005
2006   // Build the animation
2007   float durationSeconds(2.0f);
2008   Animation animation = Animation::New(durationSeconds);
2009   float targetValue(50.0f);
2010   float relativeValue(targetValue - startValue);
2011   animation.AnimateBy(Property(actor, index), relativeValue);
2012
2013   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2014
2015   // Start the animation
2016   animation.Play();
2017
2018   bool signalReceived(false);
2019   AnimationFinishCheck finishCheck(signalReceived);
2020   animation.FinishedSignal().Connect(&application, finishCheck);
2021
2022   application.SendNotification();
2023   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2024
2025   // We didn't expect the animation to finish yet
2026   application.SendNotification();
2027   finishCheck.CheckSignalNotReceived();
2028   DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
2029
2030   application.SendNotification();
2031   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2032
2033   // We did expect the animation to finish
2034   application.SendNotification();
2035   finishCheck.CheckSignalReceived();
2036   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2037
2038   // Check that nothing has changed after a couple of buffer swaps
2039   application.Render(0);
2040   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2041   application.Render(0);
2042   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2043   END_TEST;
2044 }
2045
2046 int UtcDaliAnimationAnimateByFloatAlphaFunction(void)
2047 {
2048   TestApplication application;
2049
2050   Actor actor = Actor::New();
2051
2052   // Register a float property
2053   float startValue(10.0f);
2054   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2055   Stage::GetCurrent().Add(actor);
2056   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2057
2058   // Build the animation
2059   float durationSeconds(1.0f);
2060   Animation animation = Animation::New(durationSeconds);
2061   float targetValue(90.0f);
2062   float relativeValue(targetValue - startValue);
2063   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2064
2065   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2066
2067   // Start the animation
2068   animation.Play();
2069
2070   bool signalReceived(false);
2071   AnimationFinishCheck finishCheck(signalReceived);
2072   animation.FinishedSignal().Connect(&application, finishCheck);
2073
2074   application.SendNotification();
2075   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2076
2077   // We didn't expect the animation to finish yet
2078   application.SendNotification();
2079   finishCheck.CheckSignalNotReceived();
2080
2081   // The position should have moved more, than with a linear alpha function
2082   float current(actor.GetProperty<float>(index));
2083   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2084
2085   application.SendNotification();
2086   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2087
2088   // We did expect the animation to finish
2089   application.SendNotification();
2090   finishCheck.CheckSignalReceived();
2091   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2092
2093   // Check that nothing has changed after a couple of buffer swaps
2094   application.Render(0);
2095   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2096   application.Render(0);
2097   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2098   END_TEST;
2099 }
2100
2101 int UtcDaliAnimationAnimateByFloatTimePeriod(void)
2102 {
2103   TestApplication application;
2104
2105   Actor actor = Actor::New();
2106
2107   // Register a float property
2108   float startValue(10.0f);
2109   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2110   Stage::GetCurrent().Add(actor);
2111   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2112
2113   // Build the animation
2114   float durationSeconds(1.0f);
2115   Animation animation = Animation::New(durationSeconds);
2116   float targetValue(30.0f);
2117   float relativeValue(targetValue - startValue);
2118   float delay = 0.5f;
2119   animation.AnimateBy(Property(actor, index),
2120                       relativeValue,
2121                       TimePeriod(delay, durationSeconds - delay));
2122
2123   // Start the animation
2124   animation.Play();
2125
2126   bool signalReceived(false);
2127   AnimationFinishCheck finishCheck(signalReceived);
2128   animation.FinishedSignal().Connect(&application, finishCheck);
2129
2130   application.SendNotification();
2131   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2132
2133   // We didn't expect the animation to finish yet
2134   application.SendNotification();
2135   finishCheck.CheckSignalNotReceived();
2136   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2137
2138   application.SendNotification();
2139   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2140
2141   // We didn't expect the animation to finish yet
2142   application.SendNotification();
2143   finishCheck.CheckSignalNotReceived();
2144   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2145
2146   application.SendNotification();
2147   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2148
2149   // We did expect the animation to finish
2150   application.SendNotification();
2151   finishCheck.CheckSignalReceived();
2152   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2153
2154   // Check that nothing has changed after a couple of buffer swaps
2155   application.Render(0);
2156   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2157   application.Render(0);
2158   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2159   END_TEST;
2160 }
2161
2162 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void)
2163 {
2164   TestApplication application;
2165
2166   Actor actor = Actor::New();
2167
2168   // Register a float property
2169   float startValue(10.0f);
2170   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2171   Stage::GetCurrent().Add(actor);
2172   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2173
2174   // Build the animation
2175   float durationSeconds(1.0f);
2176   Animation animation = Animation::New(durationSeconds);
2177   float targetValue(30.0f);
2178   float relativeValue(targetValue - startValue);
2179   float delay = 0.5f;
2180   animation.AnimateBy(Property(actor, index),
2181                       relativeValue,
2182                       AlphaFunctions::Linear,
2183                       TimePeriod(delay, durationSeconds - delay));
2184
2185   // Start the animation
2186   animation.Play();
2187
2188   bool signalReceived(false);
2189   AnimationFinishCheck finishCheck(signalReceived);
2190   animation.FinishedSignal().Connect(&application, finishCheck);
2191
2192   application.SendNotification();
2193   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2194
2195   // We didn't expect the animation to finish yet
2196   application.SendNotification();
2197   finishCheck.CheckSignalNotReceived();
2198   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2199
2200   application.SendNotification();
2201   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2202
2203   // We didn't expect the animation to finish yet
2204   application.SendNotification();
2205   finishCheck.CheckSignalNotReceived();
2206   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2207
2208   application.SendNotification();
2209   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2210
2211   // We did expect the animation to finish
2212   application.SendNotification();
2213   finishCheck.CheckSignalReceived();
2214   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2215
2216   // Check that nothing has changed after a couple of buffer swaps
2217   application.Render(0);
2218   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2219   application.Render(0);
2220   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2221   END_TEST;
2222 }
2223
2224 int UtcDaliAnimationAnimateByInteger(void)
2225 {
2226   TestApplication application;
2227
2228   Actor actor = Actor::New();
2229
2230   // Register an integer property
2231   int startValue(1);
2232   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2233   Stage::GetCurrent().Add(actor);
2234   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2235
2236   // Build the animation
2237   float durationSeconds(2.0f);
2238   Animation animation = Animation::New(durationSeconds);
2239   int targetValue(50);
2240   int relativeValue(targetValue - startValue);
2241   animation.AnimateBy(Property(actor, index), relativeValue);
2242
2243   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2244
2245   // Start the animation
2246   animation.Play();
2247
2248   bool signalReceived(false);
2249   AnimationFinishCheck finishCheck(signalReceived);
2250   animation.FinishedSignal().Connect(&application, finishCheck);
2251
2252   application.SendNotification();
2253   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2254
2255   // We didn't expect the animation to finish yet
2256   application.SendNotification();
2257   finishCheck.CheckSignalNotReceived();
2258   DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2259
2260   application.SendNotification();
2261   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2262
2263   // We did expect the animation to finish
2264   application.SendNotification();
2265   finishCheck.CheckSignalReceived();
2266   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2267
2268   // Check that nothing has changed after a couple of buffer swaps
2269   application.Render(0);
2270   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2271   application.Render(0);
2272   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2273   END_TEST;
2274 }
2275
2276 int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
2277 {
2278   TestApplication application;
2279
2280   Actor actor = Actor::New();
2281
2282   // Register an integer property
2283   int startValue(1);
2284   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2285   Stage::GetCurrent().Add(actor);
2286   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2287
2288   // Build the animation
2289   float durationSeconds(1.0f);
2290   Animation animation = Animation::New(durationSeconds);
2291   int targetValue(90);
2292   int relativeValue(targetValue - startValue);
2293   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2294
2295   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2296
2297   // Start the animation
2298   animation.Play();
2299
2300   bool signalReceived(false);
2301   AnimationFinishCheck finishCheck(signalReceived);
2302   animation.FinishedSignal().Connect(&application, finishCheck);
2303
2304   application.SendNotification();
2305   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2306
2307   // We didn't expect the animation to finish yet
2308   application.SendNotification();
2309   finishCheck.CheckSignalNotReceived();
2310
2311   // The position should have moved more, than with a linear alpha function
2312   int current(actor.GetProperty<int>(index));
2313   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2314
2315   application.SendNotification();
2316   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2317
2318   // We did expect the animation to finish
2319   application.SendNotification();
2320   finishCheck.CheckSignalReceived();
2321   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2322
2323   // Check that nothing has changed after a couple of buffer swaps
2324   application.Render(0);
2325   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2326   application.Render(0);
2327   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2328   END_TEST;
2329 }
2330
2331 int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
2332 {
2333   TestApplication application;
2334
2335   Actor actor = Actor::New();
2336
2337   // Register an integer property
2338   int startValue(10);
2339   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2340   Stage::GetCurrent().Add(actor);
2341   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2342
2343   // Build the animation
2344   float durationSeconds(1.0f);
2345   Animation animation = Animation::New(durationSeconds);
2346   int targetValue(30);
2347   int relativeValue(targetValue - startValue);
2348   float delay = 0.5f;
2349   animation.AnimateBy(Property(actor, index),
2350                       relativeValue,
2351                       TimePeriod(delay, durationSeconds - delay));
2352
2353   // Start the animation
2354   animation.Play();
2355
2356   bool signalReceived(false);
2357   AnimationFinishCheck finishCheck(signalReceived);
2358   animation.FinishedSignal().Connect(&application, finishCheck);
2359
2360   application.SendNotification();
2361   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2362
2363   // We didn't expect the animation to finish yet
2364   application.SendNotification();
2365   finishCheck.CheckSignalNotReceived();
2366   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2367
2368   application.SendNotification();
2369   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2370
2371   // We didn't expect the animation to finish yet
2372   application.SendNotification();
2373   finishCheck.CheckSignalNotReceived();
2374   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2375
2376   application.SendNotification();
2377   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2378
2379   // We did expect the animation to finish
2380   application.SendNotification();
2381   finishCheck.CheckSignalReceived();
2382   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2383
2384   // Check that nothing has changed after a couple of buffer swaps
2385   application.Render(0);
2386   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2387   application.Render(0);
2388   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2389   END_TEST;
2390 }
2391
2392 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
2393 {
2394   TestApplication application;
2395
2396   Actor actor = Actor::New();
2397
2398   // Register an integer property
2399   int startValue(10);
2400   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2401   Stage::GetCurrent().Add(actor);
2402   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2403
2404   // Build the animation
2405   float durationSeconds(1.0f);
2406   Animation animation = Animation::New(durationSeconds);
2407   int targetValue(30);
2408   int relativeValue(targetValue - startValue);
2409   float delay = 0.5f;
2410   animation.AnimateBy(Property(actor, index),
2411                       relativeValue,
2412                       AlphaFunctions::Linear,
2413                       TimePeriod(delay, durationSeconds - delay));
2414
2415   // Start the animation
2416   animation.Play();
2417
2418   bool signalReceived(false);
2419   AnimationFinishCheck finishCheck(signalReceived);
2420   animation.FinishedSignal().Connect(&application, finishCheck);
2421
2422   application.SendNotification();
2423   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2424
2425   // We didn't expect the animation to finish yet
2426   application.SendNotification();
2427   finishCheck.CheckSignalNotReceived();
2428   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2429
2430   application.SendNotification();
2431   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2432
2433   // We didn't expect the animation to finish yet
2434   application.SendNotification();
2435   finishCheck.CheckSignalNotReceived();
2436   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2437
2438   application.SendNotification();
2439   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2440
2441   // We did expect the animation to finish
2442   application.SendNotification();
2443   finishCheck.CheckSignalReceived();
2444   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2445
2446   // Check that nothing has changed after a couple of buffer swaps
2447   application.Render(0);
2448   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2449   application.Render(0);
2450   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2451   END_TEST;
2452 }
2453
2454 int UtcDaliAnimationAnimateByVector2(void)
2455 {
2456   TestApplication application;
2457
2458   Actor actor = Actor::New();
2459
2460   // Register a Vector2 property
2461   Vector2 startValue(10.0f, 10.0f);
2462   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2463   Stage::GetCurrent().Add(actor);
2464   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2465
2466   // Build the animation
2467   float durationSeconds(2.0f);
2468   Animation animation = Animation::New(durationSeconds);
2469   Vector2 targetValue(60.0f, 60.0f);
2470   Vector2 relativeValue(targetValue - startValue);
2471   animation.AnimateBy(Property(actor, index), relativeValue);
2472
2473   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2474
2475   // Start the animation
2476   animation.Play();
2477
2478   bool signalReceived(false);
2479   AnimationFinishCheck finishCheck(signalReceived);
2480   animation.FinishedSignal().Connect(&application, finishCheck);
2481
2482   application.SendNotification();
2483   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2484
2485   // We didn't expect the animation to finish yet
2486   application.SendNotification();
2487   finishCheck.CheckSignalNotReceived();
2488   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2489
2490   application.SendNotification();
2491   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2492
2493   // We did expect the animation to finish
2494   application.SendNotification();
2495   finishCheck.CheckSignalReceived();
2496   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2497
2498   // Check that nothing has changed after a couple of buffer swaps
2499   application.Render(0);
2500   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2501   application.Render(0);
2502   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2503   END_TEST;
2504 }
2505
2506 int UtcDaliAnimationAnimateByVector2AlphaFunction(void)
2507 {
2508   TestApplication application;
2509
2510   Actor actor = Actor::New();
2511
2512   // Register a Vector2 property
2513   Vector2 startValue(100.0f, 100.0f);
2514   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2515   Stage::GetCurrent().Add(actor);
2516   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2517
2518   // Build the animation
2519   float durationSeconds(1.0f);
2520   Animation animation = Animation::New(durationSeconds);
2521   Vector2 targetValue(20.0f, 20.0f);
2522   Vector2 relativeValue(targetValue - startValue);
2523   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2524
2525   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2526
2527   // Start the animation
2528   animation.Play();
2529
2530   bool signalReceived(false);
2531   AnimationFinishCheck finishCheck(signalReceived);
2532   animation.FinishedSignal().Connect(&application, finishCheck);
2533
2534   application.SendNotification();
2535   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2536
2537   // We didn't expect the animation to finish yet
2538   application.SendNotification();
2539   finishCheck.CheckSignalNotReceived();
2540
2541   // The position should have moved more, than with a linear alpha function
2542   Vector2 current(actor.GetProperty<Vector2>(index));
2543   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2544   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2545
2546   application.SendNotification();
2547   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2548
2549   // We did expect the animation to finish
2550   application.SendNotification();
2551   finishCheck.CheckSignalReceived();
2552   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2553
2554   // Check that nothing has changed after a couple of buffer swaps
2555   application.Render(0);
2556   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2557   application.Render(0);
2558   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2559   END_TEST;
2560 }
2561
2562 int UtcDaliAnimationAnimateByVector2TimePeriod(void)
2563 {
2564   TestApplication application;
2565
2566   Actor actor = Actor::New();
2567
2568   // Register a Vector2 property
2569   Vector2 startValue(10.0f, 10.0f);
2570   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2571   Stage::GetCurrent().Add(actor);
2572   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2573
2574   // Build the animation
2575   float durationSeconds(1.0f);
2576   Animation animation = Animation::New(durationSeconds);
2577   Vector2 targetValue(30.0f, 30.0f);
2578   Vector2 relativeValue(targetValue - startValue);
2579   float delay = 0.5f;
2580   animation.AnimateBy(Property(actor, index),
2581                       relativeValue,
2582                       TimePeriod(delay, durationSeconds - delay));
2583
2584   // Start the animation
2585   animation.Play();
2586
2587   bool signalReceived(false);
2588   AnimationFinishCheck finishCheck(signalReceived);
2589   animation.FinishedSignal().Connect(&application, finishCheck);
2590
2591   application.SendNotification();
2592   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2593
2594   // We didn't expect the animation to finish yet
2595   application.SendNotification();
2596   finishCheck.CheckSignalNotReceived();
2597   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2598
2599   application.SendNotification();
2600   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2601
2602   // We didn't expect the animation to finish yet
2603   application.SendNotification();
2604   finishCheck.CheckSignalNotReceived();
2605   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2606
2607   application.SendNotification();
2608   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2609
2610   // We did expect the animation to finish
2611   application.SendNotification();
2612   finishCheck.CheckSignalReceived();
2613   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2614
2615   // Check that nothing has changed after a couple of buffer swaps
2616   application.Render(0);
2617   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2618   application.Render(0);
2619   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2620   END_TEST;
2621 }
2622
2623 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void)
2624 {
2625   TestApplication application;
2626
2627   Actor actor = Actor::New();
2628
2629   // Register a Vector2 property
2630   Vector2 startValue(5.0f, 5.0f);
2631   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2632   Stage::GetCurrent().Add(actor);
2633   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2634
2635   // Build the animation
2636   float durationSeconds(1.0f);
2637   Animation animation = Animation::New(durationSeconds);
2638   Vector2 targetValue(10.0f, 10.0f);
2639   Vector2 relativeValue(targetValue - startValue);
2640   float delay = 0.5f;
2641   animation.AnimateBy(Property(actor, index),
2642                       relativeValue,
2643                       AlphaFunctions::Linear,
2644                       TimePeriod(delay, durationSeconds - delay));
2645
2646   // Start the animation
2647   animation.Play();
2648
2649   bool signalReceived(false);
2650   AnimationFinishCheck finishCheck(signalReceived);
2651   animation.FinishedSignal().Connect(&application, finishCheck);
2652
2653   application.SendNotification();
2654   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2655
2656   // We didn't expect the animation to finish yet
2657   application.SendNotification();
2658   finishCheck.CheckSignalNotReceived();
2659   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2660
2661   application.SendNotification();
2662   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2663
2664   // We didn't expect the animation to finish yet
2665   application.SendNotification();
2666   finishCheck.CheckSignalNotReceived();
2667   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2668
2669   application.SendNotification();
2670   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2671
2672   // We did expect the animation to finish
2673   application.SendNotification();
2674   finishCheck.CheckSignalReceived();
2675   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2676
2677   // Check that nothing has changed after a couple of buffer swaps
2678   application.Render(0);
2679   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2680   application.Render(0);
2681   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2682   END_TEST;
2683 }
2684
2685 int UtcDaliAnimationAnimateByVector3(void)
2686 {
2687   TestApplication application;
2688
2689   Actor actor = Actor::New();
2690
2691   // Register a Vector3 property
2692   Vector3 startValue(10.0f, 10.0f, 10.0f);
2693   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2694   Stage::GetCurrent().Add(actor);
2695   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2696
2697   // Build the animation
2698   float durationSeconds(2.0f);
2699   Animation animation = Animation::New(durationSeconds);
2700   Vector3 targetValue(60.0f, 60.0f, 60.0f);
2701   Vector3 relativeValue(targetValue - startValue);
2702   animation.AnimateBy(Property(actor, index), relativeValue);
2703
2704   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2705
2706   // Start the animation
2707   animation.Play();
2708
2709   bool signalReceived(false);
2710   AnimationFinishCheck finishCheck(signalReceived);
2711   animation.FinishedSignal().Connect(&application, finishCheck);
2712
2713   application.SendNotification();
2714   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2715
2716   // We didn't expect the animation to finish yet
2717   application.SendNotification();
2718   finishCheck.CheckSignalNotReceived();
2719   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2720
2721   application.SendNotification();
2722   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2723
2724   // We did expect the animation to finish
2725   application.SendNotification();
2726   finishCheck.CheckSignalReceived();
2727   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2728
2729   // Check that nothing has changed after a couple of buffer swaps
2730   application.Render(0);
2731   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2732   application.Render(0);
2733   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2734   END_TEST;
2735 }
2736
2737 int UtcDaliAnimationAnimateByVector3AlphaFunction(void)
2738 {
2739   TestApplication application;
2740
2741   Actor actor = Actor::New();
2742
2743   // Register a Vector3 property
2744   Vector3 startValue(100.0f, 100.0f, 100.0f);
2745   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2746   Stage::GetCurrent().Add(actor);
2747   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2748
2749   // Build the animation
2750   float durationSeconds(1.0f);
2751   Animation animation = Animation::New(durationSeconds);
2752   Vector3 targetValue(20.0f, 20.0f, 20.0f);
2753   Vector3 relativeValue(targetValue - startValue);
2754   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2755
2756   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2757
2758   // Start the animation
2759   animation.Play();
2760
2761   bool signalReceived(false);
2762   AnimationFinishCheck finishCheck(signalReceived);
2763   animation.FinishedSignal().Connect(&application, finishCheck);
2764
2765   application.SendNotification();
2766   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2767
2768   // We didn't expect the animation to finish yet
2769   application.SendNotification();
2770   finishCheck.CheckSignalNotReceived();
2771
2772   // The position should have moved more, than with a linear alpha function
2773   Vector3 current(actor.GetProperty<Vector3>(index));
2774   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2775   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2776   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2777
2778   application.SendNotification();
2779   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2780
2781   // We did expect the animation to finish
2782   application.SendNotification();
2783   finishCheck.CheckSignalReceived();
2784   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2785
2786   // Check that nothing has changed after a couple of buffer swaps
2787   application.Render(0);
2788   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2789   application.Render(0);
2790   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2791   END_TEST;
2792 }
2793
2794 int UtcDaliAnimationAnimateByVector3TimePeriod(void)
2795 {
2796   TestApplication application;
2797
2798   Actor actor = Actor::New();
2799
2800   // Register a Vector3 property
2801   Vector3 startValue(10.0f, 10.0f, 10.0f);
2802   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2803   Stage::GetCurrent().Add(actor);
2804   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2805
2806   // Build the animation
2807   float durationSeconds(1.0f);
2808   Animation animation = Animation::New(durationSeconds);
2809   Vector3 targetValue(30.0f, 30.0f, 30.0f);
2810   Vector3 relativeValue(targetValue - startValue);
2811   float delay = 0.5f;
2812   animation.AnimateBy(Property(actor, index),
2813                       relativeValue,
2814                       TimePeriod(delay, durationSeconds - delay));
2815
2816   // Start the animation
2817   animation.Play();
2818
2819   bool signalReceived(false);
2820   AnimationFinishCheck finishCheck(signalReceived);
2821   animation.FinishedSignal().Connect(&application, finishCheck);
2822
2823   application.SendNotification();
2824   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2825
2826   // We didn't expect the animation to finish yet
2827   application.SendNotification();
2828   finishCheck.CheckSignalNotReceived();
2829   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2830
2831   application.SendNotification();
2832   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2833
2834   // We didn't expect the animation to finish yet
2835   application.SendNotification();
2836   finishCheck.CheckSignalNotReceived();
2837   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2838
2839   application.SendNotification();
2840   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2841
2842   // We did expect the animation to finish
2843   application.SendNotification();
2844   finishCheck.CheckSignalReceived();
2845   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2846
2847   // Check that nothing has changed after a couple of buffer swaps
2848   application.Render(0);
2849   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2850   application.Render(0);
2851   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2852   END_TEST;
2853 }
2854
2855 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void)
2856 {
2857   TestApplication application;
2858
2859   Actor actor = Actor::New();
2860
2861   // Register a Vector3 property
2862   Vector3 startValue(5.0f, 5.0f, 5.0f);
2863   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2864   Stage::GetCurrent().Add(actor);
2865   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2866
2867   // Build the animation
2868   float durationSeconds(1.0f);
2869   Animation animation = Animation::New(durationSeconds);
2870   Vector3 targetValue(10.0f, 10.0f, 10.0f);
2871   Vector3 relativeValue(targetValue - startValue);
2872   float delay = 0.5f;
2873   animation.AnimateBy(Property(actor, index),
2874                       relativeValue,
2875                       AlphaFunctions::Linear,
2876                       TimePeriod(delay, durationSeconds - delay));
2877
2878   // Start the animation
2879   animation.Play();
2880
2881   bool signalReceived(false);
2882   AnimationFinishCheck finishCheck(signalReceived);
2883   animation.FinishedSignal().Connect(&application, finishCheck);
2884
2885   application.SendNotification();
2886   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2887
2888   // We didn't expect the animation to finish yet
2889   application.SendNotification();
2890   finishCheck.CheckSignalNotReceived();
2891   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2892
2893   application.SendNotification();
2894   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2895
2896   // We didn't expect the animation to finish yet
2897   application.SendNotification();
2898   finishCheck.CheckSignalNotReceived();
2899   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2900
2901   application.SendNotification();
2902   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2903
2904   // We did expect the animation to finish
2905   application.SendNotification();
2906   finishCheck.CheckSignalReceived();
2907   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2908
2909   // Check that nothing has changed after a couple of buffer swaps
2910   application.Render(0);
2911   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2912   application.Render(0);
2913   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2914   END_TEST;
2915 }
2916
2917 int UtcDaliAnimationAnimateByVector4(void)
2918 {
2919   TestApplication application;
2920
2921   Actor actor = Actor::New();
2922
2923   // Register a Vector4 property
2924   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
2925   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2926   Stage::GetCurrent().Add(actor);
2927   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2928
2929   // Build the animation
2930   float durationSeconds(2.0f);
2931   Animation animation = Animation::New(durationSeconds);
2932   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
2933   Vector4 relativeValue(targetValue - startValue);
2934   animation.AnimateBy(Property(actor, index), relativeValue);
2935
2936   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2937
2938   // Start the animation
2939   animation.Play();
2940
2941   bool signalReceived(false);
2942   AnimationFinishCheck finishCheck(signalReceived);
2943   animation.FinishedSignal().Connect(&application, finishCheck);
2944
2945   application.SendNotification();
2946   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2947
2948   // We didn't expect the animation to finish yet
2949   application.SendNotification();
2950   finishCheck.CheckSignalNotReceived();
2951   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
2952
2953   application.SendNotification();
2954   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2955
2956   // We did expect the animation to finish
2957   application.SendNotification();
2958   finishCheck.CheckSignalReceived();
2959   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2960
2961   // Check that nothing has changed after a couple of buffer swaps
2962   application.Render(0);
2963   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2964   application.Render(0);
2965   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
2966   END_TEST;
2967 }
2968
2969 int UtcDaliAnimationAnimateByVector4AlphaFunction(void)
2970 {
2971   TestApplication application;
2972
2973   Actor actor = Actor::New();
2974
2975   // Register a Vector4 property
2976   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
2977   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2978   Stage::GetCurrent().Add(actor);
2979   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
2980
2981   // Build the animation
2982   float durationSeconds(1.0f);
2983   Animation animation = Animation::New(durationSeconds);
2984   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
2985   Vector4 relativeValue(targetValue - startValue);
2986   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
2987
2988   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2989
2990   // Start the animation
2991   animation.Play();
2992
2993   bool signalReceived(false);
2994   AnimationFinishCheck finishCheck(signalReceived);
2995   animation.FinishedSignal().Connect(&application, finishCheck);
2996
2997   application.SendNotification();
2998   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2999
3000   // We didn't expect the animation to finish yet
3001   application.SendNotification();
3002   finishCheck.CheckSignalNotReceived();
3003
3004   // The position should have moved more, than with a linear alpha function
3005   Vector4 current(actor.GetProperty<Vector4>(index));
3006   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3007   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3008   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3009   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
3010
3011   application.SendNotification();
3012   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3013
3014   // We did expect the animation to finish
3015   application.SendNotification();
3016   finishCheck.CheckSignalReceived();
3017   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3018
3019   // Check that nothing has changed after a couple of buffer swaps
3020   application.Render(0);
3021   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3022   application.Render(0);
3023   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3024   END_TEST;
3025 }
3026
3027 int UtcDaliAnimationAnimateByVector4TimePeriod(void)
3028 {
3029   TestApplication application;
3030
3031   Actor actor = Actor::New();
3032
3033   // Register a Vector4 property
3034   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3035   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3036   Stage::GetCurrent().Add(actor);
3037   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3038
3039   // Build the animation
3040   float durationSeconds(1.0f);
3041   Animation animation = Animation::New(durationSeconds);
3042   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3043   Vector4 relativeValue(targetValue - startValue);
3044   float delay = 0.5f;
3045   animation.AnimateBy(Property(actor, index),
3046                       relativeValue,
3047                       TimePeriod(delay, durationSeconds - delay));
3048
3049   // Start the animation
3050   animation.Play();
3051
3052   bool signalReceived(false);
3053   AnimationFinishCheck finishCheck(signalReceived);
3054   animation.FinishedSignal().Connect(&application, finishCheck);
3055
3056   application.SendNotification();
3057   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3058
3059   // We didn't expect the animation to finish yet
3060   application.SendNotification();
3061   finishCheck.CheckSignalNotReceived();
3062   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3063
3064   application.SendNotification();
3065   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3066
3067   // We didn't expect the animation to finish yet
3068   application.SendNotification();
3069   finishCheck.CheckSignalNotReceived();
3070   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3071
3072   application.SendNotification();
3073   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3074
3075   // We did expect the animation to finish
3076   application.SendNotification();
3077   finishCheck.CheckSignalReceived();
3078   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3079
3080   // Check that nothing has changed after a couple of buffer swaps
3081   application.Render(0);
3082   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3083   application.Render(0);
3084   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3085   END_TEST;
3086 }
3087
3088 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void)
3089 {
3090   TestApplication application;
3091
3092   Actor actor = Actor::New();
3093
3094   // Register a Vector4 property
3095   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
3096   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3097   Stage::GetCurrent().Add(actor);
3098   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3099
3100   // Build the animation
3101   float durationSeconds(1.0f);
3102   Animation animation = Animation::New(durationSeconds);
3103   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
3104   Vector4 relativeValue(targetValue - startValue);
3105   float delay = 0.5f;
3106   animation.AnimateBy(Property(actor, index),
3107                       relativeValue,
3108                       AlphaFunctions::Linear,
3109                       TimePeriod(delay, durationSeconds - delay));
3110
3111   // Start the animation
3112   animation.Play();
3113
3114   bool signalReceived(false);
3115   AnimationFinishCheck finishCheck(signalReceived);
3116   animation.FinishedSignal().Connect(&application, finishCheck);
3117
3118   application.SendNotification();
3119   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3120
3121   // We didn't expect the animation to finish yet
3122   application.SendNotification();
3123   finishCheck.CheckSignalNotReceived();
3124   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3125
3126   application.SendNotification();
3127   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3128
3129   // We didn't expect the animation to finish yet
3130   application.SendNotification();
3131   finishCheck.CheckSignalNotReceived();
3132   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3133
3134   application.SendNotification();
3135   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3136
3137   // We did expect the animation to finish
3138   application.SendNotification();
3139   finishCheck.CheckSignalReceived();
3140   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3141
3142   // Check that nothing has changed after a couple of buffer swaps
3143   application.Render(0);
3144   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3145   application.Render(0);
3146   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3147   END_TEST;
3148 }
3149
3150 int UtcDaliAnimationAnimateByActorPosition(void)
3151 {
3152   TestApplication application;
3153
3154   Actor actor = Actor::New();
3155   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3156   actor.SetPosition(startPosition);
3157   Stage::GetCurrent().Add(actor);
3158   application.SendNotification();
3159   application.Render(0);
3160   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3161
3162   // Build the animation
3163   float durationSeconds(1.0f);
3164   Animation animation = Animation::New(durationSeconds);
3165   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3166   Vector3 relativePosition(targetPosition - startPosition);
3167   animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition);
3168
3169   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3170
3171   // Start the animation
3172   animation.Play();
3173
3174   bool signalReceived(false);
3175   AnimationFinishCheck finishCheck(signalReceived);
3176   animation.FinishedSignal().Connect(&application, finishCheck);
3177
3178   application.SendNotification();
3179   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3180
3181   // We didn't expect the animation to finish yet
3182   application.SendNotification();
3183   finishCheck.CheckSignalNotReceived();
3184   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3185
3186   application.SendNotification();
3187   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3188
3189   // We did expect the animation to finish
3190   application.SendNotification();
3191   finishCheck.CheckSignalReceived();
3192   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3193
3194   // Check that nothing has changed after a couple of buffer swaps
3195   application.Render(0);
3196   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3197   application.Render(0);
3198   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3199   END_TEST;
3200 }
3201
3202 int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void)
3203 {
3204   TestApplication application;
3205
3206   Actor actor = Actor::New();
3207   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3208   actor.SetPosition(startPosition);
3209   Stage::GetCurrent().Add(actor);
3210   application.SendNotification();
3211   application.Render(0);
3212   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3213
3214   // Build the animation
3215   float durationSeconds(1.0f);
3216   Animation animation = Animation::New(durationSeconds);
3217   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3218   Vector3 relativePosition(targetPosition - startPosition);
3219   animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut);
3220
3221   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3222
3223   // Start the animation
3224   animation.Play();
3225
3226   bool signalReceived(false);
3227   AnimationFinishCheck finishCheck(signalReceived);
3228   animation.FinishedSignal().Connect(&application, finishCheck);
3229
3230   application.SendNotification();
3231   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3232
3233   // We didn't expect the animation to finish yet
3234   application.SendNotification();
3235   finishCheck.CheckSignalNotReceived();
3236
3237   // The position should have moved more, than with a linear alpha function
3238   Vector3 current(actor.GetCurrentPosition());
3239   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3240   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3241   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3242
3243   application.SendNotification();
3244   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3245
3246   // We did expect the animation to finish
3247   application.SendNotification();
3248   finishCheck.CheckSignalReceived();
3249   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3250
3251   // Check that nothing has changed after a couple of buffer swaps
3252   application.Render(0);
3253   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3254   application.Render(0);
3255   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3256   END_TEST;
3257 }
3258
3259 int UtcDaliAnimationAnimateByActorPositionTimePeriod(void)
3260 {
3261   TestApplication application;
3262
3263   Actor actor = Actor::New();
3264   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3265   actor.SetPosition(startPosition);
3266   Stage::GetCurrent().Add(actor);
3267   application.SendNotification();
3268   application.Render(0);
3269   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3270
3271   // Build the animation
3272   float durationSeconds(1.0f);
3273   Animation animation = Animation::New(durationSeconds);
3274   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3275   Vector3 relativePosition(targetPosition - startPosition);
3276   float delay = 0.5f;
3277   animation.AnimateBy(Property(actor, Actor::POSITION),
3278                       relativePosition,
3279                       TimePeriod(delay, durationSeconds - delay));
3280
3281   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3282
3283   // Start the animation
3284   animation.Play();
3285
3286   bool signalReceived(false);
3287   AnimationFinishCheck finishCheck(signalReceived);
3288   animation.FinishedSignal().Connect(&application, finishCheck);
3289
3290   application.SendNotification();
3291   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3292
3293   // We didn't expect the animation to finish yet
3294   application.SendNotification();
3295   finishCheck.CheckSignalNotReceived();
3296   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3297
3298   application.SendNotification();
3299   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3300
3301   // We did expect the animation to finish
3302   application.SendNotification();
3303   finishCheck.CheckSignalReceived();
3304   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3305
3306   // Check that nothing has changed after a couple of buffer swaps
3307   application.Render(0);
3308   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3309   application.Render(0);
3310   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3311   END_TEST;
3312 }
3313
3314 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void)
3315 {
3316   TestApplication application;
3317
3318   Actor actor = Actor::New();
3319   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3320   actor.SetPosition(startPosition);
3321   Stage::GetCurrent().Add(actor);
3322   application.SendNotification();
3323   application.Render(0);
3324   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3325
3326   // Build the animation
3327   float durationSeconds(1.0f);
3328   Animation animation = Animation::New(durationSeconds);
3329   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3330   Vector3 relativePosition(targetPosition - startPosition);
3331   float delay = 0.5f;
3332   animation.AnimateBy(Property(actor, Actor::POSITION),
3333                       relativePosition,
3334                       AlphaFunctions::Linear,
3335                       TimePeriod(delay, durationSeconds - delay));
3336
3337   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3338
3339   // Start the animation
3340   animation.Play();
3341
3342   bool signalReceived(false);
3343   AnimationFinishCheck finishCheck(signalReceived);
3344   animation.FinishedSignal().Connect(&application, finishCheck);
3345
3346   application.SendNotification();
3347   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3348
3349   // We didn't expect the animation to finish yet
3350   application.SendNotification();
3351   finishCheck.CheckSignalNotReceived();
3352   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3353
3354   application.SendNotification();
3355   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3356
3357   // We did expect the animation to finish
3358   application.SendNotification();
3359   finishCheck.CheckSignalReceived();
3360   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3361
3362   // Check that nothing has changed after a couple of buffer swaps
3363   application.Render(0);
3364   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3365   application.Render(0);
3366   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3367   END_TEST;
3368 }
3369
3370 int UtcDaliAnimationAnimateToBoolean(void)
3371 {
3372   TestApplication application;
3373
3374   Actor actor = Actor::New();
3375
3376   // Register a boolean property
3377   const bool startValue(false);
3378   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3379   Stage::GetCurrent().Add(actor);
3380   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3381
3382   // Build the animation
3383   float durationSeconds(2.0f);
3384   Animation animation = Animation::New(durationSeconds);
3385   const bool targetValue( !startValue );
3386   animation.AnimateTo(Property(actor, index), targetValue);
3387
3388   // Start the animation
3389   animation.Play();
3390
3391   bool signalReceived(false);
3392   AnimationFinishCheck finishCheck(signalReceived);
3393   animation.FinishedSignal().Connect(&application, finishCheck);
3394
3395   application.SendNotification();
3396   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3397
3398   // We didn't expect the animation to finish yet
3399   application.SendNotification();
3400   finishCheck.CheckSignalNotReceived();
3401   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3402
3403   application.SendNotification();
3404   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3405
3406   // We did expect the animation to finish
3407   application.SendNotification();
3408   finishCheck.CheckSignalReceived();
3409   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3410
3411   // Check that nothing has changed after a couple of buffer swaps
3412   application.Render(0);
3413   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3414   application.Render(0);
3415   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3416
3417   // Repeat with target value "false"
3418   animation = Animation::New(durationSeconds);
3419   const bool finalValue( !targetValue );
3420   animation.AnimateTo(Property(actor, index), finalValue);
3421
3422   // Start the animation
3423   animation.Play();
3424
3425   finishCheck.Reset();
3426   animation.FinishedSignal().Connect(&application, finishCheck);
3427
3428   application.SendNotification();
3429   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3430
3431   // We didn't expect the animation to finish yet
3432   application.SendNotification();
3433   finishCheck.CheckSignalNotReceived();
3434   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3435
3436   application.SendNotification();
3437   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3438
3439   // We did expect the animation to finish
3440   application.SendNotification();
3441   finishCheck.CheckSignalReceived();
3442   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3443
3444   // Check that nothing has changed after a couple of buffer swaps
3445   application.Render(0);
3446   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3447   application.Render(0);
3448   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3449   END_TEST;
3450 }
3451
3452 int UtcDaliAnimationAnimateToBooleanAlphaFunction(void)
3453 {
3454   TestApplication application;
3455
3456   Actor actor = Actor::New();
3457
3458   // Register a boolean property
3459   const bool startValue(false);
3460   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3461   Stage::GetCurrent().Add(actor);
3462   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3463
3464   // Build the animation
3465   float durationSeconds(2.0f);
3466   Animation animation = Animation::New(durationSeconds);
3467   const bool targetValue( !startValue );
3468   animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
3469
3470   // Start the animation
3471   animation.Play();
3472
3473   bool signalReceived(false);
3474   AnimationFinishCheck finishCheck(signalReceived);
3475   animation.FinishedSignal().Connect(&application, finishCheck);
3476
3477   application.SendNotification();
3478   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3479
3480   // We didn't expect the animation to finish yet
3481   application.SendNotification();
3482   finishCheck.CheckSignalNotReceived();
3483   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3484
3485   application.SendNotification();
3486   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3487
3488   // We did expect the animation to finish
3489   application.SendNotification();
3490   finishCheck.CheckSignalReceived();
3491   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3492
3493   // Check that nothing has changed after a couple of buffer swaps
3494   application.Render(0);
3495   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3496   application.Render(0);
3497   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3498
3499   // Repeat with target value "false"
3500   animation = Animation::New(durationSeconds);
3501   const bool finalValue( !targetValue );
3502   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut);
3503
3504   // Start the animation
3505   animation.Play();
3506
3507   finishCheck.Reset();
3508   animation.FinishedSignal().Connect(&application, finishCheck);
3509
3510   application.SendNotification();
3511   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3512
3513   // We didn't expect the animation to finish yet
3514   application.SendNotification();
3515   finishCheck.CheckSignalNotReceived();
3516   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3517
3518   application.SendNotification();
3519   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3520
3521   // We did expect the animation to finish
3522   application.SendNotification();
3523   finishCheck.CheckSignalReceived();
3524   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3525
3526   // Check that nothing has changed after a couple of buffer swaps
3527   application.Render(0);
3528   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3529   application.Render(0);
3530   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3531   END_TEST;
3532 }
3533
3534 int UtcDaliAnimationAnimateToBooleanTimePeriod(void)
3535 {
3536   TestApplication application;
3537
3538   Actor actor = Actor::New();
3539
3540   // Register a boolean property
3541   bool startValue(false);
3542   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3543   Stage::GetCurrent().Add(actor);
3544   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3545
3546   // Build the animation
3547   float durationSeconds(2.0f);
3548   Animation animation = Animation::New(durationSeconds);
3549   bool finalValue( !startValue );
3550   float animatorDurationSeconds(durationSeconds * 0.5f);
3551   animation.AnimateTo( Property(actor, index),
3552                        finalValue,
3553                        TimePeriod( animatorDurationSeconds ) );
3554
3555   // Start the animation
3556   animation.Play();
3557
3558   bool signalReceived(false);
3559   AnimationFinishCheck finishCheck(signalReceived);
3560   animation.FinishedSignal().Connect(&application, finishCheck);
3561
3562   application.SendNotification();
3563   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3564
3565   // We didn't expect the animation to finish yet
3566   application.SendNotification();
3567   finishCheck.CheckSignalNotReceived();
3568   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3569
3570   application.SendNotification();
3571   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3572
3573   // We didn't expect the animation to finish yet...
3574   application.SendNotification();
3575   finishCheck.CheckSignalNotReceived();
3576
3577   // ...however we should have reached the final value
3578   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3579
3580   application.SendNotification();
3581   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3582
3583   // We did expect the animation to finish
3584   application.SendNotification();
3585   finishCheck.CheckSignalReceived();
3586   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3587
3588   // Check that nothing has changed after a couple of buffer swaps
3589   application.Render(0);
3590   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3591   application.Render(0);
3592   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3593   END_TEST;
3594 }
3595
3596 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void)
3597 {
3598   TestApplication application;
3599
3600   Actor actor = Actor::New();
3601
3602   // Register a boolean property
3603   bool startValue(false);
3604   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3605   Stage::GetCurrent().Add(actor);
3606   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3607
3608   // Build the animation
3609   float durationSeconds(2.0f);
3610   Animation animation = Animation::New(durationSeconds);
3611   bool finalValue( !startValue );
3612   float animatorDurationSeconds(durationSeconds * 0.5f);
3613   animation.AnimateTo( Property(actor, index),
3614                        finalValue,
3615                        AlphaFunctions::Linear,
3616                        TimePeriod( animatorDurationSeconds ) );
3617
3618   // Start the animation
3619   animation.Play();
3620
3621   bool signalReceived(false);
3622   AnimationFinishCheck finishCheck(signalReceived);
3623   animation.FinishedSignal().Connect(&application, finishCheck);
3624
3625   application.SendNotification();
3626   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3627
3628   // We didn't expect the animation to finish yet
3629   application.SendNotification();
3630   finishCheck.CheckSignalNotReceived();
3631   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3632
3633   application.SendNotification();
3634   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3635
3636   // We didn't expect the animation to finish yet...
3637   application.SendNotification();
3638   finishCheck.CheckSignalNotReceived();
3639
3640   // ...however we should have reached the final value
3641   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3642
3643   application.SendNotification();
3644   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3645
3646   // We did expect the animation to finish
3647   application.SendNotification();
3648   finishCheck.CheckSignalReceived();
3649   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3650
3651   // Check that nothing has changed after a couple of buffer swaps
3652   application.Render(0);
3653   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3654   application.Render(0);
3655   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3656   END_TEST;
3657 }
3658
3659 int UtcDaliAnimationAnimateToFloat(void)
3660 {
3661   TestApplication application;
3662
3663   Actor actor = Actor::New();
3664
3665   // Register a float property
3666   float startValue(10.0f);
3667   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3668   Stage::GetCurrent().Add(actor);
3669   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3670
3671   // Build the animation
3672   float durationSeconds(2.0f);
3673   Animation animation = Animation::New(durationSeconds);
3674   float targetValue(50.0f);
3675   float relativeValue(targetValue - startValue);
3676   animation.AnimateTo(Property(actor, "test-property"), targetValue);
3677
3678   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3679
3680   // Start the animation
3681   animation.Play();
3682
3683   bool signalReceived(false);
3684   AnimationFinishCheck finishCheck(signalReceived);
3685   animation.FinishedSignal().Connect(&application, finishCheck);
3686
3687   application.SendNotification();
3688   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3689
3690   // We didn't expect the animation to finish yet
3691   application.SendNotification();
3692   finishCheck.CheckSignalNotReceived();
3693   DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3694
3695   application.SendNotification();
3696   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3697
3698   // We did expect the animation to finish
3699   application.SendNotification();
3700   finishCheck.CheckSignalReceived();
3701   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3702   END_TEST;
3703 }
3704
3705 int UtcDaliAnimationAnimateToFloatAlphaFunction(void)
3706 {
3707   TestApplication application;
3708
3709   Actor actor = Actor::New();
3710
3711   // Register a float property
3712   float startValue(10.0f);
3713   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3714   Stage::GetCurrent().Add(actor);
3715   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3716
3717   // Build the animation
3718   float durationSeconds(1.0f);
3719   Animation animation = Animation::New(durationSeconds);
3720   float targetValue(90.0f);
3721   float relativeValue(targetValue - startValue);
3722   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3723
3724   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3725
3726   // Start the animation
3727   animation.Play();
3728
3729   bool signalReceived(false);
3730   AnimationFinishCheck finishCheck(signalReceived);
3731   animation.FinishedSignal().Connect(&application, finishCheck);
3732
3733   application.SendNotification();
3734   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3735
3736   // We didn't expect the animation to finish yet
3737   application.SendNotification();
3738   finishCheck.CheckSignalNotReceived();
3739
3740   // The position should have moved more, than with a linear alpha function
3741   float current(actor.GetProperty<float>(index));
3742   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3743
3744   application.SendNotification();
3745   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3746
3747   // We did expect the animation to finish
3748   application.SendNotification();
3749   finishCheck.CheckSignalReceived();
3750   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3751   END_TEST;
3752 }
3753
3754 int UtcDaliAnimationAnimateToFloatTimePeriod(void)
3755 {
3756   TestApplication application;
3757
3758   Actor actor = Actor::New();
3759
3760   // Register a float property
3761   float startValue(10.0f);
3762   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3763   Stage::GetCurrent().Add(actor);
3764   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3765
3766   // Build the animation
3767   float durationSeconds(1.0f);
3768   Animation animation = Animation::New(durationSeconds);
3769   float targetValue(30.0f);
3770   float relativeValue(targetValue - startValue);
3771   float delay = 0.5f;
3772   animation.AnimateTo(Property(actor, index),
3773                       targetValue,
3774                       TimePeriod(delay, durationSeconds - delay));
3775
3776   // Start the animation
3777   animation.Play();
3778
3779   bool signalReceived(false);
3780   AnimationFinishCheck finishCheck(signalReceived);
3781   animation.FinishedSignal().Connect(&application, finishCheck);
3782
3783   application.SendNotification();
3784   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3785
3786   // We didn't expect the animation to finish yet
3787   application.SendNotification();
3788   finishCheck.CheckSignalNotReceived();
3789   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3790
3791   application.SendNotification();
3792   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3793
3794   // We didn't expect the animation to finish yet
3795   application.SendNotification();
3796   finishCheck.CheckSignalNotReceived();
3797   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3798
3799   application.SendNotification();
3800   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3801
3802   // We did expect the animation to finish
3803   application.SendNotification();
3804   finishCheck.CheckSignalReceived();
3805   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3806   END_TEST;
3807 }
3808
3809 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void)
3810 {
3811   TestApplication application;
3812
3813   Actor actor = Actor::New();
3814
3815   // Register a float property
3816   float startValue(10.0f);
3817   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3818   Stage::GetCurrent().Add(actor);
3819   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3820
3821   // Build the animation
3822   float durationSeconds(1.0f);
3823   Animation animation = Animation::New(durationSeconds);
3824   float targetValue(30.0f);
3825   float relativeValue(targetValue - startValue);
3826   float delay = 0.5f;
3827   animation.AnimateTo(Property(actor, index),
3828                       targetValue,
3829                       AlphaFunctions::Linear,
3830                       TimePeriod(delay, durationSeconds - delay));
3831
3832   // Start the animation
3833   animation.Play();
3834
3835   bool signalReceived(false);
3836   AnimationFinishCheck finishCheck(signalReceived);
3837   animation.FinishedSignal().Connect(&application, finishCheck);
3838
3839   application.SendNotification();
3840   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3841
3842   // We didn't expect the animation to finish yet
3843   application.SendNotification();
3844   finishCheck.CheckSignalNotReceived();
3845   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3846
3847   application.SendNotification();
3848   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3849
3850   // We didn't expect the animation to finish yet
3851   application.SendNotification();
3852   finishCheck.CheckSignalNotReceived();
3853   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3854
3855   application.SendNotification();
3856   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3857
3858   // We did expect the animation to finish
3859   application.SendNotification();
3860   finishCheck.CheckSignalReceived();
3861   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3862   END_TEST;
3863 }
3864
3865 int UtcDaliAnimationAnimateToInteger(void)
3866 {
3867   TestApplication application;
3868
3869   Actor actor = Actor::New();
3870
3871   // Register an integer property
3872   int startValue(10);
3873   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3874   Stage::GetCurrent().Add(actor);
3875   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3876
3877   // Build the animation
3878   float durationSeconds(2.0f);
3879   Animation animation = Animation::New(durationSeconds);
3880   int targetValue(50);
3881   int relativeValue(targetValue - startValue);
3882   animation.AnimateTo(Property(actor, "test-property"), targetValue);
3883
3884   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3885
3886   // Start the animation
3887   animation.Play();
3888
3889   bool signalReceived(false);
3890   AnimationFinishCheck finishCheck(signalReceived);
3891   animation.FinishedSignal().Connect(&application, finishCheck);
3892
3893   application.SendNotification();
3894   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3895
3896   // We didn't expect the animation to finish yet
3897   application.SendNotification();
3898   finishCheck.CheckSignalNotReceived();
3899   DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3900
3901   application.SendNotification();
3902   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3903
3904   // We did expect the animation to finish
3905   application.SendNotification();
3906   finishCheck.CheckSignalReceived();
3907   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3908   END_TEST;
3909 }
3910
3911 int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
3912 {
3913   TestApplication application;
3914
3915   Actor actor = Actor::New();
3916
3917   // Register an integer property
3918   int startValue(10);
3919   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3920   Stage::GetCurrent().Add(actor);
3921   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3922
3923   // Build the animation
3924   float durationSeconds(1.0f);
3925   Animation animation = Animation::New(durationSeconds);
3926   int targetValue(90);
3927   int relativeValue(targetValue - startValue);
3928   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
3929
3930   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3931
3932   // Start the animation
3933   animation.Play();
3934
3935   bool signalReceived(false);
3936   AnimationFinishCheck finishCheck(signalReceived);
3937   animation.FinishedSignal().Connect(&application, finishCheck);
3938
3939   application.SendNotification();
3940   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3941
3942   // We didn't expect the animation to finish yet
3943   application.SendNotification();
3944   finishCheck.CheckSignalNotReceived();
3945
3946   // The position should have moved more, than with a linear alpha function
3947   int current(actor.GetProperty<int>(index));
3948   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3949
3950   application.SendNotification();
3951   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3952
3953   // We did expect the animation to finish
3954   application.SendNotification();
3955   finishCheck.CheckSignalReceived();
3956   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3957   END_TEST;
3958 }
3959
3960 int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
3961 {
3962   TestApplication application;
3963
3964   Actor actor = Actor::New();
3965
3966   // Register an integer property
3967   int startValue(10);
3968   Property::Index index = actor.RegisterProperty( "test-property", startValue );
3969   Stage::GetCurrent().Add(actor);
3970   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3971
3972   // Build the animation
3973   float durationSeconds(1.0f);
3974   Animation animation = Animation::New(durationSeconds);
3975   int targetValue(30);
3976   int relativeValue(targetValue - startValue);
3977   float delay = 0.5f;
3978   animation.AnimateTo(Property(actor, index),
3979                       targetValue,
3980                       TimePeriod(delay, durationSeconds - delay));
3981
3982   // Start the animation
3983   animation.Play();
3984
3985   bool signalReceived(false);
3986   AnimationFinishCheck finishCheck(signalReceived);
3987   animation.FinishedSignal().Connect(&application, finishCheck);
3988
3989   application.SendNotification();
3990   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3991
3992   // We didn't expect the animation to finish yet
3993   application.SendNotification();
3994   finishCheck.CheckSignalNotReceived();
3995   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3996
3997   application.SendNotification();
3998   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3999
4000   // We didn't expect the animation to finish yet
4001   application.SendNotification();
4002   finishCheck.CheckSignalNotReceived();
4003   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4004
4005   application.SendNotification();
4006   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4007
4008   // We did expect the animation to finish
4009   application.SendNotification();
4010   finishCheck.CheckSignalReceived();
4011   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4012   END_TEST;
4013 }
4014
4015 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
4016 {
4017   TestApplication application;
4018
4019   Actor actor = Actor::New();
4020
4021   // Register an integer property
4022   int startValue(10);
4023   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4024   Stage::GetCurrent().Add(actor);
4025   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4026
4027   // Build the animation
4028   float durationSeconds(1.0f);
4029   Animation animation = Animation::New(durationSeconds);
4030   int targetValue(30);
4031   int relativeValue(targetValue - startValue);
4032   float delay = 0.5f;
4033   animation.AnimateTo(Property(actor, index),
4034                       targetValue,
4035                       AlphaFunctions::Linear,
4036                       TimePeriod(delay, durationSeconds - delay));
4037
4038   // Start the animation
4039   animation.Play();
4040
4041   bool signalReceived(false);
4042   AnimationFinishCheck finishCheck(signalReceived);
4043   animation.FinishedSignal().Connect(&application, finishCheck);
4044
4045   application.SendNotification();
4046   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4047
4048   // We didn't expect the animation to finish yet
4049   application.SendNotification();
4050   finishCheck.CheckSignalNotReceived();
4051   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4052
4053   application.SendNotification();
4054   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4055
4056   // We didn't expect the animation to finish yet
4057   application.SendNotification();
4058   finishCheck.CheckSignalNotReceived();
4059   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4060
4061   application.SendNotification();
4062   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4063
4064   // We did expect the animation to finish
4065   application.SendNotification();
4066   finishCheck.CheckSignalReceived();
4067   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4068   END_TEST;
4069 }
4070
4071 int UtcDaliAnimationAnimateToVector2(void)
4072 {
4073   TestApplication application;
4074
4075   Actor actor = Actor::New();
4076
4077   // Register a Vector2 property
4078   Vector2 startValue(-50.0f, -50.0f);
4079   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4080   Stage::GetCurrent().Add(actor);
4081   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4082
4083   // Build the animation
4084   float durationSeconds(2.0f);
4085   Animation animation = Animation::New(durationSeconds);
4086   Vector2 targetValue(50.0f, 50.0f);
4087   Vector2 relativeValue(targetValue - startValue);
4088   animation.AnimateTo(Property(actor, index), targetValue);
4089
4090   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4091
4092   // Start the animation
4093   animation.Play();
4094
4095   bool signalReceived(false);
4096   AnimationFinishCheck finishCheck(signalReceived);
4097   animation.FinishedSignal().Connect(&application, finishCheck);
4098
4099   application.SendNotification();
4100   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4101
4102   // We didn't expect the animation to finish yet
4103   application.SendNotification();
4104   finishCheck.CheckSignalNotReceived();
4105   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
4106
4107   application.SendNotification();
4108   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4109
4110   // We did expect the animation to finish
4111   application.SendNotification();
4112   finishCheck.CheckSignalReceived();
4113   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4114   END_TEST;
4115 }
4116
4117 int UtcDaliAnimationAnimateToVector2AlphaFunction(void)
4118 {
4119   TestApplication application;
4120
4121   Actor actor = Actor::New();
4122
4123   // Register a Vector2 property
4124   Vector2 startValue(1000.0f, 1000.0f);
4125   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4126   Stage::GetCurrent().Add(actor);
4127   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4128
4129   // Build the animation
4130   float durationSeconds(1.0f);
4131   Animation animation = Animation::New(durationSeconds);
4132   Vector2 targetValue(9000.0f, 9000.0f);
4133   Vector2 relativeValue(targetValue - startValue);
4134   animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut);
4135
4136   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4137
4138   // Start the animation
4139   animation.Play();
4140
4141   bool signalReceived(false);
4142   AnimationFinishCheck finishCheck(signalReceived);
4143   animation.FinishedSignal().Connect(&application, finishCheck);
4144
4145   application.SendNotification();
4146   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4147
4148   // We didn't expect the animation to finish yet
4149   application.SendNotification();
4150   finishCheck.CheckSignalNotReceived();
4151
4152   // The position should have moved more, than with a linear alpha function
4153   Vector2 current(actor.GetProperty<Vector2>(index));
4154   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4155   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4156
4157   application.SendNotification();
4158   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4159
4160   // We did expect the animation to finish
4161   application.SendNotification();
4162   finishCheck.CheckSignalReceived();
4163   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4164   END_TEST;
4165 }
4166
4167 int UtcDaliAnimationAnimateToVector2TimePeriod(void)
4168 {
4169   TestApplication application;
4170
4171   Actor actor = Actor::New();
4172
4173   // Register a Vector2 property
4174   Vector2 startValue(10.0f, 10.0f);
4175   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4176   Stage::GetCurrent().Add(actor);
4177   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4178
4179   // Build the animation
4180   float durationSeconds(1.0f);
4181   Animation animation = Animation::New(durationSeconds);
4182   Vector2 targetValue(-10.0f, 20.0f);
4183   Vector2 relativeValue(targetValue - startValue);
4184   float delay = 0.5f;
4185   animation.AnimateTo(Property(actor, index),
4186                       targetValue,
4187                       TimePeriod(delay, durationSeconds - delay));
4188
4189   // Start the animation
4190   animation.Play();
4191
4192   bool signalReceived(false);
4193   AnimationFinishCheck finishCheck(signalReceived);
4194   animation.FinishedSignal().Connect(&application, finishCheck);
4195
4196   application.SendNotification();
4197   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4198
4199   // We didn't expect the animation to finish yet
4200   application.SendNotification();
4201   finishCheck.CheckSignalNotReceived();
4202   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4203
4204   application.SendNotification();
4205   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4206
4207   // We didn't expect the animation to finish yet
4208   application.SendNotification();
4209   finishCheck.CheckSignalNotReceived();
4210   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4211
4212   application.SendNotification();
4213   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4214
4215   // We did expect the animation to finish
4216   application.SendNotification();
4217   finishCheck.CheckSignalReceived();
4218   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4219   END_TEST;
4220 }
4221
4222 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void)
4223 {
4224   TestApplication application;
4225
4226   Actor actor = Actor::New();
4227
4228   // Register a Vector2 property
4229   Vector2 startValue(10.0f, 10.0f);
4230   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4231   Stage::GetCurrent().Add(actor);
4232   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4233
4234   // Build the animation
4235   float durationSeconds(1.0f);
4236   Animation animation = Animation::New(durationSeconds);
4237   Vector2 targetValue(30.0f, 30.0f);
4238   Vector2 relativeValue(targetValue - startValue);
4239   float delay = 0.5f;
4240   animation.AnimateTo(Property(actor, index),
4241                       targetValue,
4242                       AlphaFunctions::Linear,
4243                       TimePeriod(delay, durationSeconds - delay));
4244
4245   // Start the animation
4246   animation.Play();
4247
4248   bool signalReceived(false);
4249   AnimationFinishCheck finishCheck(signalReceived);
4250   animation.FinishedSignal().Connect(&application, finishCheck);
4251
4252   application.SendNotification();
4253   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4254
4255   // We didn't expect the animation to finish yet
4256   application.SendNotification();
4257   finishCheck.CheckSignalNotReceived();
4258   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4259
4260   application.SendNotification();
4261   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4262
4263   // We didn't expect the animation to finish yet
4264   application.SendNotification();
4265   finishCheck.CheckSignalNotReceived();
4266   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4267
4268   application.SendNotification();
4269   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4270
4271   // We did expect the animation to finish
4272   application.SendNotification();
4273   finishCheck.CheckSignalReceived();
4274   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4275   END_TEST;
4276 }
4277
4278 int UtcDaliAnimationAnimateToVector3(void)
4279 {
4280   TestApplication application;
4281
4282   Actor actor = Actor::New();
4283
4284   // Register a Vector3 property
4285   Vector3 startValue(-50.0f, -50.0f, -50.0f);
4286   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4287   Stage::GetCurrent().Add(actor);
4288   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4289
4290   // Build the animation
4291   float durationSeconds(2.0f);
4292   Animation animation = Animation::New(durationSeconds);
4293   Vector3 targetValue(50.0f, 50.0f, 50.0f);
4294   Vector3 relativeValue(targetValue - startValue);
4295   animation.AnimateTo(Property(actor, index), targetValue);
4296
4297   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4298
4299   // Start the animation
4300   animation.Play();
4301
4302   bool signalReceived(false);
4303   AnimationFinishCheck finishCheck(signalReceived);
4304   animation.FinishedSignal().Connect(&application, finishCheck);
4305
4306   application.SendNotification();
4307   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4308
4309   // We didn't expect the animation to finish yet
4310   application.SendNotification();
4311   finishCheck.CheckSignalNotReceived();
4312   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4313
4314   application.SendNotification();
4315   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4316
4317   // We did expect the animation to finish
4318   application.SendNotification();
4319   finishCheck.CheckSignalReceived();
4320   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4321   END_TEST;
4322 }
4323
4324 int UtcDaliAnimationAnimateToVector3AlphaFunction(void)
4325 {
4326   TestApplication application;
4327
4328   Actor actor = Actor::New();
4329
4330   // Register a Vector3 property
4331   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4332   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4333   Stage::GetCurrent().Add(actor);
4334   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4335
4336   // Build the animation
4337   float durationSeconds(1.0f);
4338   Animation animation = Animation::New(durationSeconds);
4339   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4340   Vector3 relativeValue(targetValue - startValue);
4341   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4342
4343   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4344
4345   // Start the animation
4346   animation.Play();
4347
4348   bool signalReceived(false);
4349   AnimationFinishCheck finishCheck(signalReceived);
4350   animation.FinishedSignal().Connect(&application, finishCheck);
4351
4352   application.SendNotification();
4353   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4354
4355   // We didn't expect the animation to finish yet
4356   application.SendNotification();
4357   finishCheck.CheckSignalNotReceived();
4358
4359   // The position should have moved more, than with a linear alpha function
4360   Vector3 current(actor.GetProperty<Vector3>(index));
4361   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4362   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4363   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4364
4365   application.SendNotification();
4366   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4367
4368   // We did expect the animation to finish
4369   application.SendNotification();
4370   finishCheck.CheckSignalReceived();
4371   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4372   END_TEST;
4373 }
4374
4375 int UtcDaliAnimationAnimateToVector3TimePeriod(void)
4376 {
4377   TestApplication application;
4378
4379   Actor actor = Actor::New();
4380
4381   // Register a Vector3 property
4382   Vector3 startValue(10.0f, 10.0f, 10.0f);
4383   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4384   Stage::GetCurrent().Add(actor);
4385   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4386
4387   // Build the animation
4388   float durationSeconds(1.0f);
4389   Animation animation = Animation::New(durationSeconds);
4390   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4391   Vector3 relativeValue(targetValue - startValue);
4392   float delay = 0.5f;
4393   animation.AnimateTo(Property(actor, index),
4394                       targetValue,
4395                       TimePeriod(delay, durationSeconds - delay));
4396
4397   // Start the animation
4398   animation.Play();
4399
4400   bool signalReceived(false);
4401   AnimationFinishCheck finishCheck(signalReceived);
4402   animation.FinishedSignal().Connect(&application, finishCheck);
4403
4404   application.SendNotification();
4405   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4406
4407   // We didn't expect the animation to finish yet
4408   application.SendNotification();
4409   finishCheck.CheckSignalNotReceived();
4410   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4411
4412   application.SendNotification();
4413   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4414
4415   // We didn't expect the animation to finish yet
4416   application.SendNotification();
4417   finishCheck.CheckSignalNotReceived();
4418   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4419
4420   application.SendNotification();
4421   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4422
4423   // We did expect the animation to finish
4424   application.SendNotification();
4425   finishCheck.CheckSignalReceived();
4426   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4427   END_TEST;
4428 }
4429
4430 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void)
4431 {
4432   TestApplication application;
4433
4434   Actor actor = Actor::New();
4435
4436   // Register a Vector3 property
4437   Vector3 startValue(10.0f, 10.0f, 10.0f);
4438   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4439   Stage::GetCurrent().Add(actor);
4440   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4441
4442   // Build the animation
4443   float durationSeconds(1.0f);
4444   Animation animation = Animation::New(durationSeconds);
4445   Vector3 targetValue(30.0f, 30.0f, 30.0f);
4446   Vector3 relativeValue(targetValue - startValue);
4447   float delay = 0.5f;
4448   animation.AnimateTo(Property(actor, "test-property"),
4449                       targetValue,
4450                       AlphaFunctions::Linear,
4451                       TimePeriod(delay, durationSeconds - delay));
4452
4453   // Start the animation
4454   animation.Play();
4455
4456   bool signalReceived(false);
4457   AnimationFinishCheck finishCheck(signalReceived);
4458   animation.FinishedSignal().Connect(&application, finishCheck);
4459
4460   application.SendNotification();
4461   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4462
4463   // We didn't expect the animation to finish yet
4464   application.SendNotification();
4465   finishCheck.CheckSignalNotReceived();
4466   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4467
4468   application.SendNotification();
4469   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4470
4471   // We didn't expect the animation to finish yet
4472   application.SendNotification();
4473   finishCheck.CheckSignalNotReceived();
4474   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4475
4476   application.SendNotification();
4477   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4478
4479   // We did expect the animation to finish
4480   application.SendNotification();
4481   finishCheck.CheckSignalReceived();
4482   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4483   END_TEST;
4484 }
4485
4486 int UtcDaliAnimationAnimateToVector3Component(void)
4487 {
4488   TestApplication application;
4489
4490   Actor actor = Actor::New();
4491
4492   // Register a Vector3 property
4493   Vector3 startValue(10.0f, 10.0f, 10.0f);
4494   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4495   Stage::GetCurrent().Add(actor);
4496   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4497
4498   // Build the animation
4499   float durationSeconds(1.0f);
4500   Animation animation = Animation::New(durationSeconds);
4501   Vector3 targetValue(30.0f, 30.0f, 10.0f);
4502   Vector3 relativeValue(targetValue - startValue);
4503   float delay = 0.5f;
4504   animation.AnimateTo(Property(actor, "test-property", 0),
4505                       30.0f,
4506                       AlphaFunctions::Linear,
4507                       TimePeriod(delay, durationSeconds - delay));
4508   animation.AnimateTo(Property(actor, index, 1),
4509                       30.0f,
4510                       AlphaFunctions::Linear,
4511                       TimePeriod(delay, durationSeconds - delay));
4512
4513   // Start the animation
4514   animation.Play();
4515
4516   bool signalReceived(false);
4517   AnimationFinishCheck finishCheck(signalReceived);
4518   animation.FinishedSignal().Connect(&application, finishCheck);
4519
4520   application.SendNotification();
4521   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4522
4523   // We didn't expect the animation to finish yet
4524   application.SendNotification();
4525   finishCheck.CheckSignalNotReceived();
4526   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4527
4528   application.SendNotification();
4529   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4530
4531   // We didn't expect the animation to finish yet
4532   application.SendNotification();
4533   finishCheck.CheckSignalNotReceived();
4534   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4535
4536   application.SendNotification();
4537   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4538
4539   // We did expect the animation to finish
4540   application.SendNotification();
4541   finishCheck.CheckSignalReceived();
4542   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4543   END_TEST;
4544 }
4545
4546 int UtcDaliAnimationAnimateToVector4(void)
4547 {
4548   TestApplication application;
4549
4550   Actor actor = Actor::New();
4551
4552   // Register a Vector4 property
4553   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4554   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4555   Stage::GetCurrent().Add(actor);
4556   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4557
4558   // Build the animation
4559   float durationSeconds(2.0f);
4560   Animation animation = Animation::New(durationSeconds);
4561   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4562   Vector4 relativeValue(targetValue - startValue);
4563   animation.AnimateTo(Property(actor, index), targetValue);
4564
4565   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4566
4567   // Start the animation
4568   animation.Play();
4569
4570   bool signalReceived(false);
4571   AnimationFinishCheck finishCheck(signalReceived);
4572   animation.FinishedSignal().Connect(&application, finishCheck);
4573
4574   application.SendNotification();
4575   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4576
4577   // We didn't expect the animation to finish yet
4578   application.SendNotification();
4579   finishCheck.CheckSignalNotReceived();
4580   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4581
4582   application.SendNotification();
4583   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4584
4585   // We did expect the animation to finish
4586   application.SendNotification();
4587   finishCheck.CheckSignalReceived();
4588   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4589   END_TEST;
4590 }
4591
4592 int UtcDaliAnimationAnimateToVector4AlphaFunction(void)
4593 {
4594   TestApplication application;
4595
4596   Actor actor = Actor::New();
4597
4598   // Register a Vector4 property
4599   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4600   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4601   Stage::GetCurrent().Add(actor);
4602   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4603
4604   // Build the animation
4605   float durationSeconds(1.0f);
4606   Animation animation = Animation::New(durationSeconds);
4607   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4608   Vector4 relativeValue(targetValue - startValue);
4609   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
4610
4611   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4612
4613   // Start the animation
4614   animation.Play();
4615
4616   bool signalReceived(false);
4617   AnimationFinishCheck finishCheck(signalReceived);
4618   animation.FinishedSignal().Connect(&application, finishCheck);
4619
4620   application.SendNotification();
4621   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4622
4623   // We didn't expect the animation to finish yet
4624   application.SendNotification();
4625   finishCheck.CheckSignalNotReceived();
4626
4627   // The position should have moved more, than with a linear alpha function
4628   Vector4 current(actor.GetProperty<Vector4>(index));
4629   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4630   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4631   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4632   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
4633
4634   application.SendNotification();
4635   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4636
4637   // We did expect the animation to finish
4638   application.SendNotification();
4639   finishCheck.CheckSignalReceived();
4640   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4641   END_TEST;
4642 }
4643
4644 int UtcDaliAnimationAnimateToVector4TimePeriod(void)
4645 {
4646   TestApplication application;
4647
4648   Actor actor = Actor::New();
4649
4650   // Register a Vector4 property
4651   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4652   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4653   Stage::GetCurrent().Add(actor);
4654   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4655
4656   // Build the animation
4657   float durationSeconds(1.0f);
4658   Animation animation = Animation::New(durationSeconds);
4659   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
4660   Vector4 relativeValue(targetValue - startValue);
4661   float delay = 0.5f;
4662   animation.AnimateTo(Property(actor, index),
4663                       targetValue,
4664                       TimePeriod(delay, durationSeconds - delay));
4665
4666   // Start the animation
4667   animation.Play();
4668
4669   bool signalReceived(false);
4670   AnimationFinishCheck finishCheck(signalReceived);
4671   animation.FinishedSignal().Connect(&application, finishCheck);
4672
4673   application.SendNotification();
4674   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4675
4676   // We didn't expect the animation to finish yet
4677   application.SendNotification();
4678   finishCheck.CheckSignalNotReceived();
4679   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
4680
4681   application.SendNotification();
4682   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4683
4684   // We didn't expect the animation to finish yet
4685   application.SendNotification();
4686   finishCheck.CheckSignalNotReceived();
4687   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
4688
4689   application.SendNotification();
4690   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4691
4692   // We did expect the animation to finish
4693   application.SendNotification();
4694   finishCheck.CheckSignalReceived();
4695   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
4696   END_TEST;
4697 }
4698
4699 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void)
4700 {
4701   TestApplication application;
4702
4703   Actor actor = Actor::New();
4704
4705   // Register a Vector4 property
4706   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4707   Property::Index index = actor.RegisterProperty( "test-property", startValue );
4708   Stage::GetCurrent().Add(actor);
4709   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4710
4711   // Build the animation
4712   float durationSeconds(1.0f);
4713   Animation animation = Animation::New(durationSeconds);
4714   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4715   Vector4 relativeValue(targetValue - startValue);
4716   float delay = 0.5f;
4717   animation.AnimateTo(Property(actor, index),
4718                       targetValue,
4719                       AlphaFunctions::Linear,
4720                       TimePeriod(delay, durationSeconds - delay));
4721
4722   // Start the animation
4723   animation.Play();
4724
4725   bool signalReceived(false);
4726   AnimationFinishCheck finishCheck(signalReceived);
4727   animation.FinishedSignal().Connect(&application, finishCheck);
4728
4729   application.SendNotification();
4730   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4731
4732   // We didn't expect the animation to finish yet
4733   application.SendNotification();
4734   finishCheck.CheckSignalNotReceived();
4735   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4736
4737   application.SendNotification();
4738   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4739
4740   // We didn't expect the animation to finish yet
4741   application.SendNotification();
4742   finishCheck.CheckSignalNotReceived();
4743   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4744
4745   application.SendNotification();
4746   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4747
4748   // We did expect the animation to finish
4749   application.SendNotification();
4750   finishCheck.CheckSignalReceived();
4751   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4752   END_TEST;
4753 }
4754
4755 int UtcDaliAnimationAnimateToActorParentOrigin(void)
4756 {
4757   TestApplication application;
4758
4759   Actor actor = Actor::New();
4760   Stage::GetCurrent().Add(actor);
4761   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
4762
4763   // Build the animation
4764   float durationSeconds(1.0f);
4765   Animation animation = Animation::New(durationSeconds);
4766   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
4767
4768   try
4769   {
4770     animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin );
4771   }
4772   catch (Dali::DaliException& e)
4773   {
4774     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4775     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4776   }
4777   END_TEST;
4778 }
4779
4780 int UtcDaliAnimationAnimateToActorParentOriginX(void)
4781 {
4782   TestApplication application;
4783
4784   Actor actor = Actor::New();
4785   Stage::GetCurrent().Add(actor);
4786   float startValue(0.0f);
4787   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
4788   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
4789
4790   // Build the animation
4791   float durationSeconds(1.0f);
4792   Animation animation = Animation::New(durationSeconds);
4793   float targetX(1.0f);
4794
4795   try
4796   {
4797     animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX );
4798   }
4799   catch (Dali::DaliException& e)
4800   {
4801     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4802     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4803   }
4804   END_TEST;
4805 }
4806
4807 int UtcDaliAnimationAnimateToActorParentOriginY(void)
4808 {
4809   TestApplication application;
4810
4811   Actor actor = Actor::New();
4812   Stage::GetCurrent().Add(actor);
4813   float startValue(0.0f);
4814   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
4815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
4816
4817   // Build the animation
4818   float durationSeconds(1.0f);
4819   Animation animation = Animation::New(durationSeconds);
4820   float targetY(1.0f);
4821
4822   try
4823   {
4824     animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY );
4825   }
4826   catch (Dali::DaliException& e)
4827   {
4828     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4829     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4830   }
4831   END_TEST;
4832 }
4833
4834 int UtcDaliAnimationAnimateToActorParentOriginZ(void)
4835 {
4836   TestApplication application;
4837
4838   Actor actor = Actor::New();
4839   Stage::GetCurrent().Add(actor);
4840   float startValue(0.5f);
4841   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
4842   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
4843
4844   // Build the animation
4845   float durationSeconds(1.0f);
4846   Animation animation = Animation::New(durationSeconds);
4847   float targetZ(1.0f);
4848
4849   try
4850   {
4851     animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ );
4852   }
4853   catch (Dali::DaliException& e)
4854   {
4855     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4856     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4857   }
4858   END_TEST;
4859 }
4860
4861 int UtcDaliAnimationAnimateToActorAnchorPoint(void)
4862 {
4863   TestApplication application;
4864
4865   Actor actor = Actor::New();
4866   Stage::GetCurrent().Add(actor);
4867   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
4868
4869   // Build the animation
4870   float durationSeconds(1.0f);
4871   Animation animation = Animation::New(durationSeconds);
4872   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
4873
4874   try
4875   {
4876     animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint);
4877   }
4878   catch (Dali::DaliException& e)
4879   {
4880     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4881     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4882   }
4883   END_TEST;
4884 }
4885
4886 int UtcDaliAnimationAnimateToActorAnchorPointX(void)
4887 {
4888   TestApplication application;
4889
4890   Actor actor = Actor::New();
4891   Stage::GetCurrent().Add(actor);
4892   float startValue(0.5f);
4893   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
4894   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION );
4895
4896   // Build the animation
4897   float durationSeconds(1.0f);
4898   Animation animation = Animation::New(durationSeconds);
4899   float targetX(1.0f);
4900
4901   try
4902   {
4903     animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX );
4904   }
4905   catch (Dali::DaliException& e)
4906   {
4907     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4908     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4909   }
4910   END_TEST;
4911 }
4912
4913 int UtcDaliAnimationAnimateToActorAnchorPointY(void)
4914 {
4915   TestApplication application;
4916
4917   Actor actor = Actor::New();
4918   Stage::GetCurrent().Add(actor);
4919   float startValue(0.5f);
4920   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
4921   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
4922
4923   // Build the animation
4924   float durationSeconds(1.0f);
4925   Animation animation = Animation::New(durationSeconds);
4926   float targetY(0.0f);
4927
4928   try
4929   {
4930     animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY );
4931   }
4932   catch (Dali::DaliException& e)
4933   {
4934     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4935     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4936   }
4937   END_TEST;
4938 }
4939
4940 int UtcDaliAnimationAnimateToActorAnchorPointZ(void)
4941 {
4942   TestApplication application;
4943
4944   Actor actor = Actor::New();
4945   Stage::GetCurrent().Add(actor);
4946   float startValue(0.5f);
4947   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
4948   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
4949
4950   // Build the animation
4951   float durationSeconds(1.0f);
4952   Animation animation = Animation::New(durationSeconds);
4953   float targetZ(100.0f);
4954
4955   try
4956   {
4957     animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ );
4958   }
4959   catch (Dali::DaliException& e)
4960   {
4961     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
4962     DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION);
4963   }
4964   END_TEST;
4965 }
4966
4967 int UtcDaliAnimationAnimateToActorSize(void)
4968 {
4969   TestApplication application;
4970
4971   Actor actor = Actor::New();
4972   Stage::GetCurrent().Add(actor);
4973   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
4974
4975   // Build the animation
4976   float durationSeconds(1.0f);
4977   Animation animation = Animation::New(durationSeconds);
4978   Vector3 targetSize(100.0f, 100.0f, 100.0f);
4979   animation.AnimateTo( Property(actor, Actor::SIZE), targetSize );
4980
4981   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
4982
4983   // Start the animation
4984   animation.Play();
4985
4986   bool signalReceived(false);
4987   AnimationFinishCheck finishCheck(signalReceived);
4988   animation.FinishedSignal().Connect(&application, finishCheck);
4989
4990   application.SendNotification();
4991   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4992
4993   // We didn't expect the animation to finish yet
4994   application.SendNotification();
4995   finishCheck.CheckSignalNotReceived();
4996   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
4997
4998   application.SendNotification();
4999   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5000
5001   // We did expect the animation to finish
5002   application.SendNotification();
5003   finishCheck.CheckSignalReceived();
5004   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5005
5006   // Reset everything
5007   finishCheck.Reset();
5008   actor.SetSize(Vector3::ZERO);
5009   application.SendNotification();
5010   application.Render(0);
5011   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5012
5013   // Repeat with a different (ease-in) alpha function
5014   animation = Animation::New(durationSeconds);
5015   animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn);
5016   animation.FinishedSignal().Connect(&application, finishCheck);
5017   animation.Play();
5018
5019   application.SendNotification();
5020   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5021
5022   // We didn't expect the animation to finish yet
5023   application.SendNotification();
5024   finishCheck.CheckSignalNotReceived();
5025
5026   // The size should have travelled less, than with a linear alpha function
5027   Vector3 current(actor.GetCurrentSize());
5028   DALI_TEST_CHECK( current.x > 0.0f );
5029   DALI_TEST_CHECK( current.y > 0.0f );
5030   DALI_TEST_CHECK( current.z > 0.0f );
5031   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5032   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5033   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5034
5035   application.SendNotification();
5036   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5037
5038   // We did expect the animation to finish
5039   application.SendNotification();
5040   finishCheck.CheckSignalReceived();
5041   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5042
5043   // Reset everything
5044   finishCheck.Reset();
5045   actor.SetSize(Vector3::ZERO);
5046   application.SendNotification();
5047   application.Render(0);
5048   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5049
5050   // Repeat with a delay
5051   float delay = 0.5f;
5052   animation = Animation::New(durationSeconds);
5053   animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5054   animation.FinishedSignal().Connect(&application, finishCheck);
5055   animation.Play();
5056
5057   application.SendNotification();
5058   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5059
5060   // We didn't expect the animation to finish yet
5061   application.SendNotification();
5062   finishCheck.CheckSignalNotReceived();
5063   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5064
5065   application.SendNotification();
5066   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5067
5068   // We did expect the animation to finish
5069   application.SendNotification();
5070   finishCheck.CheckSignalReceived();
5071   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5072   END_TEST;
5073 }
5074
5075 int UtcDaliAnimationAnimateToActorSizeWidth(void)
5076 {
5077   TestApplication application;
5078
5079   Actor actor = Actor::New();
5080   Stage::GetCurrent().Add(actor);
5081   float startValue(0.0f);
5082   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
5083   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), startValue, TEST_LOCATION );
5084
5085   // Build the animation
5086   float durationSeconds(1.0f);
5087   Animation animation = Animation::New(durationSeconds);
5088   float targetWidth(10.0f);
5089   animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth );
5090
5091   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
5092
5093   // Start the animation
5094   animation.Play();
5095
5096   bool signalReceived(false);
5097   AnimationFinishCheck finishCheck(signalReceived);
5098   animation.FinishedSignal().Connect(&application, finishCheck);
5099
5100   application.SendNotification();
5101   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5102
5103   // We didn't expect the animation to finish yet
5104   application.SendNotification();
5105   finishCheck.CheckSignalNotReceived();
5106   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
5107   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
5108
5109   application.SendNotification();
5110   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5111
5112   // We did expect the animation to finish
5113   application.SendNotification();
5114   finishCheck.CheckSignalReceived();
5115   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5116   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5117   END_TEST;
5118 }
5119
5120 int UtcDaliAnimationAnimateToActorSizeHeight(void)
5121 {
5122   TestApplication application;
5123
5124   Actor actor = Actor::New();
5125   Stage::GetCurrent().Add(actor);
5126   float startValue(0.0f);
5127   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5128   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION );
5129
5130   // Build the animation
5131   float durationSeconds(1.0f);
5132   Animation animation = Animation::New(durationSeconds);
5133   float targetHeight(-10.0f);
5134   animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight );
5135
5136   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5137
5138   // Start the animation
5139   animation.Play();
5140
5141   bool signalReceived(false);
5142   AnimationFinishCheck finishCheck(signalReceived);
5143   animation.FinishedSignal().Connect(&application, finishCheck);
5144
5145   application.SendNotification();
5146   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5147
5148   // We didn't expect the animation to finish yet
5149   application.SendNotification();
5150   finishCheck.CheckSignalNotReceived();
5151   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5152   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5153
5154   application.SendNotification();
5155   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5156
5157   // We did expect the animation to finish
5158   application.SendNotification();
5159   finishCheck.CheckSignalReceived();
5160   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5161   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5162   END_TEST;
5163 }
5164
5165 int UtcDaliAnimationAnimateToActorSizeDepth(void)
5166 {
5167   TestApplication application;
5168
5169   Actor actor = Actor::New();
5170   Stage::GetCurrent().Add(actor);
5171   float startValue(0.0f);
5172   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5173   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), startValue, TEST_LOCATION );
5174
5175   // Build the animation
5176   float durationSeconds(1.0f);
5177   Animation animation = Animation::New(durationSeconds);
5178   float targetDepth(-10.0f);
5179   animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth );
5180
5181   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5182
5183   // Start the animation
5184   animation.Play();
5185
5186   bool signalReceived(false);
5187   AnimationFinishCheck finishCheck(signalReceived);
5188   animation.FinishedSignal().Connect(&application, finishCheck);
5189
5190   application.SendNotification();
5191   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5192
5193   // We didn't expect the animation to finish yet
5194   application.SendNotification();
5195   finishCheck.CheckSignalNotReceived();
5196   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5197   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5198
5199   application.SendNotification();
5200   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5201
5202   // We did expect the animation to finish
5203   application.SendNotification();
5204   finishCheck.CheckSignalReceived();
5205   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5206   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5207   END_TEST;
5208 }
5209
5210 int UtcDaliAnimationAnimateToActorPosition(void)
5211 {
5212   TestApplication application;
5213
5214   Actor actor = Actor::New();
5215   Stage::GetCurrent().Add(actor);
5216   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5217
5218   // Build the animation
5219   float durationSeconds(1.0f);
5220   Animation animation = Animation::New(durationSeconds);
5221   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5222   animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition);
5223
5224   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5225
5226   // Start the animation
5227   animation.Play();
5228
5229   bool signalReceived(false);
5230   AnimationFinishCheck finishCheck(signalReceived);
5231   animation.FinishedSignal().Connect(&application, finishCheck);
5232
5233   application.SendNotification();
5234   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5235
5236   // We didn't expect the animation to finish yet
5237   application.SendNotification();
5238   finishCheck.CheckSignalNotReceived();
5239   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5240
5241   application.SendNotification();
5242   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5243
5244   // We did expect the animation to finish
5245   application.SendNotification();
5246   finishCheck.CheckSignalReceived();
5247   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5248   END_TEST;
5249 }
5250
5251 int UtcDaliAnimationAnimateToActorPositionX(void)
5252 {
5253   TestApplication application;
5254
5255   Actor actor = Actor::New();
5256   Stage::GetCurrent().Add(actor);
5257   float startValue(0.0f);
5258   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5259   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5260   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5261   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5262
5263   // Build the animation
5264   float durationSeconds(1.0f);
5265   Animation animation = Animation::New(durationSeconds);
5266   float targetX(1.0f);
5267   animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX );
5268
5269   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5270
5271   // Start the animation
5272   animation.Play();
5273
5274   bool signalReceived(false);
5275   AnimationFinishCheck finishCheck(signalReceived);
5276   animation.FinishedSignal().Connect(&application, finishCheck);
5277
5278   application.SendNotification();
5279   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5280
5281   // We didn't expect the animation to finish yet
5282   application.SendNotification();
5283   finishCheck.CheckSignalNotReceived();
5284   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5285   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5286   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5287   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5288
5289   application.SendNotification();
5290   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5291
5292   // We did expect the animation to finish
5293   application.SendNotification();
5294   finishCheck.CheckSignalReceived();
5295   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5296   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), targetX, TEST_LOCATION );
5297   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5298   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5299   END_TEST;
5300 }
5301
5302 int UtcDaliAnimationAnimateToActorPositionY(void)
5303 {
5304   TestApplication application;
5305
5306   Actor actor = Actor::New();
5307   Stage::GetCurrent().Add(actor);
5308   float startValue(0.0f);
5309   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5310   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5311   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5312   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5313
5314   // Build the animation
5315   float durationSeconds(1.0f);
5316   Animation animation = Animation::New(durationSeconds);
5317   float targetY(10.0f);
5318   animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY );
5319
5320   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5321
5322   // Start the animation
5323   animation.Play();
5324
5325   bool signalReceived(false);
5326   AnimationFinishCheck finishCheck(signalReceived);
5327   animation.FinishedSignal().Connect(&application, finishCheck);
5328
5329   application.SendNotification();
5330   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5331
5332   // We didn't expect the animation to finish yet
5333   application.SendNotification();
5334   finishCheck.CheckSignalNotReceived();
5335   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5336   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5337   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5338   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5339
5340   application.SendNotification();
5341   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5342
5343   // We did expect the animation to finish
5344   application.SendNotification();
5345   finishCheck.CheckSignalReceived();
5346   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), targetY, TEST_LOCATION );
5349   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5350   END_TEST;
5351 }
5352
5353 int UtcDaliAnimationAnimateToActorPositionZ(void)
5354 {
5355   TestApplication application;
5356
5357   Actor actor = Actor::New();
5358   Stage::GetCurrent().Add(actor);
5359   float startValue(0.0f);
5360   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5361   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5362   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5363   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), startValue, TEST_LOCATION );
5364
5365   // Build the animation
5366   float durationSeconds(1.0f);
5367   Animation animation = Animation::New(durationSeconds);
5368   float targetZ(-5.0f);
5369   animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ );
5370
5371   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5372
5373   // Start the animation
5374   animation.Play();
5375
5376   bool signalReceived(false);
5377   AnimationFinishCheck finishCheck(signalReceived);
5378   animation.FinishedSignal().Connect(&application, finishCheck);
5379
5380   application.SendNotification();
5381   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5382
5383   // We didn't expect the animation to finish yet
5384   application.SendNotification();
5385   finishCheck.CheckSignalNotReceived();
5386   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5387   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5388   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5389   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5390
5391   application.SendNotification();
5392   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5393
5394   // We did expect the animation to finish
5395   application.SendNotification();
5396   finishCheck.CheckSignalReceived();
5397   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5398   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_X), startValue, TEST_LOCATION );
5399   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Y), startValue, TEST_LOCATION );
5400   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::POSITION_Z), targetZ, TEST_LOCATION );
5401   END_TEST;
5402 }
5403
5404 int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void)
5405 {
5406   TestApplication application;
5407
5408   Actor actor = Actor::New();
5409   Stage::GetCurrent().Add(actor);
5410   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5411
5412   // Build the animation
5413   float durationSeconds(1.0f);
5414   Animation animation = Animation::New(durationSeconds);
5415   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5416   animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn);
5417
5418   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5419
5420   // Start the animation
5421   animation.Play();
5422
5423   bool signalReceived(false);
5424   AnimationFinishCheck finishCheck(signalReceived);
5425   animation.FinishedSignal().Connect(&application, finishCheck);
5426
5427   application.SendNotification();
5428   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5429
5430   // We didn't expect the animation to finish yet
5431   application.SendNotification();
5432   finishCheck.CheckSignalNotReceived();
5433
5434   // The position should have moved less, than with a linear alpha function
5435   Vector3 current(actor.GetCurrentPosition());
5436   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5437   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5438   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5439   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5440   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5441   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5442
5443   application.SendNotification();
5444   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5445
5446   // We did expect the animation to finish
5447   application.SendNotification();
5448   finishCheck.CheckSignalReceived();
5449   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5450   END_TEST;
5451 }
5452
5453 int UtcDaliAnimationAnimateToActorPositionTimePeriod(void)
5454 {
5455   TestApplication application;
5456
5457   Actor actor = Actor::New();
5458   Stage::GetCurrent().Add(actor);
5459   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5460
5461   // Build the animation
5462   float durationSeconds(1.0f);
5463   Animation animation = Animation::New(durationSeconds);
5464   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5465   float delay = 0.5f;
5466   animation.AnimateTo( Property(actor, Actor::POSITION),
5467                        targetPosition,
5468                        TimePeriod( delay, durationSeconds - delay ) );
5469
5470   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5471
5472   // Start the animation
5473   animation.Play();
5474
5475   bool signalReceived(false);
5476   AnimationFinishCheck finishCheck(signalReceived);
5477   animation.FinishedSignal().Connect(&application, finishCheck);
5478
5479   application.SendNotification();
5480   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5481
5482   // We didn't expect the animation to finish yet
5483   application.SendNotification();
5484   finishCheck.CheckSignalNotReceived();
5485   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5486
5487   application.SendNotification();
5488   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5489
5490   // We didn't expect the animation to finish yet
5491   application.SendNotification();
5492   finishCheck.CheckSignalNotReceived();
5493   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5494
5495   application.SendNotification();
5496   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5497
5498   // We did expect the animation to finish
5499   application.SendNotification();
5500   finishCheck.CheckSignalReceived();
5501   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5502   END_TEST;
5503 }
5504
5505 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void)
5506 {
5507   TestApplication application;
5508
5509   Actor actor = Actor::New();
5510   Stage::GetCurrent().Add(actor);
5511   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5512
5513   // Build the animation
5514   float durationSeconds(1.0f);
5515   Animation animation = Animation::New(durationSeconds);
5516   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5517   float delay = 0.5f;
5518   animation.AnimateTo( Property(actor, Actor::POSITION),
5519                        targetPosition,
5520                        AlphaFunctions::Linear,
5521                        TimePeriod( delay, durationSeconds - delay ) );
5522
5523   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5524
5525   // Start the animation
5526   animation.Play();
5527
5528   bool signalReceived(false);
5529   AnimationFinishCheck finishCheck(signalReceived);
5530   animation.FinishedSignal().Connect(&application, finishCheck);
5531
5532   application.SendNotification();
5533   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5534
5535   // We didn't expect the animation to finish yet
5536   application.SendNotification();
5537   finishCheck.CheckSignalNotReceived();
5538   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5539
5540   application.SendNotification();
5541   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5542
5543   // We didn't expect the animation to finish yet
5544   application.SendNotification();
5545   finishCheck.CheckSignalNotReceived();
5546   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5547
5548   application.SendNotification();
5549   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5550
5551   // We did expect the animation to finish
5552   application.SendNotification();
5553   finishCheck.CheckSignalReceived();
5554   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5555   END_TEST;
5556 }
5557
5558 int UtcDaliAnimationAnimateToActorRotationAngleAxis(void)
5559 {
5560   TestApplication application;
5561
5562   Actor actor = Actor::New();
5563   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5564   Stage::GetCurrent().Add(actor);
5565   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5566
5567   // Build the animation
5568   float durationSeconds(1.0f);
5569   Animation animation = Animation::New(durationSeconds);
5570   Degree targetRotationDegrees(90.0f);
5571   Radian targetRotationRadians(targetRotationDegrees);
5572   animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
5573
5574   // Start the animation
5575   animation.Play();
5576
5577   bool signalReceived(false);
5578   AnimationFinishCheck finishCheck(signalReceived);
5579   animation.FinishedSignal().Connect(&application, finishCheck);
5580
5581   application.SendNotification();
5582   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5583
5584   // We didn't expect the animation to finish yet
5585   application.SendNotification();
5586   finishCheck.CheckSignalNotReceived();
5587   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5588
5589   application.SendNotification();
5590   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5591
5592   // We didn't expect the animation to finish yet
5593   application.SendNotification();
5594   finishCheck.CheckSignalNotReceived();
5595   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5596
5597   application.SendNotification();
5598   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5599
5600   // We didn't expect the animation to finish yet
5601   application.SendNotification();
5602   finishCheck.CheckSignalNotReceived();
5603   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5604
5605   application.SendNotification();
5606   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5607
5608   // We did expect the animation to finish
5609   application.SendNotification();
5610   finishCheck.CheckSignalReceived();
5611   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5612   END_TEST;
5613 }
5614
5615 int UtcDaliAnimationAnimateToActorRotationQuaternion(void)
5616 {
5617   TestApplication application;
5618
5619   Actor actor = Actor::New();
5620   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5621   Stage::GetCurrent().Add(actor);
5622   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5623
5624   // Build the animation
5625   float durationSeconds(1.0f);
5626   Animation animation = Animation::New(durationSeconds);
5627   Degree targetRotationDegrees(90.0f);
5628   Radian targetRotationRadians(targetRotationDegrees);
5629   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
5630   animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation );
5631
5632   // Start the animation
5633   animation.Play();
5634
5635   bool signalReceived(false);
5636   AnimationFinishCheck finishCheck(signalReceived);
5637   animation.FinishedSignal().Connect(&application, finishCheck);
5638
5639   application.SendNotification();
5640   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5641
5642   // We didn't expect the animation to finish yet
5643   application.SendNotification();
5644   finishCheck.CheckSignalNotReceived();
5645   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5646
5647   application.SendNotification();
5648   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5649
5650   // We didn't expect the animation to finish yet
5651   application.SendNotification();
5652   finishCheck.CheckSignalNotReceived();
5653   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5654
5655   application.SendNotification();
5656   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5657
5658   // We didn't expect the animation to finish yet
5659   application.SendNotification();
5660   finishCheck.CheckSignalNotReceived();
5661   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5662
5663   application.SendNotification();
5664   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5665
5666   // We did expect the animation to finish
5667   application.SendNotification();
5668   finishCheck.CheckSignalReceived();
5669   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5670   END_TEST;
5671 }
5672
5673 int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void)
5674 {
5675   TestApplication application;
5676
5677   Actor actor = Actor::New();
5678   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5679   Stage::GetCurrent().Add(actor);
5680   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5681
5682   // Build the animation
5683   float durationSeconds(1.0f);
5684   Animation animation = Animation::New(durationSeconds);
5685   Degree targetRotationDegrees(90.0f);
5686   Radian targetRotationRadians(targetRotationDegrees);
5687   animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
5688
5689   // Start the animation
5690   animation.Play();
5691
5692   bool signalReceived(false);
5693   AnimationFinishCheck finishCheck(signalReceived);
5694   animation.FinishedSignal().Connect(&application, finishCheck);
5695
5696   application.SendNotification();
5697   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5698
5699   // We didn't expect the animation to finish yet
5700   application.SendNotification();
5701   finishCheck.CheckSignalNotReceived();
5702   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5703
5704   application.SendNotification();
5705   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5706
5707   // We didn't expect the animation to finish yet
5708   application.SendNotification();
5709   finishCheck.CheckSignalNotReceived();
5710   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5711
5712   application.SendNotification();
5713   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5714
5715   // We didn't expect the animation to finish yet
5716   application.SendNotification();
5717   finishCheck.CheckSignalNotReceived();
5718   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5719
5720   application.SendNotification();
5721   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5722
5723   // We did expect the animation to finish
5724   application.SendNotification();
5725   finishCheck.CheckSignalReceived();
5726   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5727   END_TEST;
5728 }
5729
5730 int UtcDaliAnimationAnimateToActorRotationTimePeriod(void)
5731 {
5732   TestApplication application;
5733
5734   Actor actor = Actor::New();
5735   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5736   Stage::GetCurrent().Add(actor);
5737   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5738
5739   // Build the animation
5740   float durationSeconds(1.0f);
5741   Animation animation = Animation::New(durationSeconds);
5742   Degree targetRotationDegrees(90.0f);
5743   Radian targetRotationRadians(targetRotationDegrees);
5744   float delay(0.1f);
5745   animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
5746
5747   // Start the animation
5748   animation.Play();
5749
5750   bool signalReceived(false);
5751   AnimationFinishCheck finishCheck(signalReceived);
5752   animation.FinishedSignal().Connect(&application, finishCheck);
5753
5754   application.SendNotification();
5755   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5756
5757   // We didn't expect the animation to finish yet
5758   application.SendNotification();
5759   finishCheck.CheckSignalNotReceived();
5760   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5761   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5762
5763   application.SendNotification();
5764   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5765
5766   // We didn't expect the animation to finish yet
5767   application.SendNotification();
5768   finishCheck.CheckSignalNotReceived();
5769   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5770   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5771
5772   application.SendNotification();
5773   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5774
5775   // We didn't expect the animation to finish yet
5776   application.SendNotification();
5777   finishCheck.CheckSignalNotReceived();
5778   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5779   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5780
5781   application.SendNotification();
5782   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5783
5784   // We did expect the animation to finish
5785   application.SendNotification();
5786   finishCheck.CheckSignalReceived();
5787   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5788   END_TEST;
5789 }
5790
5791 int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void)
5792 {
5793   TestApplication application;
5794
5795   Actor actor = Actor::New();
5796   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
5797   Stage::GetCurrent().Add(actor);
5798   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5799
5800   // Build the animation
5801   float durationSeconds(1.0f);
5802   Animation animation = Animation::New(durationSeconds);
5803   Degree targetRotationDegrees(90.0f);
5804   Radian targetRotationRadians(targetRotationDegrees);
5805   float delay(0.1f);
5806   animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
5807
5808   // Start the animation
5809   animation.Play();
5810
5811   bool signalReceived(false);
5812   AnimationFinishCheck finishCheck(signalReceived);
5813   animation.FinishedSignal().Connect(&application, finishCheck);
5814
5815   application.SendNotification();
5816   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5817
5818   // We didn't expect the animation to finish yet
5819   application.SendNotification();
5820   finishCheck.CheckSignalNotReceived();
5821   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5822   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5823
5824   application.SendNotification();
5825   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5826
5827   // We didn't expect the animation to finish yet
5828   application.SendNotification();
5829   finishCheck.CheckSignalNotReceived();
5830   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5831   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5832
5833   application.SendNotification();
5834   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5835
5836   // We didn't expect the animation to finish yet
5837   application.SendNotification();
5838   finishCheck.CheckSignalNotReceived();
5839   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5840   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5841
5842   application.SendNotification();
5843   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5844
5845   // We did expect the animation to finish
5846   application.SendNotification();
5847   finishCheck.CheckSignalReceived();
5848   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5849   END_TEST;
5850 }
5851
5852 int UtcDaliAnimationAnimateToActorScale(void)
5853 {
5854   TestApplication application;
5855
5856   Actor actor = Actor::New();
5857   Stage::GetCurrent().Add(actor);
5858   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5859
5860   // Build the animation
5861   float durationSeconds(1.0f);
5862   Animation animation = Animation::New(durationSeconds);
5863   Vector3 targetScale(2.0f, 2.0f, 2.0f);
5864   animation.AnimateTo( Property(actor, Actor::SCALE), targetScale );
5865
5866   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
5867
5868   // Start the animation
5869   animation.Play();
5870
5871   bool signalReceived(false);
5872   AnimationFinishCheck finishCheck(signalReceived);
5873   animation.FinishedSignal().Connect(&application, finishCheck);
5874
5875   application.SendNotification();
5876   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5877
5878   // We didn't expect the animation to finish yet
5879   application.SendNotification();
5880   finishCheck.CheckSignalNotReceived();
5881   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
5882
5883   application.SendNotification();
5884   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5885
5886   // We did expect the animation to finish
5887   application.SendNotification();
5888   finishCheck.CheckSignalReceived();
5889   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5890
5891   // Reset everything
5892   finishCheck.Reset();
5893   actor.SetScale(Vector3::ONE);
5894   application.SendNotification();
5895   application.Render(0);
5896   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5897
5898   // Repeat with a different (ease-in) alpha function
5899   animation = Animation::New(durationSeconds);
5900   animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn);
5901   animation.FinishedSignal().Connect(&application, finishCheck);
5902   animation.Play();
5903
5904   application.SendNotification();
5905   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5906
5907   // We didn't expect the animation to finish yet
5908   application.SendNotification();
5909   finishCheck.CheckSignalNotReceived();
5910
5911   // The scale should have grown less, than with a linear alpha function
5912   Vector3 current(actor.GetCurrentScale());
5913   DALI_TEST_CHECK( current.x > 1.0f );
5914   DALI_TEST_CHECK( current.y > 1.0f );
5915   DALI_TEST_CHECK( current.z > 1.0f );
5916   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5917   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5918   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5919
5920   application.SendNotification();
5921   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5922
5923   // We did expect the animation to finish
5924   application.SendNotification();
5925   finishCheck.CheckSignalReceived();
5926   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5927
5928   // Reset everything
5929   finishCheck.Reset();
5930   actor.SetScale(Vector3::ONE);
5931   application.SendNotification();
5932   application.Render(0);
5933   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5934
5935   // Repeat with a delay
5936   float delay = 0.5f;
5937   animation = Animation::New(durationSeconds);
5938   animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
5939   animation.FinishedSignal().Connect(&application, finishCheck);
5940   animation.Play();
5941
5942   application.SendNotification();
5943   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5944
5945   // We didn't expect the animation to finish yet
5946   application.SendNotification();
5947   finishCheck.CheckSignalNotReceived();
5948   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5949
5950   application.SendNotification();
5951   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5952
5953   // We did expect the animation to finish
5954   application.SendNotification();
5955   finishCheck.CheckSignalReceived();
5956   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5957   END_TEST;
5958 }
5959
5960 int UtcDaliAnimationAnimateToActorScaleX(void)
5961 {
5962   TestApplication application;
5963
5964   Actor actor = Actor::New();
5965   Stage::GetCurrent().Add(actor);
5966   float startValue(1.0f);
5967   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
5968   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
5969   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5970   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5971
5972   // Build the animation
5973   float durationSeconds(1.0f);
5974   Animation animation = Animation::New(durationSeconds);
5975   float targetX(10.0f);
5976   animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX );
5977
5978   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5979
5980   // Start the animation
5981   animation.Play();
5982
5983   bool signalReceived(false);
5984   AnimationFinishCheck finishCheck(signalReceived);
5985   animation.FinishedSignal().Connect(&application, finishCheck);
5986
5987   application.SendNotification();
5988   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5989
5990   // We didn't expect the animation to finish yet
5991   application.SendNotification();
5992   finishCheck.CheckSignalNotReceived();
5993   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
5994   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
5995   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
5996   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
5997
5998   application.SendNotification();
5999   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6000
6001   // We did expect the animation to finish
6002   application.SendNotification();
6003   finishCheck.CheckSignalReceived();
6004   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
6005   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), targetX, TEST_LOCATION );
6006   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6007   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6008   END_TEST;
6009 }
6010
6011 int UtcDaliAnimationAnimateToActorScaleY(void)
6012 {
6013   TestApplication application;
6014
6015   Actor actor = Actor::New();
6016   Stage::GetCurrent().Add(actor);
6017   float startValue(1.0f);
6018   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
6019   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6020   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6021   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6022
6023   // Build the animation
6024   float durationSeconds(1.0f);
6025   Animation animation = Animation::New(durationSeconds);
6026   float targetY(1000.0f);
6027   animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY );
6028
6029   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6030
6031   // Start the animation
6032   animation.Play();
6033
6034   bool signalReceived(false);
6035   AnimationFinishCheck finishCheck(signalReceived);
6036   animation.FinishedSignal().Connect(&application, finishCheck);
6037
6038   application.SendNotification();
6039   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6040
6041   // We didn't expect the animation to finish yet
6042   application.SendNotification();
6043   finishCheck.CheckSignalNotReceived();
6044   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
6045   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6046   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
6047   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6048
6049   application.SendNotification();
6050   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6051
6052   // We did expect the animation to finish
6053   application.SendNotification();
6054   finishCheck.CheckSignalReceived();
6055   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
6056   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6057   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), targetY, TEST_LOCATION );
6058   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6059   END_TEST;
6060 }
6061
6062 int UtcDaliAnimationAnimateToActorScaleZ(void)
6063 {
6064   TestApplication application;
6065
6066   Actor actor = Actor::New();
6067   Stage::GetCurrent().Add(actor);
6068   float startValue(1.0f);
6069   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
6070   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6071   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6072   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), startValue, TEST_LOCATION );
6073
6074   // Build the animation
6075   float durationSeconds(1.0f);
6076   Animation animation = Animation::New(durationSeconds);
6077   float targetZ(-1000.0f);
6078   animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ );
6079
6080   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6081
6082   // Start the animation
6083   animation.Play();
6084
6085   bool signalReceived(false);
6086   AnimationFinishCheck finishCheck(signalReceived);
6087   animation.FinishedSignal().Connect(&application, finishCheck);
6088
6089   application.SendNotification();
6090   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6091
6092   // We didn't expect the animation to finish yet
6093   application.SendNotification();
6094   finishCheck.CheckSignalNotReceived();
6095   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
6096   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6097   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
6099
6100   application.SendNotification();
6101   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6102
6103   // We did expect the animation to finish
6104   application.SendNotification();
6105   finishCheck.CheckSignalReceived();
6106   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
6107   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_X), startValue, TEST_LOCATION );
6108   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Y), startValue, TEST_LOCATION );
6109   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::SCALE_Z), targetZ, TEST_LOCATION );
6110   END_TEST;
6111 }
6112
6113 int UtcDaliAnimationAnimateToActorColor(void)
6114 {
6115   TestApplication application;
6116
6117   Actor actor = Actor::New();
6118   Stage::GetCurrent().Add(actor);
6119   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6120
6121   // Build the animation
6122   float durationSeconds(1.0f);
6123   Animation animation = Animation::New(durationSeconds);
6124   Vector4 targetColor(Color::RED);
6125   animation.AnimateTo( Property(actor, Actor::COLOR), targetColor );
6126
6127   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6128   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6129
6130   // Start the animation
6131   animation.Play();
6132
6133   bool signalReceived(false);
6134   AnimationFinishCheck finishCheck(signalReceived);
6135   animation.FinishedSignal().Connect(&application, finishCheck);
6136
6137   application.SendNotification();
6138   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6139
6140   // We didn't expect the animation to finish yet
6141   application.SendNotification();
6142   finishCheck.CheckSignalNotReceived();
6143   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6144
6145   application.SendNotification();
6146   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6147
6148   // We did expect the animation to finish
6149   application.SendNotification();
6150   finishCheck.CheckSignalReceived();
6151   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6152
6153   // Reset everything
6154   finishCheck.Reset();
6155   actor.SetColor(Color::WHITE);
6156   application.SendNotification();
6157   application.Render(0);
6158   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6159
6160   // Repeat with a different (ease-in) alpha function
6161   animation = Animation::New(durationSeconds);
6162   animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn);
6163   animation.FinishedSignal().Connect(&application, finishCheck);
6164   animation.Play();
6165
6166   application.SendNotification();
6167   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6168
6169   // We didn't expect the animation to finish yet
6170   application.SendNotification();
6171   finishCheck.CheckSignalNotReceived();
6172
6173   // The color should have changed less, than with a linear alpha function
6174   Vector4 current(actor.GetCurrentColor());
6175   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6176   DALI_TEST_CHECK( current.y < 1.0f );
6177   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6178   DALI_TEST_CHECK( current.z  < 1.0f );
6179   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
6180   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6181
6182   application.SendNotification();
6183   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6184
6185   // We did expect the animation to finish
6186   application.SendNotification();
6187   finishCheck.CheckSignalReceived();
6188   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6189
6190   // Reset everything
6191   finishCheck.Reset();
6192   actor.SetColor(Color::WHITE);
6193   application.SendNotification();
6194   application.Render(0);
6195   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6196
6197   // Repeat with a shorter animator duration
6198   float animatorDuration = 0.5f;
6199   animation = Animation::New(durationSeconds);
6200   animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6201   animation.FinishedSignal().Connect(&application, finishCheck);
6202   animation.Play();
6203
6204   application.SendNotification();
6205   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6206
6207   // We didn't expect the animation to finish yet
6208   application.SendNotification();
6209   finishCheck.CheckSignalNotReceived();
6210   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6211
6212   application.SendNotification();
6213   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6214
6215   // We didn't expect the animation to finish yet
6216   application.SendNotification();
6217   finishCheck.CheckSignalNotReceived();
6218   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6219
6220   application.SendNotification();
6221   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6222
6223   // We did expect the animation to finish
6224   application.SendNotification();
6225   finishCheck.CheckSignalReceived();
6226   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6227   END_TEST;
6228 }
6229
6230 int UtcDaliAnimationAnimateToActorColorRed(void)
6231 {
6232   TestApplication application;
6233
6234   Actor actor = Actor::New();
6235   Stage::GetCurrent().Add(actor);
6236   float startValue(1.0f);
6237   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6238   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6239   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6240   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6241   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6242
6243   // Build the animation
6244   float durationSeconds(1.0f);
6245   Animation animation = Animation::New(durationSeconds);
6246   float targetRed(0.5f);
6247   animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed );
6248
6249   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6250
6251   // Start the animation
6252   animation.Play();
6253
6254   bool signalReceived(false);
6255   AnimationFinishCheck finishCheck(signalReceived);
6256   animation.FinishedSignal().Connect(&application, finishCheck);
6257
6258   application.SendNotification();
6259   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6260
6261   // We didn't expect the animation to finish yet
6262   application.SendNotification();
6263   finishCheck.CheckSignalNotReceived();
6264   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6265   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
6266   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue,           TEST_LOCATION );
6267   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue,           TEST_LOCATION );
6268   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue,           TEST_LOCATION );
6269
6270   application.SendNotification();
6271   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6272
6273   // We did expect the animation to finish
6274   application.SendNotification();
6275   finishCheck.CheckSignalReceived();
6276   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6277   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   targetRed,  TEST_LOCATION );
6278   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6279   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6280   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6281   END_TEST;
6282 }
6283
6284 int UtcDaliAnimationAnimateToActorColorGreen(void)
6285 {
6286   TestApplication application;
6287
6288   Actor actor = Actor::New();
6289   Stage::GetCurrent().Add(actor);
6290   float startValue(1.0f);
6291   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6292   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6293   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6294   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6296
6297   // Build the animation
6298   float durationSeconds(1.0f);
6299   Animation animation = Animation::New(durationSeconds);
6300   float targetGreen(0.5f);
6301   animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen );
6302
6303   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6304
6305   // Start the animation
6306   animation.Play();
6307
6308   bool signalReceived(false);
6309   AnimationFinishCheck finishCheck(signalReceived);
6310   animation.FinishedSignal().Connect(&application, finishCheck);
6311
6312   application.SendNotification();
6313   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6314
6315   // We didn't expect the animation to finish yet
6316   application.SendNotification();
6317   finishCheck.CheckSignalNotReceived();
6318   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6319   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue,           TEST_LOCATION );
6320   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6321   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue,           TEST_LOCATION );
6322   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue,           TEST_LOCATION );
6323
6324   application.SendNotification();
6325   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6326
6327   // We did expect the animation to finish
6328   application.SendNotification();
6329   finishCheck.CheckSignalReceived();
6330   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6331   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue,  TEST_LOCATION );
6332   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION );
6333   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue,  TEST_LOCATION );
6334   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue,  TEST_LOCATION );
6335   END_TEST;
6336 }
6337
6338 int UtcDaliAnimationAnimateToActorColorBlue(void)
6339 {
6340   TestApplication application;
6341
6342   Actor actor = Actor::New();
6343   Stage::GetCurrent().Add(actor);
6344   float startValue(1.0f);
6345   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6346   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6349   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6350
6351   // Build the animation
6352   float durationSeconds(1.0f);
6353   Animation animation = Animation::New(durationSeconds);
6354   float targetBlue(0.5f);
6355   animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue );
6356
6357   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6358
6359   // Start the animation
6360   animation.Play();
6361
6362   bool signalReceived(false);
6363   AnimationFinishCheck finishCheck(signalReceived);
6364   animation.FinishedSignal().Connect(&application, finishCheck);
6365
6366   application.SendNotification();
6367   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6368
6369   // We didn't expect the animation to finish yet
6370   application.SendNotification();
6371   finishCheck.CheckSignalNotReceived();
6372   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6373   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue,           TEST_LOCATION );
6374   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue,           TEST_LOCATION );
6375   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  fiftyPercentProgress, TEST_LOCATION );
6376   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue,           TEST_LOCATION );
6377
6378   application.SendNotification();
6379   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6380
6381   // We did expect the animation to finish
6382   application.SendNotification();
6383   finishCheck.CheckSignalReceived();
6384   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6385   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6386   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6387   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  targetBlue, TEST_LOCATION );
6388   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6389   END_TEST;
6390 }
6391
6392 int UtcDaliAnimationAnimateToActorColorAlpha(void)
6393 {
6394   TestApplication application;
6395
6396   Actor actor = Actor::New();
6397   Stage::GetCurrent().Add(actor);
6398   float startValue(1.0f);
6399   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6400   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6401   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6402   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6403   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6404
6405   // Build the animation
6406   float durationSeconds(1.0f);
6407   Animation animation = Animation::New(durationSeconds);
6408   float targetAlpha(0.5f);
6409   animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha );
6410
6411   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6412
6413   // Start the animation
6414   animation.Play();
6415
6416   bool signalReceived(false);
6417   AnimationFinishCheck finishCheck(signalReceived);
6418   animation.FinishedSignal().Connect(&application, finishCheck);
6419
6420   application.SendNotification();
6421   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6422
6423   // We didn't expect the animation to finish yet
6424   application.SendNotification();
6425   finishCheck.CheckSignalNotReceived();
6426   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6427   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue,           TEST_LOCATION );
6428   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue,           TEST_LOCATION );
6429   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue,           TEST_LOCATION );
6430   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6431
6432   application.SendNotification();
6433   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6434
6435   // We did expect the animation to finish
6436   application.SendNotification();
6437   finishCheck.CheckSignalReceived();
6438   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6439   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue,  TEST_LOCATION );
6440   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue,  TEST_LOCATION );
6441   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue,  TEST_LOCATION );
6442   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6443   END_TEST;
6444 }
6445
6446
6447
6448 int UtcDaliAnimationKeyFrames01(void)
6449 {
6450   TestApplication application;
6451
6452   KeyFrames keyFrames = KeyFrames::New();
6453   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6454
6455   keyFrames.Add(0.0f, 0.1f);
6456   keyFrames.Add(0.2f, 0.5f);
6457   keyFrames.Add(0.4f, 0.0f);
6458   keyFrames.Add(0.6f, 1.0f);
6459   keyFrames.Add(0.8f, 0.7f);
6460   keyFrames.Add(1.0f, 0.9f);
6461
6462   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6463
6464   try
6465   {
6466     keyFrames.Add(1.9f, false);
6467   }
6468   catch (Dali::DaliException& e)
6469   {
6470     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6471     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6472   }
6473   END_TEST;
6474 }
6475
6476 int UtcDaliAnimationKeyFrames02(void)
6477 {
6478   TestApplication application;
6479
6480   KeyFrames keyFrames = KeyFrames::New();
6481   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6482
6483   keyFrames.Add(0.0f, true);
6484   keyFrames.Add(0.2f, false);
6485   keyFrames.Add(0.4f, false);
6486   keyFrames.Add(0.6f, true);
6487   keyFrames.Add(0.8f, true);
6488   keyFrames.Add(1.0f, false);
6489
6490   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6491
6492   try
6493   {
6494     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6495   }
6496   catch (Dali::DaliException& e)
6497   {
6498     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6499     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6500   }
6501   END_TEST;
6502 }
6503
6504
6505 int UtcDaliAnimationKeyFrames03(void)
6506 {
6507   TestApplication application;
6508
6509   KeyFrames keyFrames = KeyFrames::New();
6510   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6511
6512   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6513   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6514   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6515   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6516   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6517   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6518
6519   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6520
6521   try
6522   {
6523     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6524   }
6525   catch (Dali::DaliException& e)
6526   {
6527     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6528     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6529   }
6530   END_TEST;
6531 }
6532
6533
6534 int UtcDaliAnimationKeyFrames04(void)
6535 {
6536   TestApplication application;
6537
6538   KeyFrames keyFrames = KeyFrames::New();
6539   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6540
6541   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
6542   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
6543   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
6544   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
6545   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
6546   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
6547
6548   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
6549
6550   try
6551   {
6552     keyFrames.Add(0.7f, 1.0f);
6553   }
6554   catch (Dali::DaliException& e)
6555   {
6556     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6557     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6558   }
6559   END_TEST;
6560 }
6561
6562 int UtcDaliAnimationKeyFrames05(void)
6563 {
6564   TestApplication application;
6565
6566   KeyFrames keyFrames = KeyFrames::New();
6567   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6568
6569   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
6570   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6571   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
6572   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
6573   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
6574   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
6575
6576   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
6577
6578   try
6579   {
6580     keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
6581   }
6582   catch (Dali::DaliException& e)
6583   {
6584     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6585     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6586   }
6587   END_TEST;
6588 }
6589
6590
6591 int UtcDaliAnimationKeyFrames06(void)
6592 {
6593   TestApplication application;
6594
6595   KeyFrames keyFrames = KeyFrames::New();
6596   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6597
6598   keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
6599   keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
6600   keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
6601   keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
6602   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
6603   keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
6604
6605   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
6606
6607   try
6608   {
6609     keyFrames.Add(0.7f, 1.1f);
6610   }
6611   catch (Dali::DaliException& e)
6612   {
6613     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
6614     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6615   }
6616   END_TEST;
6617 }
6618
6619
6620
6621
6622
6623 int UtcDaliAnimationAnimateBetweenActorColorAlpha(void)
6624 {
6625   TestApplication application;
6626
6627   float startValue(1.0f);
6628   Actor actor = Actor::New();
6629   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6630   Stage::GetCurrent().Add(actor);
6631
6632   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6633   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6634   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6635   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6636   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6637
6638   // Build the animation
6639   float durationSeconds(1.0f);
6640   Animation animation = Animation::New(durationSeconds);
6641
6642   KeyFrames keyFrames = KeyFrames::New();
6643   keyFrames.Add(0.0f, 0.1f);
6644   keyFrames.Add(0.2f, 0.5f);
6645   keyFrames.Add(0.4f, 0.0f);
6646   keyFrames.Add(0.6f, 1.0f);
6647   keyFrames.Add(0.8f, 0.7f);
6648   keyFrames.Add(1.0f, 0.9f);
6649
6650   animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames );
6651
6652   // Start the animation
6653   animation.Play();
6654
6655   bool signalReceived(false);
6656   AnimationFinishCheck finishCheck(signalReceived);
6657   animation.FinishedSignal().Connect(&application, finishCheck);
6658   application.SendNotification();
6659   application.Render(0);
6660   application.SendNotification();
6661   finishCheck.CheckSignalNotReceived();
6662   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
6663
6664   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6665   application.SendNotification();
6666   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6667   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6668   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6669   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
6670   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
6671
6672   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
6673   application.SendNotification();
6674   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6675   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6676   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6677   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
6678   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
6679
6680   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
6681   application.SendNotification();
6682   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6683   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6684   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6685   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
6686   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
6687
6688   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
6689   application.SendNotification();
6690   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6691   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6692   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6693   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
6694   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
6695
6696   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
6697   application.SendNotification();
6698   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6699   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6700   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6701   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
6702   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
6703
6704   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
6705   application.SendNotification();
6706   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6707   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6708   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6709   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
6710   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
6711
6712   // We did expect the animation to finish
6713
6714   finishCheck.CheckSignalReceived();
6715   END_TEST;
6716 }
6717
6718
6719 int UtcDaliAnimationAnimateBetweenActorColor(void)
6720 {
6721   TestApplication application;
6722
6723   float startValue(1.0f);
6724   Actor actor = Actor::New();
6725   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
6726   Stage::GetCurrent().Add(actor);
6727
6728   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6729   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
6730   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
6731   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
6732   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
6733
6734   // Build the animation
6735   float durationSeconds(1.0f);
6736   Animation animation = Animation::New(durationSeconds);
6737
6738   KeyFrames keyFrames = KeyFrames::New();
6739   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
6740   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
6741   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
6742
6743   animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames );
6744
6745   // Start the animation
6746   animation.Play();
6747
6748   bool signalReceived(false);
6749   AnimationFinishCheck finishCheck(signalReceived);
6750   animation.FinishedSignal().Connect(&application, finishCheck);
6751   application.SendNotification();
6752   application.Render(0);
6753   application.SendNotification();
6754   finishCheck.CheckSignalNotReceived();
6755   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
6756   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
6757   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
6758   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
6759
6760   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6761   application.SendNotification();
6762   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
6763   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
6764   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
6765   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
6766
6767   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6768   application.SendNotification();
6769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
6770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
6771   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
6772   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
6773
6774   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6775   application.SendNotification();
6776   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
6777   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
6778   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
6779   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
6780
6781   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6782   application.SendNotification();
6783   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
6784   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
6785   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
6786   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
6787
6788   // We did expect the animation to finish
6789
6790   finishCheck.CheckSignalReceived();
6791   END_TEST;
6792 }
6793
6794 int UtcDaliAnimationAnimateBetweenActorVisible01(void)
6795 {
6796   TestApplication application;
6797
6798   Actor actor = Actor::New();
6799   AngleAxis aa(Degree(90), Vector3::XAXIS);
6800   actor.SetRotation(aa.angle, aa.axis);
6801   Stage::GetCurrent().Add(actor);
6802
6803   application.SendNotification();
6804   application.Render(0);
6805
6806   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
6807
6808   // Build the animation
6809   float durationSeconds(1.0f);
6810   Animation animation = Animation::New(durationSeconds);
6811
6812   KeyFrames keyFrames = KeyFrames::New();
6813   keyFrames.Add(0.0f, false);
6814   keyFrames.Add(0.2f, true);
6815   keyFrames.Add(0.4f, true);
6816   keyFrames.Add(0.8f, false);
6817   keyFrames.Add(1.0f, true);
6818
6819   animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames );
6820
6821   // Start the animation
6822   animation.Play();
6823
6824   bool signalReceived(false);
6825   AnimationFinishCheck finishCheck(signalReceived);
6826   animation.FinishedSignal().Connect(&application, finishCheck);
6827   application.SendNotification();
6828   application.SendNotification();
6829   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6830   application.SendNotification();
6831   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6832   application.SendNotification();
6833
6834   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
6835   finishCheck.CheckSignalReceived();
6836   END_TEST;
6837 }
6838
6839 int UtcDaliAnimationAnimateBetweenActorRotation01(void)
6840 {
6841   TestApplication application;
6842
6843   Actor actor = Actor::New();
6844   AngleAxis aa(Degree(90), Vector3::XAXIS);
6845   actor.SetRotation(aa.angle, aa.axis);
6846   Stage::GetCurrent().Add(actor);
6847
6848   application.SendNotification();
6849   application.Render(0);
6850   Quaternion start(Radian(aa.angle), aa.axis);
6851   DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6852
6853   // Build the animation
6854   float durationSeconds(1.0f);
6855   Animation animation = Animation::New(durationSeconds);
6856
6857   KeyFrames keyFrames = KeyFrames::New();
6858   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
6859
6860   animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6861
6862   // Start the animation
6863   animation.Play();
6864
6865   bool signalReceived(false);
6866   AnimationFinishCheck finishCheck(signalReceived);
6867   animation.FinishedSignal().Connect(&application, finishCheck);
6868   application.SendNotification();
6869   application.SendNotification();
6870   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
6871   application.SendNotification();
6872   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
6873   application.SendNotification();
6874
6875   Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
6876
6877   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6878   finishCheck.CheckSignalReceived();
6879   END_TEST;
6880 }
6881
6882 int UtcDaliAnimationAnimateBetweenActorRotation02(void)
6883 {
6884   TestApplication application;
6885
6886   Actor actor = Actor::New();
6887   AngleAxis aa(Degree(90), Vector3::XAXIS);
6888   actor.SetRotation(aa.angle, aa.axis);
6889   application.SendNotification();
6890   application.Render(0);
6891   Stage::GetCurrent().Add(actor);
6892
6893   Quaternion start(Radian(aa.angle), aa.axis);
6894   DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION );
6895
6896   // Build the animation
6897   float durationSeconds(1.0f);
6898   Animation animation = Animation::New(durationSeconds);
6899
6900   KeyFrames keyFrames = KeyFrames::New();
6901   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
6902   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
6903   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
6904
6905   animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames );
6906
6907   // Start the animation
6908   animation.Play();
6909
6910   bool signalReceived(false);
6911   AnimationFinishCheck finishCheck(signalReceived);
6912   animation.FinishedSignal().Connect(&application, finishCheck);
6913   application.SendNotification();
6914   application.Render(0);
6915   application.SendNotification();
6916   finishCheck.CheckSignalNotReceived();
6917
6918   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
6919   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6920
6921   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6922   application.SendNotification();
6923   check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
6924   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6925
6926   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6927   application.SendNotification();
6928   check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
6929   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6930
6931   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6932   application.SendNotification();
6933   check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
6934   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6935
6936   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
6937   application.SendNotification();
6938   check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
6939   DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION );
6940
6941   // We did expect the animation to finish
6942
6943   finishCheck.CheckSignalReceived();
6944   END_TEST;
6945 }
6946
6947 int UtcDaliAnimationMoveByFloat3(void)
6948 {
6949   TestApplication application;
6950
6951   Actor actor = Actor::New();
6952   Vector3 startPosition(10.0f, 10.0f, 10.0f);
6953   actor.SetPosition(startPosition);
6954   Stage::GetCurrent().Add(actor);
6955   application.SendNotification();
6956   application.Render(0);
6957   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
6958
6959   // Build the animation
6960   float durationSeconds(1.0f);
6961   Animation animation = Animation::New(durationSeconds);
6962   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
6963   Vector3 relativePosition(targetPosition - startPosition);
6964   animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z);
6965
6966   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
6967
6968   // Start the animation
6969   animation.Play();
6970
6971   bool signalReceived(false);
6972   AnimationFinishCheck finishCheck(signalReceived);
6973   animation.FinishedSignal().Connect(&application, finishCheck);
6974
6975   application.SendNotification();
6976   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6977
6978   // We didn't expect the animation to finish yet
6979   application.SendNotification();
6980   finishCheck.CheckSignalNotReceived();
6981   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
6982
6983   application.SendNotification();
6984   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6985
6986   // We did expect the animation to finish
6987   application.SendNotification();
6988   finishCheck.CheckSignalReceived();
6989   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6990   END_TEST;
6991 }
6992
6993 int UtcDaliAnimationMoveByVector3Alpha(void)
6994 {
6995   TestApplication application;
6996
6997   Actor actor = Actor::New();
6998   Vector3 startPosition(10.0f, 10.0f, 10.0f);
6999   actor.SetPosition(startPosition);
7000   Stage::GetCurrent().Add(actor);
7001   application.SendNotification();
7002   application.Render(0);
7003   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7004
7005   // Build the animation
7006   float durationSeconds(1.0f);
7007   Animation animation = Animation::New(durationSeconds);
7008   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7009   Vector3 relativePosition(targetPosition - startPosition);
7010   animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut);
7011
7012   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7013
7014   // Start the animation
7015   animation.Play();
7016
7017   bool signalReceived(false);
7018   AnimationFinishCheck finishCheck(signalReceived);
7019   animation.FinishedSignal().Connect(&application, finishCheck);
7020
7021   application.SendNotification();
7022   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
7023
7024   // We didn't expect the animation to finish yet
7025   application.SendNotification();
7026   finishCheck.CheckSignalNotReceived();
7027
7028   // The position should have moved more, than with a linear alpha function
7029   Vector3 current(actor.GetCurrentPosition());
7030   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
7031   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
7032   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
7033
7034   application.SendNotification();
7035   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
7036
7037   // We did expect the animation to finish
7038   application.SendNotification();
7039   finishCheck.CheckSignalReceived();
7040   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7041   END_TEST;
7042 }
7043
7044 int UtcDaliAnimationMoveByVector3AlphaFloat2(void)
7045 {
7046   TestApplication application;
7047
7048   Actor actor = Actor::New();
7049   Vector3 startPosition(10.0f, 10.0f, 10.0f);
7050   actor.SetPosition(startPosition);
7051   Stage::GetCurrent().Add(actor);
7052   application.SendNotification();
7053   application.Render(0);
7054   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7055
7056   // Build the animation
7057   float durationSeconds(1.0f);
7058   Animation animation = Animation::New(durationSeconds);
7059   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
7060   Vector3 relativePosition(targetPosition - startPosition);
7061   float delay = 0.5f;
7062   animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7063
7064   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
7065
7066   // Start the animation
7067   animation.Play();
7068
7069   bool signalReceived(false);
7070   AnimationFinishCheck finishCheck(signalReceived);
7071   animation.FinishedSignal().Connect(&application, finishCheck);
7072
7073   application.SendNotification();
7074   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7075
7076   // We didn't expect the animation to finish yet
7077   application.SendNotification();
7078   finishCheck.CheckSignalNotReceived();
7079   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
7080
7081   application.SendNotification();
7082   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7083
7084   // We did expect the animation to finish
7085   application.SendNotification();
7086   finishCheck.CheckSignalReceived();
7087   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7088   END_TEST;
7089 }
7090
7091 int UtcDaliAnimationMoveToFloat3(void)
7092 {
7093   TestApplication application;
7094
7095   Actor actor = Actor::New();
7096   Stage::GetCurrent().Add(actor);
7097   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7098
7099   // Build the animation
7100   float durationSeconds(1.0f);
7101   Animation animation = Animation::New(durationSeconds);
7102   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7103   animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z);
7104
7105   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7106
7107   // Start the animation
7108   animation.Play();
7109
7110   bool signalReceived(false);
7111   AnimationFinishCheck finishCheck(signalReceived);
7112   animation.FinishedSignal().Connect(&application, finishCheck);
7113
7114   application.SendNotification();
7115   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7116
7117   // We didn't expect the animation to finish yet
7118   application.SendNotification();
7119   finishCheck.CheckSignalNotReceived();
7120   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7121
7122   application.SendNotification();
7123   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7124
7125   // We did expect the animation to finish
7126   application.SendNotification();
7127   finishCheck.CheckSignalReceived();
7128   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7129   END_TEST;
7130 }
7131
7132 int UtcDaliAnimationMoveToVector3Alpha(void)
7133 {
7134   TestApplication application;
7135
7136   Actor actor = Actor::New();
7137   Stage::GetCurrent().Add(actor);
7138   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7139
7140   // Build the animation
7141   float durationSeconds(1.0f);
7142   Animation animation = Animation::New(durationSeconds);
7143   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7144   animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn);
7145
7146   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7147
7148   // Start the animation
7149   animation.Play();
7150
7151   bool signalReceived(false);
7152   AnimationFinishCheck finishCheck(signalReceived);
7153   animation.FinishedSignal().Connect(&application, finishCheck);
7154
7155   application.SendNotification();
7156   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7157
7158   // We didn't expect the animation to finish yet
7159   application.SendNotification();
7160   finishCheck.CheckSignalNotReceived();
7161
7162   // The position should have moved less, than with a linear alpha function
7163   Vector3 current(actor.GetCurrentPosition());
7164   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7165   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7166   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7167   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7168   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7169   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7170
7171   application.SendNotification();
7172   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7173
7174   // We did expect the animation to finish
7175   application.SendNotification();
7176   finishCheck.CheckSignalReceived();
7177   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7178   END_TEST;
7179 }
7180
7181 int UtcDaliAnimationMoveToVector3AlphaFloat2(void)
7182 {
7183   TestApplication application;
7184
7185   Actor actor = Actor::New();
7186   Stage::GetCurrent().Add(actor);
7187   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7188
7189   // Build the animation
7190   float durationSeconds(1.0f);
7191   Animation animation = Animation::New(durationSeconds);
7192   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7193   float delay = 0.5f;
7194   animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay);
7195
7196   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7197
7198   // Start the animation
7199   animation.Play();
7200
7201   bool signalReceived(false);
7202   AnimationFinishCheck finishCheck(signalReceived);
7203   animation.FinishedSignal().Connect(&application, finishCheck);
7204
7205   application.SendNotification();
7206   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7207
7208   // We didn't expect the animation to finish yet
7209   application.SendNotification();
7210   finishCheck.CheckSignalNotReceived();
7211   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7212
7213   application.SendNotification();
7214   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7215
7216   // We didn't expect the animation to finish yet
7217   application.SendNotification();
7218   finishCheck.CheckSignalNotReceived();
7219   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7220
7221   application.SendNotification();
7222   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7223
7224   // We did expect the animation to finish
7225   application.SendNotification();
7226   finishCheck.CheckSignalReceived();
7227   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7228   END_TEST;
7229 }
7230
7231 int UtcDaliAnimationMove(void)
7232 {
7233   TestApplication application;
7234
7235   Actor actor = Actor::New();
7236   Vector3 initialPosition(Vector3::ZERO);
7237   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7238   Stage::GetCurrent().Add(actor);
7239
7240   // Build the animation
7241   float durationSeconds(10.0f);
7242   Animation animation = Animation::New(durationSeconds);
7243   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7244   BounceFunc func(0.0f, 0.0f, -100.0f);
7245   animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
7246
7247   // Start the animation
7248   animation.Play();
7249
7250   bool signalReceived(false);
7251   AnimationFinishCheck finishCheck(signalReceived);
7252   animation.FinishedSignal().Connect(&application, finishCheck);
7253
7254   application.SendNotification();
7255   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7256
7257   // We didn't expect the animation to finish yet
7258   application.SendNotification();
7259   finishCheck.CheckSignalNotReceived();
7260   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
7261
7262   application.SendNotification();
7263   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7264
7265   // We didn't expect the animation to finish yet
7266   application.SendNotification();
7267   finishCheck.CheckSignalNotReceived();
7268   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
7269
7270   application.SendNotification();
7271   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7272
7273   // We didn't expect the animation to finish yet
7274   application.SendNotification();
7275   finishCheck.CheckSignalNotReceived();
7276   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
7277
7278   application.SendNotification();
7279   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7280
7281   // We did expect the animation to finish
7282   application.SendNotification();
7283   finishCheck.CheckSignalReceived();
7284   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
7285   END_TEST;
7286 }
7287
7288 int UtcDaliAnimationRotateByDegreeVector3(void)
7289 {
7290   TestApplication application;
7291
7292   Actor actor = Actor::New();
7293   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7294   Stage::GetCurrent().Add(actor);
7295   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7296
7297   // Build the animation
7298   float durationSeconds(1.0f);
7299   Animation animation = Animation::New(durationSeconds);
7300   Degree relativeRotationDegrees(360.0f);
7301   Radian relativeRotationRadians(relativeRotationDegrees);
7302   animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS);
7303
7304   // Start the animation
7305   animation.Play();
7306
7307   bool signalReceived(false);
7308   AnimationFinishCheck finishCheck(signalReceived);
7309   animation.FinishedSignal().Connect(&application, finishCheck);
7310
7311   application.SendNotification();
7312   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7313
7314   // We didn't expect the animation to finish yet
7315   application.SendNotification();
7316   finishCheck.CheckSignalNotReceived();
7317   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7318
7319   application.SendNotification();
7320   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7321
7322   // We didn't expect the animation to finish yet
7323   application.SendNotification();
7324   finishCheck.CheckSignalNotReceived();
7325   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7326
7327   application.SendNotification();
7328   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7329
7330   // We didn't expect the animation to finish yet
7331   application.SendNotification();
7332   finishCheck.CheckSignalNotReceived();
7333   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7334
7335   application.SendNotification();
7336   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7337
7338   // We did expect the animation to finish
7339   application.SendNotification();
7340   finishCheck.CheckSignalReceived();
7341   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7342   END_TEST;
7343 }
7344
7345 int UtcDaliAnimationRotateByRadianVector3(void)
7346 {
7347   TestApplication application;
7348
7349   Actor actor = Actor::New();
7350   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7351   Stage::GetCurrent().Add(actor);
7352   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7353
7354   // Build the animation
7355   float durationSeconds(1.0f);
7356   Animation animation = Animation::New(durationSeconds);
7357   Degree relativeRotationDegrees(360.0f);
7358   Radian relativeRotationRadians(relativeRotationDegrees);
7359   animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS);
7360
7361   // Start the animation
7362   animation.Play();
7363
7364   bool signalReceived(false);
7365   AnimationFinishCheck finishCheck(signalReceived);
7366   animation.FinishedSignal().Connect(&application, finishCheck);
7367
7368   application.SendNotification();
7369   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7370
7371   // We didn't expect the animation to finish yet
7372   application.SendNotification();
7373   finishCheck.CheckSignalNotReceived();
7374   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7375
7376   application.SendNotification();
7377   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7378
7379   // We didn't expect the animation to finish yet
7380   application.SendNotification();
7381   finishCheck.CheckSignalNotReceived();
7382   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7383
7384   application.SendNotification();
7385   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7386
7387   // We didn't expect the animation to finish yet
7388   application.SendNotification();
7389   finishCheck.CheckSignalNotReceived();
7390   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7391
7392   application.SendNotification();
7393   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7394
7395   // We did expect the animation to finish
7396   application.SendNotification();
7397   finishCheck.CheckSignalReceived();
7398   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7399   END_TEST;
7400 }
7401
7402 int UtcDaliAnimationRotateByDegreeVector3Alpha(void)
7403 {
7404   TestApplication application;
7405
7406   Actor actor = Actor::New();
7407   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7408   Stage::GetCurrent().Add(actor);
7409   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7410
7411   // Build the animation
7412   float durationSeconds(1.0f);
7413   Animation animation = Animation::New(durationSeconds);
7414   Degree relativeRotationDegrees(360.0f);
7415   Radian relativeRotationRadians(relativeRotationDegrees);
7416   animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7417
7418   // Start the animation
7419   animation.Play();
7420
7421   bool signalReceived(false);
7422   AnimationFinishCheck finishCheck(signalReceived);
7423   animation.FinishedSignal().Connect(&application, finishCheck);
7424
7425   application.SendNotification();
7426   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7427
7428   // We didn't expect the animation to finish yet
7429   application.SendNotification();
7430   finishCheck.CheckSignalNotReceived();
7431   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7432
7433   application.SendNotification();
7434   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7435
7436   // We didn't expect the animation to finish yet
7437   application.SendNotification();
7438   finishCheck.CheckSignalNotReceived();
7439   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7440
7441   application.SendNotification();
7442   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7443
7444   // We didn't expect the animation to finish yet
7445   application.SendNotification();
7446   finishCheck.CheckSignalNotReceived();
7447   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7448
7449   application.SendNotification();
7450   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7451
7452   // We did expect the animation to finish
7453   application.SendNotification();
7454   finishCheck.CheckSignalReceived();
7455   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7456   END_TEST;
7457 }
7458
7459 int UtcDaliAnimationRotateByRadianVector3Alpha(void)
7460 {
7461   TestApplication application;
7462
7463   Actor actor = Actor::New();
7464   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7465   Stage::GetCurrent().Add(actor);
7466   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7467
7468   // Build the animation
7469   float durationSeconds(1.0f);
7470   Animation animation = Animation::New(durationSeconds);
7471   Degree relativeRotationDegrees(360.0f);
7472   Radian relativeRotationRadians(relativeRotationDegrees);
7473   animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7474
7475   // Start the animation
7476   animation.Play();
7477
7478   bool signalReceived(false);
7479   AnimationFinishCheck finishCheck(signalReceived);
7480   animation.FinishedSignal().Connect(&application, finishCheck);
7481
7482   application.SendNotification();
7483   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7484
7485   // We didn't expect the animation to finish yet
7486   application.SendNotification();
7487   finishCheck.CheckSignalNotReceived();
7488   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7489
7490   application.SendNotification();
7491   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7492
7493   // We didn't expect the animation to finish yet
7494   application.SendNotification();
7495   finishCheck.CheckSignalNotReceived();
7496   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7497
7498   application.SendNotification();
7499   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7500
7501   // We didn't expect the animation to finish yet
7502   application.SendNotification();
7503   finishCheck.CheckSignalNotReceived();
7504   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7505
7506   application.SendNotification();
7507   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7508
7509   // We did expect the animation to finish
7510   application.SendNotification();
7511   finishCheck.CheckSignalReceived();
7512   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7513   END_TEST;
7514 }
7515
7516 int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void)
7517 {
7518   TestApplication application;
7519
7520   Actor actor = Actor::New();
7521   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7522   Stage::GetCurrent().Add(actor);
7523   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7524
7525   // Build the animation
7526   float durationSeconds(1.0f);
7527   Animation animation = Animation::New(durationSeconds);
7528   Degree relativeRotationDegrees(360.0f);
7529   Radian relativeRotationRadians(relativeRotationDegrees);
7530   float delay = 0.3f;
7531   animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7532
7533   // Start the animation
7534   animation.Play();
7535
7536   bool signalReceived(false);
7537   AnimationFinishCheck finishCheck(signalReceived);
7538   animation.FinishedSignal().Connect(&application, finishCheck);
7539
7540   application.SendNotification();
7541   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7542
7543   // We didn't expect the animation to finish yet
7544   application.SendNotification();
7545   finishCheck.CheckSignalNotReceived();
7546   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7547   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7548
7549   application.SendNotification();
7550   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7551
7552   // We didn't expect the animation to finish yet
7553   application.SendNotification();
7554   finishCheck.CheckSignalNotReceived();
7555   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7556   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7557
7558   application.SendNotification();
7559   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7560
7561   // We didn't expect the animation to finish yet
7562   application.SendNotification();
7563   finishCheck.CheckSignalNotReceived();
7564   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7565   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7566
7567   application.SendNotification();
7568   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7569
7570   // We did expect the animation to finish
7571   application.SendNotification();
7572   finishCheck.CheckSignalReceived();
7573   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7574   END_TEST;
7575 }
7576
7577
7578 int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void)
7579 {
7580   TestApplication application;
7581
7582   Actor actor = Actor::New();
7583   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7584   Stage::GetCurrent().Add(actor);
7585   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7586
7587   // Build the animation
7588   float durationSeconds(1.0f);
7589   Animation animation = Animation::New(durationSeconds);
7590   Degree relativeRotationDegrees(360.0f);
7591   Radian relativeRotationRadians(relativeRotationDegrees);
7592   float delay = 0.3f;
7593   animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7594
7595   // Start the animation
7596   animation.Play();
7597
7598   bool signalReceived(false);
7599   AnimationFinishCheck finishCheck(signalReceived);
7600   animation.FinishedSignal().Connect(&application, finishCheck);
7601
7602   application.SendNotification();
7603   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7604
7605   // We didn't expect the animation to finish yet
7606   application.SendNotification();
7607   finishCheck.CheckSignalNotReceived();
7608   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7609   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7610
7611   application.SendNotification();
7612   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7613
7614   // We didn't expect the animation to finish yet
7615   application.SendNotification();
7616   finishCheck.CheckSignalNotReceived();
7617   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7618   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7619
7620   application.SendNotification();
7621   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7622
7623   // We didn't expect the animation to finish yet
7624   application.SendNotification();
7625   finishCheck.CheckSignalNotReceived();
7626   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7627   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7628
7629   application.SendNotification();
7630   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7631
7632   // We did expect the animation to finish
7633   application.SendNotification();
7634   finishCheck.CheckSignalReceived();
7635   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7636   END_TEST;
7637 }
7638
7639 int UtcDaliAnimationRotateToDegreeVector3(void)
7640 {
7641   TestApplication application;
7642
7643   Actor actor = Actor::New();
7644   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7645   Stage::GetCurrent().Add(actor);
7646   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7647
7648   // Build the animation
7649   float durationSeconds(1.0f);
7650   Animation animation = Animation::New(durationSeconds);
7651   Degree targetRotationDegrees(90.0f);
7652   Radian targetRotationRadians(targetRotationDegrees);
7653   animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS);
7654
7655   // Start the animation
7656   animation.Play();
7657
7658   bool signalReceived(false);
7659   AnimationFinishCheck finishCheck(signalReceived);
7660   animation.FinishedSignal().Connect(&application, finishCheck);
7661
7662   application.SendNotification();
7663   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7664
7665   // We didn't expect the animation to finish yet
7666   application.SendNotification();
7667   finishCheck.CheckSignalNotReceived();
7668   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7669
7670   application.SendNotification();
7671   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7672
7673   // We didn't expect the animation to finish yet
7674   application.SendNotification();
7675   finishCheck.CheckSignalNotReceived();
7676   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7677
7678   application.SendNotification();
7679   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7680
7681   // We didn't expect the animation to finish yet
7682   application.SendNotification();
7683   finishCheck.CheckSignalNotReceived();
7684   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7685
7686   application.SendNotification();
7687   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7688
7689   // We did expect the animation to finish
7690   application.SendNotification();
7691   finishCheck.CheckSignalReceived();
7692   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7693   END_TEST;
7694 }
7695
7696 int UtcDaliAnimationRotateToRadianVector3(void)
7697 {
7698   TestApplication application;
7699
7700   Actor actor = Actor::New();
7701   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7702   Stage::GetCurrent().Add(actor);
7703   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7704
7705   // Build the animation
7706   float durationSeconds(1.0f);
7707   Animation animation = Animation::New(durationSeconds);
7708   Degree targetRotationDegrees(90.0f);
7709   Radian targetRotationRadians(targetRotationDegrees);
7710   animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS);
7711
7712   // Start the animation
7713   animation.Play();
7714
7715   bool signalReceived(false);
7716   AnimationFinishCheck finishCheck(signalReceived);
7717   animation.FinishedSignal().Connect(&application, finishCheck);
7718
7719   application.SendNotification();
7720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7721
7722   // We didn't expect the animation to finish yet
7723   application.SendNotification();
7724   finishCheck.CheckSignalNotReceived();
7725   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7726
7727   application.SendNotification();
7728   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7729
7730   // We didn't expect the animation to finish yet
7731   application.SendNotification();
7732   finishCheck.CheckSignalNotReceived();
7733   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7734
7735   application.SendNotification();
7736   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7737
7738   // We didn't expect the animation to finish yet
7739   application.SendNotification();
7740   finishCheck.CheckSignalNotReceived();
7741   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7742
7743   application.SendNotification();
7744   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7745
7746   // We did expect the animation to finish
7747   application.SendNotification();
7748   finishCheck.CheckSignalReceived();
7749   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7750   END_TEST;
7751 }
7752
7753 int UtcDaliAnimationRotateToQuaternion(void)
7754 {
7755   TestApplication application;
7756
7757   Actor actor = Actor::New();
7758   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7759   Stage::GetCurrent().Add(actor);
7760   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7761
7762   // Build the animation
7763   float durationSeconds(1.0f);
7764   Animation animation = Animation::New(durationSeconds);
7765   Degree targetRotationDegrees(90.0f);
7766   Radian targetRotationRadians(targetRotationDegrees);
7767   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7768   animation.RotateTo(actor, targetRotation/*Quaternion version*/);
7769
7770   // Start the animation
7771   animation.Play();
7772
7773   bool signalReceived(false);
7774   AnimationFinishCheck finishCheck(signalReceived);
7775   animation.FinishedSignal().Connect(&application, finishCheck);
7776
7777   application.SendNotification();
7778   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7779
7780   // We didn't expect the animation to finish yet
7781   application.SendNotification();
7782   finishCheck.CheckSignalNotReceived();
7783   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7784
7785   application.SendNotification();
7786   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7787
7788   // We didn't expect the animation to finish yet
7789   application.SendNotification();
7790   finishCheck.CheckSignalNotReceived();
7791   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7792
7793   application.SendNotification();
7794   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7795
7796   // We didn't expect the animation to finish yet
7797   application.SendNotification();
7798   finishCheck.CheckSignalNotReceived();
7799   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7800
7801   application.SendNotification();
7802   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7803
7804   // We did expect the animation to finish
7805   application.SendNotification();
7806   finishCheck.CheckSignalReceived();
7807   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7808   END_TEST;
7809 }
7810
7811 int UtcDaliAnimationRotateToDegreeVector3Alpha(void)
7812 {
7813   TestApplication application;
7814
7815   Actor actor = Actor::New();
7816   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7817   Stage::GetCurrent().Add(actor);
7818   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7819
7820   // Build the animation
7821   float durationSeconds(1.0f);
7822   Animation animation = Animation::New(durationSeconds);
7823   Degree targetRotationDegrees(90.0f);
7824   Radian targetRotationRadians(targetRotationDegrees);
7825   animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7826
7827   // Start the animation
7828   animation.Play();
7829
7830   bool signalReceived(false);
7831   AnimationFinishCheck finishCheck(signalReceived);
7832   animation.FinishedSignal().Connect(&application, finishCheck);
7833
7834   application.SendNotification();
7835   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7836
7837   // We didn't expect the animation to finish yet
7838   application.SendNotification();
7839   finishCheck.CheckSignalNotReceived();
7840   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7841
7842   application.SendNotification();
7843   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7844
7845   // We didn't expect the animation to finish yet
7846   application.SendNotification();
7847   finishCheck.CheckSignalNotReceived();
7848   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7849
7850   application.SendNotification();
7851   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7852
7853   // We didn't expect the animation to finish yet
7854   application.SendNotification();
7855   finishCheck.CheckSignalNotReceived();
7856   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7857
7858   application.SendNotification();
7859   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7860
7861   // We did expect the animation to finish
7862   application.SendNotification();
7863   finishCheck.CheckSignalReceived();
7864   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7865   END_TEST;
7866 }
7867
7868 int UtcDaliAnimationRotateToRadianVector3Alpha(void)
7869 {
7870   TestApplication application;
7871
7872   Actor actor = Actor::New();
7873   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7874   Stage::GetCurrent().Add(actor);
7875   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7876
7877   // Build the animation
7878   float durationSeconds(1.0f);
7879   Animation animation = Animation::New(durationSeconds);
7880   Degree targetRotationDegrees(90.0f);
7881   Radian targetRotationRadians(targetRotationDegrees);
7882   animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn);
7883
7884   // Start the animation
7885   animation.Play();
7886
7887   bool signalReceived(false);
7888   AnimationFinishCheck finishCheck(signalReceived);
7889   animation.FinishedSignal().Connect(&application, finishCheck);
7890
7891   application.SendNotification();
7892   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7893
7894   // We didn't expect the animation to finish yet
7895   application.SendNotification();
7896   finishCheck.CheckSignalNotReceived();
7897   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7898
7899   application.SendNotification();
7900   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7901
7902   // We didn't expect the animation to finish yet
7903   application.SendNotification();
7904   finishCheck.CheckSignalNotReceived();
7905   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7906
7907   application.SendNotification();
7908   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7909
7910   // We didn't expect the animation to finish yet
7911   application.SendNotification();
7912   finishCheck.CheckSignalNotReceived();
7913   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7914
7915   application.SendNotification();
7916   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7917
7918   // We did expect the animation to finish
7919   application.SendNotification();
7920   finishCheck.CheckSignalReceived();
7921   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7922   END_TEST;
7923 }
7924
7925 int UtcDaliAnimationRotateToQuaternionAlpha(void)
7926 {
7927   TestApplication application;
7928
7929   Actor actor = Actor::New();
7930   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7931   Stage::GetCurrent().Add(actor);
7932   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7933
7934   // Build the animation
7935   float durationSeconds(1.0f);
7936   Animation animation = Animation::New(durationSeconds);
7937   Degree targetRotationDegrees(90.0f);
7938   Radian targetRotationRadians(targetRotationDegrees);
7939   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7940   animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn);
7941
7942   // Start the animation
7943   animation.Play();
7944
7945   bool signalReceived(false);
7946   AnimationFinishCheck finishCheck(signalReceived);
7947   animation.FinishedSignal().Connect(&application, finishCheck);
7948
7949   application.SendNotification();
7950   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7951
7952   // We didn't expect the animation to finish yet
7953   application.SendNotification();
7954   finishCheck.CheckSignalNotReceived();
7955   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7956
7957   application.SendNotification();
7958   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7959
7960   // We didn't expect the animation to finish yet
7961   application.SendNotification();
7962   finishCheck.CheckSignalNotReceived();
7963   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7964
7965   application.SendNotification();
7966   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7967
7968   // We didn't expect the animation to finish yet
7969   application.SendNotification();
7970   finishCheck.CheckSignalNotReceived();
7971   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7972
7973   application.SendNotification();
7974   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7975
7976   // We did expect the animation to finish
7977   application.SendNotification();
7978   finishCheck.CheckSignalReceived();
7979   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7980   END_TEST;
7981 }
7982
7983 int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void)
7984 {
7985   TestApplication application;
7986
7987   Actor actor = Actor::New();
7988   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
7989   Stage::GetCurrent().Add(actor);
7990   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7991
7992   // Build the animation
7993   float durationSeconds(1.0f);
7994   Animation animation = Animation::New(durationSeconds);
7995   Degree targetRotationDegrees(90.0f);
7996   Radian targetRotationRadians(targetRotationDegrees);
7997   float delay(0.1f);
7998   animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
7999
8000   // Start the animation
8001   animation.Play();
8002
8003   bool signalReceived(false);
8004   AnimationFinishCheck finishCheck(signalReceived);
8005   animation.FinishedSignal().Connect(&application, finishCheck);
8006
8007   application.SendNotification();
8008   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8009
8010   // We didn't expect the animation to finish yet
8011   application.SendNotification();
8012   finishCheck.CheckSignalNotReceived();
8013   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8014   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8015
8016   application.SendNotification();
8017   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8018
8019   // We didn't expect the animation to finish yet
8020   application.SendNotification();
8021   finishCheck.CheckSignalNotReceived();
8022   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8023   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8024
8025   application.SendNotification();
8026   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8027
8028   // We didn't expect the animation to finish yet
8029   application.SendNotification();
8030   finishCheck.CheckSignalNotReceived();
8031   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8032   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8033
8034   application.SendNotification();
8035   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8036
8037   // We did expect the animation to finish
8038   application.SendNotification();
8039   finishCheck.CheckSignalReceived();
8040   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8041   END_TEST;
8042 }
8043
8044 int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void)
8045 {
8046   TestApplication application;
8047
8048   Actor actor = Actor::New();
8049   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8050   Stage::GetCurrent().Add(actor);
8051   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8052
8053   // Build the animation
8054   float durationSeconds(1.0f);
8055   Animation animation = Animation::New(durationSeconds);
8056   Degree targetRotationDegrees(90.0f);
8057   Radian targetRotationRadians(targetRotationDegrees);
8058   float delay(0.1f);
8059   animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8060
8061   // Start the animation
8062   animation.Play();
8063
8064   bool signalReceived(false);
8065   AnimationFinishCheck finishCheck(signalReceived);
8066   animation.FinishedSignal().Connect(&application, finishCheck);
8067
8068   application.SendNotification();
8069   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8070
8071   // We didn't expect the animation to finish yet
8072   application.SendNotification();
8073   finishCheck.CheckSignalNotReceived();
8074   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8075   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8076
8077   application.SendNotification();
8078   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8079
8080   // We didn't expect the animation to finish yet
8081   application.SendNotification();
8082   finishCheck.CheckSignalNotReceived();
8083   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8084   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8085
8086   application.SendNotification();
8087   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8088
8089   // We didn't expect the animation to finish yet
8090   application.SendNotification();
8091   finishCheck.CheckSignalNotReceived();
8092   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8093   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8094
8095   application.SendNotification();
8096   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8097
8098   // We did expect the animation to finish
8099   application.SendNotification();
8100   finishCheck.CheckSignalReceived();
8101   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8102   END_TEST;
8103 }
8104
8105 int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void)
8106 {
8107   TestApplication application;
8108
8109   Actor actor = Actor::New();
8110   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
8111   Stage::GetCurrent().Add(actor);
8112   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8113
8114   // Build the animation
8115   float durationSeconds(1.0f);
8116   Animation animation = Animation::New(durationSeconds);
8117   Degree targetRotationDegrees(90.0f);
8118   Radian targetRotationRadians(targetRotationDegrees);
8119   float delay(0.1f);
8120   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
8121   animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay);
8122
8123   // Start the animation
8124   animation.Play();
8125
8126   bool signalReceived(false);
8127   AnimationFinishCheck finishCheck(signalReceived);
8128   animation.FinishedSignal().Connect(&application, finishCheck);
8129
8130   application.SendNotification();
8131   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8132
8133   // We didn't expect the animation to finish yet
8134   application.SendNotification();
8135   finishCheck.CheckSignalNotReceived();
8136   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8137   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8138
8139   application.SendNotification();
8140   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8141
8142   // We didn't expect the animation to finish yet
8143   application.SendNotification();
8144   finishCheck.CheckSignalNotReceived();
8145   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8146   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8147
8148   application.SendNotification();
8149   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8150
8151   // We didn't expect the animation to finish yet
8152   application.SendNotification();
8153   finishCheck.CheckSignalNotReceived();
8154   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8155   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8156
8157   application.SendNotification();
8158   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8159
8160   // We did expect the animation to finish
8161   application.SendNotification();
8162   finishCheck.CheckSignalReceived();
8163   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8164   END_TEST;
8165 }
8166
8167 int UtcDaliAnimationRotate(void)
8168 {
8169   TestApplication application;
8170
8171   Actor actor = Actor::New();
8172   Quaternion initialRotation(0.0f, Vector3::YAXIS);
8173   actor.SetRotation(initialRotation);
8174   Stage::GetCurrent().Add(actor);
8175   DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION );
8176
8177   // Build the animation
8178   float durationSeconds(1.0f);
8179   Animation animation = Animation::New(durationSeconds);
8180   TumbleFunc func(Vector3::YAXIS);
8181   animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds);
8182
8183   // Start the animation
8184   animation.Play();
8185
8186   bool signalReceived(false);
8187   AnimationFinishCheck finishCheck(signalReceived);
8188   animation.FinishedSignal().Connect(&application, finishCheck);
8189
8190   application.SendNotification();
8191   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8192
8193   // We didn't expect the animation to finish yet
8194   application.SendNotification();
8195   finishCheck.CheckSignalNotReceived();
8196   DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8197
8198   application.SendNotification();
8199   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8200
8201   // We didn't expect the animation to finish yet
8202   application.SendNotification();
8203   finishCheck.CheckSignalNotReceived();
8204   DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8205
8206   application.SendNotification();
8207   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8208
8209   // We didn't expect the animation to finish yet
8210   application.SendNotification();
8211   finishCheck.CheckSignalNotReceived();
8212   DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8213
8214   application.SendNotification();
8215   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8216
8217   // We did expect the animation to finish
8218   application.SendNotification();
8219   finishCheck.CheckSignalReceived();
8220   DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION );
8221   END_TEST;
8222 }
8223
8224 int UtcDaliAnimationScaleBy(void)
8225 {
8226   TestApplication application;
8227
8228   Actor actor = Actor::New();
8229   Stage::GetCurrent().Add(actor);
8230   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8231
8232   // Build the animation
8233   float durationSeconds(1.0f);
8234   Animation animation = Animation::New(durationSeconds);
8235   Vector3 targetScale(2.0f, 2.0f, 2.0f);
8236   Vector3 relativeScale(targetScale - Vector3::ONE);
8237   animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z);
8238
8239   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
8240
8241   // Start the animation
8242   animation.Play();
8243
8244   bool signalReceived(false);
8245   AnimationFinishCheck finishCheck(signalReceived);
8246   animation.FinishedSignal().Connect(&application, finishCheck);
8247
8248   application.SendNotification();
8249   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8250
8251   // We didn't expect the animation to finish yet
8252   application.SendNotification();
8253   finishCheck.CheckSignalNotReceived();
8254   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8255
8256   application.SendNotification();
8257   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8258
8259   // We did expect the animation to finish
8260   application.SendNotification();
8261   finishCheck.CheckSignalReceived();
8262   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8263
8264   // Reset everything
8265   finishCheck.Reset();
8266   actor.SetScale(Vector3::ONE);
8267   application.SendNotification();
8268   application.Render(0);
8269   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8270
8271   // Repeat with a different (ease-in) alpha function
8272   animation = Animation::New(durationSeconds);
8273   animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn);
8274   animation.FinishedSignal().Connect(&application, finishCheck);
8275   animation.Play();
8276
8277   application.SendNotification();
8278   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8279
8280   // We didn't expect the animation to finish yet
8281   application.SendNotification();
8282   finishCheck.CheckSignalNotReceived();
8283
8284   // The scale should have grown less, than with a linear alpha function
8285   Vector3 current(actor.GetCurrentScale());
8286   DALI_TEST_CHECK( current.x > 1.0f );
8287   DALI_TEST_CHECK( current.y > 1.0f );
8288   DALI_TEST_CHECK( current.z > 1.0f );
8289   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8290   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8291   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8292
8293   application.SendNotification();
8294   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8295
8296   // We did expect the animation to finish
8297   application.SendNotification();
8298   finishCheck.CheckSignalReceived();
8299   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8300
8301   // Reset everything
8302   finishCheck.Reset();
8303   actor.SetScale(Vector3::ONE);
8304   application.SendNotification();
8305   application.Render(0);
8306   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8307
8308   // Repeat with a delay
8309   float delay = 0.5f;
8310   animation = Animation::New(durationSeconds);
8311   animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8312   animation.FinishedSignal().Connect(&application, finishCheck);
8313   animation.Play();
8314
8315   application.SendNotification();
8316   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8317
8318   // We didn't expect the animation to finish yet
8319   application.SendNotification();
8320   finishCheck.CheckSignalNotReceived();
8321   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8322
8323   application.SendNotification();
8324   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8325
8326   // We did expect the animation to finish
8327   application.SendNotification();
8328   finishCheck.CheckSignalReceived();
8329   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8330   END_TEST;
8331 }
8332
8333 int UtcDaliAnimationScaleTo(void)
8334 {
8335   TestApplication application;
8336
8337   Actor actor = Actor::New();
8338   Stage::GetCurrent().Add(actor);
8339   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8340
8341   // Build the animation
8342   float durationSeconds(1.0f);
8343   Animation animation = Animation::New(durationSeconds);
8344   Vector3 targetScale(2.0f, 2.0f, 2.0f);
8345   animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
8346
8347   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8348
8349   // Start the animation
8350   animation.Play();
8351
8352   bool signalReceived(false);
8353   AnimationFinishCheck finishCheck(signalReceived);
8354   animation.FinishedSignal().Connect(&application, finishCheck);
8355
8356   application.SendNotification();
8357   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8358
8359   // We didn't expect the animation to finish yet
8360   application.SendNotification();
8361   finishCheck.CheckSignalNotReceived();
8362   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
8363
8364   application.SendNotification();
8365   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8366
8367   // We did expect the animation to finish
8368   application.SendNotification();
8369   finishCheck.CheckSignalReceived();
8370   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8371
8372   // Reset everything
8373   finishCheck.Reset();
8374   actor.SetScale(Vector3::ONE);
8375   application.SendNotification();
8376   application.Render(0);
8377   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8378
8379   // Repeat with a different (ease-in) alpha function
8380   animation = Animation::New(durationSeconds);
8381   animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
8382   animation.FinishedSignal().Connect(&application, finishCheck);
8383   animation.Play();
8384
8385   application.SendNotification();
8386   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8387
8388   // We didn't expect the animation to finish yet
8389   application.SendNotification();
8390   finishCheck.CheckSignalNotReceived();
8391
8392   // The scale should have grown less, than with a linear alpha function
8393   Vector3 current(actor.GetCurrentScale());
8394   DALI_TEST_CHECK( current.x > 1.0f );
8395   DALI_TEST_CHECK( current.y > 1.0f );
8396   DALI_TEST_CHECK( current.z > 1.0f );
8397   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8398   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8399   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8400
8401   application.SendNotification();
8402   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8403
8404   // We did expect the animation to finish
8405   application.SendNotification();
8406   finishCheck.CheckSignalReceived();
8407   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8408
8409   // Reset everything
8410   finishCheck.Reset();
8411   actor.SetScale(Vector3::ONE);
8412   application.SendNotification();
8413   application.Render(0);
8414   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8415
8416   // Repeat with a delay
8417   float delay = 0.5f;
8418   animation = Animation::New(durationSeconds);
8419   animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
8420   animation.FinishedSignal().Connect(&application, finishCheck);
8421   animation.Play();
8422
8423   application.SendNotification();
8424   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8425
8426   // We didn't expect the animation to finish yet
8427   application.SendNotification();
8428   finishCheck.CheckSignalNotReceived();
8429   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8430
8431   application.SendNotification();
8432   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8433
8434   // We did expect the animation to finish
8435   application.SendNotification();
8436   finishCheck.CheckSignalReceived();
8437   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8438   END_TEST;
8439 }
8440
8441 int UtcDaliAnimationShow(void)
8442 {
8443   TestApplication application;
8444
8445   Actor actor = Actor::New();
8446   actor.SetVisible(false);
8447   application.SendNotification();
8448   application.Render(0);
8449   DALI_TEST_CHECK( !actor.IsVisible() );
8450   Stage::GetCurrent().Add(actor);
8451
8452   // Start the animation
8453   float durationSeconds(10.0f);
8454   Animation animation = Animation::New(durationSeconds);
8455   animation.Show(actor, durationSeconds*0.5f);
8456   animation.Play();
8457
8458   bool signalReceived(false);
8459   AnimationFinishCheck finishCheck(signalReceived);
8460   animation.FinishedSignal().Connect(&application, finishCheck);
8461
8462   application.SendNotification();
8463   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8464
8465   // We didn't expect the animation to finish yet
8466   application.SendNotification();
8467   finishCheck.CheckSignalNotReceived();
8468   DALI_TEST_CHECK( !actor.IsVisible() );
8469
8470   application.SendNotification();
8471   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8472
8473   // We didn't expect the animation to finish yet
8474   application.SendNotification();
8475   finishCheck.CheckSignalNotReceived();
8476   DALI_TEST_CHECK( actor.IsVisible() );
8477
8478   application.SendNotification();
8479   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8480
8481   // We did expect the animation to finish
8482   application.SendNotification();
8483   finishCheck.CheckSignalReceived();
8484   DALI_TEST_CHECK( actor.IsVisible() );
8485   END_TEST;
8486 }
8487
8488 int UtcDaliAnimationHide(void)
8489 {
8490   TestApplication application;
8491
8492   Actor actor = Actor::New();
8493   DALI_TEST_CHECK( actor.IsVisible() );
8494   Stage::GetCurrent().Add(actor);
8495
8496   // Start the animation
8497   float durationSeconds(10.0f);
8498   Animation animation = Animation::New(durationSeconds);
8499   animation.Hide(actor, durationSeconds*0.5f);
8500   animation.Play();
8501
8502   bool signalReceived(false);
8503   AnimationFinishCheck finishCheck(signalReceived);
8504   animation.FinishedSignal().Connect(&application, finishCheck);
8505
8506   application.SendNotification();
8507   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8508
8509   // We didn't expect the animation to finish yet
8510   application.SendNotification();
8511   finishCheck.CheckSignalNotReceived();
8512   DALI_TEST_CHECK( actor.IsVisible() );
8513
8514   application.SendNotification();
8515   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8516
8517   // We didn't expect the animation to finish yet
8518   application.SendNotification();
8519   finishCheck.CheckSignalNotReceived();
8520   DALI_TEST_CHECK( !actor.IsVisible() );
8521
8522   application.SendNotification();
8523   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8524
8525   // We did expect the animation to finish
8526   application.SendNotification();
8527   finishCheck.CheckSignalReceived();
8528   DALI_TEST_CHECK( !actor.IsVisible() );
8529   END_TEST;
8530 }
8531
8532 int UtcDaliAnimationShowHideAtEnd(void)
8533 {
8534   // Test that show/hide delay can be the same as animation duration
8535   // i.e. to show/hide at the end of the animation
8536
8537   TestApplication application;
8538
8539   Actor actor = Actor::New();
8540   DALI_TEST_CHECK( actor.IsVisible() );
8541   Stage::GetCurrent().Add(actor);
8542
8543   // Start Hide animation
8544   float durationSeconds(10.0f);
8545   Animation animation = Animation::New(durationSeconds);
8546   animation.Hide(actor, durationSeconds/*Hide at end*/);
8547   animation.Play();
8548
8549   bool signalReceived(false);
8550   AnimationFinishCheck finishCheck(signalReceived);
8551   animation.FinishedSignal().Connect(&application, finishCheck);
8552
8553   application.SendNotification();
8554   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8555
8556   // We did expect the animation to finish
8557   application.SendNotification();
8558   finishCheck.CheckSignalReceived();
8559   DALI_TEST_CHECK( !actor.IsVisible() );
8560
8561   // Start Show animation
8562   animation = Animation::New(durationSeconds);
8563   animation.Show(actor, durationSeconds/*Show at end*/);
8564   animation.FinishedSignal().Connect(&application, finishCheck);
8565   animation.Play();
8566
8567   application.SendNotification();
8568   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8569
8570   // We did expect the animation to finish
8571   application.SendNotification();
8572   finishCheck.CheckSignalReceived();
8573   DALI_TEST_CHECK( actor.IsVisible() );
8574   END_TEST;
8575 }
8576
8577 int UtcDaliAnimationOpacityBy(void)
8578 {
8579   TestApplication application;
8580   Actor actor = Actor::New();
8581   float startingOpacity(0.5f);
8582   actor.SetOpacity(startingOpacity);
8583   application.SendNotification();
8584   application.Render(0);
8585   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8586   Stage::GetCurrent().Add(actor);
8587
8588   // Build the animation
8589   float durationSeconds(1.0f);
8590   Animation animation = Animation::New(durationSeconds);
8591   float relativeOpacity(-0.5f); // target of zero
8592   animation.OpacityBy(actor, relativeOpacity);
8593
8594   float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
8595
8596   // Start the animation
8597   animation.Play();
8598
8599   bool signalReceived(false);
8600   AnimationFinishCheck finishCheck(signalReceived);
8601   animation.FinishedSignal().Connect(&application, finishCheck);
8602
8603   application.SendNotification();
8604   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8605
8606   // We didn't expect the animation to finish yet
8607   application.SendNotification();
8608   finishCheck.CheckSignalNotReceived();
8609   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8610
8611   application.SendNotification();
8612   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8613
8614   // We did expect the animation to finish
8615   application.SendNotification();
8616   finishCheck.CheckSignalReceived();
8617   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8618
8619   // Reset everything
8620   finishCheck.Reset();
8621   actor.SetOpacity(startingOpacity);
8622   application.SendNotification();
8623   application.Render(0);
8624   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8625
8626   // Repeat with a different (ease-in) alpha function
8627   animation = Animation::New(durationSeconds);
8628   animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
8629   animation.FinishedSignal().Connect(&application, finishCheck);
8630   animation.Play();
8631
8632   application.SendNotification();
8633   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
8634
8635   // We didn't expect the animation to finish yet
8636   application.SendNotification();
8637   finishCheck.CheckSignalNotReceived();
8638
8639   // The opacity should reduce less, than with a linear alpha function
8640   float current(actor.GetCurrentOpacity());
8641   DALI_TEST_CHECK( current < 1.0f );
8642   DALI_TEST_CHECK( current > seventyFivePercentProgress );
8643
8644   application.SendNotification();
8645   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8646
8647   // We did expect the animation to finish
8648   application.SendNotification();
8649   finishCheck.CheckSignalReceived();
8650   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8651
8652   // Reset everything
8653   finishCheck.Reset();
8654   actor.SetOpacity(startingOpacity);
8655   application.SendNotification();
8656   application.Render(0);
8657   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8658
8659   // Repeat with a delay
8660   float delay = 0.5f;
8661   animation = Animation::New(durationSeconds);
8662   animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8663   animation.FinishedSignal().Connect(&application, finishCheck);
8664   animation.Play();
8665
8666   application.SendNotification();
8667   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8668
8669   // We didn't expect the animation to finish yet
8670   application.SendNotification();
8671   finishCheck.CheckSignalNotReceived();
8672   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
8673
8674   application.SendNotification();
8675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
8676
8677   // We didn't expect the animation to finish yet
8678   application.SendNotification();
8679   finishCheck.CheckSignalNotReceived();
8680   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
8681
8682   application.SendNotification();
8683   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
8684
8685   // We did expect the animation to finish
8686   application.SendNotification();
8687   finishCheck.CheckSignalReceived();
8688   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
8689   END_TEST;
8690 }
8691
8692 int UtcDaliAnimationOpacityTo(void)
8693 {
8694   TestApplication application;
8695
8696   Actor actor = Actor::New();
8697   Stage::GetCurrent().Add(actor);
8698   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8699
8700   // Build the animation
8701   float durationSeconds(1.0f);
8702   Animation animation = Animation::New(durationSeconds);
8703   float targetOpacity(0.0f);
8704   animation.OpacityTo(actor, targetOpacity);
8705
8706   float ninetyNinePercentProgress(0.01f);
8707
8708   // Start the animation
8709   animation.Play();
8710
8711   bool signalReceived(false);
8712   AnimationFinishCheck finishCheck(signalReceived);
8713   animation.FinishedSignal().Connect(&application, finishCheck);
8714
8715   application.SendNotification();
8716   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8717
8718   // We didn't expect the animation to finish yet
8719   application.SendNotification();
8720   finishCheck.CheckSignalNotReceived();
8721   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
8722
8723   application.SendNotification();
8724   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8725
8726   // We did expect the animation to finish
8727   application.SendNotification();
8728   finishCheck.CheckSignalReceived();
8729   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8730
8731   // Reset everything
8732   finishCheck.Reset();
8733   actor.SetOpacity(1.0f);
8734   application.SendNotification();
8735   application.Render(0);
8736   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8737
8738   // Repeat with a different (ease-in) alpha function
8739   animation = Animation::New(durationSeconds);
8740   animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
8741   animation.FinishedSignal().Connect(&application, finishCheck);
8742   animation.Play();
8743
8744   application.SendNotification();
8745   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8746
8747   // We didn't expect the animation to finish yet
8748   application.SendNotification();
8749   finishCheck.CheckSignalNotReceived();
8750
8751   // The opacity should reduce less, than with a linear alpha function
8752   float current(actor.GetCurrentOpacity());
8753   DALI_TEST_CHECK( current < 1.0f );
8754   DALI_TEST_CHECK( current > ninetyNinePercentProgress );
8755
8756   application.SendNotification();
8757   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8758
8759   // We did expect the animation to finish
8760   application.SendNotification();
8761   finishCheck.CheckSignalReceived();
8762   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8763
8764   // Reset everything
8765   finishCheck.Reset();
8766   actor.SetOpacity(1.0f);
8767   application.SendNotification();
8768   application.Render(0);
8769   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8770
8771   // Repeat with a delay
8772   float delay = 0.5f;
8773   animation = Animation::New(durationSeconds);
8774   animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
8775   animation.FinishedSignal().Connect(&application, finishCheck);
8776   animation.Play();
8777
8778   application.SendNotification();
8779   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8780
8781   // We didn't expect the animation to finish yet
8782   application.SendNotification();
8783   finishCheck.CheckSignalNotReceived();
8784   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
8785
8786   application.SendNotification();
8787   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8788
8789   // We did expect the animation to finish
8790   application.SendNotification();
8791   finishCheck.CheckSignalReceived();
8792   DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
8793   END_TEST;
8794 }
8795
8796 int UtcDaliAnimationColorBy(void)
8797 {
8798   TestApplication application;
8799
8800   Actor actor = Actor::New();
8801   actor.SetColor(Color::BLACK);
8802   application.SendNotification();
8803   application.Render(0);
8804   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
8805   Stage::GetCurrent().Add(actor);
8806
8807   // Build the animation
8808   float durationSeconds(1.0f);
8809   Animation animation = Animation::New(durationSeconds);
8810   Vector4 targetColor(Color::GREEN);
8811   Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
8812   animation.ColorBy(actor, relativeColor);
8813
8814   Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
8815   Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
8816
8817   // Start the animation
8818   animation.Play();
8819
8820   bool signalReceived(false);
8821   AnimationFinishCheck finishCheck(signalReceived);
8822   animation.FinishedSignal().Connect(&application, finishCheck);
8823
8824   application.SendNotification();
8825   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8826
8827   // We didn't expect the animation to finish yet
8828   application.SendNotification();
8829   finishCheck.CheckSignalNotReceived();
8830   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
8831
8832   application.SendNotification();
8833   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8834
8835   // We did expect the animation to finish
8836   application.SendNotification();
8837   finishCheck.CheckSignalReceived();
8838   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8839
8840   // Reset everything
8841   finishCheck.Reset();
8842   actor.SetColor(Color::BLACK);
8843   application.SendNotification();
8844   application.Render(0);
8845   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8846
8847   // Repeat with a different (ease-in) alpha function
8848   animation = Animation::New(durationSeconds);
8849   animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
8850   animation.FinishedSignal().Connect(&application, finishCheck);
8851   animation.Play();
8852
8853   application.SendNotification();
8854   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8855
8856   // We didn't expect the animation to finish yet
8857   application.SendNotification();
8858   finishCheck.CheckSignalNotReceived();
8859
8860   // The color should have changed less, than with a linear alpha function
8861   Vector4 current(actor.GetCurrentWorldColor());
8862   DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
8863   DALI_TEST_CHECK( current.y > 0.0f );
8864   DALI_TEST_CHECK( current.y < tenPercentProgress.y );
8865   DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
8866   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8867
8868   application.SendNotification();
8869   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8870
8871   // We did expect the animation to finish
8872   application.SendNotification();
8873   finishCheck.CheckSignalReceived();
8874   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8875
8876   // Reset everything
8877   finishCheck.Reset();
8878   actor.SetColor(Color::BLACK);
8879   application.SendNotification();
8880   application.Render(0);
8881   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
8882
8883   // Repeat with a shorter animator duration
8884   float animatorDuration = 0.5f;
8885   animation = Animation::New(durationSeconds);
8886   animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
8887   animation.FinishedSignal().Connect(&application, finishCheck);
8888   animation.Play();
8889
8890   application.SendNotification();
8891   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8892
8893   // We didn't expect the animation to finish yet
8894   application.SendNotification();
8895   finishCheck.CheckSignalNotReceived();
8896   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
8897
8898   application.SendNotification();
8899   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8900
8901   // We didn't expect the animation to finish yet
8902   application.SendNotification();
8903   finishCheck.CheckSignalNotReceived();
8904   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8905
8906   application.SendNotification();
8907   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8908
8909   // We did expect the animation to finish
8910   application.SendNotification();
8911   finishCheck.CheckSignalReceived();
8912   DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
8913   END_TEST;
8914 }
8915
8916 int UtcDaliAnimationColorTo(void)
8917 {
8918   TestApplication application;
8919
8920   Actor actor = Actor::New();
8921   Stage::GetCurrent().Add(actor);
8922   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8923
8924   // Build the animation
8925   float durationSeconds(1.0f);
8926   Animation animation = Animation::New(durationSeconds);
8927   Vector4 targetColor(Color::RED);
8928   animation.ColorTo(actor, targetColor);
8929
8930   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8931   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8932
8933   // Start the animation
8934   animation.Play();
8935
8936   bool signalReceived(false);
8937   AnimationFinishCheck finishCheck(signalReceived);
8938   animation.FinishedSignal().Connect(&application, finishCheck);
8939
8940   application.SendNotification();
8941   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8942
8943   // We didn't expect the animation to finish yet
8944   application.SendNotification();
8945   finishCheck.CheckSignalNotReceived();
8946   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8947
8948   application.SendNotification();
8949   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8950
8951   // We did expect the animation to finish
8952   application.SendNotification();
8953   finishCheck.CheckSignalReceived();
8954   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8955
8956   // Reset everything
8957   finishCheck.Reset();
8958   actor.SetColor(Color::WHITE);
8959   application.SendNotification();
8960   application.Render(0);
8961   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8962
8963   // Repeat with a different (ease-in) alpha function
8964   animation = Animation::New(durationSeconds);
8965   animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
8966   animation.FinishedSignal().Connect(&application, finishCheck);
8967   animation.Play();
8968
8969   application.SendNotification();
8970   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8971
8972   // We didn't expect the animation to finish yet
8973   application.SendNotification();
8974   finishCheck.CheckSignalNotReceived();
8975
8976   // The color should have changed less, than with a linear alpha function
8977   Vector4 current(actor.GetCurrentColor());
8978   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8979   DALI_TEST_CHECK( current.y < 1.0f );
8980   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8981   DALI_TEST_CHECK( current.z  < 1.0f );
8982   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8983   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8984
8985   application.SendNotification();
8986   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8987
8988   // We did expect the animation to finish
8989   application.SendNotification();
8990   finishCheck.CheckSignalReceived();
8991   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8992
8993   // Reset everything
8994   finishCheck.Reset();
8995   actor.SetColor(Color::WHITE);
8996   application.SendNotification();
8997   application.Render(0);
8998   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8999
9000   // Repeat with a shorter animator duration
9001   float animatorDuration = 0.5f;
9002   animation = Animation::New(durationSeconds);
9003   animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
9004   animation.FinishedSignal().Connect(&application, finishCheck);
9005   animation.Play();
9006
9007   application.SendNotification();
9008   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
9009
9010   // We didn't expect the animation to finish yet
9011   application.SendNotification();
9012   finishCheck.CheckSignalNotReceived();
9013   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
9014
9015   application.SendNotification();
9016   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
9017
9018   // We didn't expect the animation to finish yet
9019   application.SendNotification();
9020   finishCheck.CheckSignalNotReceived();
9021   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9022
9023   application.SendNotification();
9024   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9025
9026   // We did expect the animation to finish
9027   application.SendNotification();
9028   finishCheck.CheckSignalReceived();
9029   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
9030   END_TEST;
9031 }
9032
9033 int UtcDaliAnimationResize(void)
9034 {
9035   TestApplication application;
9036
9037   Actor actor = Actor::New();
9038   Stage::GetCurrent().Add(actor);
9039   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9040
9041   // Build the animation
9042   float durationSeconds(1.0f);
9043   Animation animation = Animation::New(durationSeconds);
9044   Vector3 targetSize(100.0f, 100.0f, 100.0f);
9045   animation.Resize(actor, targetSize);
9046
9047   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9048
9049   // Start the animation
9050   animation.Play();
9051
9052   bool signalReceived(false);
9053   AnimationFinishCheck finishCheck(signalReceived);
9054   animation.FinishedSignal().Connect(&application, finishCheck);
9055
9056   application.SendNotification();
9057   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9058
9059   // We didn't expect the animation to finish yet
9060   application.SendNotification();
9061   finishCheck.CheckSignalNotReceived();
9062   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9063
9064   application.SendNotification();
9065   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9066
9067   // We did expect the animation to finish
9068   application.SendNotification();
9069   finishCheck.CheckSignalReceived();
9070   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9071
9072   // Reset everything
9073   finishCheck.Reset();
9074   actor.SetSize(Vector3::ZERO);
9075   application.SendNotification();
9076   application.Render(0);
9077   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9078
9079   // Repeat with a different (ease-in) alpha function
9080   animation = Animation::New(durationSeconds);
9081   animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
9082   animation.FinishedSignal().Connect(&application, finishCheck);
9083   animation.Play();
9084
9085   application.SendNotification();
9086   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9087
9088   // We didn't expect the animation to finish yet
9089   application.SendNotification();
9090   finishCheck.CheckSignalNotReceived();
9091
9092   // The size should have travelled less, than with a linear alpha function
9093   Vector3 current(actor.GetCurrentSize());
9094   DALI_TEST_CHECK( current.x > 0.0f );
9095   DALI_TEST_CHECK( current.y > 0.0f );
9096   DALI_TEST_CHECK( current.z > 0.0f );
9097   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9098   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9099   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9100
9101   application.SendNotification();
9102   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9103
9104   // We did expect the animation to finish
9105   application.SendNotification();
9106   finishCheck.CheckSignalReceived();
9107   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9108
9109   // Reset everything
9110   finishCheck.Reset();
9111   actor.SetSize(Vector3::ZERO);
9112   application.SendNotification();
9113   application.Render(0);
9114   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9115
9116   // Repeat with a delay
9117   float delay = 0.5f;
9118   animation = Animation::New(durationSeconds);
9119   animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
9120   animation.FinishedSignal().Connect(&application, finishCheck);
9121   animation.Play();
9122
9123   application.SendNotification();
9124   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9125
9126   // We didn't expect the animation to finish yet
9127   application.SendNotification();
9128   finishCheck.CheckSignalNotReceived();
9129   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9130
9131   application.SendNotification();
9132   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9133
9134   // We did expect the animation to finish
9135   application.SendNotification();
9136   finishCheck.CheckSignalReceived();
9137   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9138   END_TEST;
9139 }
9140
9141 int UtcDaliAnimationAnimateBool(void)
9142 {
9143   TestApplication application;
9144
9145   Actor actor = Actor::New();
9146   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9147   Stage::GetCurrent().Add(actor);
9148
9149   // Build the animation
9150   float durationSeconds(10.0f);
9151   Animation animation = Animation::New(durationSeconds);
9152   animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
9153
9154   // Start the animation
9155   animation.Play();
9156
9157   bool signalReceived(false);
9158   AnimationFinishCheck finishCheck(signalReceived);
9159   animation.FinishedSignal().Connect(&application, finishCheck);
9160
9161   application.SendNotification();
9162   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9163
9164   // We didn't expect the animation to finish yet
9165   application.SendNotification();
9166   finishCheck.CheckSignalNotReceived();
9167
9168   // Should still be visible
9169   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9170
9171   application.SendNotification();
9172   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9173
9174   // We didn't expect the animation to finish yet
9175   application.SendNotification();
9176   finishCheck.CheckSignalNotReceived();
9177
9178   // Now animate functor should have hidden the actor
9179   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9180
9181   application.SendNotification();
9182   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9183
9184   // We did expect the animation to finish
9185   application.SendNotification();
9186   finishCheck.CheckSignalReceived();
9187   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
9188   END_TEST;
9189 }
9190
9191 int UtcDaliAnimationAnimateFloat(void)
9192 {
9193   TestApplication application;
9194
9195   Actor actor = Actor::New();
9196   Stage::GetCurrent().Add(actor);
9197
9198   // Register a float property
9199   float startValue(10.0f);
9200   Property::Index index = actor.RegisterProperty( "test-property", startValue );
9201   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9202
9203   // Build the animation
9204   float durationSeconds(10.0f);
9205   Animation animation = Animation::New(durationSeconds);
9206   float targetPosition(0.0f);
9207   AnimateFloatTestFunctor func( 100, targetPosition );
9208   animation.Animate<float>( Property(actor, index), func );
9209
9210   // Start the animation
9211   animation.Play();
9212
9213   bool signalReceived(false);
9214   AnimationFinishCheck finishCheck(signalReceived);
9215   animation.FinishedSignal().Connect(&application, finishCheck);
9216
9217   application.SendNotification();
9218   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9219
9220   // We didn't expect the animation to finish yet
9221   application.SendNotification();
9222   finishCheck.CheckSignalNotReceived();
9223   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
9224
9225   application.SendNotification();
9226   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9227
9228   // We didn't expect the animation to finish yet
9229   application.SendNotification();
9230   finishCheck.CheckSignalNotReceived();
9231   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
9232
9233   application.SendNotification();
9234   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9235
9236   // We didn't expect the animation to finish yet
9237   application.SendNotification();
9238   finishCheck.CheckSignalNotReceived();
9239   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
9240
9241   application.SendNotification();
9242   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9243
9244   // We did expect the animation to finish
9245   application.SendNotification();
9246   finishCheck.CheckSignalReceived();
9247   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
9248   END_TEST;
9249 }
9250
9251 int UtcDaliAnimationAnimateInteger(void)
9252 {
9253   TestApplication application;
9254
9255   Actor actor = Actor::New();
9256   Stage::GetCurrent().Add(actor);
9257
9258   // Register an integer property
9259   int startValue(10);
9260   Property::Index index = actor.RegisterProperty( "test-property", startValue );
9261   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
9262
9263   // Build the animation
9264   float durationSeconds(10.0f);
9265   Animation animation = Animation::New(durationSeconds);
9266   int targetPosition(0);
9267   AnimateIntegerTestFunctor func( 100, targetPosition );
9268   animation.Animate<int>( Property(actor, index), func );
9269
9270   // Start the animation
9271   animation.Play();
9272
9273   bool signalReceived(false);
9274   AnimationFinishCheck finishCheck(signalReceived);
9275   animation.FinishedSignal().Connect(&application, finishCheck);
9276
9277   application.SendNotification();
9278   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9279
9280   // We didn't expect the animation to finish yet
9281   application.SendNotification();
9282   finishCheck.CheckSignalNotReceived();
9283   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
9284
9285   application.SendNotification();
9286   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9287
9288   // We didn't expect the animation to finish yet
9289   application.SendNotification();
9290   finishCheck.CheckSignalNotReceived();
9291   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
9292
9293   application.SendNotification();
9294   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9295
9296   // We didn't expect the animation to finish yet
9297   application.SendNotification();
9298   finishCheck.CheckSignalNotReceived();
9299   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
9300
9301   application.SendNotification();
9302   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9303
9304   // We did expect the animation to finish
9305   application.SendNotification();
9306   finishCheck.CheckSignalReceived();
9307   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
9308   END_TEST;
9309 }
9310
9311 int UtcDaliAnimationAnimateVector2(void)
9312 {
9313   TestApplication application;
9314
9315   Actor actor = Actor::New();
9316   Stage::GetCurrent().Add(actor);
9317
9318   // Register a Vector2 property
9319   Vector2 startValue(10.0f, 10.0f);
9320   Property::Index index = actor.RegisterProperty( "test-property", startValue );
9321   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
9322
9323   // Build the animation
9324   float durationSeconds(10.0f);
9325   Animation animation = Animation::New(durationSeconds);
9326   Vector2 targetPosition(0.0f, 0.0f);
9327   AnimateVector2TestFunctor func( Vector2(100,100), targetPosition );
9328   animation.Animate<Vector2>( Property(actor, index), func );
9329
9330   // Start the animation
9331   animation.Play();
9332
9333   bool signalReceived(false);
9334   AnimationFinishCheck finishCheck(signalReceived);
9335   animation.FinishedSignal().Connect(&application, finishCheck);
9336
9337   application.SendNotification();
9338   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9339
9340   // We didn't expect the animation to finish yet
9341   application.SendNotification();
9342   finishCheck.CheckSignalNotReceived();
9343   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(75,75), TEST_LOCATION );
9344
9345   application.SendNotification();
9346   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9347
9348   // We didn't expect the animation to finish yet
9349   application.SendNotification();
9350   finishCheck.CheckSignalNotReceived();
9351   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(50,50), TEST_LOCATION );
9352
9353   application.SendNotification();
9354   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9355
9356   // We didn't expect the animation to finish yet
9357   application.SendNotification();
9358   finishCheck.CheckSignalNotReceived();
9359   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), Vector2(25,25), TEST_LOCATION );
9360
9361   application.SendNotification();
9362   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9363
9364   // We did expect the animation to finish
9365   application.SendNotification();
9366   finishCheck.CheckSignalReceived();
9367   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetPosition, TEST_LOCATION );
9368   END_TEST;
9369 }
9370
9371 int UtcDaliAnimationAnimateVector3(void)
9372 {
9373   TestApplication application;
9374
9375   Actor actor = Actor::New();
9376   Vector3 initialPosition(Vector3::ZERO);
9377   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9378   Stage::GetCurrent().Add(actor);
9379
9380   // Build the animation
9381   float durationSeconds(10.0f);
9382   Animation animation = Animation::New(durationSeconds);
9383   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9384   BounceFunc func(0.0f, 0.0f, -100.0f);
9385   animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds );
9386
9387   // Start the animation
9388   animation.Play();
9389
9390   bool signalReceived(false);
9391   AnimationFinishCheck finishCheck(signalReceived);
9392   animation.FinishedSignal().Connect(&application, finishCheck);
9393
9394   application.SendNotification();
9395   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9396
9397   // We didn't expect the animation to finish yet
9398   application.SendNotification();
9399   finishCheck.CheckSignalNotReceived();
9400   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9401
9402   application.SendNotification();
9403   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9404
9405   // We didn't expect the animation to finish yet
9406   application.SendNotification();
9407   finishCheck.CheckSignalNotReceived();
9408   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9409
9410   application.SendNotification();
9411   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9412
9413   // We didn't expect the animation to finish yet
9414   application.SendNotification();
9415   finishCheck.CheckSignalNotReceived();
9416   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9417
9418   application.SendNotification();
9419   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9420
9421   // We did expect the animation to finish
9422   application.SendNotification();
9423   finishCheck.CheckSignalReceived();
9424   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9425   END_TEST;
9426 }
9427
9428 int UtcDaliAnimationAnimateVector4(void)
9429 {
9430   TestApplication application;
9431
9432   Actor actor = Actor::New();
9433   Stage::GetCurrent().Add(actor);
9434
9435   // Register a Vector4 property
9436   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
9437   Property::Index index = actor.RegisterProperty( "test-property", startValue );
9438   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
9439
9440   // Build the animation
9441   float durationSeconds(10.0f);
9442   Animation animation = Animation::New(durationSeconds);
9443   Vector4 targetPosition(200,400,0,-1000);
9444   AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition );
9445   animation.Animate<Vector4>( Property(actor, index), func );
9446
9447   // Start the animation
9448   animation.Play();
9449
9450   bool signalReceived(false);
9451   AnimationFinishCheck finishCheck(signalReceived);
9452   animation.FinishedSignal().Connect(&application, finishCheck);
9453
9454   application.SendNotification();
9455   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9456
9457   // We didn't expect the animation to finish yet
9458   application.SendNotification();
9459   finishCheck.CheckSignalNotReceived();
9460   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(800,850,750,500), TEST_LOCATION );
9461
9462   application.SendNotification();
9463   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9464
9465   // We didn't expect the animation to finish yet
9466   application.SendNotification();
9467   finishCheck.CheckSignalNotReceived();
9468   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(600,700,500,0), TEST_LOCATION );
9469
9470   application.SendNotification();
9471   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9472
9473   // We didn't expect the animation to finish yet
9474   application.SendNotification();
9475   finishCheck.CheckSignalNotReceived();
9476   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), Vector4(400,550,250,-500), TEST_LOCATION );
9477
9478   application.SendNotification();
9479   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9480
9481   // We did expect the animation to finish
9482   application.SendNotification();
9483   finishCheck.CheckSignalReceived();
9484   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetPosition, TEST_LOCATION );
9485   END_TEST;
9486 }
9487
9488 int UtcDaliAnimationAnimateQuaternion(void)
9489 {
9490   TestApplication application;
9491
9492   Actor actor = Actor::New();
9493   actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS));
9494   Stage::GetCurrent().Add(actor);
9495   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9496
9497   // Build the animation
9498   float durationSeconds(1.0f);
9499   Animation animation = Animation::New(durationSeconds);
9500
9501   Degree sourceRotationDegrees(90.0f);
9502   Radian sourceRotationRadians(sourceRotationDegrees);
9503   Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS);
9504
9505   Degree targetRotationDegrees(150.0f);
9506   Radian targetRotationRadians(targetRotationDegrees);
9507   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
9508
9509   AnimateQuaternionTestFunctor func( sourceRotation, targetRotation );
9510   animation.Animate<Quaternion>( Property(actor, Actor::ROTATION), func );
9511
9512   // Start the animation
9513   animation.Play();
9514
9515   bool signalReceived(false);
9516   AnimationFinishCheck finishCheck(signalReceived);
9517   animation.FinishedSignal().Connect(&application, finishCheck);
9518
9519   application.SendNotification();
9520   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9521
9522   // We didn't expect the animation to finish yet
9523   application.SendNotification();
9524   finishCheck.CheckSignalNotReceived();
9525   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9526
9527   application.SendNotification();
9528   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9529
9530   // We didn't expect the animation to finish yet
9531   application.SendNotification();
9532   finishCheck.CheckSignalNotReceived();
9533   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9534
9535   application.SendNotification();
9536   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9537
9538   // We didn't expect the animation to finish yet
9539   application.SendNotification();
9540   finishCheck.CheckSignalNotReceived();
9541   DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
9542
9543   application.SendNotification();
9544   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9545
9546   // We did expect the animation to finish
9547   application.SendNotification();
9548   finishCheck.CheckSignalReceived();
9549   DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION );
9550   END_TEST;
9551 }
9552
9553 int UtcDaliKeyFramesCreateDestroy(void)
9554 {
9555   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9556
9557   KeyFrames* keyFrames = new KeyFrames;
9558   delete keyFrames;
9559   DALI_TEST_CHECK( true );
9560   END_TEST;
9561 }
9562
9563 int UtcDaliKeyFramesDownCast(void)
9564 {
9565   TestApplication application;
9566   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9567
9568   KeyFrames keyFrames = KeyFrames::New();
9569   BaseHandle object(keyFrames);
9570
9571   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9572   DALI_TEST_CHECK(keyFrames2);
9573
9574   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9575   DALI_TEST_CHECK(keyFrames3);
9576
9577   BaseHandle unInitializedObject;
9578   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9579   DALI_TEST_CHECK(!keyFrames4);
9580
9581   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9582   DALI_TEST_CHECK(!keyFrames5);
9583   END_TEST;
9584 }
9585
9586 int UtcDaliAnimationResizeByXY(void)
9587 {
9588   TestApplication application;
9589
9590   Actor actor = Actor::New();
9591   Stage::GetCurrent().Add(actor);
9592   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9593
9594   // Build the animation
9595   float durationSeconds(1.0f);
9596   Animation animation = Animation::New(durationSeconds);
9597   Vector3 targetSize(100.0f, 100.0f, 100.0f);
9598   animation.Resize(actor, targetSize);
9599
9600   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
9601
9602   // Start the animation
9603   animation.Play();
9604
9605   bool signalReceived(false);
9606   AnimationFinishCheck finishCheck(signalReceived);
9607   animation.FinishedSignal().Connect(&application, finishCheck);
9608
9609   application.SendNotification();
9610   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9611
9612   // We didn't expect the animation to finish yet
9613   application.SendNotification();
9614   finishCheck.CheckSignalNotReceived();
9615   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
9616
9617   application.SendNotification();
9618   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9619
9620   // We did expect the animation to finish
9621   application.SendNotification();
9622   finishCheck.CheckSignalReceived();
9623   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9624
9625   // Reset everything
9626   finishCheck.Reset();
9627   actor.SetSize(Vector3::ZERO);
9628   application.SendNotification();
9629   application.Render(0);
9630   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9631
9632   // Repeat with a different (ease-in) alpha function
9633   animation = Animation::New(durationSeconds);
9634   animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn);
9635   animation.FinishedSignal().Connect(&application, finishCheck);
9636   animation.Play();
9637
9638   application.SendNotification();
9639   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
9640
9641   // We didn't expect the animation to finish yet
9642   application.SendNotification();
9643   finishCheck.CheckSignalNotReceived();
9644
9645   // The size should have travelled less, than with a linear alpha function
9646   Vector3 current(actor.GetCurrentSize());
9647   DALI_TEST_CHECK( current.x > 0.0f );
9648   DALI_TEST_CHECK( current.y > 0.0f );
9649   DALI_TEST_CHECK( current.z > 0.0f );
9650   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
9651   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
9652   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
9653
9654   application.SendNotification();
9655   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
9656
9657   // We did expect the animation to finish
9658   application.SendNotification();
9659   finishCheck.CheckSignalReceived();
9660   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9661
9662   // Reset everything
9663   finishCheck.Reset();
9664   actor.SetSize(Vector3::ZERO);
9665   application.SendNotification();
9666   application.Render(0);
9667   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9668
9669   // Repeat with a delay
9670   float delay = 0.5f;
9671   animation = Animation::New(durationSeconds);
9672   animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay);
9673   animation.FinishedSignal().Connect(&application, finishCheck);
9674   animation.Play();
9675
9676   application.SendNotification();
9677   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9678
9679   // We didn't expect the animation to finish yet
9680   application.SendNotification();
9681   finishCheck.CheckSignalNotReceived();
9682   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
9683
9684   application.SendNotification();
9685   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9686
9687   // We did expect the animation to finish
9688   application.SendNotification();
9689   finishCheck.CheckSignalReceived();
9690   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
9691   END_TEST;
9692 }
9693
9694
9695 int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void)
9696 {
9697   TestApplication application;
9698
9699   float startValue(1.0f);
9700   Actor actor = Actor::New();
9701   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9702   Stage::GetCurrent().Add(actor);
9703
9704   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9705   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
9706   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9707   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
9708   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9709
9710   // Build the animation
9711   float durationSeconds(1.0f);
9712   Animation animation = Animation::New(durationSeconds);
9713
9714   KeyFrames keyFrames = KeyFrames::New();
9715   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9716   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9717   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9718
9719   animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) );
9720
9721   // Start the animation
9722   animation.Play();
9723
9724   bool signalReceived(false);
9725   AnimationFinishCheck finishCheck(signalReceived);
9726   animation.FinishedSignal().Connect(&application, finishCheck);
9727   application.SendNotification();
9728   application.Render(0);
9729   application.SendNotification();
9730   finishCheck.CheckSignalNotReceived();
9731   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9732   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9733   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9734   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9735
9736   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9737   application.SendNotification();
9738   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
9739   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9740   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
9741   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9742
9743   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9744   application.SendNotification();
9745   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9746   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9747   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9748   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9749
9750   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9751   application.SendNotification();
9752   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
9753   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9754   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
9755   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9756
9757   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9758   application.SendNotification();
9759   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9760   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9761   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9762   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9763
9764   // We did expect the animation to finish
9765
9766   finishCheck.CheckSignalReceived();
9767   END_TEST;
9768 }
9769
9770 int UtcDaliAnimationAnimateBetweenActorColorFunction(void)
9771 {
9772   TestApplication application;
9773
9774   float startValue(1.0f);
9775   Actor actor = Actor::New();
9776   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9777   Stage::GetCurrent().Add(actor);
9778
9779   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9780   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
9781   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9782   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
9783   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9784
9785   // Build the animation
9786   float durationSeconds(1.0f);
9787   Animation animation = Animation::New(durationSeconds);
9788
9789   KeyFrames keyFrames = KeyFrames::New();
9790   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9791   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9792   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9793
9794   animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear );
9795
9796   // Start the animation
9797   animation.Play();
9798
9799   bool signalReceived(false);
9800   AnimationFinishCheck finishCheck(signalReceived);
9801   animation.FinishedSignal().Connect(&application, finishCheck);
9802   application.SendNotification();
9803   application.Render(0);
9804   application.SendNotification();
9805   finishCheck.CheckSignalNotReceived();
9806   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9807   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9808   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9809   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9810
9811   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9812   application.SendNotification();
9813   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
9814   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
9816   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9817
9818   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9819   application.SendNotification();
9820   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9821   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9822   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9823   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9824
9825   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9826   application.SendNotification();
9827   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
9828   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9829   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
9830   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9831
9832   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9833   application.SendNotification();
9834   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9835   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9836   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9837   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9838
9839   // We did expect the animation to finish
9840
9841   finishCheck.CheckSignalReceived();
9842   END_TEST;
9843 }
9844
9845 int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void)
9846 {
9847   TestApplication application;
9848
9849   float startValue(1.0f);
9850   Actor actor = Actor::New();
9851   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9852   Stage::GetCurrent().Add(actor);
9853
9854   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9855   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   startValue, TEST_LOCATION );
9856   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), startValue, TEST_LOCATION );
9857   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  startValue, TEST_LOCATION );
9858   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), startValue, TEST_LOCATION );
9859
9860   // Build the animation
9861   float durationSeconds(1.0f);
9862   Animation animation = Animation::New(durationSeconds);
9863
9864   KeyFrames keyFrames = KeyFrames::New();
9865   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9866   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9867   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9868
9869   animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) );
9870
9871   // Start the animation
9872   animation.Play();
9873
9874   bool signalReceived(false);
9875   AnimationFinishCheck finishCheck(signalReceived);
9876   animation.FinishedSignal().Connect(&application, finishCheck);
9877   application.SendNotification();
9878   application.Render(0);
9879   application.SendNotification();
9880   finishCheck.CheckSignalNotReceived();
9881   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9882   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9883   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9884   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9885
9886   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9887   application.SendNotification();
9888   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
9889   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9890   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
9891   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9892
9893   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9894   application.SendNotification();
9895   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9896   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9897   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9899
9900   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9901   application.SendNotification();
9902   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
9903   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9904   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
9905   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9906
9907   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9908   application.SendNotification();
9909   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9910   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9911   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9912   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9913
9914   // We did expect the animation to finish
9915
9916   finishCheck.CheckSignalReceived();
9917   END_TEST;
9918 }
9919
9920 int UtcDaliAnimationAnimateVector3Func(void)
9921 {
9922   TestApplication application;
9923
9924   Actor actor = Actor::New();
9925   Vector3 initialPosition(Vector3::ZERO);
9926   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9927   Stage::GetCurrent().Add(actor);
9928
9929   // Build the animation
9930   float durationSeconds(10.0f);
9931   Animation animation = Animation::New(durationSeconds);
9932   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
9933   BounceFunc func(0.0f, 0.0f, -100.0f);
9934   animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
9935
9936   // Start the animation
9937   animation.Play();
9938
9939   bool signalReceived(false);
9940   AnimationFinishCheck finishCheck(signalReceived);
9941   animation.FinishedSignal().Connect(&application, finishCheck);
9942
9943   application.SendNotification();
9944   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9945
9946   // We didn't expect the animation to finish yet
9947   application.SendNotification();
9948   finishCheck.CheckSignalNotReceived();
9949   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION );
9950
9951   application.SendNotification();
9952   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9953
9954   // We didn't expect the animation to finish yet
9955   application.SendNotification();
9956   finishCheck.CheckSignalNotReceived();
9957   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION );
9958
9959   application.SendNotification();
9960   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9961
9962   // We didn't expect the animation to finish yet
9963   application.SendNotification();
9964   finishCheck.CheckSignalNotReceived();
9965   DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION );
9966
9967   application.SendNotification();
9968   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9969
9970   // We did expect the animation to finish
9971   application.SendNotification();
9972   finishCheck.CheckSignalReceived();
9973   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
9974   END_TEST;
9975 }
9976
9977 int UtcDaliAnimationCreateDestroy(void)
9978 {
9979   TestApplication application;
9980   Animation* animation = new Animation;
9981   DALI_TEST_CHECK( animation );
9982   delete animation;
9983   END_TEST;
9984 }
9985
9986 struct UpdateManagerTestConstraint
9987 {
9988   UpdateManagerTestConstraint(TestApplication& application)
9989   : mApplication(application)
9990   {
9991   }
9992
9993   Vector3 operator()(const Vector3& current)
9994   {
9995     mApplication.SendNotification();  // Process events
9996     return current;
9997   }
9998
9999   TestApplication& mApplication;
10000 };
10001
10002 int UtcDaliAnimationUpdateManager(void)
10003 {
10004   TestApplication application;
10005
10006   Actor actor = Actor::New();
10007   Stage::GetCurrent().Add( actor );
10008
10009   // Build the animation
10010   Animation animation = Animation::New( 0.0f );
10011
10012   bool signalReceived = false;
10013   AnimationFinishCheck finishCheck( signalReceived );
10014   animation.FinishedSignal().Connect( &application, finishCheck );
10015
10016   Vector3 startValue(1.0f, 1.0f, 1.0f);
10017   Property::Index index = actor.RegisterProperty( "test-property", startValue );
10018   Constraint constraint = Constraint::New<Vector3>( index, UpdateManagerTestConstraint( application ) );
10019   actor.ApplyConstraint( constraint );
10020
10021   // Apply animation to actor
10022   BounceFunc func(0.0f, 0.0f, -100.0f);
10023   animation.Animate<Vector3>( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear );
10024
10025   animation.Play();
10026
10027   application.SendNotification();
10028   application.UpdateOnly( 16 );
10029
10030   finishCheck.CheckSignalNotReceived();
10031
10032   application.SendNotification();   // Process events
10033
10034   finishCheck.CheckSignalReceived();
10035
10036   END_TEST;
10037 }
10038
10039 int UtcDaliAnimationSignalOrder(void)
10040 {
10041   TestApplication application;
10042
10043   Actor actor = Actor::New();
10044   Stage::GetCurrent().Add( actor );
10045
10046   // Build the animations
10047   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10048   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10049
10050   bool signal1Received = false;
10051   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10052
10053   bool signal2Received = false;
10054   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10055
10056   // Apply animations to actor
10057   animation1.AnimateTo( Property(actor, Actor::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
10058   animation1.Play();
10059   animation2.AnimateTo( Property(actor, Actor::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
10060   animation2.Play();
10061
10062   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10063   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10064
10065   application.SendNotification();
10066   application.UpdateOnly( 10 ); // 10ms progress
10067
10068   // no notifications yet
10069   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10070   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10071
10072   application.SendNotification();
10073
10074   // first completed
10075   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10076   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10077   signal1Received = false;
10078
10079   // 1st animation is complete now, do another update with no ProcessEvents in between
10080   application.UpdateOnly( 20 ); // 20ms progress
10081
10082   // ProcessEvents
10083   application.SendNotification();
10084
10085   // 2nd should complete now
10086   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10087   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10088
10089   END_TEST;
10090 }
10091
10092 int UtcDaliAnimationExtendDuration(void)
10093 {
10094   TestApplication application;
10095
10096   Actor actor = Actor::New();
10097
10098   // Register a float property
10099   float startValue(10.0f);
10100   Property::Index index = actor.RegisterProperty( "test-property", startValue );
10101   Stage::GetCurrent().Add(actor);
10102   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10103
10104   // Build the animation
10105   float initialDurationSeconds(1.0f);
10106   float animatorDelay = 5.0f;
10107   float animatorDurationSeconds(5.0f);
10108   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10109   Animation animation = Animation::New(initialDurationSeconds);
10110   float targetValue(30.0f);
10111   float relativeValue(targetValue - startValue);
10112
10113   animation.AnimateTo(Property(actor, index),
10114                       targetValue,
10115                       TimePeriod(animatorDelay, animatorDurationSeconds));
10116
10117   // The duration should have been extended
10118   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10119
10120   // Start the animation
10121   animation.Play();
10122
10123   bool signalReceived(false);
10124   AnimationFinishCheck finishCheck(signalReceived);
10125   animation.FinishedSignal().Connect(&application, finishCheck);
10126
10127   application.SendNotification();
10128   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10129
10130   // We didn't expect the animation to finish yet
10131   application.SendNotification();
10132   finishCheck.CheckSignalNotReceived();
10133   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10134
10135   application.SendNotification();
10136   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10137
10138   // We didn't expect the animation to finish yet
10139   application.SendNotification();
10140   finishCheck.CheckSignalNotReceived();
10141   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
10142
10143   application.SendNotification();
10144   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10145
10146   // We did expect the animation to finish
10147   application.SendNotification();
10148   finishCheck.CheckSignalReceived();
10149   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
10150   END_TEST;
10151 }
10152