[dali_1.2.17] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2016 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 UtcDaliAnimationAnimateByActorOrientationP1(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 UtcDaliAnimationAnimateByActorOrientationP2(void)
4505 {
4506   TestApplication application;
4507
4508   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4509
4510   Actor actor = Actor::New();
4511   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4512   Stage::GetCurrent().Add(actor);
4513   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4514
4515   // Build the animation
4516   float durationSeconds(1.0f);
4517   Animation animation = Animation::New(durationSeconds);
4518   Degree relativeRotationDegrees(710.0f);
4519   Radian relativeRotationRadians(relativeRotationDegrees);
4520
4521   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4522
4523   // Start the animation
4524   animation.Play();
4525
4526   bool signalReceived(false);
4527   AnimationFinishCheck finishCheck(signalReceived);
4528   animation.FinishedSignal().Connect(&application, finishCheck);
4529
4530   application.SendNotification();
4531   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4532
4533   // We didn't expect the animation to finish yet
4534   application.SendNotification();
4535   finishCheck.CheckSignalNotReceived();
4536   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4537
4538   application.SendNotification();
4539   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4540
4541   // We didn't expect the animation to finish yet
4542   application.SendNotification();
4543   finishCheck.CheckSignalNotReceived();
4544   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4545
4546   application.SendNotification();
4547   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4548
4549   // We didn't expect the animation to finish yet
4550   application.SendNotification();
4551   finishCheck.CheckSignalNotReceived();
4552   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4553
4554   application.SendNotification();
4555   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4556
4557   // We did expect the animation to finish
4558   application.SendNotification();
4559   finishCheck.CheckSignalReceived();
4560   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4561   END_TEST;
4562 }
4563
4564
4565 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4566 {
4567   TestApplication application;
4568
4569   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4570
4571   Actor actor = Actor::New();
4572   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4573   Stage::GetCurrent().Add(actor);
4574   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4575
4576   // Build the animation
4577   float durationSeconds(1.0f);
4578   Animation animation = Animation::New(durationSeconds);
4579   Degree relativeRotationDegrees(730.0f);
4580   Radian relativeRotationRadians(relativeRotationDegrees);
4581
4582   Radian actualRotationRadians( Degree(10.0f) );
4583
4584   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4585
4586   // Start the animation
4587   animation.Play();
4588
4589   bool signalReceived(false);
4590   AnimationFinishCheck finishCheck(signalReceived);
4591   animation.FinishedSignal().Connect(&application, finishCheck);
4592
4593   application.SendNotification();
4594   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4595
4596   // We didn't expect the animation to finish yet
4597   application.SendNotification();
4598   finishCheck.CheckSignalNotReceived();
4599   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4600
4601   application.SendNotification();
4602   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4603
4604   // We didn't expect the animation to finish yet
4605   application.SendNotification();
4606   finishCheck.CheckSignalNotReceived();
4607   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4608
4609   application.SendNotification();
4610   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4611
4612   // We didn't expect the animation to finish yet
4613   application.SendNotification();
4614   finishCheck.CheckSignalNotReceived();
4615   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4616
4617   application.SendNotification();
4618   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4619
4620   // We did expect the animation to finish
4621   application.SendNotification();
4622   finishCheck.CheckSignalReceived();
4623   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4624   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4625   END_TEST;
4626 }
4627
4628
4629 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4630 {
4631   TestApplication application;
4632
4633   Actor actor = Actor::New();
4634   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4635   Stage::GetCurrent().Add(actor);
4636   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4637
4638   // Build the animation
4639   float durationSeconds(1.0f);
4640   Animation animation = Animation::New(durationSeconds);
4641   Degree relativeRotationDegrees(360.0f);
4642   Radian relativeRotationRadians(relativeRotationDegrees);
4643   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4644
4645   // Start the animation
4646   animation.Play();
4647
4648   bool signalReceived(false);
4649   AnimationFinishCheck finishCheck(signalReceived);
4650   animation.FinishedSignal().Connect(&application, finishCheck);
4651
4652   application.SendNotification();
4653   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4654
4655   // We didn't expect the animation to finish yet
4656   application.SendNotification();
4657   finishCheck.CheckSignalNotReceived();
4658   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4659
4660   application.SendNotification();
4661   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4662
4663   // We didn't expect the animation to finish yet
4664   application.SendNotification();
4665   finishCheck.CheckSignalNotReceived();
4666   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4667
4668   application.SendNotification();
4669   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4670
4671   // We didn't expect the animation to finish yet
4672   application.SendNotification();
4673   finishCheck.CheckSignalNotReceived();
4674   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4675
4676   application.SendNotification();
4677   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4678
4679   // We did expect the animation to finish
4680   application.SendNotification();
4681   finishCheck.CheckSignalReceived();
4682   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4683   END_TEST;
4684 }
4685
4686 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4687 {
4688   TestApplication application;
4689
4690   Actor actor = Actor::New();
4691   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4692   Stage::GetCurrent().Add(actor);
4693   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4694
4695   // Build the animation
4696   float durationSeconds(1.0f);
4697   Animation animation = Animation::New(durationSeconds);
4698   Degree relativeRotationDegrees(360.0f);
4699   Radian relativeRotationRadians(relativeRotationDegrees);
4700   float delay = 0.3f;
4701   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4702                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4703
4704   // Start the animation
4705   animation.Play();
4706
4707   bool signalReceived(false);
4708   AnimationFinishCheck finishCheck(signalReceived);
4709   animation.FinishedSignal().Connect(&application, finishCheck);
4710
4711   application.SendNotification();
4712   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4713
4714   // We didn't expect the animation to finish yet
4715   application.SendNotification();
4716   finishCheck.CheckSignalNotReceived();
4717   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4718   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4719
4720   application.SendNotification();
4721   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4722
4723   // We didn't expect the animation to finish yet
4724   application.SendNotification();
4725   finishCheck.CheckSignalNotReceived();
4726   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4727   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4728
4729   application.SendNotification();
4730   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4731
4732   // We didn't expect the animation to finish yet
4733   application.SendNotification();
4734   finishCheck.CheckSignalNotReceived();
4735   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4736   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4737
4738   application.SendNotification();
4739   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4740
4741   // We did expect the animation to finish
4742   application.SendNotification();
4743   finishCheck.CheckSignalReceived();
4744   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4745   END_TEST;
4746 }
4747
4748 int UtcDaliAnimationAnimateByActorScaleP(void)
4749 {
4750   TestApplication application;
4751
4752   Actor actor = Actor::New();
4753   Stage::GetCurrent().Add(actor);
4754   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4755
4756   // Build the animation
4757   float durationSeconds(1.0f);
4758   Animation animation = Animation::New(durationSeconds);
4759   Vector3 targetScale(2.0f, 2.0f, 2.0f);
4760   Vector3 relativeScale(targetScale - Vector3::ONE);
4761   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4762
4763   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4764
4765   // Start the animation
4766   animation.Play();
4767
4768   bool signalReceived(false);
4769   AnimationFinishCheck finishCheck(signalReceived);
4770   animation.FinishedSignal().Connect(&application, finishCheck);
4771
4772   application.SendNotification();
4773   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4774
4775   // We didn't expect the animation to finish yet
4776   application.SendNotification();
4777   finishCheck.CheckSignalNotReceived();
4778   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4779
4780   application.SendNotification();
4781   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4782
4783   // We did expect the animation to finish
4784   application.SendNotification();
4785   finishCheck.CheckSignalReceived();
4786   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4787
4788   // Reset everything
4789   finishCheck.Reset();
4790   actor.SetScale(Vector3::ONE);
4791   application.SendNotification();
4792   application.Render(0);
4793   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4794
4795   // Repeat with a different (ease-in) alpha function
4796   animation = Animation::New(durationSeconds);
4797   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4798   animation.FinishedSignal().Connect(&application, finishCheck);
4799   animation.Play();
4800
4801   application.SendNotification();
4802   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4803
4804   // We didn't expect the animation to finish yet
4805   application.SendNotification();
4806   finishCheck.CheckSignalNotReceived();
4807
4808   // The scale should have grown less, than with a linear alpha function
4809   Vector3 current(actor.GetCurrentScale());
4810   DALI_TEST_CHECK( current.x > 1.0f );
4811   DALI_TEST_CHECK( current.y > 1.0f );
4812   DALI_TEST_CHECK( current.z > 1.0f );
4813   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4814   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4815   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4816
4817   application.SendNotification();
4818   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4819
4820   // We did expect the animation to finish
4821   application.SendNotification();
4822   finishCheck.CheckSignalReceived();
4823   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4824
4825   // Reset everything
4826   finishCheck.Reset();
4827   actor.SetScale(Vector3::ONE);
4828   application.SendNotification();
4829   application.Render(0);
4830   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4831
4832   // Repeat with a delay
4833   float delay = 0.5f;
4834   animation = Animation::New(durationSeconds);
4835   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
4836   animation.FinishedSignal().Connect(&application, finishCheck);
4837   animation.Play();
4838
4839   application.SendNotification();
4840   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4841
4842   // We didn't expect the animation to finish yet
4843   application.SendNotification();
4844   finishCheck.CheckSignalNotReceived();
4845   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4846
4847   application.SendNotification();
4848   application.Render(static_cast<unsigned int>(durationSeconds*500.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_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4854   END_TEST;
4855 }
4856
4857 int UtcDaliAnimationAnimateToBooleanP(void)
4858 {
4859   TestApplication application;
4860
4861   Actor actor = Actor::New();
4862
4863   // Register a boolean property
4864   const bool startValue(false);
4865   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4866   Stage::GetCurrent().Add(actor);
4867   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4868
4869   // Build the animation
4870   float durationSeconds(2.0f);
4871   Animation animation = Animation::New(durationSeconds);
4872   const bool targetValue( !startValue );
4873   animation.AnimateTo(Property(actor, index), targetValue);
4874
4875   // Start the animation
4876   animation.Play();
4877
4878   bool signalReceived(false);
4879   AnimationFinishCheck finishCheck(signalReceived);
4880   animation.FinishedSignal().Connect(&application, finishCheck);
4881
4882   application.SendNotification();
4883   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4884
4885   // We didn't expect the animation to finish yet
4886   application.SendNotification();
4887   finishCheck.CheckSignalNotReceived();
4888   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4889
4890   application.SendNotification();
4891   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4892
4893   // We did expect the animation to finish
4894   application.SendNotification();
4895   finishCheck.CheckSignalReceived();
4896   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4897
4898   // Check that nothing has changed after a couple of buffer swaps
4899   application.Render(0);
4900   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4901   application.Render(0);
4902   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4903
4904   // Repeat with target value "false"
4905   animation = Animation::New(durationSeconds);
4906   const bool finalValue( !targetValue );
4907   animation.AnimateTo(Property(actor, index), finalValue);
4908
4909   // Start the animation
4910   animation.Play();
4911
4912   finishCheck.Reset();
4913   animation.FinishedSignal().Connect(&application, finishCheck);
4914
4915   application.SendNotification();
4916   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4917
4918   // We didn't expect the animation to finish yet
4919   application.SendNotification();
4920   finishCheck.CheckSignalNotReceived();
4921   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4922
4923   application.SendNotification();
4924   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4925
4926   // We did expect the animation to finish
4927   application.SendNotification();
4928   finishCheck.CheckSignalReceived();
4929   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4930
4931   // Check that nothing has changed after a couple of buffer swaps
4932   application.Render(0);
4933   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4934   application.Render(0);
4935   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4936   END_TEST;
4937 }
4938
4939 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
4940 {
4941   TestApplication application;
4942
4943   Actor actor = Actor::New();
4944
4945   // Register a boolean property
4946   const bool startValue(false);
4947   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4948   Stage::GetCurrent().Add(actor);
4949   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4950
4951   // Build the animation
4952   float durationSeconds(2.0f);
4953   Animation animation = Animation::New(durationSeconds);
4954   const bool targetValue( !startValue );
4955   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
4956
4957   // Start the animation
4958   animation.Play();
4959
4960   bool signalReceived(false);
4961   AnimationFinishCheck finishCheck(signalReceived);
4962   animation.FinishedSignal().Connect(&application, finishCheck);
4963
4964   application.SendNotification();
4965   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4966
4967   // We didn't expect the animation to finish yet
4968   application.SendNotification();
4969   finishCheck.CheckSignalNotReceived();
4970   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4971
4972   application.SendNotification();
4973   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4974
4975   // We did expect the animation to finish
4976   application.SendNotification();
4977   finishCheck.CheckSignalReceived();
4978   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4979
4980   // Check that nothing has changed after a couple of buffer swaps
4981   application.Render(0);
4982   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4983   application.Render(0);
4984   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
4985
4986   // Repeat with target value "false"
4987   animation = Animation::New(durationSeconds);
4988   const bool finalValue( !targetValue );
4989   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
4990
4991   // Start the animation
4992   animation.Play();
4993
4994   finishCheck.Reset();
4995   animation.FinishedSignal().Connect(&application, finishCheck);
4996
4997   application.SendNotification();
4998   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4999
5000   // We didn't expect the animation to finish yet
5001   application.SendNotification();
5002   finishCheck.CheckSignalNotReceived();
5003   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
5004
5005   application.SendNotification();
5006   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*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 UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5022 {
5023   TestApplication application;
5024
5025   Actor actor = Actor::New();
5026
5027   // Register a boolean property
5028   bool startValue(false);
5029   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5030   Stage::GetCurrent().Add(actor);
5031   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5032
5033   // Build the animation
5034   float durationSeconds(2.0f);
5035   Animation animation = Animation::New(durationSeconds);
5036   bool finalValue( !startValue );
5037   float animatorDurationSeconds(durationSeconds * 0.5f);
5038   animation.AnimateTo( Property(actor, index),
5039                        finalValue,
5040                        TimePeriod( animatorDurationSeconds ) );
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>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5051
5052   // We didn't expect the animation to finish yet
5053   application.SendNotification();
5054   finishCheck.CheckSignalNotReceived();
5055   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5056
5057   application.SendNotification();
5058   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5059
5060   // We didn't expect the animation to finish yet...
5061   application.SendNotification();
5062   finishCheck.CheckSignalNotReceived();
5063
5064   // ...however we should have reached the final value
5065   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5066
5067   application.SendNotification();
5068   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5069
5070   // We did expect the animation to finish
5071   application.SendNotification();
5072   finishCheck.CheckSignalReceived();
5073   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5074
5075   // Check that nothing has changed after a couple of buffer swaps
5076   application.Render(0);
5077   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5078   application.Render(0);
5079   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5080   END_TEST;
5081 }
5082
5083 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5084 {
5085   TestApplication application;
5086
5087   Actor actor = Actor::New();
5088
5089   // Register a boolean property
5090   bool startValue(false);
5091   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5092   Stage::GetCurrent().Add(actor);
5093   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5094
5095   // Build the animation
5096   float durationSeconds(2.0f);
5097   Animation animation = Animation::New(durationSeconds);
5098   bool finalValue( !startValue );
5099   float animatorDurationSeconds(durationSeconds * 0.5f);
5100   animation.AnimateTo( Property(actor, index),
5101                        finalValue,
5102                        AlphaFunction::LINEAR,
5103                        TimePeriod( animatorDurationSeconds ) );
5104
5105   // Start the animation
5106   animation.Play();
5107
5108   bool signalReceived(false);
5109   AnimationFinishCheck finishCheck(signalReceived);
5110   animation.FinishedSignal().Connect(&application, finishCheck);
5111
5112   application.SendNotification();
5113   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5114
5115   // We didn't expect the animation to finish yet
5116   application.SendNotification();
5117   finishCheck.CheckSignalNotReceived();
5118   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5119
5120   application.SendNotification();
5121   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5122
5123   // We didn't expect the animation to finish yet...
5124   application.SendNotification();
5125   finishCheck.CheckSignalNotReceived();
5126
5127   // ...however we should have reached the final value
5128   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5129
5130   application.SendNotification();
5131   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5132
5133   // We did expect the animation to finish
5134   application.SendNotification();
5135   finishCheck.CheckSignalReceived();
5136   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5137
5138   // Check that nothing has changed after a couple of buffer swaps
5139   application.Render(0);
5140   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5141   application.Render(0);
5142   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
5143   END_TEST;
5144 }
5145
5146 int UtcDaliAnimationAnimateToFloatP(void)
5147 {
5148   TestApplication application;
5149
5150   Actor actor = Actor::New();
5151
5152   // Register a float property
5153   float startValue(10.0f);
5154   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5155   Stage::GetCurrent().Add(actor);
5156   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5157
5158   // Build the animation
5159   float durationSeconds(2.0f);
5160   Animation animation = Animation::New(durationSeconds);
5161   float targetValue(50.0f);
5162   float relativeValue(targetValue - startValue);
5163   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5164
5165   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5166
5167   // Start the animation
5168   animation.Play();
5169
5170   bool signalReceived(false);
5171   AnimationFinishCheck finishCheck(signalReceived);
5172   animation.FinishedSignal().Connect(&application, finishCheck);
5173
5174   application.SendNotification();
5175   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5176
5177   // We didn't expect the animation to finish yet
5178   application.SendNotification();
5179   finishCheck.CheckSignalNotReceived();
5180   DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
5181
5182   application.SendNotification();
5183   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5184
5185   // We did expect the animation to finish
5186   application.SendNotification();
5187   finishCheck.CheckSignalReceived();
5188   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
5189   END_TEST;
5190 }
5191
5192 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5193 {
5194   TestApplication application;
5195
5196   Actor actor = Actor::New();
5197
5198   // Register a float property
5199   float startValue(10.0f);
5200   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5201   Stage::GetCurrent().Add(actor);
5202   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5203
5204   // Build the animation
5205   float durationSeconds(1.0f);
5206   Animation animation = Animation::New(durationSeconds);
5207   float targetValue(90.0f);
5208   float relativeValue(targetValue - startValue);
5209   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5210
5211   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5212
5213   // Start the animation
5214   animation.Play();
5215
5216   bool signalReceived(false);
5217   AnimationFinishCheck finishCheck(signalReceived);
5218   animation.FinishedSignal().Connect(&application, finishCheck);
5219
5220   application.SendNotification();
5221   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5222
5223   // We didn't expect the animation to finish yet
5224   application.SendNotification();
5225   finishCheck.CheckSignalNotReceived();
5226
5227   // The position should have moved more, than with a linear alpha function
5228   float current(actor.GetProperty<float>(index));
5229   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5230
5231   application.SendNotification();
5232   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5233
5234   // We did expect the animation to finish
5235   application.SendNotification();
5236   finishCheck.CheckSignalReceived();
5237   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
5238   END_TEST;
5239 }
5240
5241 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5242 {
5243   TestApplication application;
5244
5245   Actor actor = Actor::New();
5246
5247   // Register a float property
5248   float startValue(10.0f);
5249   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5250   Stage::GetCurrent().Add(actor);
5251   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5252
5253   // Build the animation
5254   float durationSeconds(1.0f);
5255   Animation animation = Animation::New(durationSeconds);
5256   float targetValue(30.0f);
5257   float relativeValue(targetValue - startValue);
5258   float delay = 0.5f;
5259   animation.AnimateTo(Property(actor, index),
5260                       targetValue,
5261                       TimePeriod(delay, durationSeconds - delay));
5262
5263   // Start the animation
5264   animation.Play();
5265
5266   bool signalReceived(false);
5267   AnimationFinishCheck finishCheck(signalReceived);
5268   animation.FinishedSignal().Connect(&application, finishCheck);
5269
5270   application.SendNotification();
5271   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5272
5273   // We didn't expect the animation to finish yet
5274   application.SendNotification();
5275   finishCheck.CheckSignalNotReceived();
5276   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5277
5278   application.SendNotification();
5279   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5280
5281   // We didn't expect the animation to finish yet
5282   application.SendNotification();
5283   finishCheck.CheckSignalNotReceived();
5284   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5285
5286   application.SendNotification();
5287   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5288
5289   // We did expect the animation to finish
5290   application.SendNotification();
5291   finishCheck.CheckSignalReceived();
5292   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
5293   END_TEST;
5294 }
5295
5296 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5297 {
5298   TestApplication application;
5299
5300   Actor actor = Actor::New();
5301
5302   // Register a float property
5303   float startValue(10.0f);
5304   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5305   Stage::GetCurrent().Add(actor);
5306   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5307
5308   // Build the animation
5309   float durationSeconds(1.0f);
5310   Animation animation = Animation::New(durationSeconds);
5311   float targetValue(30.0f);
5312   float relativeValue(targetValue - startValue);
5313   float delay = 0.5f;
5314   animation.AnimateTo(Property(actor, index),
5315                       targetValue,
5316                       AlphaFunction::LINEAR,
5317                       TimePeriod(delay, durationSeconds - delay));
5318
5319   // Start the animation
5320   animation.Play();
5321
5322   bool signalReceived(false);
5323   AnimationFinishCheck finishCheck(signalReceived);
5324   animation.FinishedSignal().Connect(&application, finishCheck);
5325
5326   application.SendNotification();
5327   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5328
5329   // We didn't expect the animation to finish yet
5330   application.SendNotification();
5331   finishCheck.CheckSignalNotReceived();
5332   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5333
5334   application.SendNotification();
5335   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5336
5337   // We didn't expect the animation to finish yet
5338   application.SendNotification();
5339   finishCheck.CheckSignalNotReceived();
5340   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5341
5342   application.SendNotification();
5343   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5344
5345   // We did expect the animation to finish
5346   application.SendNotification();
5347   finishCheck.CheckSignalReceived();
5348   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
5349   END_TEST;
5350 }
5351
5352 int UtcDaliAnimationAnimateToIntegerP(void)
5353 {
5354   TestApplication application;
5355
5356   Actor actor = Actor::New();
5357
5358   // Register an integer property
5359   int startValue(10);
5360   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5361   Stage::GetCurrent().Add(actor);
5362   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5363
5364   // Build the animation
5365   float durationSeconds(2.0f);
5366   Animation animation = Animation::New(durationSeconds);
5367   int targetValue(50);
5368   int relativeValue(targetValue - startValue);
5369   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5370
5371   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5372
5373   // Start the animation
5374   animation.Play();
5375
5376   bool signalReceived(false);
5377   AnimationFinishCheck finishCheck(signalReceived);
5378   animation.FinishedSignal().Connect(&application, finishCheck);
5379
5380   application.SendNotification();
5381   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5382
5383   // We didn't expect the animation to finish yet
5384   application.SendNotification();
5385   finishCheck.CheckSignalNotReceived();
5386   DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
5387
5388   application.SendNotification();
5389   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5390
5391   // We did expect the animation to finish
5392   application.SendNotification();
5393   finishCheck.CheckSignalReceived();
5394   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
5395   END_TEST;
5396 }
5397
5398 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5399 {
5400   TestApplication application;
5401
5402   Actor actor = Actor::New();
5403
5404   // Register an integer property
5405   int startValue(10);
5406   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5407   Stage::GetCurrent().Add(actor);
5408   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5409
5410   // Build the animation
5411   float durationSeconds(1.0f);
5412   Animation animation = Animation::New(durationSeconds);
5413   int targetValue(90);
5414   int relativeValue(targetValue - startValue);
5415   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5416
5417   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5418
5419   // Start the animation
5420   animation.Play();
5421
5422   bool signalReceived(false);
5423   AnimationFinishCheck finishCheck(signalReceived);
5424   animation.FinishedSignal().Connect(&application, finishCheck);
5425
5426   application.SendNotification();
5427   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5428
5429   // We didn't expect the animation to finish yet
5430   application.SendNotification();
5431   finishCheck.CheckSignalNotReceived();
5432
5433   // The position should have moved more, than with a linear alpha function
5434   int current(actor.GetProperty<int>(index));
5435   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5436
5437   application.SendNotification();
5438   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5439
5440   // We did expect the animation to finish
5441   application.SendNotification();
5442   finishCheck.CheckSignalReceived();
5443   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
5444   END_TEST;
5445 }
5446
5447 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5448 {
5449   TestApplication application;
5450
5451   Actor actor = Actor::New();
5452
5453   // Register an integer property
5454   int startValue(10);
5455   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5456   Stage::GetCurrent().Add(actor);
5457   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5458
5459   // Build the animation
5460   float durationSeconds(1.0f);
5461   Animation animation = Animation::New(durationSeconds);
5462   int targetValue(30);
5463   int relativeValue(targetValue - startValue);
5464   float delay = 0.5f;
5465   animation.AnimateTo(Property(actor, index),
5466                       targetValue,
5467                       TimePeriod(delay, durationSeconds - delay));
5468
5469   // Start the animation
5470   animation.Play();
5471
5472   bool signalReceived(false);
5473   AnimationFinishCheck finishCheck(signalReceived);
5474   animation.FinishedSignal().Connect(&application, finishCheck);
5475
5476   application.SendNotification();
5477   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5478
5479   // We didn't expect the animation to finish yet
5480   application.SendNotification();
5481   finishCheck.CheckSignalNotReceived();
5482   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5483
5484   application.SendNotification();
5485   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5486
5487   // We didn't expect the animation to finish yet
5488   application.SendNotification();
5489   finishCheck.CheckSignalNotReceived();
5490   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5491
5492   application.SendNotification();
5493   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5494
5495   // We did expect the animation to finish
5496   application.SendNotification();
5497   finishCheck.CheckSignalReceived();
5498   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
5499   END_TEST;
5500 }
5501
5502 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5503 {
5504   TestApplication application;
5505
5506   Actor actor = Actor::New();
5507
5508   // Register an integer property
5509   int startValue(10);
5510   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5511   Stage::GetCurrent().Add(actor);
5512   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5513
5514   // Build the animation
5515   float durationSeconds(1.0f);
5516   Animation animation = Animation::New(durationSeconds);
5517   int targetValue(30);
5518   int relativeValue(targetValue - startValue);
5519   float delay = 0.5f;
5520   animation.AnimateTo(Property(actor, index),
5521                       targetValue,
5522                       AlphaFunction::LINEAR,
5523                       TimePeriod(delay, durationSeconds - delay));
5524
5525   // Start the animation
5526   animation.Play();
5527
5528   bool signalReceived(false);
5529   AnimationFinishCheck finishCheck(signalReceived);
5530   animation.FinishedSignal().Connect(&application, finishCheck);
5531
5532   application.SendNotification();
5533   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5534
5535   // We didn't expect the animation to finish yet
5536   application.SendNotification();
5537   finishCheck.CheckSignalNotReceived();
5538   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5539
5540   application.SendNotification();
5541   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5542
5543   // We didn't expect the animation to finish yet
5544   application.SendNotification();
5545   finishCheck.CheckSignalNotReceived();
5546   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5547
5548   application.SendNotification();
5549   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5550
5551   // We did expect the animation to finish
5552   application.SendNotification();
5553   finishCheck.CheckSignalReceived();
5554   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
5555   END_TEST;
5556 }
5557
5558 int UtcDaliAnimationAnimateToVector2P(void)
5559 {
5560   TestApplication application;
5561
5562   Actor actor = Actor::New();
5563
5564   // Register a Vector2 property
5565   Vector2 startValue(-50.0f, -50.0f);
5566   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5567   Stage::GetCurrent().Add(actor);
5568   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5569
5570   // Build the animation
5571   float durationSeconds(2.0f);
5572   Animation animation = Animation::New(durationSeconds);
5573   Vector2 targetValue(50.0f, 50.0f);
5574   Vector2 relativeValue(targetValue - startValue);
5575   animation.AnimateTo(Property(actor, index), targetValue);
5576
5577   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5578
5579   // Start the animation
5580   animation.Play();
5581
5582   bool signalReceived(false);
5583   AnimationFinishCheck finishCheck(signalReceived);
5584   animation.FinishedSignal().Connect(&application, finishCheck);
5585
5586   application.SendNotification();
5587   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5588
5589   // We didn't expect the animation to finish yet
5590   application.SendNotification();
5591   finishCheck.CheckSignalNotReceived();
5592   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
5593
5594   application.SendNotification();
5595   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5596
5597   // We did expect the animation to finish
5598   application.SendNotification();
5599   finishCheck.CheckSignalReceived();
5600   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
5601   END_TEST;
5602 }
5603
5604 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
5605 {
5606   TestApplication application;
5607
5608   Actor actor = Actor::New();
5609
5610   // Register a Vector2 property
5611   Vector2 startValue(1000.0f, 1000.0f);
5612   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5613   Stage::GetCurrent().Add(actor);
5614   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5615
5616   // Build the animation
5617   float durationSeconds(1.0f);
5618   Animation animation = Animation::New(durationSeconds);
5619   Vector2 targetValue(9000.0f, 9000.0f);
5620   Vector2 relativeValue(targetValue - startValue);
5621   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5622
5623   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5624
5625   // Start the animation
5626   animation.Play();
5627
5628   bool signalReceived(false);
5629   AnimationFinishCheck finishCheck(signalReceived);
5630   animation.FinishedSignal().Connect(&application, finishCheck);
5631
5632   application.SendNotification();
5633   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5634
5635   // We didn't expect the animation to finish yet
5636   application.SendNotification();
5637   finishCheck.CheckSignalNotReceived();
5638
5639   // The position should have moved more, than with a linear alpha function
5640   Vector2 current(actor.GetProperty<Vector2>(index));
5641   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
5642   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
5643
5644   application.SendNotification();
5645   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5646
5647   // We did expect the animation to finish
5648   application.SendNotification();
5649   finishCheck.CheckSignalReceived();
5650   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
5651   END_TEST;
5652 }
5653
5654 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
5655 {
5656   TestApplication application;
5657
5658   Actor actor = Actor::New();
5659
5660   // Register a Vector2 property
5661   Vector2 startValue(10.0f, 10.0f);
5662   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5663   Stage::GetCurrent().Add(actor);
5664   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5665
5666   // Build the animation
5667   float durationSeconds(1.0f);
5668   Animation animation = Animation::New(durationSeconds);
5669   Vector2 targetValue(-10.0f, 20.0f);
5670   Vector2 relativeValue(targetValue - startValue);
5671   float delay = 0.5f;
5672   animation.AnimateTo(Property(actor, index),
5673                       targetValue,
5674                       TimePeriod(delay, durationSeconds - delay));
5675
5676   // Start the animation
5677   animation.Play();
5678
5679   bool signalReceived(false);
5680   AnimationFinishCheck finishCheck(signalReceived);
5681   animation.FinishedSignal().Connect(&application, finishCheck);
5682
5683   application.SendNotification();
5684   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5685
5686   // We didn't expect the animation to finish yet
5687   application.SendNotification();
5688   finishCheck.CheckSignalNotReceived();
5689   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5690
5691   application.SendNotification();
5692   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5693
5694   // We didn't expect the animation to finish yet
5695   application.SendNotification();
5696   finishCheck.CheckSignalNotReceived();
5697   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5698
5699   application.SendNotification();
5700   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5701
5702   // We did expect the animation to finish
5703   application.SendNotification();
5704   finishCheck.CheckSignalReceived();
5705   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
5706   END_TEST;
5707 }
5708
5709 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
5710 {
5711   TestApplication application;
5712
5713   Actor actor = Actor::New();
5714
5715   // Register a Vector2 property
5716   Vector2 startValue(10.0f, 10.0f);
5717   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5718   Stage::GetCurrent().Add(actor);
5719   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5720
5721   // Build the animation
5722   float durationSeconds(1.0f);
5723   Animation animation = Animation::New(durationSeconds);
5724   Vector2 targetValue(30.0f, 30.0f);
5725   Vector2 relativeValue(targetValue - startValue);
5726   float delay = 0.5f;
5727   animation.AnimateTo(Property(actor, index),
5728                       targetValue,
5729                       AlphaFunction::LINEAR,
5730                       TimePeriod(delay, durationSeconds - delay));
5731
5732   // Start the animation
5733   animation.Play();
5734
5735   bool signalReceived(false);
5736   AnimationFinishCheck finishCheck(signalReceived);
5737   animation.FinishedSignal().Connect(&application, finishCheck);
5738
5739   application.SendNotification();
5740   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5741
5742   // We didn't expect the animation to finish yet
5743   application.SendNotification();
5744   finishCheck.CheckSignalNotReceived();
5745   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
5746
5747   application.SendNotification();
5748   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5749
5750   // We didn't expect the animation to finish yet
5751   application.SendNotification();
5752   finishCheck.CheckSignalNotReceived();
5753   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5754
5755   application.SendNotification();
5756   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5757
5758   // We did expect the animation to finish
5759   application.SendNotification();
5760   finishCheck.CheckSignalReceived();
5761   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
5762   END_TEST;
5763 }
5764
5765 int UtcDaliAnimationAnimateToVector3P(void)
5766 {
5767   TestApplication application;
5768
5769   Actor actor = Actor::New();
5770
5771   // Register a Vector3 property
5772   Vector3 startValue(-50.0f, -50.0f, -50.0f);
5773   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5774   Stage::GetCurrent().Add(actor);
5775   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5776
5777   // Build the animation
5778   float durationSeconds(2.0f);
5779   Animation animation = Animation::New(durationSeconds);
5780   Vector3 targetValue(50.0f, 50.0f, 50.0f);
5781   Vector3 relativeValue(targetValue - startValue);
5782   animation.AnimateTo(Property(actor, index), targetValue);
5783
5784   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5785
5786   // Start the animation
5787   animation.Play();
5788
5789   bool signalReceived(false);
5790   AnimationFinishCheck finishCheck(signalReceived);
5791   animation.FinishedSignal().Connect(&application, finishCheck);
5792
5793   application.SendNotification();
5794   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5795
5796   // We didn't expect the animation to finish yet
5797   application.SendNotification();
5798   finishCheck.CheckSignalNotReceived();
5799   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
5800
5801   application.SendNotification();
5802   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5803
5804   // We did expect the animation to finish
5805   application.SendNotification();
5806   finishCheck.CheckSignalReceived();
5807   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
5808   END_TEST;
5809 }
5810
5811 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
5812 {
5813   TestApplication application;
5814
5815   Actor actor = Actor::New();
5816
5817   // Register a Vector3 property
5818   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
5819   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5820   Stage::GetCurrent().Add(actor);
5821   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5822
5823   // Build the animation
5824   float durationSeconds(1.0f);
5825   Animation animation = Animation::New(durationSeconds);
5826   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
5827   Vector3 relativeValue(targetValue - startValue);
5828   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5829
5830   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5831
5832   // Start the animation
5833   animation.Play();
5834
5835   bool signalReceived(false);
5836   AnimationFinishCheck finishCheck(signalReceived);
5837   animation.FinishedSignal().Connect(&application, finishCheck);
5838
5839   application.SendNotification();
5840   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5841
5842   // We didn't expect the animation to finish yet
5843   application.SendNotification();
5844   finishCheck.CheckSignalNotReceived();
5845
5846   // The position should have moved more, than with a linear alpha function
5847   Vector3 current(actor.GetProperty<Vector3>(index));
5848   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
5849   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
5850   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
5851
5852   application.SendNotification();
5853   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5854
5855   // We did expect the animation to finish
5856   application.SendNotification();
5857   finishCheck.CheckSignalReceived();
5858   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
5859   END_TEST;
5860 }
5861
5862 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
5863 {
5864   TestApplication application;
5865
5866   Actor actor = Actor::New();
5867
5868   // Register a Vector3 property
5869   Vector3 startValue(10.0f, 10.0f, 10.0f);
5870   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5871   Stage::GetCurrent().Add(actor);
5872   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5873
5874   // Build the animation
5875   float durationSeconds(1.0f);
5876   Animation animation = Animation::New(durationSeconds);
5877   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
5878   Vector3 relativeValue(targetValue - startValue);
5879   float delay = 0.5f;
5880   animation.AnimateTo(Property(actor, index),
5881                       targetValue,
5882                       TimePeriod(delay, durationSeconds - delay));
5883
5884   // Start the animation
5885   animation.Play();
5886
5887   bool signalReceived(false);
5888   AnimationFinishCheck finishCheck(signalReceived);
5889   animation.FinishedSignal().Connect(&application, finishCheck);
5890
5891   application.SendNotification();
5892   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5893
5894   // We didn't expect the animation to finish yet
5895   application.SendNotification();
5896   finishCheck.CheckSignalNotReceived();
5897   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5898
5899   application.SendNotification();
5900   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5901
5902   // We didn't expect the animation to finish yet
5903   application.SendNotification();
5904   finishCheck.CheckSignalNotReceived();
5905   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5906
5907   application.SendNotification();
5908   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5909
5910   // We did expect the animation to finish
5911   application.SendNotification();
5912   finishCheck.CheckSignalReceived();
5913   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
5914   END_TEST;
5915 }
5916
5917 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
5918 {
5919   TestApplication application;
5920
5921   Actor actor = Actor::New();
5922
5923   // Register a Vector3 property
5924   Vector3 startValue(10.0f, 10.0f, 10.0f);
5925   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5926   Stage::GetCurrent().Add(actor);
5927   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5928
5929   // Build the animation
5930   float durationSeconds(1.0f);
5931   Animation animation = Animation::New(durationSeconds);
5932   Vector3 targetValue(30.0f, 30.0f, 30.0f);
5933   Vector3 relativeValue(targetValue - startValue);
5934   float delay = 0.5f;
5935   animation.AnimateTo(Property(actor, "testProperty"),
5936                       targetValue,
5937                       AlphaFunction::LINEAR,
5938                       TimePeriod(delay, durationSeconds - delay));
5939
5940   // Start the animation
5941   animation.Play();
5942
5943   bool signalReceived(false);
5944   AnimationFinishCheck finishCheck(signalReceived);
5945   animation.FinishedSignal().Connect(&application, finishCheck);
5946
5947   application.SendNotification();
5948   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5949
5950   // We didn't expect the animation to finish yet
5951   application.SendNotification();
5952   finishCheck.CheckSignalNotReceived();
5953   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5954
5955   application.SendNotification();
5956   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5957
5958   // We didn't expect the animation to finish yet
5959   application.SendNotification();
5960   finishCheck.CheckSignalNotReceived();
5961   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5962
5963   application.SendNotification();
5964   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5965
5966   // We did expect the animation to finish
5967   application.SendNotification();
5968   finishCheck.CheckSignalReceived();
5969   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
5970   END_TEST;
5971 }
5972
5973 int UtcDaliAnimationAnimateToVector3ComponentP(void)
5974 {
5975   TestApplication application;
5976
5977   Actor actor = Actor::New();
5978
5979   // Register a Vector3 property
5980   Vector3 startValue(10.0f, 10.0f, 10.0f);
5981   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5982   Stage::GetCurrent().Add(actor);
5983   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5984
5985   // Build the animation
5986   float durationSeconds(1.0f);
5987   Animation animation = Animation::New(durationSeconds);
5988   Vector3 targetValue(30.0f, 30.0f, 10.0f);
5989   Vector3 relativeValue(targetValue - startValue);
5990   float delay = 0.5f;
5991   animation.AnimateTo(Property(actor, "testProperty",  0),
5992                       30.0f,
5993                       AlphaFunction::LINEAR,
5994                       TimePeriod(delay, durationSeconds - delay));
5995   animation.AnimateTo(Property(actor, index, 1),
5996                       30.0f,
5997                       AlphaFunction::LINEAR,
5998                       TimePeriod(delay, durationSeconds - delay));
5999
6000   // Start the animation
6001   animation.Play();
6002
6003   bool signalReceived(false);
6004   AnimationFinishCheck finishCheck(signalReceived);
6005   animation.FinishedSignal().Connect(&application, finishCheck);
6006
6007   application.SendNotification();
6008   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6009
6010   // We didn't expect the animation to finish yet
6011   application.SendNotification();
6012   finishCheck.CheckSignalNotReceived();
6013   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6014
6015   application.SendNotification();
6016   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6017
6018   // We didn't expect the animation to finish yet
6019   application.SendNotification();
6020   finishCheck.CheckSignalNotReceived();
6021   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
6022
6023   application.SendNotification();
6024   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6025
6026   // We did expect the animation to finish
6027   application.SendNotification();
6028   finishCheck.CheckSignalReceived();
6029   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
6030   END_TEST;
6031 }
6032
6033 int UtcDaliAnimationAnimateToVector4P(void)
6034 {
6035   TestApplication application;
6036
6037   Actor actor = Actor::New();
6038
6039   // Register a Vector4 property
6040   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6041   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6042   Stage::GetCurrent().Add(actor);
6043   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6044
6045   // Build the animation
6046   float durationSeconds(2.0f);
6047   Animation animation = Animation::New(durationSeconds);
6048   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6049   Vector4 relativeValue(targetValue - startValue);
6050   animation.AnimateTo(Property(actor, index), targetValue);
6051
6052   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6053
6054   // Start the animation
6055   animation.Play();
6056
6057   bool signalReceived(false);
6058   AnimationFinishCheck finishCheck(signalReceived);
6059   animation.FinishedSignal().Connect(&application, finishCheck);
6060
6061   application.SendNotification();
6062   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6063
6064   // We didn't expect the animation to finish yet
6065   application.SendNotification();
6066   finishCheck.CheckSignalNotReceived();
6067   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
6068
6069   application.SendNotification();
6070   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6071
6072   // We did expect the animation to finish
6073   application.SendNotification();
6074   finishCheck.CheckSignalReceived();
6075   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
6076   END_TEST;
6077 }
6078
6079 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6080 {
6081   TestApplication application;
6082
6083   Actor actor = Actor::New();
6084
6085   // Register a Vector4 property
6086   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6087   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6088   Stage::GetCurrent().Add(actor);
6089   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6090
6091   // Build the animation
6092   float durationSeconds(1.0f);
6093   Animation animation = Animation::New(durationSeconds);
6094   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6095   Vector4 relativeValue(targetValue - startValue);
6096   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6097
6098   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6099
6100   // Start the animation
6101   animation.Play();
6102
6103   bool signalReceived(false);
6104   AnimationFinishCheck finishCheck(signalReceived);
6105   animation.FinishedSignal().Connect(&application, finishCheck);
6106
6107   application.SendNotification();
6108   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6109
6110   // We didn't expect the animation to finish yet
6111   application.SendNotification();
6112   finishCheck.CheckSignalNotReceived();
6113
6114   // The position should have moved more, than with a linear alpha function
6115   Vector4 current(actor.GetProperty<Vector4>(index));
6116   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6117   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6118   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6119   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6120
6121   application.SendNotification();
6122   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6123
6124   // We did expect the animation to finish
6125   application.SendNotification();
6126   finishCheck.CheckSignalReceived();
6127   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
6128   END_TEST;
6129 }
6130
6131 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6132 {
6133   TestApplication application;
6134
6135   Actor actor = Actor::New();
6136
6137   // Register a Vector4 property
6138   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6139   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6140   Stage::GetCurrent().Add(actor);
6141   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6142
6143   // Build the animation
6144   float durationSeconds(1.0f);
6145   Animation animation = Animation::New(durationSeconds);
6146   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6147   Vector4 relativeValue(targetValue - startValue);
6148   float delay = 0.5f;
6149   animation.AnimateTo(Property(actor, index),
6150                       targetValue,
6151                       TimePeriod(delay, durationSeconds - delay));
6152
6153   // Start the animation
6154   animation.Play();
6155
6156   bool signalReceived(false);
6157   AnimationFinishCheck finishCheck(signalReceived);
6158   animation.FinishedSignal().Connect(&application, finishCheck);
6159
6160   application.SendNotification();
6161   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6162
6163   // We didn't expect the animation to finish yet
6164   application.SendNotification();
6165   finishCheck.CheckSignalNotReceived();
6166   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6167
6168   application.SendNotification();
6169   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6170
6171   // We didn't expect the animation to finish yet
6172   application.SendNotification();
6173   finishCheck.CheckSignalNotReceived();
6174   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6175
6176   application.SendNotification();
6177   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6178
6179   // We did expect the animation to finish
6180   application.SendNotification();
6181   finishCheck.CheckSignalReceived();
6182   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6183   END_TEST;
6184 }
6185
6186 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6187 {
6188   TestApplication application;
6189
6190   Actor actor = Actor::New();
6191
6192   // Register a Vector4 property
6193   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6194   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6195   Stage::GetCurrent().Add(actor);
6196   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6197
6198   // Build the animation
6199   float durationSeconds(1.0f);
6200   Animation animation = Animation::New(durationSeconds);
6201   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6202   Vector4 relativeValue(targetValue - startValue);
6203   float delay = 0.5f;
6204   animation.AnimateTo(Property(actor, index),
6205                       targetValue,
6206                       AlphaFunction::LINEAR,
6207                       TimePeriod(delay, durationSeconds - delay));
6208
6209   // Start the animation
6210   animation.Play();
6211
6212   bool signalReceived(false);
6213   AnimationFinishCheck finishCheck(signalReceived);
6214   animation.FinishedSignal().Connect(&application, finishCheck);
6215
6216   application.SendNotification();
6217   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6218
6219   // We didn't expect the animation to finish yet
6220   application.SendNotification();
6221   finishCheck.CheckSignalNotReceived();
6222   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6223
6224   application.SendNotification();
6225   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6226
6227   // We didn't expect the animation to finish yet
6228   application.SendNotification();
6229   finishCheck.CheckSignalNotReceived();
6230   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
6231
6232   application.SendNotification();
6233   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6234
6235   // We did expect the animation to finish
6236   application.SendNotification();
6237   finishCheck.CheckSignalReceived();
6238   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
6239   END_TEST;
6240 }
6241
6242 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6243 {
6244   TestApplication application;
6245
6246   Actor actor = Actor::New();
6247   Stage::GetCurrent().Add(actor);
6248   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6249
6250   // Build the animation
6251   float durationSeconds(1.0f);
6252   Animation animation = Animation::New(durationSeconds);
6253   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6254
6255   try
6256   {
6257     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6258   }
6259   catch (Dali::DaliException& e)
6260   {
6261     DALI_TEST_PRINT_ASSERT( e );
6262     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6263   }
6264   END_TEST;
6265 }
6266
6267 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
6268 {
6269   TestApplication application;
6270
6271   Actor actor = Actor::New();
6272   Stage::GetCurrent().Add(actor);
6273   float startValue(0.0f);
6274   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6275   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6276
6277   // Build the animation
6278   float durationSeconds(1.0f);
6279   Animation animation = Animation::New(durationSeconds);
6280   float targetX(1.0f);
6281
6282   try
6283   {
6284     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6285   }
6286   catch (Dali::DaliException& e)
6287   {
6288     DALI_TEST_PRINT_ASSERT( e );
6289     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6290   }
6291   END_TEST;
6292 }
6293
6294 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
6295 {
6296   TestApplication application;
6297
6298   Actor actor = Actor::New();
6299   Stage::GetCurrent().Add(actor);
6300   float startValue(0.0f);
6301   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6302   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6303
6304   // Build the animation
6305   float durationSeconds(1.0f);
6306   Animation animation = Animation::New(durationSeconds);
6307   float targetY(1.0f);
6308
6309   try
6310   {
6311     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6312   }
6313   catch (Dali::DaliException& e)
6314   {
6315     DALI_TEST_PRINT_ASSERT( e );
6316     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6317   }
6318   END_TEST;
6319 }
6320
6321 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
6322 {
6323   TestApplication application;
6324
6325   Actor actor = Actor::New();
6326   Stage::GetCurrent().Add(actor);
6327   float startValue(0.5f);
6328   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6329   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6330
6331   // Build the animation
6332   float durationSeconds(1.0f);
6333   Animation animation = Animation::New(durationSeconds);
6334   float targetZ(1.0f);
6335
6336   try
6337   {
6338     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6339   }
6340   catch (Dali::DaliException& e)
6341   {
6342     DALI_TEST_PRINT_ASSERT( e );
6343     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6344   }
6345   END_TEST;
6346 }
6347
6348 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
6349 {
6350   TestApplication application;
6351
6352   Actor actor = Actor::New();
6353   Stage::GetCurrent().Add(actor);
6354   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6355
6356   // Build the animation
6357   float durationSeconds(1.0f);
6358   Animation animation = Animation::New(durationSeconds);
6359   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6360
6361   try
6362   {
6363     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6364   }
6365   catch (Dali::DaliException& e)
6366   {
6367     DALI_TEST_PRINT_ASSERT( e );
6368     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6369   }
6370   END_TEST;
6371 }
6372
6373 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
6374 {
6375   TestApplication application;
6376
6377   Actor actor = Actor::New();
6378   Stage::GetCurrent().Add(actor);
6379   float startValue(0.5f);
6380   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6381   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6382
6383   // Build the animation
6384   float durationSeconds(1.0f);
6385   Animation animation = Animation::New(durationSeconds);
6386   float targetX(1.0f);
6387
6388   try
6389   {
6390     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6391   }
6392   catch (Dali::DaliException& e)
6393   {
6394     DALI_TEST_PRINT_ASSERT( e );
6395     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6396   }
6397   END_TEST;
6398 }
6399
6400 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
6401 {
6402   TestApplication application;
6403
6404   Actor actor = Actor::New();
6405   Stage::GetCurrent().Add(actor);
6406   float startValue(0.5f);
6407   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6408   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6409
6410   // Build the animation
6411   float durationSeconds(1.0f);
6412   Animation animation = Animation::New(durationSeconds);
6413   float targetY(0.0f);
6414
6415   try
6416   {
6417     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6418   }
6419   catch (Dali::DaliException& e)
6420   {
6421     DALI_TEST_PRINT_ASSERT( e );
6422     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6423   }
6424   END_TEST;
6425 }
6426
6427 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
6428 {
6429   TestApplication application;
6430
6431   Actor actor = Actor::New();
6432   Stage::GetCurrent().Add(actor);
6433   float startValue(0.5f);
6434   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6435   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6436
6437   // Build the animation
6438   float durationSeconds(1.0f);
6439   Animation animation = Animation::New(durationSeconds);
6440   float targetZ(100.0f);
6441
6442   try
6443   {
6444     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6445   }
6446   catch (Dali::DaliException& e)
6447   {
6448     DALI_TEST_PRINT_ASSERT( e );
6449     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6450   }
6451   END_TEST;
6452 }
6453
6454 int UtcDaliAnimationAnimateToActorSizeP(void)
6455 {
6456   TestApplication application;
6457
6458   Actor actor = Actor::New();
6459   Stage::GetCurrent().Add(actor);
6460   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6461
6462   // Build the animation
6463   float durationSeconds(1.0f);
6464   Animation animation = Animation::New(durationSeconds);
6465   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6466   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6467
6468   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6469
6470   // Start the animation
6471   animation.Play();
6472
6473   bool signalReceived(false);
6474   AnimationFinishCheck finishCheck(signalReceived);
6475   animation.FinishedSignal().Connect(&application, finishCheck);
6476
6477   application.SendNotification();
6478   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6479
6480   // We didn't expect the animation to finish yet
6481   application.SendNotification();
6482   finishCheck.CheckSignalNotReceived();
6483   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6484
6485   application.SendNotification();
6486   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6487
6488   // We did expect the animation to finish
6489   application.SendNotification();
6490   finishCheck.CheckSignalReceived();
6491   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6492
6493   // Reset everything
6494   finishCheck.Reset();
6495   actor.SetSize(Vector3::ZERO);
6496   application.SendNotification();
6497   application.Render(0);
6498   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6499
6500   // Repeat with a different (ease-in) alpha function
6501   animation = Animation::New(durationSeconds);
6502   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6503   animation.FinishedSignal().Connect(&application, finishCheck);
6504   animation.Play();
6505
6506   application.SendNotification();
6507   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6508
6509   // We didn't expect the animation to finish yet
6510   application.SendNotification();
6511   finishCheck.CheckSignalNotReceived();
6512
6513   // The size should have travelled less, than with a linear alpha function
6514   Vector3 current(actor.GetCurrentSize());
6515   DALI_TEST_CHECK( current.x > 0.0f );
6516   DALI_TEST_CHECK( current.y > 0.0f );
6517   DALI_TEST_CHECK( current.z > 0.0f );
6518   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6519   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6520   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6521
6522   application.SendNotification();
6523   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6524
6525   // We did expect the animation to finish
6526   application.SendNotification();
6527   finishCheck.CheckSignalReceived();
6528   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6529
6530   // Reset everything
6531   finishCheck.Reset();
6532   actor.SetSize(Vector3::ZERO);
6533   application.SendNotification();
6534   application.Render(0);
6535   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6536
6537   // Repeat with a delay
6538   float delay = 0.5f;
6539   animation = Animation::New(durationSeconds);
6540   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6541   animation.FinishedSignal().Connect(&application, finishCheck);
6542   animation.Play();
6543
6544   application.SendNotification();
6545   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6546
6547   // We didn't expect the animation to finish yet
6548   application.SendNotification();
6549   finishCheck.CheckSignalNotReceived();
6550   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6551
6552   application.SendNotification();
6553   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6554
6555   // We did expect the animation to finish
6556   application.SendNotification();
6557   finishCheck.CheckSignalReceived();
6558   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6559   END_TEST;
6560 }
6561
6562 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6563 {
6564   TestApplication application;
6565
6566   Actor actor = Actor::New();
6567   Stage::GetCurrent().Add(actor);
6568   float startValue(0.0f);
6569   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6570   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6571
6572   // Build the animation
6573   float durationSeconds(1.0f);
6574   Animation animation = Animation::New(durationSeconds);
6575   float targetWidth(10.0f);
6576   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
6577
6578   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
6579
6580   // Start the animation
6581   animation.Play();
6582
6583   bool signalReceived(false);
6584   AnimationFinishCheck finishCheck(signalReceived);
6585   animation.FinishedSignal().Connect(&application, finishCheck);
6586
6587   application.SendNotification();
6588   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6589
6590   // We didn't expect the animation to finish yet
6591   application.SendNotification();
6592   finishCheck.CheckSignalNotReceived();
6593   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
6594
6595   application.SendNotification();
6596   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6597
6598   // We did expect the animation to finish
6599   application.SendNotification();
6600   finishCheck.CheckSignalReceived();
6601   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
6602   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
6603   END_TEST;
6604 }
6605
6606 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
6607 {
6608   TestApplication application;
6609
6610   Actor actor = Actor::New();
6611   Stage::GetCurrent().Add(actor);
6612   float startValue(0.0f);
6613   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
6614   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
6615
6616   // Build the animation
6617   float durationSeconds(1.0f);
6618   Animation animation = Animation::New(durationSeconds);
6619   float targetHeight(-10.0f);
6620   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
6621
6622   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
6623
6624   // Start the animation
6625   animation.Play();
6626
6627   bool signalReceived(false);
6628   AnimationFinishCheck finishCheck(signalReceived);
6629   animation.FinishedSignal().Connect(&application, finishCheck);
6630
6631   application.SendNotification();
6632   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6633
6634   // We didn't expect the animation to finish yet
6635   application.SendNotification();
6636   finishCheck.CheckSignalNotReceived();
6637   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
6638
6639   application.SendNotification();
6640   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6641
6642   // We did expect the animation to finish
6643   application.SendNotification();
6644   finishCheck.CheckSignalReceived();
6645   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
6646   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
6647   END_TEST;
6648 }
6649
6650 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
6651 {
6652   TestApplication application;
6653
6654   Actor actor = Actor::New();
6655   Stage::GetCurrent().Add(actor);
6656   float startValue(0.0f);
6657   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
6658   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
6659
6660   // Build the animation
6661   float durationSeconds(1.0f);
6662   Animation animation = Animation::New(durationSeconds);
6663   float targetDepth(-10.0f);
6664   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
6665
6666   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
6667
6668   // Start the animation
6669   animation.Play();
6670
6671   bool signalReceived(false);
6672   AnimationFinishCheck finishCheck(signalReceived);
6673   animation.FinishedSignal().Connect(&application, finishCheck);
6674
6675   application.SendNotification();
6676   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6677
6678   // We didn't expect the animation to finish yet
6679   application.SendNotification();
6680   finishCheck.CheckSignalNotReceived();
6681   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
6682
6683   application.SendNotification();
6684   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6685
6686   // We did expect the animation to finish
6687   application.SendNotification();
6688   finishCheck.CheckSignalReceived();
6689   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
6690   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
6691   END_TEST;
6692 }
6693
6694 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
6695 {
6696   TestApplication application;
6697
6698   Actor actor = Actor::New();
6699   Stage::GetCurrent().Add(actor);
6700   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6701
6702   // Build the animation
6703   float durationSeconds(1.0f);
6704   Animation animation = Animation::New(durationSeconds);
6705   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6706   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
6707
6708   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6709
6710   // Start the animation
6711   animation.Play();
6712
6713   bool signalReceived(false);
6714   AnimationFinishCheck finishCheck(signalReceived);
6715   animation.FinishedSignal().Connect(&application, finishCheck);
6716
6717   application.SendNotification();
6718   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6719
6720   // We didn't expect the animation to finish yet
6721   application.SendNotification();
6722   finishCheck.CheckSignalNotReceived();
6723   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6724
6725   application.SendNotification();
6726   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6727
6728   // We did expect the animation to finish
6729   application.SendNotification();
6730   finishCheck.CheckSignalReceived();
6731   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6732
6733   // Reset everything
6734   finishCheck.Reset();
6735   actor.SetSize(Vector3::ZERO);
6736   application.SendNotification();
6737   application.Render(0);
6738   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6739
6740   // Repeat with a different (ease-in) alpha function
6741   animation = Animation::New(durationSeconds);
6742   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
6743   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
6744   animation.FinishedSignal().Connect(&application, finishCheck);
6745   animation.Play();
6746
6747   application.SendNotification();
6748   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6749
6750   // We didn't expect the animation to finish yet
6751   application.SendNotification();
6752   finishCheck.CheckSignalNotReceived();
6753
6754   // The size should have travelled less, than with a linear alpha function
6755   Vector3 current(actor.GetCurrentSize());
6756   DALI_TEST_CHECK( current.x > 0.0f );
6757   DALI_TEST_CHECK( current.y > 0.0f );
6758   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6759   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6760
6761   application.SendNotification();
6762   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6763
6764   // We did expect the animation to finish
6765   application.SendNotification();
6766   finishCheck.CheckSignalReceived();
6767   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
6768   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
6769
6770   // Reset everything
6771   finishCheck.Reset();
6772   actor.SetSize(Vector3::ZERO);
6773   application.SendNotification();
6774   application.Render(0);
6775   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6776
6777   // Repeat with a delay
6778   float delay = 0.5f;
6779   animation = Animation::New(durationSeconds);
6780   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
6781   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
6782   animation.FinishedSignal().Connect(&application, finishCheck);
6783   animation.Play();
6784
6785   application.SendNotification();
6786   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6787
6788   // We didn't expect the animation to finish yet
6789   application.SendNotification();
6790   finishCheck.CheckSignalNotReceived();
6791   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6792
6793   application.SendNotification();
6794   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6795
6796   // We did expect the animation to finish
6797   application.SendNotification();
6798   finishCheck.CheckSignalReceived();
6799   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
6800   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
6801   END_TEST;
6802 }
6803
6804 int UtcDaliAnimationAnimateToActorPositionP(void)
6805 {
6806   TestApplication application;
6807
6808   Actor actor = Actor::New();
6809   Stage::GetCurrent().Add(actor);
6810   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6811
6812   // Build the animation
6813   float durationSeconds(1.0f);
6814   Animation animation = Animation::New(durationSeconds);
6815   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6816   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
6817
6818   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6819
6820   // Start the animation
6821   animation.Play();
6822
6823   bool signalReceived(false);
6824   AnimationFinishCheck finishCheck(signalReceived);
6825   animation.FinishedSignal().Connect(&application, finishCheck);
6826
6827   application.SendNotification();
6828   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6829
6830   // We didn't expect the animation to finish yet
6831   application.SendNotification();
6832   finishCheck.CheckSignalNotReceived();
6833   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6834
6835   application.SendNotification();
6836   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6837
6838   // We did expect the animation to finish
6839   application.SendNotification();
6840   finishCheck.CheckSignalReceived();
6841   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6842   END_TEST;
6843 }
6844
6845 int UtcDaliAnimationAnimateToActorPositionXP(void)
6846 {
6847   TestApplication application;
6848
6849   Actor actor = Actor::New();
6850   Stage::GetCurrent().Add(actor);
6851   float startValue(0.0f);
6852   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
6853   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6854   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6855   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6856
6857   // Build the animation
6858   float durationSeconds(1.0f);
6859   Animation animation = Animation::New(durationSeconds);
6860   float targetX(1.0f);
6861   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
6862
6863   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
6864
6865   // Start the animation
6866   animation.Play();
6867
6868   bool signalReceived(false);
6869   AnimationFinishCheck finishCheck(signalReceived);
6870   animation.FinishedSignal().Connect(&application, finishCheck);
6871
6872   application.SendNotification();
6873   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6874
6875   // We didn't expect the animation to finish yet
6876   application.SendNotification();
6877   finishCheck.CheckSignalNotReceived();
6878   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
6879
6880   application.SendNotification();
6881   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6882
6883   // We did expect the animation to finish
6884   application.SendNotification();
6885   finishCheck.CheckSignalReceived();
6886   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
6887   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
6888   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6889   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6890   END_TEST;
6891 }
6892
6893 int UtcDaliAnimationAnimateToActorPositionYP(void)
6894 {
6895   TestApplication application;
6896
6897   Actor actor = Actor::New();
6898   Stage::GetCurrent().Add(actor);
6899   float startValue(0.0f);
6900   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
6901   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6902   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6903   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6904
6905   // Build the animation
6906   float durationSeconds(1.0f);
6907   Animation animation = Animation::New(durationSeconds);
6908   float targetY(10.0f);
6909   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
6910
6911   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6912
6913   // Start the animation
6914   animation.Play();
6915
6916   bool signalReceived(false);
6917   AnimationFinishCheck finishCheck(signalReceived);
6918   animation.FinishedSignal().Connect(&application, finishCheck);
6919
6920   application.SendNotification();
6921   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6922
6923   // We didn't expect the animation to finish yet
6924   application.SendNotification();
6925   finishCheck.CheckSignalNotReceived();
6926   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
6927
6928   application.SendNotification();
6929   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6930
6931   // We did expect the animation to finish
6932   application.SendNotification();
6933   finishCheck.CheckSignalReceived();
6934   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
6935   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6936   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
6937   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6938   END_TEST;
6939 }
6940
6941 int UtcDaliAnimationAnimateToActorPositionZP(void)
6942 {
6943   TestApplication application;
6944
6945   Actor actor = Actor::New();
6946   Stage::GetCurrent().Add(actor);
6947   float startValue(0.0f);
6948   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
6949   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6950   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6951   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6952
6953   // Build the animation
6954   float durationSeconds(1.0f);
6955   Animation animation = Animation::New(durationSeconds);
6956   float targetZ(-5.0f);
6957   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
6958
6959   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6960
6961   // Start the animation
6962   animation.Play();
6963
6964   bool signalReceived(false);
6965   AnimationFinishCheck finishCheck(signalReceived);
6966   animation.FinishedSignal().Connect(&application, finishCheck);
6967
6968   application.SendNotification();
6969   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6970
6971   // We didn't expect the animation to finish yet
6972   application.SendNotification();
6973   finishCheck.CheckSignalNotReceived();
6974   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
6975
6976   application.SendNotification();
6977   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6978
6979   // We did expect the animation to finish
6980   application.SendNotification();
6981   finishCheck.CheckSignalReceived();
6982   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
6983   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6984   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6985   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
6986   END_TEST;
6987 }
6988
6989 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
6990 {
6991   TestApplication application;
6992
6993   Actor actor = Actor::New();
6994   Stage::GetCurrent().Add(actor);
6995   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6996
6997   // Build the animation
6998   float durationSeconds(1.0f);
6999   Animation animation = Animation::New(durationSeconds);
7000   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7001   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7002
7003   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7004
7005   // Start the animation
7006   animation.Play();
7007
7008   bool signalReceived(false);
7009   AnimationFinishCheck finishCheck(signalReceived);
7010   animation.FinishedSignal().Connect(&application, finishCheck);
7011
7012   application.SendNotification();
7013   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7014
7015   // We didn't expect the animation to finish yet
7016   application.SendNotification();
7017   finishCheck.CheckSignalNotReceived();
7018
7019   // The position should have moved less, than with a linear alpha function
7020   Vector3 current(actor.GetCurrentPosition());
7021   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7022   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7023   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7024   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7025   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7026   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7027
7028   application.SendNotification();
7029   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7030
7031   // We did expect the animation to finish
7032   application.SendNotification();
7033   finishCheck.CheckSignalReceived();
7034   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7035   END_TEST;
7036 }
7037
7038 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7039 {
7040   TestApplication application;
7041
7042   Actor actor = Actor::New();
7043   Stage::GetCurrent().Add(actor);
7044   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7045
7046   // Build the animation
7047   float durationSeconds(1.0f);
7048   Animation animation = Animation::New(durationSeconds);
7049   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7050   float delay = 0.5f;
7051   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7052                        targetPosition,
7053                        TimePeriod( delay, durationSeconds - delay ) );
7054
7055   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7056
7057   // Start the animation
7058   animation.Play();
7059
7060   bool signalReceived(false);
7061   AnimationFinishCheck finishCheck(signalReceived);
7062   animation.FinishedSignal().Connect(&application, finishCheck);
7063
7064   application.SendNotification();
7065   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7066
7067   // We didn't expect the animation to finish yet
7068   application.SendNotification();
7069   finishCheck.CheckSignalNotReceived();
7070   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7071
7072   application.SendNotification();
7073   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7074
7075   // We didn't expect the animation to finish yet
7076   application.SendNotification();
7077   finishCheck.CheckSignalNotReceived();
7078   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7079
7080   application.SendNotification();
7081   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7082
7083   // We did expect the animation to finish
7084   application.SendNotification();
7085   finishCheck.CheckSignalReceived();
7086   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7087   END_TEST;
7088 }
7089
7090 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7091 {
7092   TestApplication application;
7093
7094   Actor actor = Actor::New();
7095   Stage::GetCurrent().Add(actor);
7096   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7097
7098   // Build the animation
7099   float durationSeconds(1.0f);
7100   Animation animation = Animation::New(durationSeconds);
7101   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7102   float delay = 0.5f;
7103   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7104                        targetPosition,
7105                        AlphaFunction::LINEAR,
7106                        TimePeriod( delay, durationSeconds - delay ) );
7107
7108   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7109
7110   // Start the animation
7111   animation.Play();
7112
7113   bool signalReceived(false);
7114   AnimationFinishCheck finishCheck(signalReceived);
7115   animation.FinishedSignal().Connect(&application, finishCheck);
7116
7117   application.SendNotification();
7118   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7119
7120   // We didn't expect the animation to finish yet
7121   application.SendNotification();
7122   finishCheck.CheckSignalNotReceived();
7123   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7124
7125   application.SendNotification();
7126   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7127
7128   // We didn't expect the animation to finish yet
7129   application.SendNotification();
7130   finishCheck.CheckSignalNotReceived();
7131   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7132
7133   application.SendNotification();
7134   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7135
7136   // We did expect the animation to finish
7137   application.SendNotification();
7138   finishCheck.CheckSignalReceived();
7139   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7140   END_TEST;
7141 }
7142
7143 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7144 {
7145   TestApplication application;
7146
7147   Actor actor = Actor::New();
7148   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7149   Stage::GetCurrent().Add(actor);
7150   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7151
7152   // Build the animation
7153   float durationSeconds(1.0f);
7154   Animation animation = Animation::New(durationSeconds);
7155   Degree targetRotationDegrees(90.0f);
7156   Radian targetRotationRadians(targetRotationDegrees);
7157   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7158
7159   // Start the animation
7160   animation.Play();
7161
7162   bool signalReceived(false);
7163   AnimationFinishCheck finishCheck(signalReceived);
7164   animation.FinishedSignal().Connect(&application, finishCheck);
7165
7166   application.SendNotification();
7167   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7168
7169   // We didn't expect the animation to finish yet
7170   application.SendNotification();
7171   finishCheck.CheckSignalNotReceived();
7172   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7173
7174   application.SendNotification();
7175   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7176
7177   // We didn't expect the animation to finish yet
7178   application.SendNotification();
7179   finishCheck.CheckSignalNotReceived();
7180   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7181
7182   application.SendNotification();
7183   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7184
7185   // We didn't expect the animation to finish yet
7186   application.SendNotification();
7187   finishCheck.CheckSignalNotReceived();
7188   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7189
7190   application.SendNotification();
7191   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7192
7193   // We did expect the animation to finish
7194   application.SendNotification();
7195   finishCheck.CheckSignalReceived();
7196   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7197   END_TEST;
7198 }
7199
7200 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7201 {
7202   TestApplication application;
7203
7204   Actor actor = Actor::New();
7205   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7206   Stage::GetCurrent().Add(actor);
7207   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7208
7209   // Build the animation
7210   float durationSeconds(1.0f);
7211   Animation animation = Animation::New(durationSeconds);
7212   Degree targetRotationDegrees(90.0f);
7213   Radian targetRotationRadians(targetRotationDegrees);
7214   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7215   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7216
7217   // Start the animation
7218   animation.Play();
7219
7220   bool signalReceived(false);
7221   AnimationFinishCheck finishCheck(signalReceived);
7222   animation.FinishedSignal().Connect(&application, finishCheck);
7223
7224   application.SendNotification();
7225   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7226
7227   // We didn't expect the animation to finish yet
7228   application.SendNotification();
7229   finishCheck.CheckSignalNotReceived();
7230   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7231
7232   application.SendNotification();
7233   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7234
7235   // We didn't expect the animation to finish yet
7236   application.SendNotification();
7237   finishCheck.CheckSignalNotReceived();
7238   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7239
7240   application.SendNotification();
7241   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7242
7243   // We didn't expect the animation to finish yet
7244   application.SendNotification();
7245   finishCheck.CheckSignalNotReceived();
7246   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7247
7248   application.SendNotification();
7249   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7250
7251   // We did expect the animation to finish
7252   application.SendNotification();
7253   finishCheck.CheckSignalReceived();
7254   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7255   END_TEST;
7256 }
7257
7258 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7259 {
7260   TestApplication application;
7261
7262   Actor actor = Actor::New();
7263   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7264   Stage::GetCurrent().Add(actor);
7265   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7266
7267   // Build the animation
7268   float durationSeconds(1.0f);
7269   Animation animation = Animation::New(durationSeconds);
7270   Degree targetRotationDegrees(90.0f);
7271   Radian targetRotationRadians(targetRotationDegrees);
7272   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7273
7274   // Start the animation
7275   animation.Play();
7276
7277   bool signalReceived(false);
7278   AnimationFinishCheck finishCheck(signalReceived);
7279   animation.FinishedSignal().Connect(&application, finishCheck);
7280
7281   application.SendNotification();
7282   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7283
7284   // We didn't expect the animation to finish yet
7285   application.SendNotification();
7286   finishCheck.CheckSignalNotReceived();
7287   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7288
7289   application.SendNotification();
7290   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7291
7292   // We didn't expect the animation to finish yet
7293   application.SendNotification();
7294   finishCheck.CheckSignalNotReceived();
7295   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7296
7297   application.SendNotification();
7298   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7299
7300   // We didn't expect the animation to finish yet
7301   application.SendNotification();
7302   finishCheck.CheckSignalNotReceived();
7303   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7304
7305   application.SendNotification();
7306   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7307
7308   // We did expect the animation to finish
7309   application.SendNotification();
7310   finishCheck.CheckSignalReceived();
7311   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7312   END_TEST;
7313 }
7314
7315 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7316 {
7317   TestApplication application;
7318
7319   Actor actor = Actor::New();
7320   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7321   Stage::GetCurrent().Add(actor);
7322   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7323
7324   // Build the animation
7325   float durationSeconds(1.0f);
7326   Animation animation = Animation::New(durationSeconds);
7327   Degree targetRotationDegrees(90.0f);
7328   Radian targetRotationRadians(targetRotationDegrees);
7329   float delay(0.1f);
7330   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7331
7332   // Start the animation
7333   animation.Play();
7334
7335   bool signalReceived(false);
7336   AnimationFinishCheck finishCheck(signalReceived);
7337   animation.FinishedSignal().Connect(&application, finishCheck);
7338
7339   application.SendNotification();
7340   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7341
7342   // We didn't expect the animation to finish yet
7343   application.SendNotification();
7344   finishCheck.CheckSignalNotReceived();
7345   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7346   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7347
7348   application.SendNotification();
7349   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7350
7351   // We didn't expect the animation to finish yet
7352   application.SendNotification();
7353   finishCheck.CheckSignalNotReceived();
7354   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7355   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7356
7357   application.SendNotification();
7358   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7359
7360   // We didn't expect the animation to finish yet
7361   application.SendNotification();
7362   finishCheck.CheckSignalNotReceived();
7363   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7364   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7365
7366   application.SendNotification();
7367   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7368
7369   // We did expect the animation to finish
7370   application.SendNotification();
7371   finishCheck.CheckSignalReceived();
7372   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7373   END_TEST;
7374 }
7375
7376 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7377 {
7378   TestApplication application;
7379
7380   Actor actor = Actor::New();
7381   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7382   Stage::GetCurrent().Add(actor);
7383   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7384
7385   // Build the animation
7386   float durationSeconds(1.0f);
7387   Animation animation = Animation::New(durationSeconds);
7388   Degree targetRotationDegrees(90.0f);
7389   Radian targetRotationRadians(targetRotationDegrees);
7390   float delay(0.1f);
7391   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7392
7393   // Start the animation
7394   animation.Play();
7395
7396   bool signalReceived(false);
7397   AnimationFinishCheck finishCheck(signalReceived);
7398   animation.FinishedSignal().Connect(&application, finishCheck);
7399
7400   application.SendNotification();
7401   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7402
7403   // We didn't expect the animation to finish yet
7404   application.SendNotification();
7405   finishCheck.CheckSignalNotReceived();
7406   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7407   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7408
7409   application.SendNotification();
7410   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7411
7412   // We didn't expect the animation to finish yet
7413   application.SendNotification();
7414   finishCheck.CheckSignalNotReceived();
7415   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7416   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7417
7418   application.SendNotification();
7419   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7420
7421   // We didn't expect the animation to finish yet
7422   application.SendNotification();
7423   finishCheck.CheckSignalNotReceived();
7424   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7425   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7426
7427   application.SendNotification();
7428   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7429
7430   // We did expect the animation to finish
7431   application.SendNotification();
7432   finishCheck.CheckSignalReceived();
7433   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7434   END_TEST;
7435 }
7436
7437 int UtcDaliAnimationAnimateToActorScaleP(void)
7438 {
7439   TestApplication application;
7440
7441   Actor actor = Actor::New();
7442   Stage::GetCurrent().Add(actor);
7443   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7444
7445   // Build the animation
7446   float durationSeconds(1.0f);
7447   Animation animation = Animation::New(durationSeconds);
7448   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7449   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7450
7451   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7452
7453   // Start the animation
7454   animation.Play();
7455
7456   bool signalReceived(false);
7457   AnimationFinishCheck finishCheck(signalReceived);
7458   animation.FinishedSignal().Connect(&application, finishCheck);
7459
7460   application.SendNotification();
7461   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7462
7463   // We didn't expect the animation to finish yet
7464   application.SendNotification();
7465   finishCheck.CheckSignalNotReceived();
7466   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7467
7468   application.SendNotification();
7469   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7470
7471   // We did expect the animation to finish
7472   application.SendNotification();
7473   finishCheck.CheckSignalReceived();
7474   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7475
7476   // Reset everything
7477   finishCheck.Reset();
7478   actor.SetScale(Vector3::ONE);
7479   application.SendNotification();
7480   application.Render(0);
7481   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7482
7483   // Repeat with a different (ease-in) alpha function
7484   animation = Animation::New(durationSeconds);
7485   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7486   animation.FinishedSignal().Connect(&application, finishCheck);
7487   animation.Play();
7488
7489   application.SendNotification();
7490   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7491
7492   // We didn't expect the animation to finish yet
7493   application.SendNotification();
7494   finishCheck.CheckSignalNotReceived();
7495
7496   // The scale should have grown less, than with a linear alpha function
7497   Vector3 current(actor.GetCurrentScale());
7498   DALI_TEST_CHECK( current.x > 1.0f );
7499   DALI_TEST_CHECK( current.y > 1.0f );
7500   DALI_TEST_CHECK( current.z > 1.0f );
7501   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7502   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7503   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7504
7505   application.SendNotification();
7506   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7507
7508   // We did expect the animation to finish
7509   application.SendNotification();
7510   finishCheck.CheckSignalReceived();
7511   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7512
7513   // Reset everything
7514   finishCheck.Reset();
7515   actor.SetScale(Vector3::ONE);
7516   application.SendNotification();
7517   application.Render(0);
7518   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7519
7520   // Repeat with a delay
7521   float delay = 0.5f;
7522   animation = Animation::New(durationSeconds);
7523   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
7524   animation.FinishedSignal().Connect(&application, finishCheck);
7525   animation.Play();
7526
7527   application.SendNotification();
7528   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7529
7530   // We didn't expect the animation to finish yet
7531   application.SendNotification();
7532   finishCheck.CheckSignalNotReceived();
7533   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7534
7535   application.SendNotification();
7536   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7537
7538   // We did expect the animation to finish
7539   application.SendNotification();
7540   finishCheck.CheckSignalReceived();
7541   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7542   END_TEST;
7543 }
7544
7545 int UtcDaliAnimationAnimateToActorScaleXP(void)
7546 {
7547   TestApplication application;
7548
7549   Actor actor = Actor::New();
7550   Stage::GetCurrent().Add(actor);
7551   float startValue(1.0f);
7552   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
7553   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7554   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7555   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7556
7557   // Build the animation
7558   float durationSeconds(1.0f);
7559   Animation animation = Animation::New(durationSeconds);
7560   float targetX(10.0f);
7561   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
7562
7563   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7564
7565   // Start the animation
7566   animation.Play();
7567
7568   bool signalReceived(false);
7569   AnimationFinishCheck finishCheck(signalReceived);
7570   animation.FinishedSignal().Connect(&application, finishCheck);
7571
7572   application.SendNotification();
7573   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7574
7575   // We didn't expect the animation to finish yet
7576   application.SendNotification();
7577   finishCheck.CheckSignalNotReceived();
7578   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
7579   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
7580   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7581   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7582
7583   application.SendNotification();
7584   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7585
7586   // We did expect the animation to finish
7587   application.SendNotification();
7588   finishCheck.CheckSignalReceived();
7589   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
7590   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), targetX, TEST_LOCATION );
7591   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7592   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7593   END_TEST;
7594 }
7595
7596 int UtcDaliAnimationAnimateToActorScaleYP(void)
7597 {
7598   TestApplication application;
7599
7600   Actor actor = Actor::New();
7601   Stage::GetCurrent().Add(actor);
7602   float startValue(1.0f);
7603   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
7604   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7605   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7606   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7607
7608   // Build the animation
7609   float durationSeconds(1.0f);
7610   Animation animation = Animation::New(durationSeconds);
7611   float targetY(1000.0f);
7612   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
7613
7614   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7615
7616   // Start the animation
7617   animation.Play();
7618
7619   bool signalReceived(false);
7620   AnimationFinishCheck finishCheck(signalReceived);
7621   animation.FinishedSignal().Connect(&application, finishCheck);
7622
7623   application.SendNotification();
7624   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7625
7626   // We didn't expect the animation to finish yet
7627   application.SendNotification();
7628   finishCheck.CheckSignalNotReceived();
7629   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
7630   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7631   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
7632   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7633
7634   application.SendNotification();
7635   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7636
7637   // We did expect the animation to finish
7638   application.SendNotification();
7639   finishCheck.CheckSignalReceived();
7640   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
7641   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7642   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), targetY, TEST_LOCATION );
7643   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7644   END_TEST;
7645 }
7646
7647 int UtcDaliAnimationAnimateToActorScaleZP(void)
7648 {
7649   TestApplication application;
7650
7651   Actor actor = Actor::New();
7652   Stage::GetCurrent().Add(actor);
7653   float startValue(1.0f);
7654   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
7655   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7656   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7657   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7658
7659   // Build the animation
7660   float durationSeconds(1.0f);
7661   Animation animation = Animation::New(durationSeconds);
7662   float targetZ(-1000.0f);
7663   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
7664
7665   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7666
7667   // Start the animation
7668   animation.Play();
7669
7670   bool signalReceived(false);
7671   AnimationFinishCheck finishCheck(signalReceived);
7672   animation.FinishedSignal().Connect(&application, finishCheck);
7673
7674   application.SendNotification();
7675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7676
7677   // We didn't expect the animation to finish yet
7678   application.SendNotification();
7679   finishCheck.CheckSignalNotReceived();
7680   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
7681   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7682   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7683   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
7684
7685   application.SendNotification();
7686   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7687
7688   // We did expect the animation to finish
7689   application.SendNotification();
7690   finishCheck.CheckSignalReceived();
7691   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
7692   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7693   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7694   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), targetZ, TEST_LOCATION );
7695   END_TEST;
7696 }
7697
7698 int UtcDaliAnimationAnimateToActorColorP(void)
7699 {
7700   TestApplication application;
7701
7702   Actor actor = Actor::New();
7703   Stage::GetCurrent().Add(actor);
7704   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7705
7706   // Build the animation
7707   float durationSeconds(1.0f);
7708   Animation animation = Animation::New(durationSeconds);
7709   Vector4 targetColor(Color::RED);
7710   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
7711
7712   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
7713   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
7714
7715   // Start the animation
7716   animation.Play();
7717
7718   bool signalReceived(false);
7719   AnimationFinishCheck finishCheck(signalReceived);
7720   animation.FinishedSignal().Connect(&application, finishCheck);
7721
7722   application.SendNotification();
7723   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7724
7725   // We didn't expect the animation to finish yet
7726   application.SendNotification();
7727   finishCheck.CheckSignalNotReceived();
7728   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
7729
7730   application.SendNotification();
7731   application.Render(static_cast<unsigned int>(durationSeconds*900.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(), targetColor, TEST_LOCATION );
7737
7738   // Reset everything
7739   finishCheck.Reset();
7740   actor.SetColor(Color::WHITE);
7741   application.SendNotification();
7742   application.Render(0);
7743   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7744
7745   // Repeat with a different (ease-in) alpha function
7746   animation = Animation::New(durationSeconds);
7747   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
7748   animation.FinishedSignal().Connect(&application, finishCheck);
7749   animation.Play();
7750
7751   application.SendNotification();
7752   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7753
7754   // We didn't expect the animation to finish yet
7755   application.SendNotification();
7756   finishCheck.CheckSignalNotReceived();
7757
7758   // The color should have changed less, than with a linear alpha function
7759   Vector4 current(actor.GetCurrentColor());
7760   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
7761   DALI_TEST_CHECK( current.y < 1.0f );
7762   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
7763   DALI_TEST_CHECK( current.z  < 1.0f );
7764   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
7765   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
7766
7767   application.SendNotification();
7768   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7769
7770   // We did expect the animation to finish
7771   application.SendNotification();
7772   finishCheck.CheckSignalReceived();
7773   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7774
7775   // Reset everything
7776   finishCheck.Reset();
7777   actor.SetColor(Color::WHITE);
7778   application.SendNotification();
7779   application.Render(0);
7780   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7781
7782   // Repeat with a shorter animator duration
7783   float animatorDuration = 0.5f;
7784   animation = Animation::New(durationSeconds);
7785   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
7786   animation.FinishedSignal().Connect(&application, finishCheck);
7787   animation.Play();
7788
7789   application.SendNotification();
7790   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
7791
7792   // We didn't expect the animation to finish yet
7793   application.SendNotification();
7794   finishCheck.CheckSignalNotReceived();
7795   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
7796
7797   application.SendNotification();
7798   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
7799
7800   // We didn't expect the animation to finish yet
7801   application.SendNotification();
7802   finishCheck.CheckSignalNotReceived();
7803   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7804
7805   application.SendNotification();
7806   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7807
7808   // We did expect the animation to finish
7809   application.SendNotification();
7810   finishCheck.CheckSignalReceived();
7811   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7812   END_TEST;
7813 }
7814
7815 int UtcDaliAnimationAnimateToActorColorRedP(void)
7816 {
7817   TestApplication application;
7818
7819   Actor actor = Actor::New();
7820   Stage::GetCurrent().Add(actor);
7821   float startValue(1.0f);
7822   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
7823   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7824   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7827
7828   // Build the animation
7829   float durationSeconds(1.0f);
7830   Animation animation = Animation::New(durationSeconds);
7831   float targetRed(0.5f);
7832   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
7833
7834   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
7835
7836   // Start the animation
7837   animation.Play();
7838
7839   bool signalReceived(false);
7840   AnimationFinishCheck finishCheck(signalReceived);
7841   animation.FinishedSignal().Connect(&application, finishCheck);
7842
7843   application.SendNotification();
7844   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7845
7846   // We didn't expect the animation to finish yet
7847   application.SendNotification();
7848   finishCheck.CheckSignalNotReceived();
7849   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
7850   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
7851   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
7852   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
7853   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
7854
7855   application.SendNotification();
7856   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7857
7858   // We did expect the animation to finish
7859   application.SendNotification();
7860   finishCheck.CheckSignalReceived();
7861   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
7862   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
7863   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7864   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7865   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7866   END_TEST;
7867 }
7868
7869 int UtcDaliAnimationAnimateToActorColorGreenP(void)
7870 {
7871   TestApplication application;
7872
7873   Actor actor = Actor::New();
7874   Stage::GetCurrent().Add(actor);
7875   float startValue(1.0f);
7876   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
7877   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7878   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7879   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7880   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7881
7882   // Build the animation
7883   float durationSeconds(1.0f);
7884   Animation animation = Animation::New(durationSeconds);
7885   float targetGreen(0.5f);
7886   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
7887
7888   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
7889
7890   // Start the animation
7891   animation.Play();
7892
7893   bool signalReceived(false);
7894   AnimationFinishCheck finishCheck(signalReceived);
7895   animation.FinishedSignal().Connect(&application, finishCheck);
7896
7897   application.SendNotification();
7898   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7899
7900   // We didn't expect the animation to finish yet
7901   application.SendNotification();
7902   finishCheck.CheckSignalNotReceived();
7903   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
7904   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
7905   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
7906   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
7907   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
7908
7909   application.SendNotification();
7910   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7911
7912   // We did expect the animation to finish
7913   application.SendNotification();
7914   finishCheck.CheckSignalReceived();
7915   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
7916   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
7917   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
7918   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
7919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
7920   END_TEST;
7921 }
7922
7923 int UtcDaliAnimationAnimateToActorColorBlueP(void)
7924 {
7925   TestApplication application;
7926
7927   Actor actor = Actor::New();
7928   Stage::GetCurrent().Add(actor);
7929   float startValue(1.0f);
7930   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
7931   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7932   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7933   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7934   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7935
7936   // Build the animation
7937   float durationSeconds(1.0f);
7938   Animation animation = Animation::New(durationSeconds);
7939   float targetBlue(0.5f);
7940   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
7941
7942   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
7943
7944   // Start the animation
7945   animation.Play();
7946
7947   bool signalReceived(false);
7948   AnimationFinishCheck finishCheck(signalReceived);
7949   animation.FinishedSignal().Connect(&application, finishCheck);
7950
7951   application.SendNotification();
7952   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7953
7954   // We didn't expect the animation to finish yet
7955   application.SendNotification();
7956   finishCheck.CheckSignalNotReceived();
7957   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
7958   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
7959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
7960   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  fiftyPercentProgress, TEST_LOCATION );
7961   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
7962
7963   application.SendNotification();
7964   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7965
7966   // We did expect the animation to finish
7967   application.SendNotification();
7968   finishCheck.CheckSignalReceived();
7969   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
7970   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7971   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7972   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  targetBlue, TEST_LOCATION );
7973   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7974   END_TEST;
7975 }
7976
7977 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
7978 {
7979   TestApplication application;
7980
7981   Actor actor = Actor::New();
7982   Stage::GetCurrent().Add(actor);
7983   float startValue(1.0f);
7984   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7985   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7986   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7987   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7988   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7989
7990   // Build the animation
7991   float durationSeconds(1.0f);
7992   Animation animation = Animation::New(durationSeconds);
7993   float targetAlpha(0.5f);
7994   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
7995
7996   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
7997
7998   // Start the animation
7999   animation.Play();
8000
8001   bool signalReceived(false);
8002   AnimationFinishCheck finishCheck(signalReceived);
8003   animation.FinishedSignal().Connect(&application, finishCheck);
8004
8005   application.SendNotification();
8006   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8007
8008   // We didn't expect the animation to finish yet
8009   application.SendNotification();
8010   finishCheck.CheckSignalNotReceived();
8011   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8012   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8013   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8014   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8015   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
8016
8017   application.SendNotification();
8018   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8019
8020   // We did expect the animation to finish
8021   application.SendNotification();
8022   finishCheck.CheckSignalReceived();
8023   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8024   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8025   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,  TEST_LOCATION );
8026   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8027   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
8028   END_TEST;
8029 }
8030
8031 int UtcDaliAnimationKeyFrames01P(void)
8032 {
8033   TestApplication application;
8034
8035   KeyFrames keyFrames = KeyFrames::New();
8036   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8037
8038   keyFrames.Add(0.0f, 0.1f);
8039
8040   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8041
8042   KeyFrames keyFrames2( keyFrames);
8043   DALI_TEST_CHECK( keyFrames2 );
8044   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8045
8046   KeyFrames keyFrames3 = KeyFrames::New();
8047   keyFrames3.Add(0.6f, true);
8048   DALI_TEST_CHECK( keyFrames3 );
8049   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8050
8051   keyFrames3 = keyFrames;
8052   DALI_TEST_CHECK( keyFrames3 );
8053   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8054
8055   END_TEST;
8056 }
8057
8058 int UtcDaliAnimationKeyFrames02P(void)
8059 {
8060   TestApplication application;
8061
8062   KeyFrames keyFrames = KeyFrames::New();
8063   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8064
8065   keyFrames.Add(0.0f, 0.1f);
8066   keyFrames.Add(0.2f, 0.5f);
8067   keyFrames.Add(0.4f, 0.0f);
8068   keyFrames.Add(0.6f, 1.0f);
8069   keyFrames.Add(0.8f, 0.7f);
8070   keyFrames.Add(1.0f, 0.9f);
8071
8072   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8073
8074   try
8075   {
8076     keyFrames.Add(1.9f, false);
8077   }
8078   catch (Dali::DaliException& e)
8079   {
8080     DALI_TEST_PRINT_ASSERT( e );
8081     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8082   }
8083   END_TEST;
8084 }
8085
8086 int UtcDaliAnimationKeyFrames03P(void)
8087 {
8088   TestApplication application;
8089
8090   KeyFrames keyFrames = KeyFrames::New();
8091   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8092
8093   keyFrames.Add(0.0f, true);
8094   keyFrames.Add(0.2f, false);
8095   keyFrames.Add(0.4f, false);
8096   keyFrames.Add(0.6f, true);
8097   keyFrames.Add(0.8f, true);
8098   keyFrames.Add(1.0f, false);
8099
8100   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8101
8102   try
8103   {
8104     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8105   }
8106   catch (Dali::DaliException& e)
8107   {
8108     DALI_TEST_PRINT_ASSERT( e );
8109     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8110   }
8111   END_TEST;
8112 }
8113
8114 int UtcDaliAnimationKeyFrames04P(void)
8115 {
8116   TestApplication application;
8117
8118   KeyFrames keyFrames = KeyFrames::New();
8119   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8120
8121   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8122   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8123   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8124   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8125   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8126   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8127
8128   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8129
8130   try
8131   {
8132     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8133   }
8134   catch (Dali::DaliException& e)
8135   {
8136     DALI_TEST_PRINT_ASSERT( e );
8137     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8138   }
8139   END_TEST;
8140 }
8141
8142 int UtcDaliAnimationKeyFrames05P(void)
8143 {
8144   TestApplication application;
8145
8146   KeyFrames keyFrames = KeyFrames::New();
8147   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8148
8149   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8150   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8151   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8152   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8153   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8154   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8155
8156   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8157
8158   try
8159   {
8160     keyFrames.Add(0.7f, 1.0f);
8161   }
8162   catch (Dali::DaliException& e)
8163   {
8164     DALI_TEST_PRINT_ASSERT( e );
8165     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8166   }
8167   END_TEST;
8168 }
8169
8170 int UtcDaliAnimationKeyFrames06P(void)
8171 {
8172   TestApplication application;
8173
8174   KeyFrames keyFrames = KeyFrames::New();
8175   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8176
8177   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8178   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8179   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8180   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8181   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8182   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8183
8184   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8185
8186   try
8187   {
8188     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8189   }
8190   catch (Dali::DaliException& e)
8191   {
8192     DALI_TEST_PRINT_ASSERT( e );
8193     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8194   }
8195   END_TEST;
8196 }
8197
8198 int UtcDaliAnimationKeyFrames07P(void)
8199 {
8200   TestApplication application;
8201
8202   KeyFrames keyFrames = KeyFrames::New();
8203   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8204
8205   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8206   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8207   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8208   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8209   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8210   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8211
8212   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8213
8214   try
8215   {
8216     keyFrames.Add(0.7f, 1.1f);
8217   }
8218   catch (Dali::DaliException& e)
8219   {
8220     DALI_TEST_PRINT_ASSERT( e );
8221     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8222   }
8223   END_TEST;
8224 }
8225
8226 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8227 {
8228   TestApplication application;
8229
8230   float startValue(1.0f);
8231   Actor actor = Actor::New();
8232   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8233   Stage::GetCurrent().Add(actor);
8234
8235   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8236   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8237   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8238   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8239   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8240
8241   // Build the animation
8242   float durationSeconds(1.0f);
8243   Animation animation = Animation::New(durationSeconds);
8244
8245   KeyFrames keyFrames = KeyFrames::New();
8246   keyFrames.Add(0.0f, 0.1f);
8247   keyFrames.Add(0.2f, 0.5f);
8248   keyFrames.Add(0.4f, 0.0f);
8249   keyFrames.Add(0.6f, 1.0f);
8250   keyFrames.Add(0.8f, 0.7f);
8251   keyFrames.Add(1.0f, 0.9f);
8252
8253   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8254
8255   // Start the animation
8256   animation.Play();
8257
8258   bool signalReceived(false);
8259   AnimationFinishCheck finishCheck(signalReceived);
8260   animation.FinishedSignal().Connect(&application, finishCheck);
8261   application.SendNotification();
8262   application.Render(0);
8263   application.SendNotification();
8264   finishCheck.CheckSignalNotReceived();
8265   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8266
8267   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8268   application.SendNotification();
8269   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8270   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8271   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8272   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8273   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8274
8275   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8276   application.SendNotification();
8277   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8278   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8279   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8280   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8281   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8282
8283   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8284   application.SendNotification();
8285   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8286   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8287   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8288   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8289   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8290
8291   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8292   application.SendNotification();
8293   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8294   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8296   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8297   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8298
8299   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8300   application.SendNotification();
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), 0.8f, 0.01f, TEST_LOCATION );
8305   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8306
8307   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8308   application.SendNotification();
8309   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8310   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8311   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8312   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8313   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8314
8315   // We did expect the animation to finish
8316
8317   finishCheck.CheckSignalReceived();
8318   END_TEST;
8319 }
8320
8321 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8322 {
8323   TestApplication application;
8324
8325   float startValue(1.0f);
8326   Actor actor = Actor::New();
8327   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8328   Stage::GetCurrent().Add(actor);
8329
8330   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8331   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8332   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8333   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8334   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8335
8336   // Build the animation
8337   float durationSeconds(1.0f);
8338   Animation animation = Animation::New(durationSeconds);
8339
8340   KeyFrames keyFrames = KeyFrames::New();
8341   keyFrames.Add(0.0f, 0.1f);
8342   keyFrames.Add(0.2f, 0.5f);
8343   keyFrames.Add(0.4f, 0.0f);
8344   keyFrames.Add(0.6f, 1.0f);
8345   keyFrames.Add(0.8f, 0.7f);
8346   keyFrames.Add(1.0f, 0.9f);
8347
8348   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8349
8350   // Start the animation
8351   animation.Play();
8352
8353   bool signalReceived(false);
8354   AnimationFinishCheck finishCheck(signalReceived);
8355   animation.FinishedSignal().Connect(&application, finishCheck);
8356   application.SendNotification();
8357   application.Render(0);
8358   application.SendNotification();
8359   finishCheck.CheckSignalNotReceived();
8360   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8361
8362   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8363   application.SendNotification();
8364   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8365   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8366   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8367   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION );
8368   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8369
8370   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8371   application.SendNotification();
8372   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8373   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8374   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8375   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION );
8376   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8377
8378   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8379   application.SendNotification();
8380   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8381   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8382   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8383   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8384   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8385
8386   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8387   application.SendNotification();
8388   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8389   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8390   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8391   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8392   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8393
8394   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8395   application.SendNotification();
8396   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8397   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8398   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8399   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION );
8400   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8401
8402   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8403   application.SendNotification();
8404   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8405   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8406   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8407   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8408   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8409
8410   // We did expect the animation to finish
8411
8412   finishCheck.CheckSignalReceived();
8413   END_TEST;
8414 }
8415
8416 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8417 {
8418   TestApplication application;
8419
8420   float startValue(1.0f);
8421   Actor actor = Actor::New();
8422   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8423   Stage::GetCurrent().Add(actor);
8424
8425   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8426   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8427   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8428   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8429   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8430
8431   // Build the animation
8432   float durationSeconds(1.0f);
8433   Animation animation = Animation::New(durationSeconds);
8434
8435   KeyFrames keyFrames = KeyFrames::New();
8436   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8437   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8438   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8439
8440   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8441
8442   // Start the animation
8443   animation.Play();
8444
8445   bool signalReceived(false);
8446   AnimationFinishCheck finishCheck(signalReceived);
8447   animation.FinishedSignal().Connect(&application, finishCheck);
8448   application.SendNotification();
8449   application.Render(0);
8450   application.SendNotification();
8451   finishCheck.CheckSignalNotReceived();
8452   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8453   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8454   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8455   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8456
8457   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8458   application.SendNotification();
8459   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
8460   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8461   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
8462   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8463
8464   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8465   application.SendNotification();
8466   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8467   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8468   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8469   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8470
8471   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8472   application.SendNotification();
8473   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
8474   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8475   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
8476   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8477
8478   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8479   application.SendNotification();
8480   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8481   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8482   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8483   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8484
8485   // We did expect the animation to finish
8486
8487   finishCheck.CheckSignalReceived();
8488   END_TEST;
8489 }
8490
8491 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
8492 {
8493   TestApplication application;
8494
8495   float startValue(1.0f);
8496   Actor actor = Actor::New();
8497   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8498   Stage::GetCurrent().Add(actor);
8499
8500   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8501   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8502   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8503   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8504   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8505
8506   // Build the animation
8507   float durationSeconds(1.0f);
8508   Animation animation = Animation::New(durationSeconds);
8509
8510   KeyFrames keyFrames = KeyFrames::New();
8511   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8512   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8513   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8514
8515   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
8516
8517   // Start the animation
8518   animation.Play();
8519
8520   bool signalReceived(false);
8521   AnimationFinishCheck finishCheck(signalReceived);
8522   animation.FinishedSignal().Connect(&application, finishCheck);
8523   application.SendNotification();
8524   application.Render(0);
8525   application.SendNotification();
8526   finishCheck.CheckSignalNotReceived();
8527   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8528   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8529   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8530   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8531
8532   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8533   application.SendNotification();
8534   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8535   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8536   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8537   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8538
8539   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8540   application.SendNotification();
8541   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8542   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8543   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8544   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8545
8546   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8547   application.SendNotification();
8548   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
8549   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
8550   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
8551   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
8552
8553   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8554   application.SendNotification();
8555   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8556   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8557   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8558   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8559
8560   // We did expect the animation to finish
8561
8562   finishCheck.CheckSignalReceived();
8563   END_TEST;
8564 }
8565
8566 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
8567 {
8568   TestApplication application;
8569
8570   Actor actor = Actor::New();
8571   AngleAxis aa(Degree(90), Vector3::XAXIS);
8572   actor.SetOrientation(aa.angle, aa.axis);
8573   Stage::GetCurrent().Add(actor);
8574
8575   application.SendNotification();
8576   application.Render(0);
8577
8578   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8579
8580   // Build the animation
8581   float durationSeconds(1.0f);
8582   Animation animation = Animation::New(durationSeconds);
8583
8584   KeyFrames keyFrames = KeyFrames::New();
8585   keyFrames.Add(0.0f, false);
8586   keyFrames.Add(0.2f, true);
8587   keyFrames.Add(0.4f, true);
8588   keyFrames.Add(0.8f, false);
8589   keyFrames.Add(1.0f, true);
8590
8591   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
8592
8593   // Start the animation
8594   animation.Play();
8595
8596   bool signalReceived(false);
8597   AnimationFinishCheck finishCheck(signalReceived);
8598   animation.FinishedSignal().Connect(&application, finishCheck);
8599   application.SendNotification();
8600   application.SendNotification();
8601   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8602   application.SendNotification();
8603   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8604   application.SendNotification();
8605
8606   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
8607   finishCheck.CheckSignalReceived();
8608   END_TEST;
8609 }
8610
8611 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
8612 {
8613   TestApplication application;
8614
8615   Actor actor = Actor::New();
8616   AngleAxis aa(Degree(90), Vector3::XAXIS);
8617   actor.SetOrientation(aa.angle, aa.axis);
8618   Stage::GetCurrent().Add(actor);
8619
8620   application.SendNotification();
8621   application.Render(0);
8622
8623   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8624
8625   // Build the animation
8626   float durationSeconds(1.0f);
8627   Animation animation = Animation::New(durationSeconds);
8628
8629   KeyFrames keyFrames = KeyFrames::New();
8630   keyFrames.Add(0.0f, false);
8631   keyFrames.Add(0.2f, true);
8632   keyFrames.Add(0.4f, true);
8633   keyFrames.Add(0.8f, false);
8634   keyFrames.Add(1.0f, true);
8635
8636   //Cubic interpolation for boolean values should be ignored
8637   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
8638
8639   // Start the animation
8640   animation.Play();
8641
8642   bool signalReceived(false);
8643   AnimationFinishCheck finishCheck(signalReceived);
8644   animation.FinishedSignal().Connect(&application, finishCheck);
8645   application.SendNotification();
8646   application.SendNotification();
8647   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8648   application.SendNotification();
8649   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8650   application.SendNotification();
8651
8652   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
8653   finishCheck.CheckSignalReceived();
8654   END_TEST;
8655 }
8656
8657 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
8658 {
8659   TestApplication application;
8660
8661   Actor actor = Actor::New();
8662   AngleAxis aa(Degree(90), Vector3::XAXIS);
8663   actor.SetOrientation(aa.angle, aa.axis);
8664   Stage::GetCurrent().Add(actor);
8665
8666   application.SendNotification();
8667   application.Render(0);
8668   Quaternion start(Radian(aa.angle), aa.axis);
8669   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8670
8671   // Build the animation
8672   float durationSeconds(1.0f);
8673   Animation animation = Animation::New(durationSeconds);
8674
8675   KeyFrames keyFrames = KeyFrames::New();
8676   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
8677
8678   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
8679
8680   // Start the animation
8681   animation.Play();
8682
8683   bool signalReceived(false);
8684   AnimationFinishCheck finishCheck(signalReceived);
8685   animation.FinishedSignal().Connect(&application, finishCheck);
8686   application.SendNotification();
8687   application.SendNotification();
8688   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8689   application.SendNotification();
8690   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8691   application.SendNotification();
8692
8693   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
8694
8695   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8696   finishCheck.CheckSignalReceived();
8697   END_TEST;
8698 }
8699
8700 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
8701 {
8702   TestApplication application;
8703
8704   Actor actor = Actor::New();
8705   AngleAxis aa(Degree(90), Vector3::XAXIS);
8706   actor.SetOrientation(aa.angle, aa.axis);
8707   application.SendNotification();
8708   application.Render(0);
8709   Stage::GetCurrent().Add(actor);
8710
8711   Quaternion start(Radian(aa.angle), aa.axis);
8712   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8713
8714   // Build the animation
8715   float durationSeconds(1.0f);
8716   Animation animation = Animation::New(durationSeconds);
8717
8718   KeyFrames keyFrames = KeyFrames::New();
8719   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
8720   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
8721   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
8722
8723   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
8724
8725   // Start the animation
8726   animation.Play();
8727
8728   bool signalReceived(false);
8729   AnimationFinishCheck finishCheck(signalReceived);
8730   animation.FinishedSignal().Connect(&application, finishCheck);
8731   application.SendNotification();
8732   application.Render(0);
8733   application.SendNotification();
8734   finishCheck.CheckSignalNotReceived();
8735
8736   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
8737   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8738
8739   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8740   application.SendNotification();
8741   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
8742   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8743
8744   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8745   application.SendNotification();
8746   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
8747   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8748
8749   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8750   application.SendNotification();
8751   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
8752   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8753
8754   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8755   application.SendNotification();
8756   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
8757   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8758
8759   // We did expect the animation to finish
8760
8761   finishCheck.CheckSignalReceived();
8762   END_TEST;
8763 }
8764
8765 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
8766 {
8767   TestApplication application;
8768
8769   Actor actor = Actor::New();
8770   AngleAxis aa(Degree(90), Vector3::XAXIS);
8771   actor.SetOrientation(aa.angle, aa.axis);
8772   Stage::GetCurrent().Add(actor);
8773
8774   application.SendNotification();
8775   application.Render(0);
8776   Quaternion start(Radian(aa.angle), aa.axis);
8777   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8778
8779   // Build the animation
8780   float durationSeconds(1.0f);
8781   Animation animation = Animation::New(durationSeconds);
8782
8783   KeyFrames keyFrames = KeyFrames::New();
8784   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
8785
8786   //Cubic interpolation should be ignored for quaternions
8787   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
8788
8789   // Start the animation
8790   animation.Play();
8791
8792   bool signalReceived(false);
8793   AnimationFinishCheck finishCheck(signalReceived);
8794   animation.FinishedSignal().Connect(&application, finishCheck);
8795   application.SendNotification();
8796   application.SendNotification();
8797   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8798   application.SendNotification();
8799   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8800   application.SendNotification();
8801
8802   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
8803
8804   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8805   finishCheck.CheckSignalReceived();
8806   END_TEST;
8807 }
8808
8809 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
8810 {
8811   TestApplication application;
8812
8813   Actor actor = Actor::New();
8814   AngleAxis aa(Degree(90), Vector3::XAXIS);
8815   actor.SetOrientation(aa.angle, aa.axis);
8816   application.SendNotification();
8817   application.Render(0);
8818   Stage::GetCurrent().Add(actor);
8819
8820   Quaternion start(Radian(aa.angle), aa.axis);
8821   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8822
8823   // Build the animation
8824   float durationSeconds(1.0f);
8825   Animation animation = Animation::New(durationSeconds);
8826
8827   KeyFrames keyFrames = KeyFrames::New();
8828   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
8829   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
8830   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
8831
8832   //Cubic interpolation should be ignored for quaternions
8833   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
8834
8835   // Start the animation
8836   animation.Play();
8837
8838   bool signalReceived(false);
8839   AnimationFinishCheck finishCheck(signalReceived);
8840   animation.FinishedSignal().Connect(&application, finishCheck);
8841   application.SendNotification();
8842   application.Render(0);
8843   application.SendNotification();
8844   finishCheck.CheckSignalNotReceived();
8845
8846   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
8847   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8848
8849   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8850   application.SendNotification();
8851   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
8852   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8853
8854   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8855   application.SendNotification();
8856   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
8857   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8858
8859   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8860   application.SendNotification();
8861   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
8862   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8863
8864   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8865   application.SendNotification();
8866   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
8867   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8868
8869   // We did expect the animation to finish
8870
8871   finishCheck.CheckSignalReceived();
8872   END_TEST;
8873 }
8874
8875 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
8876 {
8877   TestApplication application;
8878
8879   float startValue(1.0f);
8880   Actor actor = Actor::New();
8881   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8882   Stage::GetCurrent().Add(actor);
8883
8884   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8885   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8886   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8887   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8888   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8889
8890   // Build the animation
8891   float durationSeconds(1.0f);
8892   Animation animation = Animation::New(durationSeconds);
8893
8894   KeyFrames keyFrames = KeyFrames::New();
8895   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8896   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8897   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8898
8899   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
8900
8901   // Start the animation
8902   animation.Play();
8903
8904   bool signalReceived(false);
8905   AnimationFinishCheck finishCheck(signalReceived);
8906   animation.FinishedSignal().Connect(&application, finishCheck);
8907   application.SendNotification();
8908   application.Render(0);
8909   application.SendNotification();
8910   finishCheck.CheckSignalNotReceived();
8911   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8912   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8913   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8914   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8915
8916   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8917   application.SendNotification();
8918   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
8919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8920   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
8921   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8922
8923   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8924   application.SendNotification();
8925   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8926   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8927   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8928   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8929
8930   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8931   application.SendNotification();
8932   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
8933   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8934   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
8935   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8936
8937   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8938   application.SendNotification();
8939   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8940   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8941   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8942   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8943
8944   // We did expect the animation to finish
8945
8946   finishCheck.CheckSignalReceived();
8947   END_TEST;
8948 }
8949
8950 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
8951 {
8952   TestApplication application;
8953
8954   float startValue(1.0f);
8955   Actor actor = Actor::New();
8956   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8957   Stage::GetCurrent().Add(actor);
8958
8959   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8960   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8961   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8962   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8963   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8964
8965   // Build the animation
8966   float durationSeconds(1.0f);
8967   Animation animation = Animation::New(durationSeconds);
8968
8969   KeyFrames keyFrames = KeyFrames::New();
8970   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8971   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8972   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8973
8974   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
8975
8976   // Start the animation
8977   animation.Play();
8978
8979   bool signalReceived(false);
8980   AnimationFinishCheck finishCheck(signalReceived);
8981   animation.FinishedSignal().Connect(&application, finishCheck);
8982   application.SendNotification();
8983   application.Render(0);
8984   application.SendNotification();
8985   finishCheck.CheckSignalNotReceived();
8986   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8987   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8988   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8989   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8990
8991   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8992   application.SendNotification();
8993   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8994   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8995   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8996   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8997
8998   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8999   application.SendNotification();
9000   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9001   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9002   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9003   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9004
9005   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9006   application.SendNotification();
9007   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
9008   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
9009   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
9010   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
9011
9012   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9013   application.SendNotification();
9014   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9015   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9016   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9017   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9018
9019   // We did expect the animation to finish
9020
9021   finishCheck.CheckSignalReceived();
9022   END_TEST;
9023 }
9024
9025 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9026 {
9027   TestApplication application;
9028
9029   float startValue(1.0f);
9030   Actor actor = Actor::New();
9031   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9032   Stage::GetCurrent().Add(actor);
9033
9034   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9035   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9036   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9037   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9038   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9039
9040   // Build the animation
9041   float durationSeconds(1.0f);
9042   float delay = 0.5f;
9043   Animation animation = Animation::New(durationSeconds);
9044
9045   KeyFrames keyFrames = KeyFrames::New();
9046   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9047   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9048   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9049
9050   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9051
9052   // Start the animation
9053   animation.Play();
9054
9055   bool signalReceived(false);
9056   AnimationFinishCheck finishCheck(signalReceived);
9057   animation.FinishedSignal().Connect(&application, finishCheck);
9058   application.SendNotification();
9059
9060   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9061   application.SendNotification();
9062   finishCheck.CheckSignalNotReceived();
9063   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9064   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9065   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9066   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9067
9068   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9069   application.SendNotification();
9070   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
9071   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9072   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
9073   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9074
9075   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9076   application.SendNotification();
9077   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9078   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9079   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9080   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9081
9082   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9083   application.SendNotification();
9084   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
9085   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9086   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
9087   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9088
9089   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9090   application.SendNotification();
9091   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9092   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9093   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9094   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9095
9096   // We did expect the animation to finish
9097
9098   finishCheck.CheckSignalReceived();
9099   END_TEST;
9100 }
9101
9102 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9103 {
9104   TestApplication application;
9105
9106   float startValue(1.0f);
9107   Actor actor = Actor::New();
9108   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9109   Stage::GetCurrent().Add(actor);
9110
9111   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9112   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9113   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9114   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9115   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9116
9117   // Build the animation
9118   float durationSeconds(1.0f);
9119   float delay = 0.5f;
9120   Animation animation = Animation::New(durationSeconds);
9121
9122   KeyFrames keyFrames = KeyFrames::New();
9123   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9124   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9125   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9126
9127   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9128
9129   // Start the animation
9130   animation.Play();
9131
9132   bool signalReceived(false);
9133   AnimationFinishCheck finishCheck(signalReceived);
9134   animation.FinishedSignal().Connect(&application, finishCheck);
9135   application.SendNotification();
9136
9137   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9138   application.SendNotification();
9139   finishCheck.CheckSignalNotReceived();
9140   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9141   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9142   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9143   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9144
9145   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9146   application.SendNotification();
9147   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
9148   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
9149   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
9150   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
9151
9152   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9153   application.SendNotification();
9154   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9155   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9156   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9157   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9158
9159   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9160   application.SendNotification();
9161   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
9162   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
9163   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
9164   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
9165
9166   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9167   application.SendNotification();
9168   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9169   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9170   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9171   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9172
9173   // We did expect the animation to finish
9174
9175   finishCheck.CheckSignalReceived();
9176   END_TEST;
9177 }
9178
9179 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9180 {
9181   TestApplication application;
9182
9183   float startValue(1.0f);
9184   float delay = 0.5f;
9185   Actor actor = Actor::New();
9186   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9187   Stage::GetCurrent().Add(actor);
9188
9189   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9190   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9191   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9192   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9193   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9194
9195   // Build the animation
9196   float durationSeconds(1.0f);
9197   Animation animation = Animation::New(durationSeconds);
9198
9199   KeyFrames keyFrames = KeyFrames::New();
9200   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9201   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9202   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9203
9204   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9205
9206   // Start the animation
9207   animation.Play();
9208
9209   bool signalReceived(false);
9210   AnimationFinishCheck finishCheck(signalReceived);
9211   animation.FinishedSignal().Connect(&application, finishCheck);
9212   application.SendNotification();
9213
9214   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9215   application.SendNotification();
9216   finishCheck.CheckSignalNotReceived();
9217   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9218   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9219   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9220   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9221
9222   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9223   application.SendNotification();
9224   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
9225   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
9226   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
9227   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
9228
9229   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9230   application.SendNotification();
9231   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9232   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9233   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9234   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9235
9236   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9237   application.SendNotification();
9238   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
9239   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
9240   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
9241   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
9242
9243   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9244   application.SendNotification();
9245   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9246   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9247   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9248   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9249
9250   // We did expect the animation to finish
9251
9252   finishCheck.CheckSignalReceived();
9253   END_TEST;
9254 }
9255
9256 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9257 {
9258   TestApplication application;
9259
9260   float startValue(1.0f);
9261   Actor actor = Actor::New();
9262   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9263   Stage::GetCurrent().Add(actor);
9264
9265   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9266   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9267   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9268   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9269   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9270
9271   // Build the animation
9272   float durationSeconds(1.0f);
9273   float delay = 0.5f;
9274   Animation animation = Animation::New(durationSeconds);
9275
9276   KeyFrames keyFrames = KeyFrames::New();
9277   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9278   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9279   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9280
9281   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9282
9283   // Start the animation
9284   animation.Play();
9285
9286   bool signalReceived(false);
9287   AnimationFinishCheck finishCheck(signalReceived);
9288   animation.FinishedSignal().Connect(&application, finishCheck);
9289   application.SendNotification();
9290
9291   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9292   application.SendNotification();
9293   finishCheck.CheckSignalNotReceived();
9294   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
9295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
9296   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
9297   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
9298
9299   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9300   application.SendNotification();
9301   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
9302   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
9303   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
9304   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
9305
9306   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9307   application.SendNotification();
9308   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
9309   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9310   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
9311   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
9312
9313   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9314   application.SendNotification();
9315   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
9316   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
9317   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
9318   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
9319
9320   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9321   application.SendNotification();
9322   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
9323   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
9324   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
9325   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
9326
9327   // We did expect the animation to finish
9328
9329   finishCheck.CheckSignalReceived();
9330   END_TEST;
9331 }
9332
9333 int UtcDaliAnimationAnimateP(void)
9334 {
9335   TestApplication application;
9336
9337   Actor actor = Actor::New();
9338   Stage::GetCurrent().Add(actor);
9339
9340   //Build the path
9341   Vector3 position0( 30.0,  80.0,  0.0);
9342   Vector3 position1( 70.0,  120.0, 0.0);
9343   Vector3 position2( 100.0, 100.0, 0.0);
9344
9345   Dali::Path path = Dali::Path::New();
9346   path.AddPoint(position0);
9347   path.AddPoint(position1);
9348   path.AddPoint(position2);
9349
9350   //Control points for first segment
9351   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9352   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9353
9354   //Control points for second segment
9355   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9356   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9357
9358   // Build the animation
9359   float durationSeconds( 1.0f );
9360   Animation animation = Animation::New(durationSeconds);
9361   animation.Animate(actor, path, Vector3::XAXIS);
9362
9363   // Start the animation
9364   animation.Play();
9365
9366   bool signalReceived(false);
9367   AnimationFinishCheck finishCheck(signalReceived);
9368   animation.FinishedSignal().Connect(&application, finishCheck);
9369   application.SendNotification();
9370   application.Render(0);
9371   application.SendNotification();
9372   finishCheck.CheckSignalNotReceived();
9373   Vector3 position, tangent;
9374   Quaternion rotation;
9375   path.Sample( 0.0f, position, tangent );
9376   rotation = Quaternion( Vector3::XAXIS, tangent );
9377   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9378   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9379
9380   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9381   application.SendNotification();
9382   path.Sample( 0.25f, position, tangent );
9383   rotation = Quaternion( Vector3::XAXIS, tangent );
9384   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9385   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9386
9387   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9388   application.SendNotification();
9389   path.Sample( 0.5f, position, tangent );
9390   rotation = Quaternion( Vector3::XAXIS, tangent );
9391   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9392   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9393
9394   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9395   application.SendNotification();
9396   path.Sample( 0.75f, position, tangent );
9397   rotation = Quaternion( Vector3::XAXIS, tangent );
9398   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9399   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9400
9401   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9402   application.SendNotification();
9403   path.Sample( 1.0f, position, tangent );
9404   rotation = Quaternion( Vector3::XAXIS, tangent );
9405   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9406   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9407
9408   finishCheck.CheckSignalReceived();
9409   END_TEST;
9410 }
9411
9412 int UtcDaliAnimationAnimateAlphaFunctionP(void)
9413 {
9414   TestApplication application;
9415
9416   Actor actor = Actor::New();
9417   Stage::GetCurrent().Add(actor);
9418
9419   //Build the path
9420   Vector3 position0( 30.0,  80.0,  0.0);
9421   Vector3 position1( 70.0,  120.0, 0.0);
9422   Vector3 position2( 100.0, 100.0, 0.0);
9423
9424   Dali::Path path = Dali::Path::New();
9425   path.AddPoint(position0);
9426   path.AddPoint(position1);
9427   path.AddPoint(position2);
9428
9429   //Control points for first segment
9430   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9431   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9432
9433   //Control points for second segment
9434   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9435   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9436
9437   // Build the animation
9438   float durationSeconds( 1.0f );
9439   Animation animation = Animation::New(durationSeconds);
9440   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
9441
9442   // Start the animation
9443   animation.Play();
9444
9445   bool signalReceived(false);
9446   AnimationFinishCheck finishCheck(signalReceived);
9447   animation.FinishedSignal().Connect(&application, finishCheck);
9448   application.SendNotification();
9449   application.Render(0);
9450   application.SendNotification();
9451   finishCheck.CheckSignalNotReceived();
9452   Vector3 position, tangent;
9453   Quaternion rotation;
9454   path.Sample( 0.0f, position, tangent );
9455   rotation = Quaternion( Vector3::XAXIS, tangent );
9456   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9457   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9458
9459   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9460   application.SendNotification();
9461   path.Sample( 0.25f, position, tangent );
9462   rotation = Quaternion( Vector3::XAXIS, tangent );
9463   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9464   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9465
9466   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9467   application.SendNotification();
9468   path.Sample( 0.5f, position, tangent );
9469   rotation = Quaternion( Vector3::XAXIS, tangent );
9470   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9471   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9472
9473   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9474   application.SendNotification();
9475   path.Sample( 0.75f, position, tangent );
9476   rotation = Quaternion( Vector3::XAXIS, tangent );
9477   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9478   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9479
9480   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9481   application.SendNotification();
9482   path.Sample( 1.0f, position, tangent );
9483   rotation = Quaternion( Vector3::XAXIS, tangent );
9484   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9485   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9486
9487   finishCheck.CheckSignalReceived();
9488   END_TEST;
9489 }
9490
9491 int UtcDaliAnimationAnimateTimePeriodP(void)
9492 {
9493   TestApplication application;
9494
9495   Actor actor = Actor::New();
9496   Stage::GetCurrent().Add(actor);
9497
9498   //Build the path
9499   Vector3 position0( 30.0,  80.0,  0.0);
9500   Vector3 position1( 70.0,  120.0, 0.0);
9501   Vector3 position2( 100.0, 100.0, 0.0);
9502
9503   Dali::Path path = Dali::Path::New();
9504   path.AddPoint(position0);
9505   path.AddPoint(position1);
9506   path.AddPoint(position2);
9507
9508   //Control points for first segment
9509   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9510   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9511
9512   //Control points for second segment
9513   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9514   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9515
9516   // Build the animation
9517   float durationSeconds( 1.0f );
9518   Animation animation = Animation::New(durationSeconds);
9519   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
9520
9521   // Start the animation
9522   animation.Play();
9523
9524   bool signalReceived(false);
9525   AnimationFinishCheck finishCheck(signalReceived);
9526   animation.FinishedSignal().Connect(&application, finishCheck);
9527   application.SendNotification();
9528   application.Render(0);
9529   application.SendNotification();
9530   finishCheck.CheckSignalNotReceived();
9531   Vector3 position, tangent;
9532   Quaternion rotation;
9533   path.Sample( 0.0f, position, tangent );
9534   rotation = Quaternion( Vector3::XAXIS, tangent );
9535   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9536   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9537
9538   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9539   application.SendNotification();
9540   path.Sample( 0.25f, position, tangent );
9541   rotation = Quaternion( Vector3::XAXIS, tangent );
9542   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9543   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9544
9545   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9546   application.SendNotification();
9547   path.Sample( 0.5f, position, tangent );
9548   rotation = Quaternion( Vector3::XAXIS, tangent );
9549   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9550   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9551
9552   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9553   application.SendNotification();
9554   path.Sample( 0.75f, position, tangent );
9555   rotation = Quaternion( Vector3::XAXIS, tangent );
9556   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9557   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9558
9559   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9560   application.SendNotification();
9561   path.Sample( 1.0f, position, tangent );
9562   rotation = Quaternion( Vector3::XAXIS, tangent );
9563   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9564   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9565
9566   finishCheck.CheckSignalReceived();
9567   END_TEST;
9568 }
9569
9570 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
9571 {
9572   TestApplication application;
9573
9574   Actor actor = Actor::New();
9575   Stage::GetCurrent().Add(actor);
9576
9577   //Build the path
9578   Vector3 position0( 30.0,  80.0,  0.0);
9579   Vector3 position1( 70.0,  120.0, 0.0);
9580   Vector3 position2( 100.0, 100.0, 0.0);
9581
9582   Dali::Path path = Dali::Path::New();
9583   path.AddPoint(position0);
9584   path.AddPoint(position1);
9585   path.AddPoint(position2);
9586
9587   //Control points for first segment
9588   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9589   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9590
9591   //Control points for second segment
9592   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9593   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9594
9595   // Build the animation
9596   float durationSeconds( 1.0f );
9597   Animation animation = Animation::New(durationSeconds);
9598   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
9599
9600   // Start the animation
9601   animation.Play();
9602
9603   bool signalReceived(false);
9604   AnimationFinishCheck finishCheck(signalReceived);
9605   animation.FinishedSignal().Connect(&application, finishCheck);
9606   application.SendNotification();
9607   application.Render(0);
9608   application.SendNotification();
9609   finishCheck.CheckSignalNotReceived();
9610   Vector3 position, tangent;
9611   Quaternion rotation;
9612   path.Sample( 0.0f, position, tangent );
9613   rotation = Quaternion( Vector3::XAXIS, tangent );
9614   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9615   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9616
9617   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9618   application.SendNotification();
9619   path.Sample( 0.25f, position, tangent );
9620   rotation = Quaternion( Vector3::XAXIS, tangent );
9621   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9622   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9623
9624   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9625   application.SendNotification();
9626   path.Sample( 0.5f, position, tangent );
9627   rotation = Quaternion( Vector3::XAXIS, tangent );
9628   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9629   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9630
9631   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9632   application.SendNotification();
9633   path.Sample( 0.75f, position, tangent );
9634   rotation = Quaternion( Vector3::XAXIS, tangent );
9635   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9636   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9637
9638   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9639   application.SendNotification();
9640   path.Sample( 1.0f, position, tangent );
9641   rotation = Quaternion( Vector3::XAXIS, tangent );
9642   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9643   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9644
9645   finishCheck.CheckSignalReceived();
9646   END_TEST;
9647 }
9648
9649 int UtcDaliAnimationShowP(void)
9650 {
9651   TestApplication application;
9652
9653   Actor actor = Actor::New();
9654   actor.SetVisible(false);
9655   application.SendNotification();
9656   application.Render(0);
9657   DALI_TEST_CHECK( !actor.IsVisible() );
9658   Stage::GetCurrent().Add(actor);
9659
9660   // Start the animation
9661   float durationSeconds(10.0f);
9662   Animation animation = Animation::New(durationSeconds);
9663   animation.Show(actor, durationSeconds*0.5f);
9664   animation.Play();
9665
9666   bool signalReceived(false);
9667   AnimationFinishCheck finishCheck(signalReceived);
9668   animation.FinishedSignal().Connect(&application, finishCheck);
9669
9670   application.SendNotification();
9671   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
9672
9673   // We didn't expect the animation to finish yet
9674   application.SendNotification();
9675   finishCheck.CheckSignalNotReceived();
9676   DALI_TEST_CHECK( !actor.IsVisible() );
9677
9678   application.SendNotification();
9679   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
9680
9681   // We didn't expect the animation to finish yet
9682   application.SendNotification();
9683   finishCheck.CheckSignalNotReceived();
9684   DALI_TEST_CHECK( actor.IsVisible() );
9685
9686   application.SendNotification();
9687   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9688
9689   // We did expect the animation to finish
9690   application.SendNotification();
9691   finishCheck.CheckSignalReceived();
9692   DALI_TEST_CHECK( actor.IsVisible() );
9693   END_TEST;
9694 }
9695
9696 int UtcDaliAnimationHideP(void)
9697 {
9698   TestApplication application;
9699
9700   Actor actor = Actor::New();
9701   DALI_TEST_CHECK( actor.IsVisible() );
9702   Stage::GetCurrent().Add(actor);
9703
9704   // Start the animation
9705   float durationSeconds(10.0f);
9706   Animation animation = Animation::New(durationSeconds);
9707   animation.Hide(actor, durationSeconds*0.5f);
9708   animation.Play();
9709
9710   bool signalReceived(false);
9711   AnimationFinishCheck finishCheck(signalReceived);
9712   animation.FinishedSignal().Connect(&application, finishCheck);
9713
9714   application.SendNotification();
9715   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
9716
9717   // We didn't expect the animation to finish yet
9718   application.SendNotification();
9719   finishCheck.CheckSignalNotReceived();
9720   DALI_TEST_CHECK( actor.IsVisible() );
9721
9722   application.SendNotification();
9723   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
9724
9725   // We didn't expect the animation to finish yet
9726   application.SendNotification();
9727   finishCheck.CheckSignalNotReceived();
9728   DALI_TEST_CHECK( !actor.IsVisible() );
9729
9730   application.SendNotification();
9731   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9732
9733   // We did expect the animation to finish
9734   application.SendNotification();
9735   finishCheck.CheckSignalReceived();
9736   DALI_TEST_CHECK( !actor.IsVisible() );
9737   END_TEST;
9738 }
9739
9740 int UtcDaliAnimationShowHideAtEndP(void)
9741 {
9742   // Test that show/hide delay can be the same as animation duration
9743   // i.e. to show/hide at the end of the animation
9744
9745   TestApplication application;
9746
9747   Actor actor = Actor::New();
9748   DALI_TEST_CHECK( actor.IsVisible() );
9749   Stage::GetCurrent().Add(actor);
9750
9751   // Start Hide animation
9752   float durationSeconds(10.0f);
9753   Animation animation = Animation::New(durationSeconds);
9754   animation.Hide(actor, durationSeconds/*Hide at end*/);
9755   animation.Play();
9756
9757   bool signalReceived(false);
9758   AnimationFinishCheck finishCheck(signalReceived);
9759   animation.FinishedSignal().Connect(&application, finishCheck);
9760
9761   application.SendNotification();
9762   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
9763
9764   // We did expect the animation to finish
9765   application.SendNotification();
9766   finishCheck.CheckSignalReceived();
9767   DALI_TEST_CHECK( !actor.IsVisible() );
9768
9769   // Start Show animation
9770   animation = Animation::New(durationSeconds);
9771   animation.Show(actor, durationSeconds/*Show at end*/);
9772   animation.FinishedSignal().Connect(&application, finishCheck);
9773   animation.Play();
9774
9775   application.SendNotification();
9776   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
9777
9778   // We did expect the animation to finish
9779   application.SendNotification();
9780   finishCheck.CheckSignalReceived();
9781   DALI_TEST_CHECK( actor.IsVisible() );
9782   END_TEST;
9783 }
9784
9785 int UtcDaliKeyFramesCreateDestroyP(void)
9786 {
9787   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
9788
9789   KeyFrames* keyFrames = new KeyFrames;
9790   delete keyFrames;
9791   DALI_TEST_CHECK( true );
9792   END_TEST;
9793 }
9794
9795 int UtcDaliKeyFramesDownCastP(void)
9796 {
9797   TestApplication application;
9798   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
9799
9800   KeyFrames keyFrames = KeyFrames::New();
9801   BaseHandle object(keyFrames);
9802
9803   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
9804   DALI_TEST_CHECK(keyFrames2);
9805
9806   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
9807   DALI_TEST_CHECK(keyFrames3);
9808
9809   BaseHandle unInitializedObject;
9810   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
9811   DALI_TEST_CHECK(!keyFrames4);
9812
9813   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
9814   DALI_TEST_CHECK(!keyFrames5);
9815   END_TEST;
9816 }
9817
9818 int UtcDaliAnimationCreateDestroyP(void)
9819 {
9820   TestApplication application;
9821   Animation* animation = new Animation;
9822   DALI_TEST_CHECK( animation );
9823   delete animation;
9824   END_TEST;
9825 }
9826
9827 struct UpdateManagerTestConstraint
9828 {
9829   UpdateManagerTestConstraint(TestApplication& application)
9830   : mApplication(application)
9831   {
9832   }
9833
9834   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
9835   {
9836     mApplication.SendNotification();  // Process events
9837   }
9838
9839   TestApplication& mApplication;
9840 };
9841
9842 int UtcDaliAnimationUpdateManagerP(void)
9843 {
9844   TestApplication application;
9845
9846   Actor actor = Actor::New();
9847   Stage::GetCurrent().Add( actor );
9848
9849   // Build the animation
9850   Animation animation = Animation::New( 0.0f );
9851
9852   bool signalReceived = false;
9853   AnimationFinishCheck finishCheck( signalReceived );
9854   animation.FinishedSignal().Connect( &application, finishCheck );
9855
9856   Vector3 startValue(1.0f, 1.0f, 1.0f);
9857   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
9858   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
9859   constraint.Apply();
9860
9861   // Apply animation to actor
9862   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
9863
9864   animation.Play();
9865
9866   application.SendNotification();
9867   application.UpdateOnly( 16 );
9868
9869   finishCheck.CheckSignalNotReceived();
9870
9871   application.SendNotification();   // Process events
9872
9873   finishCheck.CheckSignalReceived();
9874
9875   END_TEST;
9876 }
9877
9878 int UtcDaliAnimationSignalOrderP(void)
9879 {
9880   TestApplication application;
9881
9882   Actor actor = Actor::New();
9883   Stage::GetCurrent().Add( actor );
9884
9885   // Build the animations
9886   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
9887   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
9888
9889   bool signal1Received = false;
9890   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
9891
9892   bool signal2Received = false;
9893   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
9894
9895   // Apply animations to actor
9896   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
9897   animation1.Play();
9898   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
9899   animation2.Play();
9900
9901   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9902   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9903
9904   application.SendNotification();
9905   application.UpdateOnly( 10 ); // 10ms progress
9906
9907   // no notifications yet
9908   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9909   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9910
9911   application.SendNotification();
9912
9913   // first completed
9914   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
9915   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
9916   signal1Received = false;
9917
9918   // 1st animation is complete now, do another update with no ProcessEvents in between
9919   application.UpdateOnly( 20 ); // 20ms progress
9920
9921   // ProcessEvents
9922   application.SendNotification();
9923
9924   // 2nd should complete now
9925   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
9926   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
9927
9928   END_TEST;
9929 }
9930
9931 int UtcDaliAnimationExtendDurationP(void)
9932 {
9933   TestApplication application;
9934
9935   Actor actor = Actor::New();
9936
9937   // Register a float property
9938   float startValue(10.0f);
9939   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
9940   Stage::GetCurrent().Add(actor);
9941   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9942
9943   // Build the animation
9944   float initialDurationSeconds(1.0f);
9945   float animatorDelay = 5.0f;
9946   float animatorDurationSeconds(5.0f);
9947   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
9948   Animation animation = Animation::New(initialDurationSeconds);
9949   float targetValue(30.0f);
9950   float relativeValue(targetValue - startValue);
9951
9952   animation.AnimateTo(Property(actor, index),
9953                       targetValue,
9954                       TimePeriod(animatorDelay, animatorDurationSeconds));
9955
9956   // The duration should have been extended
9957   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
9958
9959   // Start the animation
9960   animation.Play();
9961
9962   bool signalReceived(false);
9963   AnimationFinishCheck finishCheck(signalReceived);
9964   animation.FinishedSignal().Connect(&application, finishCheck);
9965
9966   application.SendNotification();
9967   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
9968
9969   // We didn't expect the animation to finish yet
9970   application.SendNotification();
9971   finishCheck.CheckSignalNotReceived();
9972   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
9973
9974   application.SendNotification();
9975   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
9976
9977   // We didn't expect the animation to finish yet
9978   application.SendNotification();
9979   finishCheck.CheckSignalNotReceived();
9980   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
9981
9982   application.SendNotification();
9983   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
9984
9985   // We did expect the animation to finish
9986   application.SendNotification();
9987   finishCheck.CheckSignalReceived();
9988   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
9989   END_TEST;
9990 }
9991
9992 int UtcDaliAnimationCustomIntProperty(void)
9993 {
9994   TestApplication application;
9995
9996   Actor actor = Actor::New();
9997   Stage::GetCurrent().Add(actor);
9998   int startValue(0u);
9999
10000   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10001   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10002
10003   // Build the animation
10004   float durationSeconds(1.0f);
10005   Animation animation = Animation::New(durationSeconds);
10006   animation.AnimateTo( Property(actor, index), 20 );
10007
10008   // Start the animation
10009   animation.Play();
10010
10011   bool signalReceived(false);
10012   AnimationFinishCheck finishCheck(signalReceived);
10013   animation.FinishedSignal().Connect(&application, finishCheck);
10014
10015   application.SendNotification();
10016   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10017
10018   // We didn't expect the animation to finish yet
10019   application.SendNotification();
10020   finishCheck.CheckSignalNotReceived();
10021   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 10, TEST_LOCATION );
10022
10023   application.SendNotification();
10024   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10025
10026   // We did expect the animation to finish
10027   application.SendNotification();
10028   finishCheck.CheckSignalReceived();
10029   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 20, TEST_LOCATION );
10030   END_TEST;
10031 }
10032
10033 int UtcDaliAnimationDuration(void)
10034 {
10035   TestApplication application;
10036
10037   Actor actor = Actor::New();
10038   Stage::GetCurrent().Add(actor);
10039
10040   Animation animation = Animation::New( 0.0f );
10041   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10042
10043   // The animation duration should automatically increase depending on the animator time period
10044
10045   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10046   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10047
10048   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10049   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10050
10051   END_TEST;
10052 }
10053
10054 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10055 {
10056   TestApplication application;
10057
10058   Actor actor = Actor::New();
10059
10060   // Register an integer property
10061   int startValue(1);
10062   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10063   Stage::GetCurrent().Add(actor);
10064   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10065
10066   try
10067   {
10068     // Build the animation
10069     Animation animation = Animation::New( 2.0f );
10070     std::string relativeValue = "relative string";
10071     animation.AnimateBy( Property(actor, index), relativeValue );
10072     tet_result(TET_FAIL);
10073   }
10074   catch ( Dali::DaliException& e )
10075   {
10076     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10077   }
10078
10079
10080   END_TEST;
10081 }
10082
10083
10084 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10085 {
10086   TestApplication application;
10087
10088   Actor actor = Actor::New();
10089
10090   // Register an integer property
10091   int startValue(1);
10092   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10093   Stage::GetCurrent().Add(actor);
10094   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10095
10096   try
10097   {
10098     // Build the animation
10099     Animation animation = Animation::New( 2.0f );
10100     std::string relativeValue = "relative string";
10101     animation.AnimateTo( Property(actor, index), relativeValue );
10102
10103     tet_result(TET_FAIL);
10104   }
10105   catch ( Dali::DaliException& e )
10106   {
10107    DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10108   }
10109
10110   END_TEST;
10111 }
10112
10113 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10114 {
10115   TestApplication application;
10116
10117   Actor actor = Actor::New();
10118
10119   // Register an integer property
10120   int startValue(1);
10121   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10122   Stage::GetCurrent().Add(actor);
10123   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10124
10125   try
10126   {
10127     // Build the animation
10128     KeyFrames keyFrames = KeyFrames::New();
10129     keyFrames.Add( 0.0f, std::string("relative string1") );
10130     keyFrames.Add( 1.0f, std::string("relative string2") );
10131     // no need to really create the animation as keyframes do the check
10132
10133     tet_result(TET_FAIL);
10134   }
10135   catch ( Dali::DaliException& e )
10136   {
10137     DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
10138   }
10139
10140   END_TEST;
10141 }