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