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