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