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