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