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