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