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