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