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