01180b8ad27dc004e29c7eb65a3c0d44b37e17e8
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2017 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/devel-api/actors/actor-devel.h>
24 #include <dali-test-suite-utils.h>
25
26 using std::max;
27 using namespace Dali;
28
29 void utc_dali_animation_startuP(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_animation_cleanuP(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 static const float ROTATION_EPSILON = 0.0001f;
43 static const float VECTOR4_EPSILON = 0.0001f;
44
45 // Functor to test whether a Finish signal is emitted
46 struct AnimationFinishCheck
47 {
48   AnimationFinishCheck(bool& signalReceived)
49   : mSignalReceived(signalReceived)
50   {
51   }
52
53   void operator()(Animation& animation)
54   {
55     mSignalReceived = true;
56   }
57
58   void Reset()
59   {
60     mSignalReceived = false;
61   }
62
63   void CheckSignalReceived()
64   {
65     if (!mSignalReceived)
66     {
67       tet_printf("Expected Finish signal was not received\n");
68       tet_result(TET_FAIL);
69     }
70     else
71     {
72       tet_result(TET_PASS);
73     }
74   }
75
76   void CheckSignalNotReceived()
77   {
78     if (mSignalReceived)
79     {
80       tet_printf("Unexpected Finish signal was received\n");
81       tet_result(TET_FAIL);
82     }
83     else
84     {
85       tet_result(TET_PASS);
86     }
87   }
88
89   bool& mSignalReceived; // owned by individual tests
90 };
91
92 } // anon namespace
93
94 int UtcDaliAnimationConstructorP(void)
95 {
96   TestApplication application;
97
98   Animation animation;
99
100   DALI_TEST_CHECK( !animation );
101   END_TEST;
102 }
103
104 int UtcDaliAnimationNewP(void)
105 {
106   TestApplication application;
107
108   Animation animation = Animation::New( 1.0f );
109
110   DALI_TEST_CHECK(animation);
111   END_TEST;
112 }
113
114 int UtcDaliAnimationNewN(void)
115 {
116   TestApplication application;
117
118   Animation animation = Animation::New( -1.0f );
119
120   DALI_TEST_CHECK(animation);
121   DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
122   END_TEST;
123 }
124
125 int UtcDaliAnimationDownCastP(void)
126 {
127   TestApplication application;
128
129   tet_infoline("Testing Dali::Animation::DownCast()");
130
131   float durationSeconds(1.0f);
132   Animation animation = Animation::New(durationSeconds);
133
134   BaseHandle object(animation);
135
136   Animation animation2 = Animation::DownCast(object);
137   DALI_TEST_CHECK(animation2);
138
139   Animation animation3 = DownCast< Animation >(object);
140   DALI_TEST_CHECK(animation3);
141   END_TEST;
142 }
143
144 int UtcDaliAnimationDownCastN(void)
145 {
146   TestApplication application;
147
148   BaseHandle unInitializedObject;
149
150   Animation animation1 = Animation::DownCast( unInitializedObject );
151   DALI_TEST_CHECK( !animation1 );
152
153   Animation animation2 = DownCast< Animation >( unInitializedObject );
154   DALI_TEST_CHECK( !animation2 );
155   END_TEST;
156 }
157
158 int UtcDaliAnimationCopyConstructorP(void)
159 {
160   TestApplication application;
161
162   // Initialize an object, ref count == 1
163   Animation animation = Animation::New( 1.0f );
164
165   Animation copy( animation );
166   DALI_TEST_CHECK( copy );
167
168   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
169   END_TEST;
170 }
171
172 int UtcDaliAnimationAssignmentOperatorP(void)
173 {
174   TestApplication application;
175
176   Animation animation = Animation::New( 1.0f );
177
178   Animation copy = animation;
179   DALI_TEST_CHECK( copy );
180
181   DALI_TEST_CHECK( animation == copy );
182
183   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
184   END_TEST;
185 }
186
187 int UtcDaliAnimationSetDurationP(void)
188 {
189   TestApplication application;
190
191   Actor actor = Actor::New();
192   Stage::GetCurrent().Add(actor);
193
194   // Build the animation
195   float durationSeconds(1.0f);
196   Animation animation = Animation::New(durationSeconds);
197   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
198
199   // Start the animation
200   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
201   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
202   animation.Play();
203
204   bool signalReceived(false);
205   AnimationFinishCheck finishCheck(signalReceived);
206   animation.FinishedSignal().Connect(&application, finishCheck);
207
208   application.SendNotification();
209   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
210
211   // We didn't expect the animation to finish yet
212   application.SendNotification();
213   finishCheck.CheckSignalNotReceived();
214
215   application.Render(2u/*just beyond the animation duration*/);
216
217   // We did expect the animation to finish
218   application.SendNotification();
219   finishCheck.CheckSignalReceived();
220   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
221
222   // Restart the animation, with a different duration
223   finishCheck.Reset();
224   actor.SetPosition(Vector3::ZERO);
225   durationSeconds = 3.5f;
226   animation.SetDuration(durationSeconds);
227   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
228   animation.Play();
229
230   application.SendNotification();
231   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
232
233   // We didn't expect the animation to finish yet
234   application.SendNotification();
235   finishCheck.CheckSignalNotReceived();
236
237   application.Render(2u/*just beyond the animation duration*/);
238
239   // We did expect the animation to finish
240   application.SendNotification();
241   finishCheck.CheckSignalReceived();
242   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
243
244   // Check that nothing has changed after a couple of buffer swaps
245   application.Render(0);
246   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
247   application.Render(0);
248   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
249   END_TEST;
250 }
251
252 int UtcDaliAnimationSetDurationN(void)
253 {
254   TestApplication application;
255
256   Animation animation = Animation::New( 1.0f );
257   DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
258
259   animation.SetDuration( -1.0f );
260   DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
261   END_TEST;
262 }
263
264 int UtcDaliAnimationGetDurationP(void)
265 {
266   TestApplication application;
267
268   Animation animation = Animation::New(1.0f);
269   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
270
271   animation.SetDuration(2.0f);
272   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
273   END_TEST;
274 }
275
276 int UtcDaliAnimationSetLoopingP(void)
277 {
278   TestApplication application;
279
280   Actor actor = Actor::New();
281   Stage::GetCurrent().Add(actor);
282
283   // Build the animation
284   float durationSeconds(1.0f);
285   Animation animation = Animation::New(durationSeconds);
286   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
287   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
288
289   // Start the animation
290   animation.SetLooping(true);
291   DALI_TEST_CHECK(animation.IsLooping());
292   animation.Play();
293
294   bool signalReceived(false);
295   AnimationFinishCheck finishCheck(signalReceived);
296   animation.FinishedSignal().Connect(&application, finishCheck);
297
298   application.SendNotification();
299
300   // Loop 5 times
301   float intervalSeconds = 0.25f;
302   float progress = 0.0f;
303   for (int iterations = 0; iterations < 5;)
304   {
305     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
306
307     progress += intervalSeconds;
308     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
309
310     if (progress >= 1.0f)
311     {
312       progress = progress - 1.0f;
313       ++iterations;
314     }
315   }
316
317   // We didn't expect the animation to finish yet
318   application.SendNotification();
319   finishCheck.CheckSignalNotReceived();
320
321   animation.SetLooping(false);
322   DALI_TEST_CHECK(!animation.IsLooping());
323
324   application.SendNotification();
325   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
326
327   // We did expect the animation to finish
328   application.SendNotification();
329   finishCheck.CheckSignalReceived();
330   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
331
332   // Check that nothing has changed after a couple of buffer swaps
333   application.Render(0);
334   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
335   application.Render(0);
336   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
337   END_TEST;
338 }
339
340 int UtcDaliAnimationSetLoopCountP(void)
341 {
342   TestApplication application;
343
344   Actor actor = Actor::New();
345   Stage::GetCurrent().Add(actor);
346
347   // Build the animation
348   float durationSeconds(1.0f);
349   Animation animation = Animation::New(durationSeconds);
350   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
351   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
352
353   // Start the animation
354   animation.SetLoopCount(3);
355   DALI_TEST_CHECK(animation.IsLooping());
356   animation.Play();
357
358   bool signalReceived(false);
359   AnimationFinishCheck finishCheck(signalReceived);
360   animation.FinishedSignal().Connect(&application, finishCheck);
361
362   application.Render(0);
363   application.SendNotification();
364   application.Render(0);
365   application.SendNotification();
366   application.Render(0);
367   application.SendNotification();
368   application.Render(0);
369   application.SendNotification();
370
371   // Loop
372   float intervalSeconds = 3.0f;
373
374   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
375   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
376
377   application.Render(0);
378   application.SendNotification();
379   application.Render(0);
380   application.SendNotification();
381   application.Render(0);
382   application.SendNotification();
383   application.Render(0);
384   application.SendNotification();
385   finishCheck.CheckSignalNotReceived();
386
387   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
388
389   application.SendNotification();
390   finishCheck.CheckSignalReceived();
391   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
392
393   finishCheck.Reset();
394
395   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
396   application.SendNotification();
397   finishCheck.CheckSignalNotReceived();
398
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.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
403   application.SendNotification();
404   finishCheck.CheckSignalNotReceived();
405
406   END_TEST;
407 }
408
409 int UtcDaliAnimationSetLoopCountP2(void)
410 {
411   TestApplication application;
412
413   //
414   // switching between forever and loop count
415   //
416
417   Actor actor = Actor::New();
418   Stage::GetCurrent().Add(actor);
419
420   // Build the animation
421   float durationSeconds(1.0f);
422   Animation animation = Animation::New(durationSeconds);
423   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
424   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
425   animation.SetEndAction(Animation::Discard);
426
427   // Start the animation
428   animation.SetLoopCount(3);
429   DALI_TEST_CHECK(animation.IsLooping());
430   animation.Play();
431
432   bool signalReceived(false);
433   AnimationFinishCheck finishCheck(signalReceived);
434   animation.FinishedSignal().Connect(&application, finishCheck);
435
436   float intervalSeconds = 3.0f;
437
438   application.SendNotification();
439   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
440   application.SendNotification();
441   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
442   application.SendNotification();
443   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
444   application.SendNotification();
445
446   application.SendNotification();
447   finishCheck.CheckSignalReceived();
448
449   finishCheck.Reset();
450
451   // Loop forever
452   animation.SetLooping(true);
453   DALI_TEST_CHECK(animation.IsLooping());
454
455   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
456   application.SendNotification();
457   finishCheck.CheckSignalNotReceived();
458
459   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
460   application.SendNotification();
461   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
462   application.SendNotification();
463   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
464   application.SendNotification();
465   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
466   application.SendNotification();
467   application.SendNotification();
468   finishCheck.CheckSignalNotReceived();
469
470   finishCheck.Reset();
471
472   // Loop N again
473   animation.SetLoopCount(3);
474   DALI_TEST_CHECK(animation.IsLooping());
475   animation.Play();
476
477   application.SendNotification();
478   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
479   application.SendNotification();
480   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
481   application.SendNotification();
482   finishCheck.CheckSignalNotReceived();
483
484   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
485   application.SendNotification();
486   finishCheck.CheckSignalReceived();
487
488   finishCheck.Reset();
489
490   // loop forever
491   animation.SetLooping(true);
492   DALI_TEST_CHECK(animation.IsLooping());
493
494   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
495   application.SendNotification();
496   finishCheck.CheckSignalNotReceived();
497
498   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
499   application.SendNotification();
500   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
501   application.SendNotification();
502   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
503   application.SendNotification();
504   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
505   application.SendNotification();
506   finishCheck.CheckSignalNotReceived();
507
508   finishCheck.Reset();
509
510   // Loop N again
511   animation.SetLoopCount(3);
512   DALI_TEST_CHECK(animation.IsLooping());
513
514   application.SendNotification();
515   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
516   application.SendNotification();
517   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
518   application.SendNotification();
519   finishCheck.CheckSignalNotReceived();
520
521   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
522   application.SendNotification();
523   finishCheck.CheckSignalNotReceived(); // we never hit play
524
525   finishCheck.Reset();
526
527
528   END_TEST;
529 }
530
531 int UtcDaliAnimationSetLoopCountP3(void)
532 {
533   TestApplication application;
534
535   //
536   // switching between forever and loop count
537   //
538   Actor actor = Actor::New();
539   Stage::GetCurrent().Add(actor);
540
541   // Build the animation
542   float durationSeconds(1.0f);
543   Animation animation = Animation::New(durationSeconds);
544   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
545   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
546   animation.SetEndAction(Animation::Discard);
547
548   float intervalSeconds = 3.0f;
549
550   bool signalReceived(false);
551   AnimationFinishCheck finishCheck(signalReceived);
552   animation.FinishedSignal().Connect(&application, finishCheck);
553
554   // loop forever
555   animation.SetLooping(true);
556   DALI_TEST_CHECK(animation.IsLooping());
557
558   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
559   application.SendNotification();
560   finishCheck.CheckSignalNotReceived();
561
562   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
563   application.SendNotification();
564   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
565   application.SendNotification();
566   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
567   application.SendNotification();
568   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
569   application.SendNotification();
570   finishCheck.CheckSignalNotReceived();
571
572   finishCheck.Reset();
573
574   // Loop N again
575   animation.SetLoopCount(3);
576   DALI_TEST_CHECK(animation.IsLooping());
577
578   application.SendNotification();
579   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
580   application.SendNotification();
581   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
582   application.SendNotification();
583   finishCheck.CheckSignalNotReceived();
584
585   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
586   application.SendNotification();
587   finishCheck.CheckSignalNotReceived(); // we never hit play
588
589   finishCheck.Reset();
590
591
592   END_TEST;
593 }
594
595 int UtcDaliAnimationSetLoopCountP4(void)
596 {
597   TestApplication application;
598
599   //
600   // ..and play again
601   //
602   Actor actor = Actor::New();
603   Stage::GetCurrent().Add(actor);
604
605   // Build the animation
606   float durationSeconds(1.0f);
607   Animation animation = Animation::New(durationSeconds);
608   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
609   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
610   animation.SetEndAction(Animation::Bake);
611
612   float intervalSeconds = 3.0f;
613
614   bool signalReceived(false);
615   AnimationFinishCheck finishCheck(signalReceived);
616   animation.FinishedSignal().Connect(&application, finishCheck);
617
618   animation.SetLoopCount(1);
619   animation.Play();
620   DALI_TEST_CHECK(!animation.IsLooping());
621
622   application.SendNotification();
623   finishCheck.CheckSignalNotReceived();
624   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
625   application.SendNotification();
626   finishCheck.CheckSignalReceived();
627
628   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
629   actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
630
631   finishCheck.Reset();
632
633   animation.Play(); // again
634   DALI_TEST_CHECK(!animation.IsLooping());
635
636   application.SendNotification();
637   finishCheck.CheckSignalNotReceived();
638   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
639   application.SendNotification();
640   finishCheck.CheckSignalReceived();
641
642   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
643
644   END_TEST;
645 }
646
647 int UtcDaliAnimationGetLoopCountP(void)
648 {
649   TestApplication application;
650
651   Actor actor = Actor::New();
652   Stage::GetCurrent().Add(actor);
653
654   // Build the animation
655   float durationSeconds(1.0f);
656   Animation animation = Animation::New(durationSeconds);
657   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
658   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
659
660   DALI_TEST_CHECK(1 == animation.GetLoopCount());
661
662   // Start the animation
663   animation.SetLoopCount(3);
664   DALI_TEST_CHECK(animation.IsLooping());
665   DALI_TEST_CHECK(3 == animation.GetLoopCount());
666
667   animation.Play();
668
669   application.Render(0);
670   application.SendNotification();
671
672   // Loop
673   float intervalSeconds = 3.0f;
674
675   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
676   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
677
678   application.Render(0);
679   application.SendNotification();
680
681   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
682   application.SendNotification();
683
684   animation.SetLoopCount(0);
685   DALI_TEST_CHECK(animation.IsLooping());
686   DALI_TEST_CHECK(0 == animation.GetLoopCount());
687
688   animation.SetLoopCount(1);
689   DALI_TEST_CHECK(!animation.IsLooping());
690   DALI_TEST_CHECK(1 == animation.GetLoopCount());
691
692   END_TEST;
693 }
694
695
696 int UtcDaliAnimationGetCurrentLoopP(void)
697 {
698   TestApplication application;
699
700   Actor actor = Actor::New();
701   Stage::GetCurrent().Add(actor);
702
703   // Build the animation
704   float durationSeconds(1.0f);
705   Animation animation = Animation::New(durationSeconds);
706   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
707   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
708
709   // Start the animation
710   animation.SetLoopCount(3);
711   DALI_TEST_CHECK(animation.IsLooping());
712   DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
713   animation.Play();
714
715   bool signalReceived(false);
716   AnimationFinishCheck finishCheck(signalReceived);
717   animation.FinishedSignal().Connect(&application, finishCheck);
718
719   application.SendNotification();
720
721   // Loop
722   float intervalSeconds = 3.0f;
723
724   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
725   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
726
727   application.SendNotification();
728   finishCheck.CheckSignalNotReceived();
729   DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
730
731   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
732
733   application.SendNotification();
734   finishCheck.CheckSignalReceived();
735   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
736   DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
737
738   finishCheck.Reset();
739
740   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
741   application.SendNotification();
742   finishCheck.CheckSignalNotReceived();
743   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
744
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.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
749   application.SendNotification();
750   finishCheck.CheckSignalNotReceived();
751   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
752
753   END_TEST;
754 }
755
756 int UtcDaliAnimationIsLoopingP(void)
757 {
758   TestApplication application;
759
760   Animation animation = Animation::New(1.0f);
761   DALI_TEST_CHECK(!animation.IsLooping());
762
763   animation.SetLooping(true);
764   DALI_TEST_CHECK(animation.IsLooping());
765   END_TEST;
766 }
767
768 int UtcDaliAnimationSetEndActioN(void)
769 {
770   TestApplication application;
771
772   Actor actor = Actor::New();
773   Stage::GetCurrent().Add(actor);
774
775   // Build the animation
776   float durationSeconds(1.0f);
777   Animation animation = Animation::New(durationSeconds);
778   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
779
780   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
781   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
782
783   // Start the animation
784   animation.Play();
785
786   bool signalReceived(false);
787   AnimationFinishCheck finishCheck(signalReceived);
788   animation.FinishedSignal().Connect(&application, finishCheck);
789
790   application.SendNotification();
791   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
792
793   // We did expect the animation to finish
794   application.SendNotification();
795   finishCheck.CheckSignalReceived();
796   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
797
798   // Go back to the start
799   actor.SetPosition(Vector3::ZERO);
800   application.SendNotification();
801   application.Render(0);
802   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
803
804   // Test BakeFinal, animate again, for half the duration
805   finishCheck.Reset();
806   animation.SetEndAction(Animation::BakeFinal);
807   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
808   animation.Play();
809
810   application.SendNotification();
811   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
812
813   // Stop the animation early
814   animation.Stop();
815
816   // We did NOT expect the animation to finish
817   application.SendNotification();
818   finishCheck.CheckSignalNotReceived();
819   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
820
821   // The position should be same with target position in the next frame
822   application.Render(0);
823   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
824
825   // Go back to the start
826   actor.SetPosition(Vector3::ZERO);
827   application.SendNotification();
828   application.Render(0);
829   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
830
831   // Test EndAction::Discard, animate again, but don't bake this time
832   finishCheck.Reset();
833   animation.SetEndAction(Animation::Discard);
834   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
835   animation.Play();
836
837   application.SendNotification();
838   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
839
840   // We did expect the animation to finish
841   application.SendNotification();
842   finishCheck.CheckSignalReceived();
843   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
844
845   // The position should be discarded in the next frame
846   application.Render(0);
847   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
848
849   // Check that nothing has changed after a couple of buffer swaps
850   application.Render(0);
851   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
852   application.Render(0);
853   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
854   END_TEST;
855 }
856
857 int UtcDaliAnimationGetEndActionP(void)
858 {
859   TestApplication application;
860
861   Animation animation = Animation::New(1.0f);
862   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
863
864   animation.SetEndAction(Animation::Discard);
865   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
866
867   animation.SetEndAction(Animation::BakeFinal);
868   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
869
870   END_TEST;
871 }
872
873 int UtcDaliAnimationSetDisconnectActionP(void)
874 {
875   TestApplication application;
876   Stage stage( Stage::GetCurrent() );
877
878   // Default: BakeFinal
879   {
880     Actor actor = Actor::New();
881     stage.Add(actor);
882
883     // Build the animation
884     float durationSeconds(1.0f);
885     Animation animation = Animation::New(durationSeconds);
886     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
887
888     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
889     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
890
891     // Start the animation
892     animation.Play();
893
894     application.SendNotification();
895     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
896
897     actor.Unparent();
898
899     application.SendNotification();
900     application.Render();
901
902     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
903   }
904
905   // Bake
906   {
907     Actor actor = Actor::New();
908     stage.Add(actor);
909
910     // Build the animation
911     float durationSeconds(1.0f);
912     Animation animation = Animation::New(durationSeconds);
913     animation.SetDisconnectAction( Animation::Bake );
914
915     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
916     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
917
918     // Start the animation
919     animation.Play();
920
921     application.SendNotification();
922     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
923
924     actor.Unparent();
925
926     application.SendNotification();
927     application.Render();
928
929     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
930   }
931
932   // Discard
933   {
934     Actor actor = Actor::New();
935     stage.Add(actor);
936
937     // Build the animation
938     float durationSeconds(1.0f);
939     Animation animation = Animation::New(durationSeconds);
940     animation.SetDisconnectAction( Animation::Discard );
941
942     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
943     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
944
945     // Start the animation
946     animation.Play();
947
948     application.SendNotification();
949     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
950
951     actor.Unparent();
952
953     application.SendNotification();
954     application.Render();
955
956     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
957   }
958
959   // Don't play the animation: disconnect action should not be applied
960   {
961     Actor actor = Actor::New();
962     stage.Add(actor);
963
964     // Build the animation
965     float durationSeconds(1.0f);
966     Animation animation = Animation::New(durationSeconds);
967
968     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
969     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
970
971     application.SendNotification();
972     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
973
974     actor.Unparent();
975
976     application.SendNotification();
977     application.Render();
978
979     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
980   }
981
982   END_TEST;
983 }
984
985 int UtcDaliAnimationGetDisconnectActionP(void)
986 {
987   TestApplication application;
988   Animation animation = Animation::New(1.0f);
989   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
990
991   animation.SetDisconnectAction(Animation::Discard);
992   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
993
994   animation.SetDisconnectAction(Animation::Bake);
995   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
996
997   END_TEST;
998 }
999
1000 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
1001 {
1002   TestApplication application;
1003
1004   Animation animation = Animation::New(1.0f);
1005   AlphaFunction func = animation.GetDefaultAlphaFunction();
1006   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1007
1008   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1009   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1010   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1011   END_TEST;
1012 }
1013
1014 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
1015 {
1016   TestApplication application;
1017
1018   Animation animation = Animation::New(1.0f);
1019   AlphaFunction func = animation.GetDefaultAlphaFunction();
1020
1021   // Test that the default is linear
1022   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1023
1024   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1025   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1026   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1027
1028   END_TEST;
1029 }
1030
1031 int UtcDaliAnimationSetCurrentProgressP(void)
1032 {
1033   TestApplication application;
1034
1035   Actor actor = Actor::New();
1036   Stage::GetCurrent().Add(actor);
1037
1038   // Build the animation
1039   Animation animation = Animation::New(0.0f);
1040
1041   //Set duration
1042   float durationSeconds(1.0f);
1043   animation.SetDuration(durationSeconds);
1044
1045   bool signalReceived(false);
1046   AnimationFinishCheck finishCheck(signalReceived);
1047   animation.FinishedSignal().Connect(&application, finishCheck);
1048   application.SendNotification();
1049
1050   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1051   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1052
1053   // Start the animation from 40% progress
1054   animation.SetCurrentProgress( 0.4f );
1055   animation.Play();
1056
1057   application.SendNotification();
1058   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1059
1060   // We didn't expect the animation to finish yet
1061   application.SendNotification();
1062   finishCheck.CheckSignalNotReceived();
1063   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1064   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1065
1066   animation.Play(); // Test that calling play has no effect, when animation is already playing
1067   application.SendNotification();
1068
1069   //Set the progress to 70%
1070   animation.SetCurrentProgress( 0.7f );
1071   application.SendNotification();
1072   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1073   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1074
1075   application.SendNotification();
1076   finishCheck.CheckSignalNotReceived();
1077   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1078   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1079
1080   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1081   // We did expect the animation to finish
1082   application.SendNotification();
1083   finishCheck.CheckSignalReceived();
1084   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1085
1086   // Check that nothing has changed after a couple of buffer swaps
1087   application.Render(0);
1088   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1089   application.Render(0);
1090   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1091   END_TEST;
1092 }
1093
1094 int UtcDaliAnimationSetCurrentProgressN(void)
1095 {
1096   TestApplication application;
1097
1098   Actor actor = Actor::New();
1099   Stage::GetCurrent().Add(actor);
1100
1101   // Build the animation
1102   Animation animation = Animation::New(0.0f);
1103
1104   //Set duration
1105   float durationSeconds(1.0f);
1106   animation.SetDuration(durationSeconds);
1107
1108   bool signalReceived(false);
1109   AnimationFinishCheck finishCheck(signalReceived);
1110   animation.FinishedSignal().Connect(&application, finishCheck);
1111   application.SendNotification();
1112
1113   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1114   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1115
1116   //Trying to set the current cursor outside the range [0..1] is ignored
1117   animation.SetCurrentProgress( -1.0f);
1118   application.SendNotification();
1119   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1120
1121   animation.SetCurrentProgress( 100.0f);
1122   application.SendNotification();
1123   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1124   END_TEST;
1125 }
1126
1127 int UtcDaliAnimationGetCurrentProgressP(void)
1128 {
1129   TestApplication application;
1130
1131   Actor actor = Actor::New();
1132   Stage::GetCurrent().Add(actor);
1133
1134   // Build the animation
1135   Animation animation = Animation::New(0.0f);
1136   animation.Play();
1137
1138   //Test GetCurrentProgress return 0.0 as the duration is 0.0
1139   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1140
1141   animation.SetCurrentProgress( 0.5f );
1142   application.SendNotification();
1143   application.Render(static_cast<unsigned int>(100.0f));
1144
1145   //Progress should still be 0.0
1146   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1147
1148   //Set duration
1149   float durationSeconds(1.0f);
1150   animation.SetDuration(durationSeconds);
1151   application.SendNotification();
1152
1153   bool signalReceived(false);
1154   AnimationFinishCheck finishCheck(signalReceived);
1155   animation.FinishedSignal().Connect(&application, finishCheck);
1156   application.SendNotification();
1157
1158   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1159   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1160
1161   // Start the animation from 40% progress
1162   animation.SetCurrentProgress( 0.4f );
1163   animation.Play();
1164
1165   application.SendNotification();
1166   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1167
1168   // We didn't expect the animation to finish yet
1169   application.SendNotification();
1170   finishCheck.CheckSignalNotReceived();
1171   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1172
1173   animation.Play(); // Test that calling play has no effect, when animation is already playing
1174   application.SendNotification();
1175
1176   //Set the progress to 70%
1177   animation.SetCurrentProgress( 0.7f );
1178   application.SendNotification();
1179   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1180   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1181
1182   application.SendNotification();
1183   finishCheck.CheckSignalNotReceived();
1184   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1185
1186   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1187   // We did expect the animation to finish
1188   application.SendNotification();
1189   finishCheck.CheckSignalReceived();
1190   END_TEST;
1191 }
1192
1193 int UtcDaliAnimationSetSpeedFactorP1(void)
1194 {
1195   TestApplication application;
1196
1197   tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1198
1199   Actor actor = Actor::New();
1200   Stage::GetCurrent().Add(actor);
1201
1202   // Build the animation
1203   float durationSeconds(1.0f);
1204   Animation animation = Animation::New(durationSeconds);
1205
1206   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1207   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1208
1209   KeyFrames keyframes = KeyFrames::New();
1210   keyframes.Add( 0.0f, initialPosition);
1211   keyframes.Add( 1.0f, targetPosition );
1212   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1213
1214   //Set speed to be x2
1215   animation.SetSpeedFactor(2.0f);
1216
1217   // Start the animation
1218   animation.Play();
1219
1220   bool signalReceived(false);
1221   AnimationFinishCheck finishCheck(signalReceived);
1222   animation.FinishedSignal().Connect(&application, finishCheck);
1223
1224   application.SendNotification();
1225   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1226
1227   // We didn't expect the animation to finish yet
1228   application.SendNotification();
1229   finishCheck.CheckSignalNotReceived();
1230   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1231
1232   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1233
1234   // We didn't expect the animation to finish yet
1235   application.SendNotification();
1236   finishCheck.CheckSignalNotReceived();
1237   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1238
1239   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1240
1241   // We did expect the animation to finish
1242   application.SendNotification();
1243   finishCheck.CheckSignalReceived();
1244   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1245
1246   // Check that nothing has changed after a couple of buffer swaps
1247   application.Render(0);
1248   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1249   application.Render(0);
1250   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1251
1252   END_TEST;
1253 }
1254
1255 int UtcDaliAnimationSetSpeedFactorP2(void)
1256 {
1257   TestApplication application;
1258
1259   Actor actor = Actor::New();
1260   Stage::GetCurrent().Add(actor);
1261
1262   // Build the animation
1263   float durationSeconds(1.0f);
1264   Animation animation = Animation::New(durationSeconds);
1265
1266   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1267   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1268
1269   KeyFrames keyframes = KeyFrames::New();
1270   keyframes.Add( 0.0f, initialPosition);
1271   keyframes.Add( 1.0f, targetPosition );
1272   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1273
1274   tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1275   animation.SetSpeedFactor( -1.0f );
1276
1277   // Start the animation
1278   animation.Play();
1279
1280   bool signalReceived(false);
1281   AnimationFinishCheck finishCheck(signalReceived);
1282   animation.FinishedSignal().Connect(&application, finishCheck);
1283
1284   application.SendNotification();
1285   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1286
1287   // We didn't expect the animation to finish yet
1288   application.SendNotification();
1289   finishCheck.CheckSignalNotReceived();
1290   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1291
1292   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1293
1294   // We didn't expect the animation to finish yet
1295   application.SendNotification();
1296   finishCheck.CheckSignalNotReceived();
1297   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1298
1299   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1300
1301   // We didn't expect the animation to finish yet
1302   application.SendNotification();
1303   finishCheck.CheckSignalNotReceived();
1304   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1305
1306   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1307
1308   // We didn't expect the animation to finish yet
1309   application.SendNotification();
1310   finishCheck.CheckSignalNotReceived();
1311   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1312
1313   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1314
1315   // We did expect the animation to finish
1316   application.SendNotification();
1317   finishCheck.CheckSignalReceived();
1318   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1319
1320   // Check that nothing has changed after a couple of buffer swaps
1321   application.Render(0);
1322   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1323   application.Render(0);
1324   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1325
1326   END_TEST;
1327 }
1328
1329 int UtcDaliAnimationSetSpeedFactorP3(void)
1330 {
1331   TestApplication application;
1332
1333   Actor actor = Actor::New();
1334   Stage::GetCurrent().Add(actor);
1335
1336   // Build the animation
1337   float durationSeconds(1.0f);
1338   Animation animation = Animation::New(durationSeconds);
1339
1340   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1341   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1342
1343   KeyFrames keyframes = KeyFrames::New();
1344   keyframes.Add( 0.0f, initialPosition);
1345   keyframes.Add( 1.0f, targetPosition );
1346   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1347
1348   bool signalReceived(false);
1349   AnimationFinishCheck finishCheck(signalReceived);
1350   animation.FinishedSignal().Connect(&application, finishCheck);
1351
1352   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1353
1354   //Set speed to be half of normal speed
1355   animation.SetSpeedFactor( 0.5f );
1356
1357   // Start the animation
1358   animation.Play();
1359
1360   application.SendNotification();
1361   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1362
1363   // We didn't expect the animation to finish yet
1364   application.SendNotification();
1365   finishCheck.CheckSignalNotReceived();
1366   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1367
1368   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1369
1370   // We didn't expect the animation to finish yet
1371   application.SendNotification();
1372   finishCheck.CheckSignalNotReceived();
1373   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1374
1375   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1376
1377   // We didn't expect the animation to finish yet
1378   application.SendNotification();
1379   finishCheck.CheckSignalNotReceived();
1380   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1381
1382   application.SendNotification();
1383   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1384
1385   // We didn't expect the animation to finish yet
1386   application.SendNotification();
1387   finishCheck.CheckSignalNotReceived();
1388   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1389
1390   application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1391
1392   // We did expect the animation to finish
1393   application.SendNotification();
1394   finishCheck.CheckSignalReceived();
1395   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1396
1397   // Check that nothing has changed after a couple of buffer swaps
1398   application.Render(0);
1399   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1400   application.Render(0);
1401   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1402   END_TEST;
1403 }
1404
1405
1406 int UtcDaliAnimationSetSpeedFactorP4(void)
1407 {
1408   TestApplication application;
1409
1410   Actor actor = Actor::New();
1411   Stage::GetCurrent().Add(actor);
1412
1413   // Build the animation
1414   float durationSeconds(1.0f);
1415   Animation animation = Animation::New(durationSeconds);
1416
1417   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1418   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1419
1420   KeyFrames keyframes = KeyFrames::New();
1421   keyframes.Add( 0.0f, initialPosition);
1422   keyframes.Add( 1.0f, targetPosition );
1423   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1424
1425   bool signalReceived(false);
1426   AnimationFinishCheck finishCheck(signalReceived);
1427   animation.FinishedSignal().Connect(&application, finishCheck);
1428
1429   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1430
1431   tet_printf("Set speed to be half of normal speed\n");
1432   tet_printf("SetSpeedFactor(0.5f)\n");
1433   animation.SetSpeedFactor( 0.5f );
1434
1435   // Start the animation
1436   animation.Play();
1437
1438   application.SendNotification();
1439   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1440
1441   // We didn't expect the animation to finish yet
1442   application.SendNotification();
1443   finishCheck.CheckSignalNotReceived();
1444   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1445
1446   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1447
1448   // We didn't expect the animation to finish yet
1449   application.SendNotification();
1450   finishCheck.CheckSignalNotReceived();
1451   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1452
1453   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1454
1455   // We didn't expect the animation to finish yet
1456   application.SendNotification();
1457   finishCheck.CheckSignalNotReceived();
1458   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1459
1460   tet_printf("Reverse direction of animation whilst playing\n");
1461   tet_printf("SetSpeedFactor(-0.5f)\n");
1462   animation.SetSpeedFactor(-0.5f);
1463
1464   application.SendNotification();
1465   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1466
1467   // We didn't expect the animation to finish yet
1468   application.SendNotification();
1469   finishCheck.CheckSignalNotReceived();
1470   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1471
1472   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1473
1474   // We didn't expect the animation to finish yet
1475   application.SendNotification();
1476   finishCheck.CheckSignalNotReceived();
1477   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1478
1479   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1480
1481   // We did expect the animation to finish
1482   application.SendNotification();
1483   finishCheck.CheckSignalReceived();
1484   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1485
1486   // Check that nothing has changed after a couple of buffer swaps
1487   application.Render(0);
1488   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1489   application.Render(0);
1490   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1491   END_TEST;
1492 }
1493
1494 int UtcDaliAnimationSetSpeedFactorAndRange(void)
1495 {
1496   TestApplication application;
1497
1498   const unsigned int NUM_FRAMES(15);
1499
1500   struct TestData
1501   {
1502     float startTime;
1503     float endTime;
1504     float startX;
1505     float endX;
1506     float expected[NUM_FRAMES];
1507   };
1508
1509   TestData testData[] = {
1510     // ACTOR 0
1511     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1512     /*                       |----------PlayRange---------------|                 */
1513     /*                                            | reverse                       */
1514     { 0.0f,                                                                  1.0f, // TimePeriod
1515       0.0f,                                                                100.0f, // POS
1516       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1517        /**/                 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1518        /**/                               50.0f,
1519        /**/                        40.0f,
1520        /**/                 30.0f,
1521        /**/                                             70.0f,
1522        /**/                                      60.0f,
1523        /**/                               50.0f,
1524        /**/
1525       }
1526     },
1527
1528     // ACTOR 1 - Across start of range
1529     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1530     /*                       |----------PlayRange---------------|                 */
1531     /*                                            | reverse                       */
1532     {                0.2f,                0.5f,                               // TimePeriod
1533                      20.0f,               50.0f,                // POS
1534       {/**/                 30.0f, 40.0f, 50.0f, 50.0f, 50.0f,  /* Loop */
1535        /**/                 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1536        /**/                               50.0f,
1537        /**/                        40.0f,
1538        /**/                 30.0f,
1539        /**/                                             50.0f,
1540        /**/                                      50.0f,
1541        /**/                               50.0f
1542       }
1543     },
1544
1545     // ACTOR 2 - Across end of range
1546     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1547     /*                       |----------PlayRange---------------|                 */
1548     /*                                            | reverse                       */
1549     {/**/                                  0.5f,                      0.9f,   // TimePeriod
1550      /**/                                 50.0f,                      90.0f,  // POS
1551      { /**/                 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1552        /**/                 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1553        /**/                               50.0f,
1554        /**/                        50.0f,
1555        /**/                 50.0f,                      70.0f,
1556        /**/                                      60.0f,
1557        /**/                               50.0f,
1558       }
1559     },
1560
1561     // ACTOR 3 - Before beginning of range
1562     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1563     /*                       |----------PlayRange---------------|                 */
1564     /*                                            | reverse                       */
1565     {/**/     0.1f,      0.25f, // TimePeriod
1566      /**/     10.0f,     25.0f, // POS
1567      { /**/
1568        /**/ 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
1569        /**/
1570       }
1571     },
1572
1573     // ACTOR 4 - After end of range
1574     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1575     /*                       |----------PlayRange---------------|                 */
1576     /*                                            | reverse                       */
1577     {/**/                                                           0.85f,   1.0f, // TimePeriod
1578      /**/                                                           85.0f,  100.0f, // POS
1579      { /**/
1580        /**/ 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
1581        /**/
1582      }
1583     },
1584     // Actor 5 - Middle of range
1585     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1586     /*                       |----------PlayRange---------------|                 */
1587     /*                                            | reverse                       */
1588     {/**/                          0.4f,            0.65f, // Time Period
1589      /**/                         40.0f,            65.0f, // Position
1590      { /**/                40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1591        /**/                40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1592        /**/                              50.0f,
1593        /**/                       40.0f,
1594        /**/                40.0f,
1595        /**/                                            65.0f,
1596        /**/                                      60.0f,
1597        /**/                              50.0f,
1598      }
1599     }
1600   };
1601
1602   const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1603
1604   // Build the animation
1605   float durationSeconds(1.0f);
1606   Animation animation = Animation::New(durationSeconds);
1607   bool signalReceived(false);
1608   AnimationFinishCheck finishCheck(signalReceived);
1609   animation.FinishedSignal().Connect(&application, finishCheck);
1610
1611   std::vector<Dali::Actor> actors;
1612
1613   for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1614   {
1615     Actor actor = Actor::New();
1616     actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1617     actors.push_back(actor);
1618     Stage::GetCurrent().Add(actor);
1619
1620     if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1621     {
1622       KeyFrames keyframes = KeyFrames::New();
1623       keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1624       keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1625       animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1626     }
1627     else
1628     {
1629       animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1630     }
1631   }
1632
1633   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1634   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1635   tet_printf("SetSpeedFactor(0.5f)\n");
1636   animation.SetSpeedFactor( 0.5f );
1637   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1638   animation.SetLooping(true);
1639
1640   // Start the animation
1641   animation.Play();
1642   application.SendNotification();
1643   application.Render(0);   // Frame 0 tests initial values
1644
1645   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1646   {
1647     unsigned int actorIndex = 0u;
1648     for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1649     {
1650       DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1651       if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) )
1652       {
1653         tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1654       }
1655     }
1656
1657     if( frame == 8 )
1658     {
1659       tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1660       tet_printf("SetSpeedFactor(-0.5f)\n");
1661       animation.SetSpeedFactor(-0.5f);
1662       application.SendNotification();
1663     }
1664     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1665
1666     // We didn't expect the animation to finish yet
1667     application.SendNotification();
1668     finishCheck.CheckSignalNotReceived();
1669   }
1670
1671   END_TEST;
1672 }
1673
1674 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void)
1675 {
1676   TestApplication application;
1677
1678   const unsigned int NUM_FRAMES(15);
1679
1680   struct TestData
1681   {
1682     float startTime;
1683     float endTime;
1684     float startX;
1685     float endX;
1686     float expected[NUM_FRAMES];
1687   };
1688
1689   TestData testData =
1690     // ACTOR 0
1691     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1692     /*                       |----------PlayRange---------------|                 */
1693     { 0.0f,                                                                  1.0f, // TimePeriod
1694       0.0f,                                                                100.0f, // POS
1695       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1696        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1697        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1698        /**/
1699       }
1700     };
1701
1702
1703   // Build the animation
1704   float durationSeconds(1.0f);
1705   Animation animation = Animation::New(durationSeconds);
1706   bool signalReceived(false);
1707   AnimationFinishCheck finishCheck(signalReceived);
1708   animation.FinishedSignal().Connect(&application, finishCheck);
1709
1710   std::vector<Dali::Actor> actors;
1711
1712   Actor actor = Actor::New();
1713   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1714   actors.push_back(actor);
1715   Stage::GetCurrent().Add(actor);
1716
1717   KeyFrames keyframes = KeyFrames::New();
1718   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1719   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1720   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1721
1722   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1723   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1724   tet_printf("SetSpeedFactor(0.5f)\n");
1725   tet_printf("SetLoopCount(3)\n");
1726   animation.SetSpeedFactor( 0.5f );
1727   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1728   animation.SetLoopCount(3);
1729
1730   // Start the animation
1731   animation.Play();
1732   application.SendNotification();
1733   application.Render(0);   // Frame 0 tests initial values
1734
1735   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1736   {
1737     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1738
1739     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1740
1741     if( frame < NUM_FRAMES-1 )
1742     {
1743       // We didn't expect the animation to finish yet
1744       application.SendNotification();
1745       finishCheck.CheckSignalNotReceived();
1746     }
1747   }
1748
1749   // We did expect the animation to finish
1750   application.SendNotification();
1751   finishCheck.CheckSignalReceived();
1752   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION );
1753
1754   END_TEST;
1755 }
1756
1757 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void)
1758 {
1759   TestApplication application;
1760
1761   const unsigned int NUM_FRAMES(15);
1762
1763   struct TestData
1764   {
1765     float startTime;
1766     float endTime;
1767     float startX;
1768     float endX;
1769     float expected[NUM_FRAMES];
1770   };
1771
1772   TestData testData =
1773     // ACTOR 0
1774     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1775     /*                       |----------PlayRange---------------|                 */
1776     { 0.0f,                                                                  1.0f, // TimePeriod
1777       0.0f,                                                                100.0f, // POS
1778       {/**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1779        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1780        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1781       }
1782     };
1783
1784
1785   // Build the animation
1786   float durationSeconds(1.0f);
1787   Animation animation = Animation::New(durationSeconds);
1788   bool signalReceived(false);
1789   AnimationFinishCheck finishCheck(signalReceived);
1790   animation.FinishedSignal().Connect(&application, finishCheck);
1791
1792   std::vector<Dali::Actor> actors;
1793
1794   Actor actor = Actor::New();
1795   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1796   actors.push_back(actor);
1797   Stage::GetCurrent().Add(actor);
1798
1799   KeyFrames keyframes = KeyFrames::New();
1800   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1801   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1802   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1803
1804   tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1805   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1806   tet_printf("SetSpeedFactor(-0.5f)\n");
1807   tet_printf("SetLoopCount(3)\n");
1808   animation.SetSpeedFactor( -0.5f );
1809   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1810   animation.SetLoopCount(3);
1811
1812   // Start the animation
1813   animation.Play();
1814   application.SendNotification();
1815   application.Render(0);   // Frame 0 tests initial values
1816
1817   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1818   {
1819     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1820
1821     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1822
1823     if( frame < NUM_FRAMES-1 )
1824     {
1825       // We didn't expect the animation to finish yet
1826       application.SendNotification();
1827       finishCheck.CheckSignalNotReceived();
1828     }
1829   }
1830
1831   // We did expect the animation to finish
1832   application.SendNotification();
1833   finishCheck.CheckSignalReceived();
1834   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION );
1835
1836   END_TEST;
1837 }
1838
1839
1840 int UtcDaliAnimationGetSpeedFactorP(void)
1841 {
1842   TestApplication application;
1843
1844   Animation animation = Animation::New(1.0f);
1845   animation.SetSpeedFactor(0.5f);
1846   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1847
1848   animation.SetSpeedFactor(-2.5f);
1849   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1850   END_TEST;
1851 }
1852
1853 int UtcDaliAnimationSetPlayRangeP(void)
1854 {
1855   TestApplication application;
1856
1857   Actor actor = Actor::New();
1858   Stage::GetCurrent().Add( actor );
1859
1860   // Build the animation
1861   float durationSeconds( 1.0f );
1862   Animation animation = Animation::New( durationSeconds );
1863
1864   bool signalReceived( false );
1865   AnimationFinishCheck finishCheck( signalReceived );
1866   animation.FinishedSignal().Connect( &application, finishCheck );
1867   application.SendNotification();
1868
1869   // Set range between 0.4 and 0.8
1870   animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1871   application.SendNotification();
1872   DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1873
1874   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1875   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1876
1877   // Start the animation from 40% progress
1878   animation.Play();
1879
1880   application.SendNotification();
1881   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1882
1883   // We didn't expect the animation to finish yet
1884   application.SendNotification();
1885   finishCheck.CheckSignalNotReceived();
1886   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
1887
1888   application.SendNotification();
1889   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1890
1891   application.SendNotification();
1892   finishCheck.CheckSignalNotReceived();
1893   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
1894
1895   application.SendNotification();
1896   application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1897
1898   // We did expect the animation to finish
1899   application.SendNotification();
1900   finishCheck.CheckSignalReceived();
1901   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1902   END_TEST;
1903 }
1904
1905 int UtcDaliAnimationSetPlayRangeN(void)
1906 {
1907   TestApplication application;
1908
1909   Actor actor = Actor::New();
1910   Stage::GetCurrent().Add(actor);
1911
1912   // Build the animation
1913   Animation animation = Animation::New(0);
1914   application.SendNotification();
1915
1916   //PlayRange out of bounds
1917   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1918   application.SendNotification();
1919   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1920   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1921   application.SendNotification();
1922   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1923
1924   //If playRange is not in the correct order it has to be ordered
1925   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1926   application.SendNotification();
1927   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1928
1929   END_TEST;
1930 }
1931
1932 int UtcDaliAnimationGetPlayRangeP(void)
1933 {
1934   TestApplication application;
1935
1936   Actor actor = Actor::New();
1937   Stage::GetCurrent().Add( actor );
1938
1939   // Build the animation
1940   Animation animation = Animation::New( 1.0f );
1941   application.SendNotification();
1942
1943   //If PlayRange not specified it should be 0.0-1.0 by default
1944   DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1945
1946   // Set range between 0.4 and 0.8
1947   animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1948   application.SendNotification();
1949   DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
1950
1951   END_TEST;
1952 }
1953
1954 int UtcDaliAnimationPlayP(void)
1955 {
1956   TestApplication application;
1957
1958   Actor actor = Actor::New();
1959   Stage::GetCurrent().Add(actor);
1960
1961   // Build the animation
1962   float durationSeconds(1.0f);
1963   Animation animation = Animation::New(durationSeconds);
1964   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1965   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1966
1967   // Start the animation
1968   animation.Play();
1969
1970   bool signalReceived(false);
1971   AnimationFinishCheck finishCheck(signalReceived);
1972   animation.FinishedSignal().Connect(&application, finishCheck);
1973
1974   application.SendNotification();
1975   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1976
1977   // We didn't expect the animation to finish yet
1978   application.SendNotification();
1979   finishCheck.CheckSignalNotReceived();
1980   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1981
1982   animation.Play(); // Test that calling play has no effect, when animation is already playing
1983   application.SendNotification();
1984   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1985
1986   // We didn't expect the animation to finish yet
1987   application.SendNotification();
1988   finishCheck.CheckSignalNotReceived();
1989   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1990
1991   animation.Play(); // Test that calling play has no effect, when animation is already playing
1992   application.SendNotification();
1993   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1994
1995   // We didn't expect the animation to finish yet
1996   application.SendNotification();
1997   finishCheck.CheckSignalNotReceived();
1998   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1999
2000   animation.Play(); // Test that calling play has no effect, when animation is already playing
2001   application.SendNotification();
2002   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2003
2004   // We didn't expect the animation to finish yet
2005   application.SendNotification();
2006   finishCheck.CheckSignalNotReceived();
2007   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2008
2009   animation.Play(); // Test that calling play has no effect, when animation is already playing
2010   application.SendNotification();
2011   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2012
2013   // We did expect the animation to finish
2014   application.SendNotification();
2015   finishCheck.CheckSignalReceived();
2016   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2017
2018   // Check that nothing has changed after a couple of buffer swaps
2019   application.Render(0);
2020   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2021   application.Render(0);
2022   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2023   END_TEST;
2024 }
2025
2026 int UtcDaliAnimationPlayOffStageP(void)
2027 {
2028   // Test that an animation can be played, when the actor is off-stage.
2029   // When the actor is added to the stage, it should appear at the current position
2030   // i.e. where it would have been anyway, if on-stage from the beginning.
2031
2032   TestApplication application;
2033
2034   Actor actor = Actor::New();
2035   Vector3 basePosition(Vector3::ZERO);
2036   DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
2037   // Not added to the stage!
2038
2039   // Build the animation
2040   float durationSeconds(1.0f);
2041   Animation animation = Animation::New(durationSeconds);
2042   animation.SetDisconnectAction( Animation::Discard );
2043   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2044   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2045
2046   // Start the animation
2047   animation.Play();
2048
2049   bool signalReceived(false);
2050   AnimationFinishCheck finishCheck(signalReceived);
2051   animation.FinishedSignal().Connect(&application, finishCheck);
2052
2053   application.SendNotification();
2054   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2055
2056   // We didn't expect the animation to finish yet
2057   application.SendNotification();
2058   finishCheck.CheckSignalNotReceived();
2059   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
2060
2061   // Add to the stage
2062   Stage::GetCurrent().Add(actor);
2063
2064   application.SendNotification();
2065   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2066
2067   // We didn't expect the animation to finish yet
2068   application.SendNotification();
2069   finishCheck.CheckSignalNotReceived();
2070   Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
2071   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
2072
2073   // Remove from the stage
2074   Stage::GetCurrent().Remove(actor);
2075
2076   application.SendNotification();
2077   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2078
2079   // We didn't expect the animation to finish yet
2080   application.SendNotification();
2081   finishCheck.CheckSignalNotReceived();
2082   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
2083
2084   // Add to the stage
2085   Stage::GetCurrent().Add(actor);
2086
2087   application.SendNotification();
2088   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2089
2090   // We didn't expect the animation to finish yet
2091   application.SendNotification();
2092   finishCheck.CheckSignalNotReceived();
2093   expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
2094   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
2095
2096   application.SendNotification();
2097   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2098
2099   // We did expect the animation to finish
2100   application.SendNotification();
2101   finishCheck.CheckSignalReceived();
2102   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2103
2104   // Check that nothing has changed after a couple of buffer swaps
2105   application.Render(0);
2106   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2107   application.Render(0);
2108   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2109   END_TEST;
2110 }
2111
2112 int UtcDaliAnimationPlayDiscardHandleP(void)
2113 {
2114   TestApplication application;
2115
2116   Actor actor = Actor::New();
2117   Stage::GetCurrent().Add(actor);
2118
2119   // Build the animation
2120   float durationSeconds(1.0f);
2121   Animation animation = Animation::New(durationSeconds);
2122   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2123   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2124
2125   bool signalReceived(false);
2126   AnimationFinishCheck finishCheck(signalReceived);
2127   animation.FinishedSignal().Connect(&application, finishCheck);
2128
2129   // Start the animation
2130   animation.Play();
2131
2132   // This is a test of the "Fire and Forget" behaviour
2133   // Discard the animation handle!
2134   animation.Reset();
2135   DALI_TEST_CHECK( !animation );
2136
2137   application.SendNotification();
2138   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2139
2140   // We didn't expect the animation to finish yet
2141   application.SendNotification();
2142   finishCheck.CheckSignalNotReceived();
2143   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2144
2145   application.SendNotification();
2146   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2147
2148   // We didn't expect the animation to finish yet
2149   application.SendNotification();
2150   finishCheck.CheckSignalNotReceived();
2151   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2152
2153   application.SendNotification();
2154   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2155
2156   // We didn't expect the animation to finish yet
2157   application.SendNotification();
2158   finishCheck.CheckSignalNotReceived();
2159   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2160
2161   application.SendNotification();
2162   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2163
2164   // We didn't expect the animation to finish yet
2165   application.SendNotification();
2166   finishCheck.CheckSignalNotReceived();
2167   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2168
2169   application.SendNotification();
2170   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2171
2172   // We did expect the animation to finish
2173   application.SendNotification();
2174   finishCheck.CheckSignalReceived();
2175   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2176
2177   // Check that nothing has changed after a couple of buffer swaps
2178   application.Render(0);
2179   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2180   application.Render(0);
2181   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2182   END_TEST;
2183 }
2184
2185 int UtcDaliAnimationPlayStopDiscardHandleP(void)
2186 {
2187   TestApplication application;
2188
2189   Actor actor = Actor::New();
2190   Stage::GetCurrent().Add(actor);
2191
2192   // Build the animation
2193   float durationSeconds(1.0f);
2194   Animation animation = Animation::New(durationSeconds);
2195   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2196   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2197
2198   // Start the animation
2199   animation.Play();
2200
2201   bool signalReceived(false);
2202   AnimationFinishCheck finishCheck(signalReceived);
2203   animation.FinishedSignal().Connect(&application, finishCheck);
2204
2205   application.SendNotification();
2206   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2207
2208   // We didn't expect the animation to finish yet
2209   application.SendNotification();
2210   finishCheck.CheckSignalNotReceived();
2211   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2212
2213   // This is a test of the "Fire and Forget" behaviour
2214   // Stop the animation, and Discard the animation handle!
2215   animation.Stop();
2216   animation.Reset();
2217   DALI_TEST_CHECK( !animation );
2218
2219   application.SendNotification();
2220   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2221
2222   // We expect the animation to finish at 20% progress
2223   application.SendNotification();
2224   finishCheck.CheckSignalReceived();
2225   finishCheck.Reset();
2226   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2227
2228   application.SendNotification();
2229   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2230
2231   // Check that nothing has changed
2232   application.SendNotification();
2233   finishCheck.CheckSignalNotReceived();
2234   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2235
2236   application.SendNotification();
2237   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2238
2239   // Check that nothing has changed
2240   application.SendNotification();
2241   finishCheck.CheckSignalNotReceived();
2242   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2243
2244   application.SendNotification();
2245   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2246
2247   // Check that nothing has changed
2248   application.SendNotification();
2249   finishCheck.CheckSignalNotReceived();
2250   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2251   END_TEST;
2252 }
2253
2254 int UtcDaliAnimationPlayRangeP(void)
2255 {
2256   TestApplication application;
2257
2258   Actor actor = Actor::New();
2259   Stage::GetCurrent().Add(actor);
2260
2261   // Build the animation
2262   float durationSeconds(1.0f);
2263   Animation animation = Animation::New(durationSeconds);
2264   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2265   KeyFrames keyframes = KeyFrames::New();
2266   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2267   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2268
2269   animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2270
2271   // Set range between 0.4 and 0.8
2272   animation.SetPlayRange( Vector2(0.4f,0.8f) );
2273   animation.Play();
2274
2275   bool signalReceived(false);
2276   AnimationFinishCheck finishCheck(signalReceived);
2277   animation.FinishedSignal().Connect(&application, finishCheck);
2278
2279   //Test that setting progress outside the range doesn't work
2280   animation.SetCurrentProgress( 0.9f );
2281   application.SendNotification();
2282   application.Render(0);
2283   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2284   animation.SetCurrentProgress( 0.2f );
2285   application.SendNotification();
2286   application.Render(0);
2287   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2288
2289   application.SendNotification();
2290   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2291
2292   // We didn't expect the animation to finish yet
2293   application.SendNotification();
2294   finishCheck.CheckSignalNotReceived();
2295   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2296
2297   animation.Play(); // Test that calling play has no effect, when animation is already playing
2298   application.SendNotification();
2299   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2300
2301   // We did expect the animation to finish
2302   application.SendNotification();
2303   finishCheck.CheckSignalReceived();
2304   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2305
2306   // Check that nothing has changed after a couple of buffer swaps
2307   application.Render(0);
2308   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2309   application.Render(0);
2310   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2311
2312
2313   //Loop inside the range
2314   finishCheck.Reset();
2315   animation.SetLooping( true );
2316   animation.Play();
2317   application.SendNotification();
2318   float intervalSeconds = 0.1f;
2319   float progress = 0.4f;
2320   for (int iterations = 0; iterations < 10; ++iterations )
2321   {
2322     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2323
2324     progress += intervalSeconds;
2325     if (progress > 0.8f)
2326     {
2327       progress = progress - 0.4f;
2328     }
2329
2330     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2331   }
2332
2333   // We didn't expect the animation to finish yet
2334   application.SendNotification();
2335   finishCheck.CheckSignalNotReceived();
2336
2337
2338   //Test change range on the fly
2339   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2340   application.SendNotification();
2341
2342   for (int iterations = 0; iterations < 10; ++iterations )
2343   {
2344     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2345
2346     progress += intervalSeconds;
2347     if (progress > 0.9f)
2348     {
2349       progress = progress - 0.7f;
2350     }
2351
2352     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2353   }
2354
2355   END_TEST;
2356 }
2357
2358 int UtcDaliAnimationPlayFromP(void)
2359 {
2360   TestApplication application;
2361
2362   Actor actor = Actor::New();
2363   Stage::GetCurrent().Add(actor);
2364
2365   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2366
2367   // Build the animation
2368   float durationSeconds(1.0f);
2369   Animation animation = Animation::New(durationSeconds);
2370   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2371   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2372
2373   // Start the animation from 40% progress
2374   animation.PlayFrom( 0.4f );
2375
2376   // Target value should be updated straight away
2377   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2378
2379   bool signalReceived(false);
2380   AnimationFinishCheck finishCheck(signalReceived);
2381   animation.FinishedSignal().Connect(&application, finishCheck);
2382
2383   application.SendNotification();
2384   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2385
2386   // We didn't expect the animation to finish yet
2387   application.SendNotification();
2388   finishCheck.CheckSignalNotReceived();
2389   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2390
2391   animation.Play(); // Test that calling play has no effect, when animation is already playing
2392   application.SendNotification();
2393   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2394
2395   // We didn't expect the animation to finish yet
2396   application.SendNotification();
2397   finishCheck.CheckSignalNotReceived();
2398   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2399
2400   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2401   // We did expect the animation to finish
2402   application.SendNotification();
2403   finishCheck.CheckSignalReceived();
2404   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2405
2406   // Check that nothing has changed after a couple of buffer swaps
2407   application.Render(0);
2408   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2409   application.Render(0);
2410   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2411   END_TEST;
2412 }
2413
2414 int UtcDaliAnimationPlayFromN(void)
2415 {
2416   TestApplication application;
2417
2418   Actor actor = Actor::New();
2419   Stage::GetCurrent().Add(actor);
2420
2421   // Build the animation
2422   float durationSeconds(1.0f);
2423   Animation animation = Animation::New(durationSeconds);
2424   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2425   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2426
2427   //PlayFrom with an argument outside the range [0..1] will be ignored
2428   animation.PlayFrom(-1.0f);
2429   application.SendNotification();
2430   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2431
2432   animation.PlayFrom(100.0f);
2433   application.SendNotification();
2434   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2435   END_TEST;
2436 }
2437
2438 int UtcDaliAnimationPauseP(void)
2439 {
2440   TestApplication application;
2441
2442   Actor actor = Actor::New();
2443   Stage::GetCurrent().Add(actor);
2444
2445   // Build the animation
2446   float durationSeconds(1.0f);
2447   Animation animation = Animation::New(durationSeconds);
2448   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2449   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2450
2451   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2452
2453   // Start the animation
2454   animation.Play();
2455
2456   bool signalReceived(false);
2457   AnimationFinishCheck finishCheck(signalReceived);
2458   animation.FinishedSignal().Connect(&application, finishCheck);
2459
2460   application.SendNotification();
2461   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2462
2463   // We didn't expect the animation to finish yet
2464   application.SendNotification();
2465   finishCheck.CheckSignalNotReceived();
2466   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2467
2468   // Pause the animation
2469   animation.Pause();
2470   application.SendNotification();
2471
2472   // Loop 5 times
2473   for (int i=0; i<5; ++i)
2474   {
2475     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2476
2477     // We didn't expect the animation to finish yet
2478     application.SendNotification();
2479     finishCheck.CheckSignalNotReceived();
2480     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2481   }
2482
2483   // Keep going
2484   animation.Play();
2485   application.SendNotification();
2486   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2487
2488   // We didn't expect the animation to finish yet
2489   application.SendNotification();
2490   finishCheck.CheckSignalNotReceived();
2491
2492   application.SendNotification();
2493   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2494
2495   // We did expect the animation to finish
2496   application.SendNotification();
2497   finishCheck.CheckSignalReceived();
2498   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2499
2500   // Check that nothing has changed after a couple of buffer swaps
2501   application.Render(0);
2502   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2503   application.Render(0);
2504   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2505   END_TEST;
2506 }
2507
2508
2509 int UtcDaliAnimationGetStateP(void)
2510 {
2511   TestApplication application;
2512
2513   Actor actor = Actor::New();
2514   Stage::GetCurrent().Add(actor);
2515
2516   // Build the animation
2517   float durationSeconds(1.0f);
2518   Animation animation = Animation::New(durationSeconds);
2519   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2520   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2521   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2522
2523   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2524
2525   // Start the animation
2526   animation.Play();
2527
2528   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2529
2530   bool signalReceived(false);
2531   AnimationFinishCheck finishCheck(signalReceived);
2532   animation.FinishedSignal().Connect(&application, finishCheck);
2533
2534   application.SendNotification();
2535   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2536
2537   // We didn't expect the animation to finish yet
2538   application.SendNotification();
2539   finishCheck.CheckSignalNotReceived();
2540   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2541   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2542
2543   // Pause the animation
2544   animation.Pause();
2545   DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2546   application.SendNotification();
2547   application.Render(0.f);
2548
2549   // Loop 5 times
2550   for (int i=0; i<5; ++i)
2551   {
2552     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2553
2554     // We didn't expect the animation to finish yet
2555     application.SendNotification();
2556     finishCheck.CheckSignalNotReceived();
2557     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2558     DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2559   }
2560
2561   // Keep going
2562   finishCheck.Reset();
2563   animation.Play();
2564   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2565   application.SendNotification();
2566   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2567   // We didn't expect the animation to finish yet
2568   application.SendNotification();
2569   finishCheck.CheckSignalNotReceived();
2570   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2571
2572   application.SendNotification();
2573   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2574
2575   // We did expect the animation to finish
2576   application.SendNotification();
2577   finishCheck.CheckSignalReceived();
2578   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2579   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2580
2581   // Check that nothing has changed after a couple of buffer swaps
2582   application.Render(0);
2583   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2584   application.Render(0);
2585   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2586   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2587
2588   // re-play
2589   finishCheck.Reset();
2590   animation.Play();
2591   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2592   application.SendNotification();
2593   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2594   application.SendNotification();
2595   finishCheck.CheckSignalNotReceived();
2596   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2597
2598
2599   END_TEST;
2600 }
2601
2602 int UtcDaliAnimationStopP(void)
2603 {
2604   TestApplication application;
2605
2606   Actor actor = Actor::New();
2607   Stage::GetCurrent().Add(actor);
2608
2609   // Build the animation
2610   float durationSeconds(1.0f);
2611   Animation animation = Animation::New(durationSeconds);
2612   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2613   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2614
2615   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2616
2617   // Start the animation
2618   animation.Play();
2619
2620   bool signalReceived(false);
2621   AnimationFinishCheck finishCheck(signalReceived);
2622   animation.FinishedSignal().Connect(&application, finishCheck);
2623
2624   application.SendNotification();
2625   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2626
2627   // We didn't expect the animation to finish yet
2628   application.SendNotification();
2629   finishCheck.CheckSignalNotReceived();
2630   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2631
2632   // Stop the animation
2633   animation.Stop();
2634   application.SendNotification();
2635
2636   // Loop 5 times
2637   for (int i=0; i<5; ++i)
2638   {
2639     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2640
2641     // We did expect the animation to finish
2642     application.SendNotification();
2643     finishCheck.CheckSignalReceived();
2644     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2645   }
2646   END_TEST;
2647 }
2648
2649 int UtcDaliAnimationStopSetPositionP(void)
2650 {
2651   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2652   // i.e. to check that the animation does not interfere with the position set.
2653
2654   TestApplication application;
2655
2656   Actor actor = Actor::New();
2657   Stage::GetCurrent().Add(actor);
2658
2659   // Build the animation
2660   float durationSeconds(1.0f);
2661   Animation animation = Animation::New(durationSeconds);
2662   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2663   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2664
2665   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2666
2667   // Start the animation
2668   animation.Play();
2669
2670   bool signalReceived(false);
2671   AnimationFinishCheck finishCheck(signalReceived);
2672   animation.FinishedSignal().Connect(&application, finishCheck);
2673
2674   application.SendNotification();
2675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2676
2677   // We didn't expect the animation to finish yet
2678   application.SendNotification();
2679   finishCheck.CheckSignalNotReceived();
2680   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2681
2682   // Stop the animation
2683   animation.Stop();
2684   Vector3 positionSet(2.0f, 3.0f, 4.0f);
2685   actor.SetPosition(positionSet);
2686   application.SendNotification();
2687
2688   // Loop 5 times
2689   for (int i=0; i<5; ++i)
2690   {
2691     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2692
2693     // We did expect the animation to finish
2694     application.SendNotification();
2695     finishCheck.CheckSignalReceived();
2696     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2697   }
2698   END_TEST;
2699 }
2700
2701 int UtcDaliAnimationClearP(void)
2702 {
2703   TestApplication application;
2704
2705   Actor actor = Actor::New();
2706   Stage::GetCurrent().Add(actor);
2707
2708   // Build the animation
2709   float durationSeconds(1.0f);
2710   Animation animation = Animation::New(durationSeconds);
2711   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2712   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2713
2714   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2715
2716   // Start the animation
2717   animation.Play();
2718
2719   bool signalReceived(false);
2720   AnimationFinishCheck finishCheck(signalReceived);
2721   animation.FinishedSignal().Connect(&application, finishCheck);
2722
2723   application.SendNotification();
2724   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2725
2726   // We didn't expect the animation to finish yet
2727   application.SendNotification();
2728   finishCheck.CheckSignalNotReceived();
2729   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2730
2731   // Clear the animation
2732   animation.Clear();
2733   application.SendNotification();
2734
2735   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2736
2737   // We don't expect the animation to finish now
2738   application.SendNotification();
2739   finishCheck.CheckSignalNotReceived();
2740   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2741
2742   // Restart as a scale animation; this should not move the actor's position
2743   finishCheck.Reset();
2744   actor.SetPosition(Vector3::ZERO);
2745   Vector3 targetScale(3.0f, 3.0f, 3.0f);
2746   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2747   animation.Play();
2748
2749   application.SendNotification();
2750   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2751
2752   // We didn't expect the animation to finish yet
2753   application.SendNotification();
2754   finishCheck.CheckSignalNotReceived();
2755   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2756   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2757
2758   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2759
2760   // We did expect the animation to finish
2761   application.SendNotification();
2762   finishCheck.CheckSignalReceived();
2763   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2764   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2765   END_TEST;
2766 }
2767
2768 int UtcDaliAnimationFinishedSignalP(void)
2769 {
2770   TestApplication application;
2771
2772   // Start the empty animation
2773   float durationSeconds(1.0f);
2774   Animation animation = Animation::New(durationSeconds);
2775   animation.Play();
2776
2777   bool signalReceived(false);
2778   AnimationFinishCheck finishCheck(signalReceived);
2779   animation.FinishedSignal().Connect(&application, finishCheck);
2780
2781   application.SendNotification();
2782   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2783
2784   // We did expect the animation to finish
2785   application.SendNotification();
2786   finishCheck.CheckSignalReceived();
2787   END_TEST;
2788 }
2789
2790 int UtcDaliAnimationAnimateByBooleanP(void)
2791 {
2792   TestApplication application;
2793
2794   Actor actor = Actor::New();
2795
2796   // Register a boolean property
2797   bool startValue(false);
2798   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2799   Stage::GetCurrent().Add(actor);
2800   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2801   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2802
2803   // Build the animation
2804   float durationSeconds(2.0f);
2805   Animation animation = Animation::New(durationSeconds);
2806   const bool relativeValue(true);
2807   const bool finalValue( false || relativeValue );
2808   animation.AnimateBy(Property(actor, index), relativeValue);
2809
2810   // Start the animation
2811   animation.Play();
2812
2813   // Target value should be retrievable straight away
2814   DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
2815
2816   bool signalReceived(false);
2817   AnimationFinishCheck finishCheck(signalReceived);
2818   animation.FinishedSignal().Connect(&application, finishCheck);
2819
2820   application.SendNotification();
2821   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2822
2823   // We didn't expect the animation to finish yet
2824   application.SendNotification();
2825   finishCheck.CheckSignalNotReceived();
2826   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2827
2828   application.SendNotification();
2829   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2830
2831   // We did expect the animation to finish
2832   application.SendNotification();
2833   finishCheck.CheckSignalReceived();
2834   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2835
2836   // Check that nothing has changed after a couple of buffer swaps
2837   application.Render(0);
2838   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2839   application.Render(0);
2840   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2841
2842   // Repeat with relative value "false" - this should be an NOOP
2843   animation = Animation::New(durationSeconds);
2844   bool noOpValue(false);
2845   animation.AnimateBy(Property(actor, index), noOpValue);
2846
2847   // Start the animation
2848   animation.Play();
2849
2850   finishCheck.Reset();
2851   animation.FinishedSignal().Connect(&application, finishCheck);
2852
2853   application.SendNotification();
2854   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2855
2856   // We didn't expect the animation to finish yet
2857   application.SendNotification();
2858   finishCheck.CheckSignalNotReceived();
2859   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2860
2861   application.SendNotification();
2862   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2863
2864   // We did expect the animation to finish
2865   application.SendNotification();
2866   finishCheck.CheckSignalReceived();
2867   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2868
2869   // Check that nothing has changed after a couple of buffer swaps
2870   application.Render(0);
2871   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2872   application.Render(0);
2873   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2874   END_TEST;
2875 }
2876
2877 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
2878 {
2879   TestApplication application;
2880
2881   Actor actor = Actor::New();
2882
2883   // Register a boolean property
2884   bool startValue(false);
2885   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2886   Stage::GetCurrent().Add(actor);
2887   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2888   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2889
2890   // Build the animation
2891   float durationSeconds(2.0f);
2892   Animation animation = Animation::New(durationSeconds);
2893   bool relativeValue(true);
2894   bool finalValue( false || relativeValue );
2895   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2896
2897   // Start the animation
2898   animation.Play();
2899
2900   bool signalReceived(false);
2901   AnimationFinishCheck finishCheck(signalReceived);
2902   animation.FinishedSignal().Connect(&application, finishCheck);
2903
2904   application.SendNotification();
2905   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2906
2907   // We didn't expect the animation to finish yet
2908   application.SendNotification();
2909   finishCheck.CheckSignalNotReceived();
2910   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2911
2912   application.SendNotification();
2913   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2914
2915   // We did expect the animation to finish
2916   application.SendNotification();
2917   finishCheck.CheckSignalReceived();
2918   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2919
2920   // Check that nothing has changed after a couple of buffer swaps
2921   application.Render(0);
2922   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2923   application.Render(0);
2924   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2925
2926   // Repeat with relative value "false" - this should be an NOOP
2927   animation = Animation::New(durationSeconds);
2928   bool noOpValue(false);
2929   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2930
2931   // Start the animation
2932   animation.Play();
2933
2934   finishCheck.Reset();
2935   animation.FinishedSignal().Connect(&application, finishCheck);
2936
2937   application.SendNotification();
2938   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2939
2940   // We didn't expect the animation to finish yet
2941   application.SendNotification();
2942   finishCheck.CheckSignalNotReceived();
2943   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2944
2945   application.SendNotification();
2946   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2947
2948   // We did expect the animation to finish
2949   application.SendNotification();
2950   finishCheck.CheckSignalReceived();
2951   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2952   END_TEST;
2953 }
2954
2955 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
2956 {
2957   TestApplication application;
2958
2959   Actor actor = Actor::New();
2960
2961   // Register a boolean property
2962   bool startValue(false);
2963   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2964   Stage::GetCurrent().Add(actor);
2965   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2966   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2967
2968   // Build the animation
2969   float durationSeconds(2.0f);
2970   Animation animation = Animation::New(durationSeconds);
2971   bool relativeValue(true);
2972   bool finalValue( false || relativeValue );
2973   float animatorDurationSeconds(durationSeconds * 0.5f);
2974   animation.AnimateBy( Property(actor, index),
2975                        relativeValue,
2976                        TimePeriod( animatorDurationSeconds ) );
2977
2978   // Start the animation
2979   animation.Play();
2980
2981   bool signalReceived(false);
2982   AnimationFinishCheck finishCheck(signalReceived);
2983   animation.FinishedSignal().Connect(&application, finishCheck);
2984
2985   application.SendNotification();
2986   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2987
2988   // We didn't expect the animation to finish yet
2989   application.SendNotification();
2990   finishCheck.CheckSignalNotReceived();
2991   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2992
2993   application.SendNotification();
2994   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2995
2996   // We didn't expect the animation to finish yet...
2997   application.SendNotification();
2998   finishCheck.CheckSignalNotReceived();
2999
3000   // ...however we should have reached the final value
3001   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3002
3003   application.SendNotification();
3004   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3005
3006   // We did expect the animation to finish
3007   application.SendNotification();
3008   finishCheck.CheckSignalReceived();
3009   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3010
3011   // Check that nothing has changed after a couple of buffer swaps
3012   application.Render(0);
3013   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3014   application.Render(0);
3015   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3016   END_TEST;
3017 }
3018
3019 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3020 {
3021   TestApplication application;
3022
3023   Actor actor = Actor::New();
3024
3025   // Register a boolean property
3026   bool startValue(false);
3027   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3028   Stage::GetCurrent().Add(actor);
3029   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3030   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3031
3032   // Build the animation
3033   float durationSeconds(2.0f);
3034   Animation animation = Animation::New(durationSeconds);
3035   bool relativeValue(true);
3036   bool finalValue( false || relativeValue );
3037   float animatorDurationSeconds(durationSeconds * 0.5f);
3038   animation.AnimateBy( Property(actor, index),
3039                        relativeValue,
3040                        AlphaFunction::EASE_IN_OUT,
3041                        TimePeriod( animatorDurationSeconds ) );
3042
3043   // Start the animation
3044   animation.Play();
3045
3046   bool signalReceived(false);
3047   AnimationFinishCheck finishCheck(signalReceived);
3048   animation.FinishedSignal().Connect(&application, finishCheck);
3049
3050   application.SendNotification();
3051   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3052
3053   // We didn't expect the animation to finish yet
3054   application.SendNotification();
3055   finishCheck.CheckSignalNotReceived();
3056   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3057
3058   application.SendNotification();
3059   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3060
3061   // We didn't expect the animation to finish yet...
3062   application.SendNotification();
3063   finishCheck.CheckSignalNotReceived();
3064
3065   // ...however we should have reached the final value
3066   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3067
3068   application.SendNotification();
3069   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3070
3071   // We did expect the animation to finish
3072   application.SendNotification();
3073   finishCheck.CheckSignalReceived();
3074   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3075
3076   // Check that nothing has changed after a couple of buffer swaps
3077   application.Render(0);
3078   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3079   application.Render(0);
3080   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3081   END_TEST;
3082 }
3083
3084 int UtcDaliAnimationAnimateByFloatP(void)
3085 {
3086   TestApplication application;
3087
3088   Actor actor = Actor::New();
3089
3090   // Register a float property
3091   float startValue(10.0f);
3092   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3093   Stage::GetCurrent().Add(actor);
3094   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3095   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3096
3097   // Build the animation
3098   float durationSeconds(2.0f);
3099   Animation animation = Animation::New(durationSeconds);
3100   float targetValue(50.0f);
3101   float relativeValue(targetValue - startValue);
3102   animation.AnimateBy(Property(actor, index), relativeValue);
3103
3104   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3105
3106   // Start the animation
3107   animation.Play();
3108
3109   // Target value should be retrievable straight away
3110   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
3111
3112   bool signalReceived(false);
3113   AnimationFinishCheck finishCheck(signalReceived);
3114   animation.FinishedSignal().Connect(&application, finishCheck);
3115
3116   application.SendNotification();
3117   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3118
3119   // We didn't expect the animation to finish yet
3120   application.SendNotification();
3121   finishCheck.CheckSignalNotReceived();
3122   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3123
3124   application.SendNotification();
3125   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3126
3127   // We did expect the animation to finish
3128   application.SendNotification();
3129   finishCheck.CheckSignalReceived();
3130   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3131
3132   // Check that nothing has changed after a couple of buffer swaps
3133   application.Render(0);
3134   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3135   application.Render(0);
3136   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3137   END_TEST;
3138 }
3139
3140 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3141 {
3142   TestApplication application;
3143
3144   Actor actor = Actor::New();
3145
3146   // Register a float property
3147   float startValue(10.0f);
3148   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3149   Stage::GetCurrent().Add(actor);
3150   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3151   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3152
3153   // Build the animation
3154   float durationSeconds(1.0f);
3155   Animation animation = Animation::New(durationSeconds);
3156   float targetValue(90.0f);
3157   float relativeValue(targetValue - startValue);
3158   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3159
3160   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3161
3162   // Start the animation
3163   animation.Play();
3164
3165   bool signalReceived(false);
3166   AnimationFinishCheck finishCheck(signalReceived);
3167   animation.FinishedSignal().Connect(&application, finishCheck);
3168
3169   application.SendNotification();
3170   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3171
3172   // We didn't expect the animation to finish yet
3173   application.SendNotification();
3174   finishCheck.CheckSignalNotReceived();
3175
3176   // The position should have moved more, than with a linear alpha function
3177   float current( actor.GetCurrentProperty< float >( index ) );
3178   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3179
3180   application.SendNotification();
3181   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3182
3183   // We did expect the animation to finish
3184   application.SendNotification();
3185   finishCheck.CheckSignalReceived();
3186   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3187
3188   // Check that nothing has changed after a couple of buffer swaps
3189   application.Render(0);
3190   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3191   application.Render(0);
3192   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3193   END_TEST;
3194 }
3195
3196 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3197 {
3198   TestApplication application;
3199
3200   Actor actor = Actor::New();
3201
3202   // Register a float property
3203   float startValue(10.0f);
3204   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3205   Stage::GetCurrent().Add(actor);
3206   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3207   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3208
3209   // Build the animation
3210   float durationSeconds(1.0f);
3211   Animation animation = Animation::New(durationSeconds);
3212   float targetValue(30.0f);
3213   float relativeValue(targetValue - startValue);
3214   float delay = 0.5f;
3215   animation.AnimateBy(Property(actor, index),
3216                       relativeValue,
3217                       TimePeriod(delay, durationSeconds - delay));
3218
3219   // Start the animation
3220   animation.Play();
3221
3222   bool signalReceived(false);
3223   AnimationFinishCheck finishCheck(signalReceived);
3224   animation.FinishedSignal().Connect(&application, finishCheck);
3225
3226   application.SendNotification();
3227   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3228
3229   // We didn't expect the animation to finish yet
3230   application.SendNotification();
3231   finishCheck.CheckSignalNotReceived();
3232   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3233
3234   application.SendNotification();
3235   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3236
3237   // We didn't expect the animation to finish yet
3238   application.SendNotification();
3239   finishCheck.CheckSignalNotReceived();
3240   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3241
3242   application.SendNotification();
3243   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3244
3245   // We did expect the animation to finish
3246   application.SendNotification();
3247   finishCheck.CheckSignalReceived();
3248   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3249
3250   // Check that nothing has changed after a couple of buffer swaps
3251   application.Render(0);
3252   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3253   application.Render(0);
3254   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3255   END_TEST;
3256 }
3257
3258 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3259 {
3260   TestApplication application;
3261
3262   Actor actor = Actor::New();
3263
3264   // Register a float property
3265   float startValue(10.0f);
3266   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3267   Stage::GetCurrent().Add(actor);
3268   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3269   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3270
3271   // Build the animation
3272   float durationSeconds(1.0f);
3273   Animation animation = Animation::New(durationSeconds);
3274   float targetValue(30.0f);
3275   float relativeValue(targetValue - startValue);
3276   float delay = 0.5f;
3277   animation.AnimateBy(Property(actor, index),
3278                       relativeValue,
3279                       AlphaFunction::LINEAR,
3280                       TimePeriod(delay, durationSeconds - delay));
3281
3282   // Start the animation
3283   animation.Play();
3284
3285   bool signalReceived(false);
3286   AnimationFinishCheck finishCheck(signalReceived);
3287   animation.FinishedSignal().Connect(&application, finishCheck);
3288
3289   application.SendNotification();
3290   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3291
3292   // We didn't expect the animation to finish yet
3293   application.SendNotification();
3294   finishCheck.CheckSignalNotReceived();
3295   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3296
3297   application.SendNotification();
3298   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3299
3300   // We didn't expect the animation to finish yet
3301   application.SendNotification();
3302   finishCheck.CheckSignalNotReceived();
3303   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3304
3305   application.SendNotification();
3306   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3307
3308   // We did expect the animation to finish
3309   application.SendNotification();
3310   finishCheck.CheckSignalReceived();
3311   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3312
3313   // Check that nothing has changed after a couple of buffer swaps
3314   application.Render(0);
3315   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3316   application.Render(0);
3317   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3318   END_TEST;
3319 }
3320
3321 int UtcDaliAnimationAnimateByIntegerP(void)
3322 {
3323   TestApplication application;
3324
3325   Actor actor = Actor::New();
3326
3327   // Register an integer property
3328   int startValue(1);
3329   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3330   Stage::GetCurrent().Add(actor);
3331   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3332   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3333
3334   // Build the animation
3335   float durationSeconds(2.0f);
3336   Animation animation = Animation::New(durationSeconds);
3337   int targetValue(50);
3338   int relativeValue(targetValue - startValue);
3339   animation.AnimateBy(Property(actor, index), relativeValue);
3340
3341   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3342
3343   // Start the animation
3344   animation.Play();
3345
3346   // Target value should be retrievable straight away
3347   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
3348
3349   bool signalReceived(false);
3350   AnimationFinishCheck finishCheck(signalReceived);
3351   animation.FinishedSignal().Connect(&application, finishCheck);
3352
3353   application.SendNotification();
3354   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3355
3356   // We didn't expect the animation to finish yet
3357   application.SendNotification();
3358   finishCheck.CheckSignalNotReceived();
3359   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3360
3361   application.SendNotification();
3362   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3363
3364   // We did expect the animation to finish
3365   application.SendNotification();
3366   finishCheck.CheckSignalReceived();
3367   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3368
3369   // Check that nothing has changed after a couple of buffer swaps
3370   application.Render(0);
3371   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3372   application.Render(0);
3373   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3374   END_TEST;
3375 }
3376
3377 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3378 {
3379   TestApplication application;
3380
3381   Actor actor = Actor::New();
3382
3383   // Register an integer property
3384   int startValue(1);
3385   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3386   Stage::GetCurrent().Add(actor);
3387   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3388   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3389
3390   // Build the animation
3391   float durationSeconds(1.0f);
3392   Animation animation = Animation::New(durationSeconds);
3393   int targetValue(90);
3394   int relativeValue(targetValue - startValue);
3395   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3396
3397   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3398
3399   // Start the animation
3400   animation.Play();
3401
3402   bool signalReceived(false);
3403   AnimationFinishCheck finishCheck(signalReceived);
3404   animation.FinishedSignal().Connect(&application, finishCheck);
3405
3406   application.SendNotification();
3407   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3408
3409   // We didn't expect the animation to finish yet
3410   application.SendNotification();
3411   finishCheck.CheckSignalNotReceived();
3412
3413   // The position should have moved more, than with a linear alpha function
3414   int current( actor.GetCurrentProperty< int >( index ) );
3415   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3416
3417   application.SendNotification();
3418   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3419
3420   // We did expect the animation to finish
3421   application.SendNotification();
3422   finishCheck.CheckSignalReceived();
3423   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3424
3425   // Check that nothing has changed after a couple of buffer swaps
3426   application.Render(0);
3427   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3428   application.Render(0);
3429   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3430   END_TEST;
3431 }
3432
3433 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3434 {
3435   TestApplication application;
3436
3437   Actor actor = Actor::New();
3438
3439   // Register an integer property
3440   int startValue(10);
3441   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3442   Stage::GetCurrent().Add(actor);
3443   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3444   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3445
3446   // Build the animation
3447   float durationSeconds(1.0f);
3448   Animation animation = Animation::New(durationSeconds);
3449   int targetValue(30);
3450   int relativeValue(targetValue - startValue);
3451   float delay = 0.5f;
3452   animation.AnimateBy(Property(actor, index),
3453                       relativeValue,
3454                       TimePeriod(delay, durationSeconds - delay));
3455
3456   // Start the animation
3457   animation.Play();
3458
3459   bool signalReceived(false);
3460   AnimationFinishCheck finishCheck(signalReceived);
3461   animation.FinishedSignal().Connect(&application, finishCheck);
3462
3463   application.SendNotification();
3464   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3465
3466   // We didn't expect the animation to finish yet
3467   application.SendNotification();
3468   finishCheck.CheckSignalNotReceived();
3469   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3470
3471   application.SendNotification();
3472   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3473
3474   // We didn't expect the animation to finish yet
3475   application.SendNotification();
3476   finishCheck.CheckSignalNotReceived();
3477   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3478
3479   application.SendNotification();
3480   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3481
3482   // We did expect the animation to finish
3483   application.SendNotification();
3484   finishCheck.CheckSignalReceived();
3485   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3486
3487   // Check that nothing has changed after a couple of buffer swaps
3488   application.Render(0);
3489   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3490   application.Render(0);
3491   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3492   END_TEST;
3493 }
3494
3495 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3496 {
3497   TestApplication application;
3498
3499   Actor actor = Actor::New();
3500
3501   // Register an integer property
3502   int startValue(10);
3503   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3504   Stage::GetCurrent().Add(actor);
3505   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3506   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3507
3508   // Build the animation
3509   float durationSeconds(1.0f);
3510   Animation animation = Animation::New(durationSeconds);
3511   int targetValue(30);
3512   int relativeValue(targetValue - startValue);
3513   float delay = 0.5f;
3514   animation.AnimateBy(Property(actor, index),
3515                       relativeValue,
3516                       AlphaFunction::LINEAR,
3517                       TimePeriod(delay, durationSeconds - delay));
3518
3519   // Start the animation
3520   animation.Play();
3521
3522   bool signalReceived(false);
3523   AnimationFinishCheck finishCheck(signalReceived);
3524   animation.FinishedSignal().Connect(&application, finishCheck);
3525
3526   application.SendNotification();
3527   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3528
3529   // We didn't expect the animation to finish yet
3530   application.SendNotification();
3531   finishCheck.CheckSignalNotReceived();
3532   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3533
3534   application.SendNotification();
3535   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3536
3537   // We didn't expect the animation to finish yet
3538   application.SendNotification();
3539   finishCheck.CheckSignalNotReceived();
3540   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3541
3542   application.SendNotification();
3543   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3544
3545   // We did expect the animation to finish
3546   application.SendNotification();
3547   finishCheck.CheckSignalReceived();
3548   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3549
3550   // Check that nothing has changed after a couple of buffer swaps
3551   application.Render(0);
3552   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3553   application.Render(0);
3554   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3555   END_TEST;
3556 }
3557
3558 int UtcDaliAnimationAnimateByQuaternionP(void)
3559 {
3560   TestApplication application;
3561
3562   Actor actor = Actor::New();
3563
3564   // Register a quaternion property
3565   const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
3566   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3567   Stage::GetCurrent().Add(actor);
3568   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3569   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3570
3571   // Build the animation
3572   float durationSeconds(2.0f);
3573   Animation animation = Animation::New(durationSeconds);
3574   const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
3575   const Quaternion finalValue( startValue * relativeValue );
3576   animation.AnimateBy(Property(actor, index), relativeValue);
3577
3578   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3579   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3580
3581   // Start the animation
3582   animation.Play();
3583
3584   // Target value should be retrievable straight away
3585   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3586
3587   application.SendNotification();
3588   application.Render( 2000 ); // animation complete
3589
3590   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3591   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
3592
3593   END_TEST;
3594 }
3595
3596 int UtcDaliAnimationAnimateByVector2P(void)
3597 {
3598   TestApplication application;
3599
3600   Actor actor = Actor::New();
3601
3602   // Register a Vector2 property
3603   Vector2 startValue(10.0f, 10.0f);
3604   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3605   Stage::GetCurrent().Add(actor);
3606   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3607   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3608
3609   // Build the animation
3610   float durationSeconds(2.0f);
3611   Animation animation = Animation::New(durationSeconds);
3612   Vector2 targetValue(60.0f, 60.0f);
3613   Vector2 relativeValue(targetValue - startValue);
3614   animation.AnimateBy(Property(actor, index), relativeValue);
3615
3616   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3617
3618   // Start the animation
3619   animation.Play();
3620
3621   // Target value should be retrievable straight away
3622   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3623
3624   bool signalReceived(false);
3625   AnimationFinishCheck finishCheck(signalReceived);
3626   animation.FinishedSignal().Connect(&application, finishCheck);
3627
3628   application.SendNotification();
3629   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3630
3631   // We didn't expect the animation to finish yet
3632   application.SendNotification();
3633   finishCheck.CheckSignalNotReceived();
3634   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3635
3636   application.SendNotification();
3637   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3638
3639   // We did expect the animation to finish
3640   application.SendNotification();
3641   finishCheck.CheckSignalReceived();
3642   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3643
3644   // Check that nothing has changed after a couple of buffer swaps
3645   application.Render(0);
3646   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3647   application.Render(0);
3648   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3649   END_TEST;
3650 }
3651
3652 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3653 {
3654   TestApplication application;
3655
3656   Actor actor = Actor::New();
3657
3658   // Register a Vector2 property
3659   Vector2 startValue(100.0f, 100.0f);
3660   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3661   Stage::GetCurrent().Add(actor);
3662   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3663   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3664
3665   // Build the animation
3666   float durationSeconds(1.0f);
3667   Animation animation = Animation::New(durationSeconds);
3668   Vector2 targetValue(20.0f, 20.0f);
3669   Vector2 relativeValue(targetValue - startValue);
3670   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3671
3672   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3673
3674   // Start the animation
3675   animation.Play();
3676
3677   bool signalReceived(false);
3678   AnimationFinishCheck finishCheck(signalReceived);
3679   animation.FinishedSignal().Connect(&application, finishCheck);
3680
3681   application.SendNotification();
3682   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3683
3684   // We didn't expect the animation to finish yet
3685   application.SendNotification();
3686   finishCheck.CheckSignalNotReceived();
3687
3688   // The position should have moved more, than with a linear alpha function
3689   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3690   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3691   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3692
3693   application.SendNotification();
3694   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3695
3696   // We did expect the animation to finish
3697   application.SendNotification();
3698   finishCheck.CheckSignalReceived();
3699   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3700
3701   // Check that nothing has changed after a couple of buffer swaps
3702   application.Render(0);
3703   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3704   application.Render(0);
3705   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3706   END_TEST;
3707 }
3708
3709 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3710 {
3711   TestApplication application;
3712
3713   Actor actor = Actor::New();
3714
3715   // Register a Vector2 property
3716   Vector2 startValue(10.0f, 10.0f);
3717   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3718   Stage::GetCurrent().Add(actor);
3719   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3720   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3721
3722   // Build the animation
3723   float durationSeconds(1.0f);
3724   Animation animation = Animation::New(durationSeconds);
3725   Vector2 targetValue(30.0f, 30.0f);
3726   Vector2 relativeValue(targetValue - startValue);
3727   float delay = 0.5f;
3728   animation.AnimateBy(Property(actor, index),
3729                       relativeValue,
3730                       TimePeriod(delay, durationSeconds - delay));
3731
3732   // Start the animation
3733   animation.Play();
3734
3735   bool signalReceived(false);
3736   AnimationFinishCheck finishCheck(signalReceived);
3737   animation.FinishedSignal().Connect(&application, finishCheck);
3738
3739   application.SendNotification();
3740   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3741
3742   // We didn't expect the animation to finish yet
3743   application.SendNotification();
3744   finishCheck.CheckSignalNotReceived();
3745   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3746
3747   application.SendNotification();
3748   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3749
3750   // We didn't expect the animation to finish yet
3751   application.SendNotification();
3752   finishCheck.CheckSignalNotReceived();
3753   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3754
3755   application.SendNotification();
3756   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3757
3758   // We did expect the animation to finish
3759   application.SendNotification();
3760   finishCheck.CheckSignalReceived();
3761   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3762
3763   // Check that nothing has changed after a couple of buffer swaps
3764   application.Render(0);
3765   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3766   application.Render(0);
3767   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3768   END_TEST;
3769 }
3770
3771 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
3772 {
3773   TestApplication application;
3774
3775   Actor actor = Actor::New();
3776
3777   // Register a Vector2 property
3778   Vector2 startValue(5.0f, 5.0f);
3779   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3780   Stage::GetCurrent().Add(actor);
3781   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3782   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3783
3784   // Build the animation
3785   float durationSeconds(1.0f);
3786   Animation animation = Animation::New(durationSeconds);
3787   Vector2 targetValue(10.0f, 10.0f);
3788   Vector2 relativeValue(targetValue - startValue);
3789   float delay = 0.5f;
3790   animation.AnimateBy(Property(actor, index),
3791                       relativeValue,
3792                       AlphaFunction::LINEAR,
3793                       TimePeriod(delay, durationSeconds - delay));
3794
3795   // Start the animation
3796   animation.Play();
3797
3798   bool signalReceived(false);
3799   AnimationFinishCheck finishCheck(signalReceived);
3800   animation.FinishedSignal().Connect(&application, finishCheck);
3801
3802   application.SendNotification();
3803   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3804
3805   // We didn't expect the animation to finish yet
3806   application.SendNotification();
3807   finishCheck.CheckSignalNotReceived();
3808   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3809
3810   application.SendNotification();
3811   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3812
3813   // We didn't expect the animation to finish yet
3814   application.SendNotification();
3815   finishCheck.CheckSignalNotReceived();
3816   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3817
3818   application.SendNotification();
3819   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3820
3821   // We did expect the animation to finish
3822   application.SendNotification();
3823   finishCheck.CheckSignalReceived();
3824   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3825
3826   // Check that nothing has changed after a couple of buffer swaps
3827   application.Render(0);
3828   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3829   application.Render(0);
3830   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3831   END_TEST;
3832 }
3833
3834 int UtcDaliAnimationAnimateByVector3P(void)
3835 {
3836   TestApplication application;
3837
3838   Actor actor = Actor::New();
3839
3840   // Register a Vector3 property
3841   Vector3 startValue(10.0f, 10.0f, 10.0f);
3842   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3843   Stage::GetCurrent().Add(actor);
3844   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3845   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3846
3847   // Build the animation
3848   float durationSeconds(2.0f);
3849   Animation animation = Animation::New(durationSeconds);
3850   Vector3 targetValue(60.0f, 60.0f, 60.0f);
3851   Vector3 relativeValue(targetValue - startValue);
3852   animation.AnimateBy(Property(actor, index), relativeValue);
3853
3854   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3855
3856   // Start the animation
3857   animation.Play();
3858
3859   // Target value should be retrievable straight away
3860   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3861
3862   bool signalReceived(false);
3863   AnimationFinishCheck finishCheck(signalReceived);
3864   animation.FinishedSignal().Connect(&application, finishCheck);
3865
3866   application.SendNotification();
3867   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3868
3869   // We didn't expect the animation to finish yet
3870   application.SendNotification();
3871   finishCheck.CheckSignalNotReceived();
3872   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3873
3874   application.SendNotification();
3875   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3876
3877   // We did expect the animation to finish
3878   application.SendNotification();
3879   finishCheck.CheckSignalReceived();
3880   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3881
3882   // Check that nothing has changed after a couple of buffer swaps
3883   application.Render(0);
3884   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3885   application.Render(0);
3886   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3887   END_TEST;
3888 }
3889
3890 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
3891 {
3892   TestApplication application;
3893
3894   Actor actor = Actor::New();
3895
3896   // Register a Vector3 property
3897   Vector3 startValue(100.0f, 100.0f, 100.0f);
3898   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3899   Stage::GetCurrent().Add(actor);
3900   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3901   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3902
3903   // Build the animation
3904   float durationSeconds(1.0f);
3905   Animation animation = Animation::New(durationSeconds);
3906   Vector3 targetValue(20.0f, 20.0f, 20.0f);
3907   Vector3 relativeValue(targetValue - startValue);
3908   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3909
3910   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3911
3912   // Start the animation
3913   animation.Play();
3914
3915   bool signalReceived(false);
3916   AnimationFinishCheck finishCheck(signalReceived);
3917   animation.FinishedSignal().Connect(&application, finishCheck);
3918
3919   application.SendNotification();
3920   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3921
3922   // We didn't expect the animation to finish yet
3923   application.SendNotification();
3924   finishCheck.CheckSignalNotReceived();
3925
3926   // The position should have moved more, than with a linear alpha function
3927   Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
3928   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3929   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3930   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3931
3932   application.SendNotification();
3933   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3934
3935   // We did expect the animation to finish
3936   application.SendNotification();
3937   finishCheck.CheckSignalReceived();
3938   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3939
3940   // Check that nothing has changed after a couple of buffer swaps
3941   application.Render(0);
3942   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3943   application.Render(0);
3944   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3945   END_TEST;
3946 }
3947
3948 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
3949 {
3950   TestApplication application;
3951
3952   Actor actor = Actor::New();
3953
3954   // Register a Vector3 property
3955   Vector3 startValue(10.0f, 10.0f, 10.0f);
3956   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3957   Stage::GetCurrent().Add(actor);
3958   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3959   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3960
3961   // Build the animation
3962   float durationSeconds(1.0f);
3963   Animation animation = Animation::New(durationSeconds);
3964   Vector3 targetValue(30.0f, 30.0f, 30.0f);
3965   Vector3 relativeValue(targetValue - startValue);
3966   float delay = 0.5f;
3967   animation.AnimateBy(Property(actor, index),
3968                       relativeValue,
3969                       TimePeriod(delay, durationSeconds - delay));
3970
3971   // Start the animation
3972   animation.Play();
3973
3974   bool signalReceived(false);
3975   AnimationFinishCheck finishCheck(signalReceived);
3976   animation.FinishedSignal().Connect(&application, finishCheck);
3977
3978   application.SendNotification();
3979   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3980
3981   // We didn't expect the animation to finish yet
3982   application.SendNotification();
3983   finishCheck.CheckSignalNotReceived();
3984   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3985
3986   application.SendNotification();
3987   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3988
3989   // We didn't expect the animation to finish yet
3990   application.SendNotification();
3991   finishCheck.CheckSignalNotReceived();
3992   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3993
3994   application.SendNotification();
3995   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3996
3997   // We did expect the animation to finish
3998   application.SendNotification();
3999   finishCheck.CheckSignalReceived();
4000   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4001
4002   // Check that nothing has changed after a couple of buffer swaps
4003   application.Render(0);
4004   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4005   application.Render(0);
4006   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4007   END_TEST;
4008 }
4009
4010 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
4011 {
4012   TestApplication application;
4013
4014   Actor actor = Actor::New();
4015
4016   // Register a Vector3 property
4017   Vector3 startValue(5.0f, 5.0f, 5.0f);
4018   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4019   Stage::GetCurrent().Add(actor);
4020   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4021   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4022
4023   // Build the animation
4024   float durationSeconds(1.0f);
4025   Animation animation = Animation::New(durationSeconds);
4026   Vector3 targetValue(10.0f, 10.0f, 10.0f);
4027   Vector3 relativeValue(targetValue - startValue);
4028   float delay = 0.5f;
4029   animation.AnimateBy(Property(actor, index),
4030                       relativeValue,
4031                       AlphaFunction::LINEAR,
4032                       TimePeriod(delay, durationSeconds - delay));
4033
4034   // Start the animation
4035   animation.Play();
4036
4037   bool signalReceived(false);
4038   AnimationFinishCheck finishCheck(signalReceived);
4039   animation.FinishedSignal().Connect(&application, finishCheck);
4040
4041   application.SendNotification();
4042   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4043
4044   // We didn't expect the animation to finish yet
4045   application.SendNotification();
4046   finishCheck.CheckSignalNotReceived();
4047   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4048
4049   application.SendNotification();
4050   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4051
4052   // We didn't expect the animation to finish yet
4053   application.SendNotification();
4054   finishCheck.CheckSignalNotReceived();
4055   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4056
4057   application.SendNotification();
4058   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4059
4060   // We did expect the animation to finish
4061   application.SendNotification();
4062   finishCheck.CheckSignalReceived();
4063   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4064
4065   // Check that nothing has changed after a couple of buffer swaps
4066   application.Render(0);
4067   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4068   application.Render(0);
4069   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4070   END_TEST;
4071 }
4072
4073 int UtcDaliAnimationAnimateByVector4P(void)
4074 {
4075   TestApplication application;
4076
4077   Actor actor = Actor::New();
4078
4079   // Register a Vector4 property
4080   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4081   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4082   Stage::GetCurrent().Add(actor);
4083   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4084   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4085
4086   // Build the animation
4087   float durationSeconds(2.0f);
4088   Animation animation = Animation::New(durationSeconds);
4089   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4090   Vector4 relativeValue(targetValue - startValue);
4091   animation.AnimateBy(Property(actor, index), relativeValue);
4092
4093   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4094
4095   // Start the animation
4096   animation.Play();
4097
4098   // Target value should be retrievable straight away
4099   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4100
4101   bool signalReceived(false);
4102   AnimationFinishCheck finishCheck(signalReceived);
4103   animation.FinishedSignal().Connect(&application, finishCheck);
4104
4105   application.SendNotification();
4106   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4107
4108   // We didn't expect the animation to finish yet
4109   application.SendNotification();
4110   finishCheck.CheckSignalNotReceived();
4111   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4112
4113   application.SendNotification();
4114   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4115
4116   // We did expect the animation to finish
4117   application.SendNotification();
4118   finishCheck.CheckSignalReceived();
4119   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4120
4121   // Check that nothing has changed after a couple of buffer swaps
4122   application.Render(0);
4123   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4124   application.Render(0);
4125   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4126   END_TEST;
4127 }
4128
4129 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4130 {
4131   TestApplication application;
4132
4133   Actor actor = Actor::New();
4134
4135   // Register a Vector4 property
4136   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4137   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4138   Stage::GetCurrent().Add(actor);
4139   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4140   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4141
4142   // Build the animation
4143   float durationSeconds(1.0f);
4144   Animation animation = Animation::New(durationSeconds);
4145   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4146   Vector4 relativeValue(targetValue - startValue);
4147   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4148
4149   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4150
4151   // Start the animation
4152   animation.Play();
4153
4154   bool signalReceived(false);
4155   AnimationFinishCheck finishCheck(signalReceived);
4156   animation.FinishedSignal().Connect(&application, finishCheck);
4157
4158   application.SendNotification();
4159   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4160
4161   // We didn't expect the animation to finish yet
4162   application.SendNotification();
4163   finishCheck.CheckSignalNotReceived();
4164
4165   // The position should have moved more, than with a linear alpha function
4166   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4167   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4168   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4169   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4170   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4171
4172   application.SendNotification();
4173   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4174
4175   // We did expect the animation to finish
4176   application.SendNotification();
4177   finishCheck.CheckSignalReceived();
4178   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4179
4180   // Check that nothing has changed after a couple of buffer swaps
4181   application.Render(0);
4182   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4183   application.Render(0);
4184   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4185   END_TEST;
4186 }
4187
4188 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4189 {
4190   TestApplication application;
4191
4192   Actor actor = Actor::New();
4193
4194   // Register a Vector4 property
4195   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4196   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4197   Stage::GetCurrent().Add(actor);
4198   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4199   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4200
4201   // Build the animation
4202   float durationSeconds(1.0f);
4203   Animation animation = Animation::New(durationSeconds);
4204   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4205   Vector4 relativeValue(targetValue - startValue);
4206   float delay = 0.5f;
4207   animation.AnimateBy(Property(actor, index),
4208                       relativeValue,
4209                       TimePeriod(delay, durationSeconds - delay));
4210
4211   // Start the animation
4212   animation.Play();
4213
4214   bool signalReceived(false);
4215   AnimationFinishCheck finishCheck(signalReceived);
4216   animation.FinishedSignal().Connect(&application, finishCheck);
4217
4218   application.SendNotification();
4219   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4220
4221   // We didn't expect the animation to finish yet
4222   application.SendNotification();
4223   finishCheck.CheckSignalNotReceived();
4224   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4225
4226   application.SendNotification();
4227   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4228
4229   // We didn't expect the animation to finish yet
4230   application.SendNotification();
4231   finishCheck.CheckSignalNotReceived();
4232   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4233
4234   application.SendNotification();
4235   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4236
4237   // We did expect the animation to finish
4238   application.SendNotification();
4239   finishCheck.CheckSignalReceived();
4240   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4241
4242   // Check that nothing has changed after a couple of buffer swaps
4243   application.Render(0);
4244   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4245   application.Render(0);
4246   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4247   END_TEST;
4248 }
4249
4250 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4251 {
4252   TestApplication application;
4253
4254   Actor actor = Actor::New();
4255
4256   // Register a Vector4 property
4257   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4258   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4259   Stage::GetCurrent().Add(actor);
4260   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4261   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4262
4263   // Build the animation
4264   float durationSeconds(1.0f);
4265   Animation animation = Animation::New(durationSeconds);
4266   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4267   Vector4 relativeValue(targetValue - startValue);
4268   float delay = 0.5f;
4269   animation.AnimateBy(Property(actor, index),
4270                       relativeValue,
4271                       AlphaFunction::LINEAR,
4272                       TimePeriod(delay, durationSeconds - delay));
4273
4274   // Start the animation
4275   animation.Play();
4276
4277   bool signalReceived(false);
4278   AnimationFinishCheck finishCheck(signalReceived);
4279   animation.FinishedSignal().Connect(&application, finishCheck);
4280
4281   application.SendNotification();
4282   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4283
4284   // We didn't expect the animation to finish yet
4285   application.SendNotification();
4286   finishCheck.CheckSignalNotReceived();
4287   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4288
4289   application.SendNotification();
4290   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4291
4292   // We didn't expect the animation to finish yet
4293   application.SendNotification();
4294   finishCheck.CheckSignalNotReceived();
4295   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4296
4297   application.SendNotification();
4298   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4299
4300   // We did expect the animation to finish
4301   application.SendNotification();
4302   finishCheck.CheckSignalReceived();
4303   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4304
4305   // Check that nothing has changed after a couple of buffer swaps
4306   application.Render(0);
4307   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4308   application.Render(0);
4309   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4310   END_TEST;
4311 }
4312
4313 int UtcDaliAnimationAnimateByActorPositionP(void)
4314 {
4315   TestApplication application;
4316
4317   Actor actor = Actor::New();
4318   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4319   actor.SetPosition(startPosition);
4320   Stage::GetCurrent().Add(actor);
4321   application.SendNotification();
4322   application.Render(0);
4323   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4324
4325   // Build the animation
4326   float durationSeconds(1.0f);
4327   Animation animation = Animation::New(durationSeconds);
4328   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4329   Vector3 relativePosition(targetPosition - startPosition);
4330   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4331
4332   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4333
4334   // Start the animation
4335   animation.Play();
4336
4337   // Target value should be retrievable straight away
4338   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4339
4340   bool signalReceived(false);
4341   AnimationFinishCheck finishCheck(signalReceived);
4342   animation.FinishedSignal().Connect(&application, finishCheck);
4343
4344   application.SendNotification();
4345   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4346
4347   // We didn't expect the animation to finish yet
4348   application.SendNotification();
4349   finishCheck.CheckSignalNotReceived();
4350   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4351
4352   application.SendNotification();
4353   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4354
4355   // We did expect the animation to finish
4356   application.SendNotification();
4357   finishCheck.CheckSignalReceived();
4358   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4359
4360   // Check that nothing has changed after a couple of buffer swaps
4361   application.Render(0);
4362   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4363   application.Render(0);
4364   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4365   END_TEST;
4366 }
4367
4368 int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
4369 {
4370   TestApplication application;
4371
4372   Actor actor = Actor::New();
4373   Stage::GetCurrent().Add(actor);
4374   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4375
4376   // Build the animation
4377   float durationSeconds(1.0f);
4378   Animation animation = Animation::New(durationSeconds);
4379   Vector3 targetPosition(200.0f, 300.0f, 400.0f);
4380   Vector3 relativePosition(targetPosition - Vector3::ZERO);
4381   animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
4382   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
4383   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
4384
4385   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4386   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4387
4388   // Start the animation
4389   animation.Play();
4390
4391   // Target value should be retrievable straight away
4392   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4393   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
4394   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
4395   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
4396
4397   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
4398
4399   application.SendNotification();
4400   application.Render( 1000 ); // 1 second progress
4401
4402   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4403
4404   END_TEST;
4405 }
4406
4407 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4408 {
4409   TestApplication application;
4410
4411   Actor actor = Actor::New();
4412   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4413   actor.SetPosition(startPosition);
4414   Stage::GetCurrent().Add(actor);
4415   application.SendNotification();
4416   application.Render(0);
4417   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4418
4419   // Build the animation
4420   float durationSeconds(1.0f);
4421   Animation animation = Animation::New(durationSeconds);
4422   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4423   Vector3 relativePosition(targetPosition - startPosition);
4424   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4425
4426   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4427
4428   // Start the animation
4429   animation.Play();
4430
4431   bool signalReceived(false);
4432   AnimationFinishCheck finishCheck(signalReceived);
4433   animation.FinishedSignal().Connect(&application, finishCheck);
4434
4435   application.SendNotification();
4436   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4437
4438   // We didn't expect the animation to finish yet
4439   application.SendNotification();
4440   finishCheck.CheckSignalNotReceived();
4441
4442   // The position should have moved more, than with a linear alpha function
4443   Vector3 current(actor.GetCurrentPosition());
4444   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4445   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4446   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4447
4448   application.SendNotification();
4449   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4450
4451   // We did expect the animation to finish
4452   application.SendNotification();
4453   finishCheck.CheckSignalReceived();
4454   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4455
4456   // Check that nothing has changed after a couple of buffer swaps
4457   application.Render(0);
4458   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4459   application.Render(0);
4460   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4461   END_TEST;
4462 }
4463
4464 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4465 {
4466   TestApplication application;
4467
4468   Actor actor = Actor::New();
4469   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4470   actor.SetPosition(startPosition);
4471   Stage::GetCurrent().Add(actor);
4472   application.SendNotification();
4473   application.Render(0);
4474   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4475
4476   // Build the animation
4477   float durationSeconds(1.0f);
4478   Animation animation = Animation::New(durationSeconds);
4479   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4480   Vector3 relativePosition(targetPosition - startPosition);
4481   float delay = 0.5f;
4482   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4483                       relativePosition,
4484                       TimePeriod(delay, durationSeconds - delay));
4485
4486   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4487
4488   // Start the animation
4489   animation.Play();
4490
4491   bool signalReceived(false);
4492   AnimationFinishCheck finishCheck(signalReceived);
4493   animation.FinishedSignal().Connect(&application, finishCheck);
4494
4495   application.SendNotification();
4496   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4497
4498   // We didn't expect the animation to finish yet
4499   application.SendNotification();
4500   finishCheck.CheckSignalNotReceived();
4501   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4502
4503   application.SendNotification();
4504   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4505
4506   // We did expect the animation to finish
4507   application.SendNotification();
4508   finishCheck.CheckSignalReceived();
4509   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4510
4511   // Check that nothing has changed after a couple of buffer swaps
4512   application.Render(0);
4513   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4514   application.Render(0);
4515   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4516   END_TEST;
4517 }
4518
4519 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4520 {
4521   TestApplication application;
4522
4523   Actor actor = Actor::New();
4524   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4525   actor.SetPosition(startPosition);
4526   Stage::GetCurrent().Add(actor);
4527   application.SendNotification();
4528   application.Render(0);
4529   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4530
4531   // Build the animation
4532   float durationSeconds(1.0f);
4533   Animation animation = Animation::New(durationSeconds);
4534   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4535   Vector3 relativePosition(targetPosition - startPosition);
4536   float delay = 0.5f;
4537   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4538                       relativePosition,
4539                       AlphaFunction::LINEAR,
4540                       TimePeriod(delay, durationSeconds - delay));
4541
4542   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4543
4544   // Start the animation
4545   animation.Play();
4546
4547   bool signalReceived(false);
4548   AnimationFinishCheck finishCheck(signalReceived);
4549   animation.FinishedSignal().Connect(&application, finishCheck);
4550
4551   application.SendNotification();
4552   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4553
4554   // We didn't expect the animation to finish yet
4555   application.SendNotification();
4556   finishCheck.CheckSignalNotReceived();
4557   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4558
4559   application.SendNotification();
4560   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4561
4562   // We did expect the animation to finish
4563   application.SendNotification();
4564   finishCheck.CheckSignalReceived();
4565   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4566
4567   // Check that nothing has changed after a couple of buffer swaps
4568   application.Render(0);
4569   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4570   application.Render(0);
4571   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4572   END_TEST;
4573 }
4574
4575 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4576 {
4577   TestApplication application;
4578
4579   Actor actor = Actor::New();
4580   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4581   Stage::GetCurrent().Add(actor);
4582   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4583
4584   // Build the animation
4585   float durationSeconds(1.0f);
4586   Animation animation = Animation::New(durationSeconds);
4587   Degree relativeRotationDegrees(360.0f);
4588   Radian relativeRotationRadians(relativeRotationDegrees);
4589   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4590
4591   // Start the animation
4592   animation.Play();
4593
4594   // Target value should be retrievable straight away
4595   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
4596
4597   bool signalReceived(false);
4598   AnimationFinishCheck finishCheck(signalReceived);
4599   animation.FinishedSignal().Connect(&application, finishCheck);
4600
4601   application.SendNotification();
4602   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% 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(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4608
4609   application.SendNotification();
4610   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% 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(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4616
4617   application.SendNotification();
4618   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4619
4620   // We didn't expect the animation to finish yet
4621   application.SendNotification();
4622   finishCheck.CheckSignalNotReceived();
4623   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4624
4625   application.SendNotification();
4626   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4627
4628   // We did expect the animation to finish
4629   application.SendNotification();
4630   finishCheck.CheckSignalReceived();
4631   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4632   END_TEST;
4633 }
4634
4635 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4636 {
4637   TestApplication application;
4638
4639   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4640
4641   Actor actor = Actor::New();
4642   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4643   Stage::GetCurrent().Add(actor);
4644   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4645
4646   // Build the animation
4647   float durationSeconds(1.0f);
4648   Animation animation = Animation::New(durationSeconds);
4649   Degree relativeRotationDegrees(710.0f);
4650   Radian relativeRotationRadians(relativeRotationDegrees);
4651
4652   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4653
4654   // Start the animation
4655   animation.Play();
4656
4657   bool signalReceived(false);
4658   AnimationFinishCheck finishCheck(signalReceived);
4659   animation.FinishedSignal().Connect(&application, finishCheck);
4660
4661   application.SendNotification();
4662   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4663
4664   // We didn't expect the animation to finish yet
4665   application.SendNotification();
4666   finishCheck.CheckSignalNotReceived();
4667   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4668
4669   application.SendNotification();
4670   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4671
4672   // We didn't expect the animation to finish yet
4673   application.SendNotification();
4674   finishCheck.CheckSignalNotReceived();
4675   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4676
4677   application.SendNotification();
4678   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4679
4680   // We didn't expect the animation to finish yet
4681   application.SendNotification();
4682   finishCheck.CheckSignalNotReceived();
4683   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4684
4685   application.SendNotification();
4686   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4687
4688   // We did expect the animation to finish
4689   application.SendNotification();
4690   finishCheck.CheckSignalReceived();
4691   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4692   END_TEST;
4693 }
4694
4695
4696 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4697 {
4698   TestApplication application;
4699
4700   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4701
4702   Actor actor = Actor::New();
4703   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4704   Stage::GetCurrent().Add(actor);
4705   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4706
4707   // Build the animation
4708   float durationSeconds(1.0f);
4709   Animation animation = Animation::New(durationSeconds);
4710   Degree relativeRotationDegrees(730.0f);
4711   Radian relativeRotationRadians(relativeRotationDegrees);
4712
4713   Radian actualRotationRadians( Degree(10.0f) );
4714
4715   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4716
4717   // Start the animation
4718   animation.Play();
4719
4720   bool signalReceived(false);
4721   AnimationFinishCheck finishCheck(signalReceived);
4722   animation.FinishedSignal().Connect(&application, finishCheck);
4723
4724   application.SendNotification();
4725   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4726
4727   // We didn't expect the animation to finish yet
4728   application.SendNotification();
4729   finishCheck.CheckSignalNotReceived();
4730   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4731
4732   application.SendNotification();
4733   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4734
4735   // We didn't expect the animation to finish yet
4736   application.SendNotification();
4737   finishCheck.CheckSignalNotReceived();
4738   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4739
4740   application.SendNotification();
4741   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4742
4743   // We didn't expect the animation to finish yet
4744   application.SendNotification();
4745   finishCheck.CheckSignalNotReceived();
4746   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4747
4748   application.SendNotification();
4749   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4750
4751   // We did expect the animation to finish
4752   application.SendNotification();
4753   finishCheck.CheckSignalReceived();
4754   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4755   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4756   END_TEST;
4757 }
4758
4759
4760 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4761 {
4762   TestApplication application;
4763
4764   Actor actor = Actor::New();
4765   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4766   Stage::GetCurrent().Add(actor);
4767   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4768
4769   // Build the animation
4770   float durationSeconds(1.0f);
4771   Animation animation = Animation::New(durationSeconds);
4772   Degree relativeRotationDegrees(360.0f);
4773   Radian relativeRotationRadians(relativeRotationDegrees);
4774   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4775
4776   // Start the animation
4777   animation.Play();
4778
4779   bool signalReceived(false);
4780   AnimationFinishCheck finishCheck(signalReceived);
4781   animation.FinishedSignal().Connect(&application, finishCheck);
4782
4783   application.SendNotification();
4784   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4785
4786   // We didn't expect the animation to finish yet
4787   application.SendNotification();
4788   finishCheck.CheckSignalNotReceived();
4789   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4790
4791   application.SendNotification();
4792   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4793
4794   // We didn't expect the animation to finish yet
4795   application.SendNotification();
4796   finishCheck.CheckSignalNotReceived();
4797   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4798
4799   application.SendNotification();
4800   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4801
4802   // We didn't expect the animation to finish yet
4803   application.SendNotification();
4804   finishCheck.CheckSignalNotReceived();
4805   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4806
4807   application.SendNotification();
4808   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4809
4810   // We did expect the animation to finish
4811   application.SendNotification();
4812   finishCheck.CheckSignalReceived();
4813   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4814   END_TEST;
4815 }
4816
4817 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4818 {
4819   TestApplication application;
4820
4821   Actor actor = Actor::New();
4822   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4823   Stage::GetCurrent().Add(actor);
4824   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4825
4826   // Build the animation
4827   float durationSeconds(1.0f);
4828   Animation animation = Animation::New(durationSeconds);
4829   Degree relativeRotationDegrees(360.0f);
4830   Radian relativeRotationRadians(relativeRotationDegrees);
4831   float delay = 0.3f;
4832   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4833                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4834
4835   // Start the animation
4836   animation.Play();
4837
4838   bool signalReceived(false);
4839   AnimationFinishCheck finishCheck(signalReceived);
4840   animation.FinishedSignal().Connect(&application, finishCheck);
4841
4842   application.SendNotification();
4843   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4844
4845   // We didn't expect the animation to finish yet
4846   application.SendNotification();
4847   finishCheck.CheckSignalNotReceived();
4848   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4849   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4850
4851   application.SendNotification();
4852   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4853
4854   // We didn't expect the animation to finish yet
4855   application.SendNotification();
4856   finishCheck.CheckSignalNotReceived();
4857   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4858   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4859
4860   application.SendNotification();
4861   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4862
4863   // We didn't expect the animation to finish yet
4864   application.SendNotification();
4865   finishCheck.CheckSignalNotReceived();
4866   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4867   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4868
4869   application.SendNotification();
4870   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4871
4872   // We did expect the animation to finish
4873   application.SendNotification();
4874   finishCheck.CheckSignalReceived();
4875   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4876   END_TEST;
4877 }
4878
4879 int UtcDaliAnimationAnimateByActorScaleP(void)
4880 {
4881   TestApplication application;
4882
4883   Actor actor = Actor::New();
4884   Stage::GetCurrent().Add(actor);
4885   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4886
4887   // Build the animation
4888   float durationSeconds(1.0f);
4889   Animation animation = Animation::New(durationSeconds);
4890   Vector3 targetScale(2.0f, 2.0f, 2.0f);
4891   Vector3 relativeScale(targetScale - Vector3::ONE);
4892   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4893
4894   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4895
4896   // Start the animation
4897   animation.Play();
4898
4899   // Target value should be retrievable straight away
4900   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
4901
4902   bool signalReceived(false);
4903   AnimationFinishCheck finishCheck(signalReceived);
4904   animation.FinishedSignal().Connect(&application, finishCheck);
4905
4906   application.SendNotification();
4907   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4908
4909   // We didn't expect the animation to finish yet
4910   application.SendNotification();
4911   finishCheck.CheckSignalNotReceived();
4912   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4913
4914   application.SendNotification();
4915   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4916
4917   // We did expect the animation to finish
4918   application.SendNotification();
4919   finishCheck.CheckSignalReceived();
4920   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4921
4922   // Reset everything
4923   finishCheck.Reset();
4924   actor.SetScale(Vector3::ONE);
4925   application.SendNotification();
4926   application.Render(0);
4927   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4928
4929   // Repeat with a different (ease-in) alpha function
4930   animation = Animation::New(durationSeconds);
4931   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4932   animation.FinishedSignal().Connect(&application, finishCheck);
4933   animation.Play();
4934
4935   application.SendNotification();
4936   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4937
4938   // We didn't expect the animation to finish yet
4939   application.SendNotification();
4940   finishCheck.CheckSignalNotReceived();
4941
4942   // The scale should have grown less, than with a linear alpha function
4943   Vector3 current(actor.GetCurrentScale());
4944   DALI_TEST_CHECK( current.x > 1.0f );
4945   DALI_TEST_CHECK( current.y > 1.0f );
4946   DALI_TEST_CHECK( current.z > 1.0f );
4947   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4948   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4949   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4950
4951   application.SendNotification();
4952   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4953
4954   // We did expect the animation to finish
4955   application.SendNotification();
4956   finishCheck.CheckSignalReceived();
4957   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4958
4959   // Reset everything
4960   finishCheck.Reset();
4961   actor.SetScale(Vector3::ONE);
4962   application.SendNotification();
4963   application.Render(0);
4964   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4965
4966   // Repeat with a delay
4967   float delay = 0.5f;
4968   animation = Animation::New(durationSeconds);
4969   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
4970   animation.FinishedSignal().Connect(&application, finishCheck);
4971   animation.Play();
4972
4973   application.SendNotification();
4974   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4975
4976   // We didn't expect the animation to finish yet
4977   application.SendNotification();
4978   finishCheck.CheckSignalNotReceived();
4979   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4980
4981   application.SendNotification();
4982   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4983
4984   // We did expect the animation to finish
4985   application.SendNotification();
4986   finishCheck.CheckSignalReceived();
4987   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4988   END_TEST;
4989 }
4990
4991 int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
4992 {
4993   TestApplication application;
4994
4995   Actor actor = Actor::New();
4996   Stage::GetCurrent().Add(actor);
4997   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4998
4999   // Build the animation
5000   float durationSeconds(1.0f);
5001   Animation animation = Animation::New(durationSeconds);
5002   Vector3 targetScale(2.0f, 3.0f, 4.0f);
5003   Vector3 relativeScale(targetScale - Vector3::ONE);
5004   animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
5005   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
5006   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
5007
5008   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5009   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5010
5011   // Start the animation
5012   animation.Play();
5013
5014   // Target value should be retrievable straight away
5015   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5016   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
5017   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
5018   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
5019
5020   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet
5021
5022   application.SendNotification();
5023   application.Render( 1000 ); // 1 second progress
5024
5025   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5026
5027   END_TEST;
5028 }
5029
5030 int UtcDaliAnimationAnimateByActorColorP(void)
5031 {
5032   TestApplication application;
5033
5034   Actor actor = Actor::New();
5035   Stage::GetCurrent().Add(actor);
5036   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5037
5038   // Build the animation
5039   float durationSeconds(1.0f);
5040   Animation animation = Animation::New(durationSeconds);
5041   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5042   Vector4 relativeColor( targetColor - Color::WHITE );
5043   animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
5044
5045   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5046   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5047
5048   // Start the animation
5049   animation.Play();
5050
5051   // Target value should be retrievable straight away
5052   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5053   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5054   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5055   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5056   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5057
5058   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5059
5060   application.SendNotification();
5061   application.Render( 1000 ); // 1 second progress
5062
5063   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5064
5065   END_TEST;
5066 }
5067
5068 int UtcDaliAnimationAnimateByActorColorComponentsP(void)
5069 {
5070   TestApplication application;
5071
5072   Actor actor = Actor::New();
5073   Stage::GetCurrent().Add(actor);
5074   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5075
5076   // Build the animation
5077   float durationSeconds(1.0f);
5078   Animation animation = Animation::New(durationSeconds);
5079   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5080   Vector4 relativeColor( targetColor - Color::WHITE );
5081   animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
5082   animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
5083   animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
5084   animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
5085
5086   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5087   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5088
5089   // Start the animation
5090   animation.Play();
5091
5092   // Target value should be retrievable straight away
5093   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5094   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5095   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5096   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5097   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5098
5099   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5100
5101   application.SendNotification();
5102   application.Render( 1000 ); // 1 second progress
5103
5104   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5105
5106   END_TEST;
5107 }
5108
5109 int UtcDaliAnimationAnimateByActorSizeP(void)
5110 {
5111   TestApplication application;
5112
5113   Actor actor = Actor::New();
5114   Stage::GetCurrent().Add(actor);
5115   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5116
5117   // Build the animation
5118   float durationSeconds(1.0f);
5119   Animation animation = Animation::New(durationSeconds);
5120   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5121   Vector3 relativeSize( targetSize - Vector3::ZERO );
5122   animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
5123
5124   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5125   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5126
5127   // Start the animation
5128   animation.Play();
5129
5130   // Target value should be retrievable straight away
5131   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5132   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5133   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5134   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5135
5136   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5137
5138   application.SendNotification();
5139   application.Render( 1000 ); // 1 second progress
5140
5141   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5142
5143   END_TEST;
5144 }
5145
5146 int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
5147 {
5148   TestApplication application;
5149
5150   Actor actor = Actor::New();
5151   Stage::GetCurrent().Add(actor);
5152   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5153
5154   // Build the animation
5155   float durationSeconds(1.0f);
5156   Animation animation = Animation::New(durationSeconds);
5157   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5158   Vector3 relativeSize( targetSize - Vector3::ZERO );
5159   animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
5160   animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
5161   animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
5162
5163   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5164   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5165
5166   // Start the animation
5167   animation.Play();
5168
5169   // Target value should be retrievable straight away
5170   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5171   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5172   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5173   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5174
5175   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5176
5177   application.SendNotification();
5178   application.Render( 1000 ); // 1 second progress
5179
5180   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5181
5182   END_TEST;
5183 }
5184
5185 int UtcDaliAnimationAnimateByActorVisibilityP(void)
5186 {
5187   TestApplication application;
5188
5189   Actor actor = Actor::New();
5190   Stage::GetCurrent().Add(actor);
5191   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5192
5193   actor.SetVisible( false );
5194
5195   application.SendNotification();
5196   application.Render();
5197
5198   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
5199
5200   // Build the animation
5201   float durationSeconds(1.0f);
5202   Animation animation = Animation::New(durationSeconds);
5203   bool targetVisibility( true );
5204   bool relativeVisibility( targetVisibility );
5205   animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
5206
5207   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5208
5209   // Start the animation
5210   animation.Play();
5211
5212   // Target value should be retrievable straight away
5213   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
5214   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet
5215
5216   application.SendNotification();
5217   application.Render( 1000 ); // 1 second progress
5218
5219   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5220
5221   END_TEST;
5222 }
5223
5224 int UtcDaliAnimationAnimateToBooleanP(void)
5225 {
5226   TestApplication application;
5227
5228   Actor actor = Actor::New();
5229
5230   // Register a boolean property
5231   const bool startValue(false);
5232   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5233   Stage::GetCurrent().Add(actor);
5234   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5235   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5236
5237   // Build the animation
5238   float durationSeconds(2.0f);
5239   Animation animation = Animation::New(durationSeconds);
5240   const bool targetValue( !startValue );
5241   animation.AnimateTo(Property(actor, index), targetValue);
5242
5243   // Start the animation
5244   animation.Play();
5245
5246   bool signalReceived(false);
5247   AnimationFinishCheck finishCheck(signalReceived);
5248   animation.FinishedSignal().Connect(&application, finishCheck);
5249
5250   application.SendNotification();
5251   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5252
5253   // We didn't expect the animation to finish yet
5254   application.SendNotification();
5255   finishCheck.CheckSignalNotReceived();
5256   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5257
5258   application.SendNotification();
5259   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5260
5261   // We did expect the animation to finish
5262   application.SendNotification();
5263   finishCheck.CheckSignalReceived();
5264   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5265
5266   // Check that nothing has changed after a couple of buffer swaps
5267   application.Render(0);
5268   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5269   application.Render(0);
5270   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5271
5272   // Repeat with target value "false"
5273   animation = Animation::New(durationSeconds);
5274   const bool finalValue( !targetValue );
5275   animation.AnimateTo(Property(actor, index), finalValue);
5276
5277   // Start the animation
5278   animation.Play();
5279
5280   finishCheck.Reset();
5281   animation.FinishedSignal().Connect(&application, finishCheck);
5282
5283   application.SendNotification();
5284   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5285
5286   // We didn't expect the animation to finish yet
5287   application.SendNotification();
5288   finishCheck.CheckSignalNotReceived();
5289   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5290
5291   application.SendNotification();
5292   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5293
5294   // We did expect the animation to finish
5295   application.SendNotification();
5296   finishCheck.CheckSignalReceived();
5297   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5298
5299   // Check that nothing has changed after a couple of buffer swaps
5300   application.Render(0);
5301   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5302   application.Render(0);
5303   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5304   END_TEST;
5305 }
5306
5307 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
5308 {
5309   TestApplication application;
5310
5311   Actor actor = Actor::New();
5312
5313   // Register a boolean property
5314   const bool startValue(false);
5315   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5316   Stage::GetCurrent().Add(actor);
5317   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5318   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5319
5320   // Build the animation
5321   float durationSeconds(2.0f);
5322   Animation animation = Animation::New(durationSeconds);
5323   const bool targetValue( !startValue );
5324   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5325
5326   // Start the animation
5327   animation.Play();
5328
5329   bool signalReceived(false);
5330   AnimationFinishCheck finishCheck(signalReceived);
5331   animation.FinishedSignal().Connect(&application, finishCheck);
5332
5333   application.SendNotification();
5334   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5335
5336   // We didn't expect the animation to finish yet
5337   application.SendNotification();
5338   finishCheck.CheckSignalNotReceived();
5339   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5340
5341   application.SendNotification();
5342   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5343
5344   // We did expect the animation to finish
5345   application.SendNotification();
5346   finishCheck.CheckSignalReceived();
5347   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5348
5349   // Check that nothing has changed after a couple of buffer swaps
5350   application.Render(0);
5351   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5352   application.Render(0);
5353   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5354
5355   // Repeat with target value "false"
5356   animation = Animation::New(durationSeconds);
5357   const bool finalValue( !targetValue );
5358   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5359
5360   // Start the animation
5361   animation.Play();
5362
5363   finishCheck.Reset();
5364   animation.FinishedSignal().Connect(&application, finishCheck);
5365
5366   application.SendNotification();
5367   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5368
5369   // We didn't expect the animation to finish yet
5370   application.SendNotification();
5371   finishCheck.CheckSignalNotReceived();
5372   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5373
5374   application.SendNotification();
5375   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5376
5377   // We did expect the animation to finish
5378   application.SendNotification();
5379   finishCheck.CheckSignalReceived();
5380   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5381
5382   // Check that nothing has changed after a couple of buffer swaps
5383   application.Render(0);
5384   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5385   application.Render(0);
5386   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5387   END_TEST;
5388 }
5389
5390 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5391 {
5392   TestApplication application;
5393
5394   Actor actor = Actor::New();
5395
5396   // Register a boolean property
5397   bool startValue(false);
5398   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5399   Stage::GetCurrent().Add(actor);
5400   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5401   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5402
5403   // Build the animation
5404   float durationSeconds(2.0f);
5405   Animation animation = Animation::New(durationSeconds);
5406   bool finalValue( !startValue );
5407   float animatorDurationSeconds(durationSeconds * 0.5f);
5408   animation.AnimateTo( Property(actor, index),
5409                        finalValue,
5410                        TimePeriod( animatorDurationSeconds ) );
5411
5412   // Start the animation
5413   animation.Play();
5414
5415   bool signalReceived(false);
5416   AnimationFinishCheck finishCheck(signalReceived);
5417   animation.FinishedSignal().Connect(&application, finishCheck);
5418
5419   application.SendNotification();
5420   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5421
5422   // We didn't expect the animation to finish yet
5423   application.SendNotification();
5424   finishCheck.CheckSignalNotReceived();
5425   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5426
5427   application.SendNotification();
5428   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5429
5430   // We didn't expect the animation to finish yet...
5431   application.SendNotification();
5432   finishCheck.CheckSignalNotReceived();
5433
5434   // ...however we should have reached the final value
5435   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5436
5437   application.SendNotification();
5438   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5439
5440   // We did expect the animation to finish
5441   application.SendNotification();
5442   finishCheck.CheckSignalReceived();
5443   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5444
5445   // Check that nothing has changed after a couple of buffer swaps
5446   application.Render(0);
5447   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5448   application.Render(0);
5449   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5450   END_TEST;
5451 }
5452
5453 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5454 {
5455   TestApplication application;
5456
5457   Actor actor = Actor::New();
5458
5459   // Register a boolean property
5460   bool startValue(false);
5461   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5462   Stage::GetCurrent().Add(actor);
5463   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5464   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5465
5466   // Build the animation
5467   float durationSeconds(2.0f);
5468   Animation animation = Animation::New(durationSeconds);
5469   bool finalValue( !startValue );
5470   float animatorDurationSeconds(durationSeconds * 0.5f);
5471   animation.AnimateTo( Property(actor, index),
5472                        finalValue,
5473                        AlphaFunction::LINEAR,
5474                        TimePeriod( animatorDurationSeconds ) );
5475
5476   // Start the animation
5477   animation.Play();
5478
5479   bool signalReceived(false);
5480   AnimationFinishCheck finishCheck(signalReceived);
5481   animation.FinishedSignal().Connect(&application, finishCheck);
5482
5483   application.SendNotification();
5484   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5485
5486   // We didn't expect the animation to finish yet
5487   application.SendNotification();
5488   finishCheck.CheckSignalNotReceived();
5489   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5490
5491   application.SendNotification();
5492   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5493
5494   // We didn't expect the animation to finish yet...
5495   application.SendNotification();
5496   finishCheck.CheckSignalNotReceived();
5497
5498   // ...however we should have reached the final value
5499   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5500
5501   application.SendNotification();
5502   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5503
5504   // We did expect the animation to finish
5505   application.SendNotification();
5506   finishCheck.CheckSignalReceived();
5507   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5508
5509   // Check that nothing has changed after a couple of buffer swaps
5510   application.Render(0);
5511   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5512   application.Render(0);
5513   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5514   END_TEST;
5515 }
5516
5517 int UtcDaliAnimationAnimateToFloatP(void)
5518 {
5519   TestApplication application;
5520
5521   Actor actor = Actor::New();
5522
5523   // Register a float property
5524   float startValue(10.0f);
5525   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5526   Stage::GetCurrent().Add(actor);
5527   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5528   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5529
5530   // Build the animation
5531   float durationSeconds(2.0f);
5532   Animation animation = Animation::New(durationSeconds);
5533   float targetValue(50.0f);
5534   float relativeValue(targetValue - startValue);
5535   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5536
5537   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5538
5539   // Start the animation
5540   animation.Play();
5541
5542   bool signalReceived(false);
5543   AnimationFinishCheck finishCheck(signalReceived);
5544   animation.FinishedSignal().Connect(&application, finishCheck);
5545
5546   application.SendNotification();
5547   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5548
5549   // We didn't expect the animation to finish yet
5550   application.SendNotification();
5551   finishCheck.CheckSignalNotReceived();
5552   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5553
5554   application.SendNotification();
5555   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5556
5557   // We did expect the animation to finish
5558   application.SendNotification();
5559   finishCheck.CheckSignalReceived();
5560   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5561   END_TEST;
5562 }
5563
5564 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5565 {
5566   TestApplication application;
5567
5568   Actor actor = Actor::New();
5569
5570   // Register a float property
5571   float startValue(10.0f);
5572   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5573   Stage::GetCurrent().Add(actor);
5574   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5575   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5576
5577   // Build the animation
5578   float durationSeconds(1.0f);
5579   Animation animation = Animation::New(durationSeconds);
5580   float targetValue(90.0f);
5581   float relativeValue(targetValue - startValue);
5582   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5583
5584   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5585
5586   // Start the animation
5587   animation.Play();
5588
5589   bool signalReceived(false);
5590   AnimationFinishCheck finishCheck(signalReceived);
5591   animation.FinishedSignal().Connect(&application, finishCheck);
5592
5593   application.SendNotification();
5594   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5595
5596   // We didn't expect the animation to finish yet
5597   application.SendNotification();
5598   finishCheck.CheckSignalNotReceived();
5599
5600   // The position should have moved more, than with a linear alpha function
5601   float current( actor.GetCurrentProperty< float >( index ) );
5602   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5603
5604   application.SendNotification();
5605   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5606
5607   // We did expect the animation to finish
5608   application.SendNotification();
5609   finishCheck.CheckSignalReceived();
5610   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5611   END_TEST;
5612 }
5613
5614 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5615 {
5616   TestApplication application;
5617
5618   Actor actor = Actor::New();
5619
5620   // Register a float property
5621   float startValue(10.0f);
5622   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5623   Stage::GetCurrent().Add(actor);
5624   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5625   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5626
5627   // Build the animation
5628   float durationSeconds(1.0f);
5629   Animation animation = Animation::New(durationSeconds);
5630   float targetValue(30.0f);
5631   float relativeValue(targetValue - startValue);
5632   float delay = 0.5f;
5633   animation.AnimateTo(Property(actor, index),
5634                       targetValue,
5635                       TimePeriod(delay, durationSeconds - delay));
5636
5637   // Start the animation
5638   animation.Play();
5639
5640   bool signalReceived(false);
5641   AnimationFinishCheck finishCheck(signalReceived);
5642   animation.FinishedSignal().Connect(&application, finishCheck);
5643
5644   application.SendNotification();
5645   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5646
5647   // We didn't expect the animation to finish yet
5648   application.SendNotification();
5649   finishCheck.CheckSignalNotReceived();
5650   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5651
5652   application.SendNotification();
5653   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5654
5655   // We didn't expect the animation to finish yet
5656   application.SendNotification();
5657   finishCheck.CheckSignalNotReceived();
5658   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5659
5660   application.SendNotification();
5661   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5662
5663   // We did expect the animation to finish
5664   application.SendNotification();
5665   finishCheck.CheckSignalReceived();
5666   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5667   END_TEST;
5668 }
5669
5670 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5671 {
5672   TestApplication application;
5673
5674   Actor actor = Actor::New();
5675
5676   // Register a float property
5677   float startValue(10.0f);
5678   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5679   Stage::GetCurrent().Add(actor);
5680   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5681   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5682
5683   // Build the animation
5684   float durationSeconds(1.0f);
5685   Animation animation = Animation::New(durationSeconds);
5686   float targetValue(30.0f);
5687   float relativeValue(targetValue - startValue);
5688   float delay = 0.5f;
5689   animation.AnimateTo(Property(actor, index),
5690                       targetValue,
5691                       AlphaFunction::LINEAR,
5692                       TimePeriod(delay, durationSeconds - delay));
5693
5694   // Start the animation
5695   animation.Play();
5696
5697   bool signalReceived(false);
5698   AnimationFinishCheck finishCheck(signalReceived);
5699   animation.FinishedSignal().Connect(&application, finishCheck);
5700
5701   application.SendNotification();
5702   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5703
5704   // We didn't expect the animation to finish yet
5705   application.SendNotification();
5706   finishCheck.CheckSignalNotReceived();
5707   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5708
5709   application.SendNotification();
5710   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5711
5712   // We didn't expect the animation to finish yet
5713   application.SendNotification();
5714   finishCheck.CheckSignalNotReceived();
5715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5716
5717   application.SendNotification();
5718   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5719
5720   // We did expect the animation to finish
5721   application.SendNotification();
5722   finishCheck.CheckSignalReceived();
5723   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5724   END_TEST;
5725 }
5726
5727 int UtcDaliAnimationAnimateToIntegerP(void)
5728 {
5729   TestApplication application;
5730
5731   Actor actor = Actor::New();
5732
5733   // Register an integer property
5734   int startValue(10);
5735   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5736   Stage::GetCurrent().Add(actor);
5737   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5738   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5739
5740   // Build the animation
5741   float durationSeconds(2.0f);
5742   Animation animation = Animation::New(durationSeconds);
5743   int targetValue(50);
5744   int relativeValue(targetValue - startValue);
5745   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5746
5747   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5748
5749   // Start the animation
5750   animation.Play();
5751
5752   bool signalReceived(false);
5753   AnimationFinishCheck finishCheck(signalReceived);
5754   animation.FinishedSignal().Connect(&application, finishCheck);
5755
5756   application.SendNotification();
5757   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5758
5759   // We didn't expect the animation to finish yet
5760   application.SendNotification();
5761   finishCheck.CheckSignalNotReceived();
5762   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5763
5764   application.SendNotification();
5765   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5766
5767   // We did expect the animation to finish
5768   application.SendNotification();
5769   finishCheck.CheckSignalReceived();
5770   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5771   END_TEST;
5772 }
5773
5774 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5775 {
5776   TestApplication application;
5777
5778   Actor actor = Actor::New();
5779
5780   // Register an integer property
5781   int startValue(10);
5782   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5783   Stage::GetCurrent().Add(actor);
5784   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5785   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5786
5787   // Build the animation
5788   float durationSeconds(1.0f);
5789   Animation animation = Animation::New(durationSeconds);
5790   int targetValue(90);
5791   int relativeValue(targetValue - startValue);
5792   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5793
5794   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5795
5796   // Start the animation
5797   animation.Play();
5798
5799   bool signalReceived(false);
5800   AnimationFinishCheck finishCheck(signalReceived);
5801   animation.FinishedSignal().Connect(&application, finishCheck);
5802
5803   application.SendNotification();
5804   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5805
5806   // We didn't expect the animation to finish yet
5807   application.SendNotification();
5808   finishCheck.CheckSignalNotReceived();
5809
5810   // The position should have moved more, than with a linear alpha function
5811   int current( actor.GetCurrentProperty< int >( index ) );
5812   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5813
5814   application.SendNotification();
5815   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5816
5817   // We did expect the animation to finish
5818   application.SendNotification();
5819   finishCheck.CheckSignalReceived();
5820   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5821   END_TEST;
5822 }
5823
5824 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5825 {
5826   TestApplication application;
5827
5828   Actor actor = Actor::New();
5829
5830   // Register an integer property
5831   int startValue(10);
5832   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5833   Stage::GetCurrent().Add(actor);
5834   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5835   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5836
5837   // Build the animation
5838   float durationSeconds(1.0f);
5839   Animation animation = Animation::New(durationSeconds);
5840   int targetValue(30);
5841   int relativeValue(targetValue - startValue);
5842   float delay = 0.5f;
5843   animation.AnimateTo(Property(actor, index),
5844                       targetValue,
5845                       TimePeriod(delay, durationSeconds - delay));
5846
5847   // Start the animation
5848   animation.Play();
5849
5850   bool signalReceived(false);
5851   AnimationFinishCheck finishCheck(signalReceived);
5852   animation.FinishedSignal().Connect(&application, finishCheck);
5853
5854   application.SendNotification();
5855   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5856
5857   // We didn't expect the animation to finish yet
5858   application.SendNotification();
5859   finishCheck.CheckSignalNotReceived();
5860   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5861
5862   application.SendNotification();
5863   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5864
5865   // We didn't expect the animation to finish yet
5866   application.SendNotification();
5867   finishCheck.CheckSignalNotReceived();
5868   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5869
5870   application.SendNotification();
5871   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5872
5873   // We did expect the animation to finish
5874   application.SendNotification();
5875   finishCheck.CheckSignalReceived();
5876   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5877   END_TEST;
5878 }
5879
5880 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5881 {
5882   TestApplication application;
5883
5884   Actor actor = Actor::New();
5885
5886   // Register an integer property
5887   int startValue(10);
5888   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5889   Stage::GetCurrent().Add(actor);
5890   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5891   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5892
5893   // Build the animation
5894   float durationSeconds(1.0f);
5895   Animation animation = Animation::New(durationSeconds);
5896   int targetValue(30);
5897   int relativeValue(targetValue - startValue);
5898   float delay = 0.5f;
5899   animation.AnimateTo(Property(actor, index),
5900                       targetValue,
5901                       AlphaFunction::LINEAR,
5902                       TimePeriod(delay, durationSeconds - delay));
5903
5904   // Start the animation
5905   animation.Play();
5906
5907   bool signalReceived(false);
5908   AnimationFinishCheck finishCheck(signalReceived);
5909   animation.FinishedSignal().Connect(&application, finishCheck);
5910
5911   application.SendNotification();
5912   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5913
5914   // We didn't expect the animation to finish yet
5915   application.SendNotification();
5916   finishCheck.CheckSignalNotReceived();
5917   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5918
5919   application.SendNotification();
5920   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5921
5922   // We didn't expect the animation to finish yet
5923   application.SendNotification();
5924   finishCheck.CheckSignalNotReceived();
5925   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5926
5927   application.SendNotification();
5928   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5929
5930   // We did expect the animation to finish
5931   application.SendNotification();
5932   finishCheck.CheckSignalReceived();
5933   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5934   END_TEST;
5935 }
5936
5937 int UtcDaliAnimationAnimateToVector2P(void)
5938 {
5939   TestApplication application;
5940
5941   Actor actor = Actor::New();
5942
5943   // Register a Vector2 property
5944   Vector2 startValue(-50.0f, -50.0f);
5945   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5946   Stage::GetCurrent().Add(actor);
5947   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5948   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5949
5950   // Build the animation
5951   float durationSeconds(2.0f);
5952   Animation animation = Animation::New(durationSeconds);
5953   Vector2 targetValue(50.0f, 50.0f);
5954   Vector2 relativeValue(targetValue - startValue);
5955   animation.AnimateTo(Property(actor, index), targetValue);
5956
5957   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5958
5959   // Start the animation
5960   animation.Play();
5961
5962   bool signalReceived(false);
5963   AnimationFinishCheck finishCheck(signalReceived);
5964   animation.FinishedSignal().Connect(&application, finishCheck);
5965
5966   application.SendNotification();
5967   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5968
5969   // We didn't expect the animation to finish yet
5970   application.SendNotification();
5971   finishCheck.CheckSignalNotReceived();
5972   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5973
5974   application.SendNotification();
5975   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5976
5977   // We did expect the animation to finish
5978   application.SendNotification();
5979   finishCheck.CheckSignalReceived();
5980   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5981   END_TEST;
5982 }
5983
5984 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
5985 {
5986   TestApplication application;
5987
5988   Actor actor = Actor::New();
5989
5990   // Register a Vector2 property
5991   Vector2 startValue(1000.0f, 1000.0f);
5992   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5993   Stage::GetCurrent().Add(actor);
5994   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5995   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5996
5997   // Build the animation
5998   float durationSeconds(1.0f);
5999   Animation animation = Animation::New(durationSeconds);
6000   Vector2 targetValue(9000.0f, 9000.0f);
6001   Vector2 relativeValue(targetValue - startValue);
6002   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
6003
6004   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6005
6006   // Start the animation
6007   animation.Play();
6008
6009   bool signalReceived(false);
6010   AnimationFinishCheck finishCheck(signalReceived);
6011   animation.FinishedSignal().Connect(&application, finishCheck);
6012
6013   application.SendNotification();
6014   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6015
6016   // We didn't expect the animation to finish yet
6017   application.SendNotification();
6018   finishCheck.CheckSignalNotReceived();
6019
6020   // The position should have moved more, than with a linear alpha function
6021   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
6022   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6023   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6024
6025   application.SendNotification();
6026   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6027
6028   // We did expect the animation to finish
6029   application.SendNotification();
6030   finishCheck.CheckSignalReceived();
6031   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6032   END_TEST;
6033 }
6034
6035 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
6036 {
6037   TestApplication application;
6038
6039   Actor actor = Actor::New();
6040
6041   // Register a Vector2 property
6042   Vector2 startValue(10.0f, 10.0f);
6043   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6044   Stage::GetCurrent().Add(actor);
6045   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6046   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6047
6048   // Build the animation
6049   float durationSeconds(1.0f);
6050   Animation animation = Animation::New(durationSeconds);
6051   Vector2 targetValue(-10.0f, 20.0f);
6052   Vector2 relativeValue(targetValue - startValue);
6053   float delay = 0.5f;
6054   animation.AnimateTo(Property(actor, index),
6055                       targetValue,
6056                       TimePeriod(delay, durationSeconds - delay));
6057
6058   // Start the animation
6059   animation.Play();
6060
6061   bool signalReceived(false);
6062   AnimationFinishCheck finishCheck(signalReceived);
6063   animation.FinishedSignal().Connect(&application, finishCheck);
6064
6065   application.SendNotification();
6066   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6067
6068   // We didn't expect the animation to finish yet
6069   application.SendNotification();
6070   finishCheck.CheckSignalNotReceived();
6071   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6072
6073   application.SendNotification();
6074   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6075
6076   // We didn't expect the animation to finish yet
6077   application.SendNotification();
6078   finishCheck.CheckSignalNotReceived();
6079   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6080
6081   application.SendNotification();
6082   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6083
6084   // We did expect the animation to finish
6085   application.SendNotification();
6086   finishCheck.CheckSignalReceived();
6087   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6088   END_TEST;
6089 }
6090
6091 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
6092 {
6093   TestApplication application;
6094
6095   Actor actor = Actor::New();
6096
6097   // Register a Vector2 property
6098   Vector2 startValue(10.0f, 10.0f);
6099   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6100   Stage::GetCurrent().Add(actor);
6101   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6102   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6103
6104   // Build the animation
6105   float durationSeconds(1.0f);
6106   Animation animation = Animation::New(durationSeconds);
6107   Vector2 targetValue(30.0f, 30.0f);
6108   Vector2 relativeValue(targetValue - startValue);
6109   float delay = 0.5f;
6110   animation.AnimateTo(Property(actor, index),
6111                       targetValue,
6112                       AlphaFunction::LINEAR,
6113                       TimePeriod(delay, durationSeconds - delay));
6114
6115   // Start the animation
6116   animation.Play();
6117
6118   bool signalReceived(false);
6119   AnimationFinishCheck finishCheck(signalReceived);
6120   animation.FinishedSignal().Connect(&application, finishCheck);
6121
6122   application.SendNotification();
6123   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6124
6125   // We didn't expect the animation to finish yet, but cached value should be the final one
6126   application.SendNotification();
6127   finishCheck.CheckSignalNotReceived();
6128   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6129   DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
6130
6131   application.SendNotification();
6132   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6133
6134   // We didn't expect the animation to finish yet
6135   application.SendNotification();
6136   finishCheck.CheckSignalNotReceived();
6137   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6138
6139   application.SendNotification();
6140   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6141
6142   // We did expect the animation to finish
6143   application.SendNotification();
6144   finishCheck.CheckSignalReceived();
6145   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6146   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6147   END_TEST;
6148 }
6149
6150 int UtcDaliAnimationAnimateToVector3P(void)
6151 {
6152   TestApplication application;
6153
6154   Actor actor = Actor::New();
6155
6156   // Register a Vector3 property
6157   Vector3 startValue(-50.0f, -50.0f, -50.0f);
6158   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6159   Stage::GetCurrent().Add(actor);
6160   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
6161   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6162
6163   // Build the animation
6164   float durationSeconds(2.0f);
6165   Animation animation = Animation::New(durationSeconds);
6166   Vector3 targetValue(50.0f, 50.0f, 50.0f);
6167   Vector3 relativeValue(targetValue - startValue);
6168   animation.AnimateTo(Property(actor, index), targetValue);
6169
6170   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6171
6172   // Start the animation
6173   animation.Play();
6174
6175   bool signalReceived(false);
6176   AnimationFinishCheck finishCheck(signalReceived);
6177   animation.FinishedSignal().Connect(&application, finishCheck);
6178
6179   application.SendNotification();
6180   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6181
6182   // We didn't expect the animation to finish yet
6183   application.SendNotification();
6184   finishCheck.CheckSignalNotReceived();
6185   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6186
6187   application.SendNotification();
6188   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6189
6190   // We did expect the animation to finish
6191   application.SendNotification();
6192   finishCheck.CheckSignalReceived();
6193   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6194   END_TEST;
6195 }
6196
6197 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
6198 {
6199   TestApplication application;
6200
6201   Actor actor = Actor::New();
6202
6203   // Register a Vector3 property
6204   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
6205   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6206   Stage::GetCurrent().Add(actor);
6207   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6208   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6209
6210   // Build the animation
6211   float durationSeconds(1.0f);
6212   Animation animation = Animation::New(durationSeconds);
6213   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
6214   Vector3 relativeValue(targetValue - startValue);
6215   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6216
6217   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6218
6219   // Start the animation
6220   animation.Play();
6221
6222   bool signalReceived(false);
6223   AnimationFinishCheck finishCheck(signalReceived);
6224   animation.FinishedSignal().Connect(&application, finishCheck);
6225
6226   application.SendNotification();
6227   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6228
6229   // We didn't expect the animation to finish yet
6230   application.SendNotification();
6231   finishCheck.CheckSignalNotReceived();
6232
6233   // The position should have moved more, than with a linear alpha function
6234   Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
6235   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6236   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6237   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6238
6239   application.SendNotification();
6240   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6241
6242   // We did expect the animation to finish
6243   application.SendNotification();
6244   finishCheck.CheckSignalReceived();
6245   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6246   END_TEST;
6247 }
6248
6249 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
6250 {
6251   TestApplication application;
6252
6253   Actor actor = Actor::New();
6254
6255   // Register a Vector3 property
6256   Vector3 startValue(10.0f, 10.0f, 10.0f);
6257   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6258   Stage::GetCurrent().Add(actor);
6259   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6260   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6261
6262   // Build the animation
6263   float durationSeconds(1.0f);
6264   Animation animation = Animation::New(durationSeconds);
6265   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
6266   Vector3 relativeValue(targetValue - startValue);
6267   float delay = 0.5f;
6268   animation.AnimateTo(Property(actor, index),
6269                       targetValue,
6270                       TimePeriod(delay, durationSeconds - delay));
6271
6272   // Start the animation
6273   animation.Play();
6274
6275   bool signalReceived(false);
6276   AnimationFinishCheck finishCheck(signalReceived);
6277   animation.FinishedSignal().Connect(&application, finishCheck);
6278
6279   application.SendNotification();
6280   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6281
6282   // We didn't expect the animation to finish yet
6283   application.SendNotification();
6284   finishCheck.CheckSignalNotReceived();
6285   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6286
6287   application.SendNotification();
6288   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6289
6290   // We didn't expect the animation to finish yet
6291   application.SendNotification();
6292   finishCheck.CheckSignalNotReceived();
6293   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6294
6295   application.SendNotification();
6296   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6297
6298   // We did expect the animation to finish
6299   application.SendNotification();
6300   finishCheck.CheckSignalReceived();
6301   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6302   END_TEST;
6303 }
6304
6305 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
6306 {
6307   TestApplication application;
6308
6309   Actor actor = Actor::New();
6310
6311   // Register a Vector3 property
6312   Vector3 startValue(10.0f, 10.0f, 10.0f);
6313   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6314   Stage::GetCurrent().Add(actor);
6315   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6316   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6317
6318   // Build the animation
6319   float durationSeconds(1.0f);
6320   Animation animation = Animation::New(durationSeconds);
6321   Vector3 targetValue(30.0f, 30.0f, 30.0f);
6322   Vector3 relativeValue(targetValue - startValue);
6323   float delay = 0.5f;
6324   animation.AnimateTo(Property(actor, "testProperty"),
6325                       targetValue,
6326                       AlphaFunction::LINEAR,
6327                       TimePeriod(delay, durationSeconds - delay));
6328
6329   // Start the animation
6330   animation.Play();
6331
6332   bool signalReceived(false);
6333   AnimationFinishCheck finishCheck(signalReceived);
6334   animation.FinishedSignal().Connect(&application, finishCheck);
6335
6336   application.SendNotification();
6337   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6338
6339   // We didn't expect the animation to finish yet
6340   application.SendNotification();
6341   finishCheck.CheckSignalNotReceived();
6342   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6343
6344   application.SendNotification();
6345   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6346
6347   // We didn't expect the animation to finish yet
6348   application.SendNotification();
6349   finishCheck.CheckSignalNotReceived();
6350   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6351
6352   application.SendNotification();
6353   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6354
6355   // We did expect the animation to finish
6356   application.SendNotification();
6357   finishCheck.CheckSignalReceived();
6358   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6359   END_TEST;
6360 }
6361
6362 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6363 {
6364   TestApplication application;
6365
6366   Actor actor = Actor::New();
6367
6368   // Register a Vector3 property
6369   Vector3 startValue(10.0f, 10.0f, 10.0f);
6370   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6371   Stage::GetCurrent().Add(actor);
6372   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6373   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6374
6375   // Build the animation
6376   float durationSeconds(1.0f);
6377   Animation animation = Animation::New(durationSeconds);
6378   Vector3 targetValue(30.0f, 30.0f, 10.0f);
6379   Vector3 relativeValue(targetValue - startValue);
6380   float delay = 0.5f;
6381   animation.AnimateTo(Property(actor, "testProperty",  0),
6382                       30.0f,
6383                       AlphaFunction::LINEAR,
6384                       TimePeriod(delay, durationSeconds - delay));
6385   animation.AnimateTo(Property(actor, index, 1),
6386                       30.0f,
6387                       AlphaFunction::LINEAR,
6388                       TimePeriod(delay, durationSeconds - delay));
6389
6390   // Start the animation
6391   animation.Play();
6392
6393   bool signalReceived(false);
6394   AnimationFinishCheck finishCheck(signalReceived);
6395   animation.FinishedSignal().Connect(&application, finishCheck);
6396
6397   application.SendNotification();
6398   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6399
6400   // We didn't expect the animation to finish yet
6401   application.SendNotification();
6402   finishCheck.CheckSignalNotReceived();
6403   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6404
6405   application.SendNotification();
6406   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6407
6408   // We didn't expect the animation to finish yet
6409   application.SendNotification();
6410   finishCheck.CheckSignalNotReceived();
6411   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6412
6413   application.SendNotification();
6414   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6415
6416   // We did expect the animation to finish
6417   application.SendNotification();
6418   finishCheck.CheckSignalReceived();
6419   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6420   END_TEST;
6421 }
6422
6423 int UtcDaliAnimationAnimateToVector4P(void)
6424 {
6425   TestApplication application;
6426
6427   Actor actor = Actor::New();
6428
6429   // Register a Vector4 property
6430   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6431   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6432   Stage::GetCurrent().Add(actor);
6433   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6434   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6435
6436   // Build the animation
6437   float durationSeconds(2.0f);
6438   Animation animation = Animation::New(durationSeconds);
6439   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6440   Vector4 relativeValue(targetValue - startValue);
6441   animation.AnimateTo(Property(actor, index), targetValue);
6442
6443   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6444
6445   // Start the animation
6446   animation.Play();
6447
6448   bool signalReceived(false);
6449   AnimationFinishCheck finishCheck(signalReceived);
6450   animation.FinishedSignal().Connect(&application, finishCheck);
6451
6452   application.SendNotification();
6453   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6454
6455   // We didn't expect the animation to finish yet
6456   application.SendNotification();
6457   finishCheck.CheckSignalNotReceived();
6458   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6459
6460   application.SendNotification();
6461   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6462
6463   // We did expect the animation to finish
6464   application.SendNotification();
6465   finishCheck.CheckSignalReceived();
6466   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6467   END_TEST;
6468 }
6469
6470 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6471 {
6472   TestApplication application;
6473
6474   Actor actor = Actor::New();
6475
6476   // Register a Vector4 property
6477   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6478   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6479   Stage::GetCurrent().Add(actor);
6480   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6481   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6482
6483   // Build the animation
6484   float durationSeconds(1.0f);
6485   Animation animation = Animation::New(durationSeconds);
6486   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6487   Vector4 relativeValue(targetValue - startValue);
6488   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6489
6490   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6491
6492   // Start the animation
6493   animation.Play();
6494
6495   bool signalReceived(false);
6496   AnimationFinishCheck finishCheck(signalReceived);
6497   animation.FinishedSignal().Connect(&application, finishCheck);
6498
6499   application.SendNotification();
6500   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6501
6502   // We didn't expect the animation to finish yet
6503   application.SendNotification();
6504   finishCheck.CheckSignalNotReceived();
6505
6506   // The position should have moved more, than with a linear alpha function
6507   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6508   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6509   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6510   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6511   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6512
6513   application.SendNotification();
6514   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6515
6516   // We did expect the animation to finish
6517   application.SendNotification();
6518   finishCheck.CheckSignalReceived();
6519   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6520   END_TEST;
6521 }
6522
6523 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6524 {
6525   TestApplication application;
6526
6527   Actor actor = Actor::New();
6528
6529   // Register a Vector4 property
6530   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6531   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6532   Stage::GetCurrent().Add(actor);
6533   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6534   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6535
6536   // Build the animation
6537   float durationSeconds(1.0f);
6538   Animation animation = Animation::New(durationSeconds);
6539   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6540   Vector4 relativeValue(targetValue - startValue);
6541   float delay = 0.5f;
6542   animation.AnimateTo(Property(actor, index),
6543                       targetValue,
6544                       TimePeriod(delay, durationSeconds - delay));
6545
6546   // Start the animation
6547   animation.Play();
6548
6549   bool signalReceived(false);
6550   AnimationFinishCheck finishCheck(signalReceived);
6551   animation.FinishedSignal().Connect(&application, finishCheck);
6552
6553   application.SendNotification();
6554   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6555
6556   // We didn't expect the animation to finish yet
6557   application.SendNotification();
6558   finishCheck.CheckSignalNotReceived();
6559   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6560
6561   application.SendNotification();
6562   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6563
6564   // We didn't expect the animation to finish yet
6565   application.SendNotification();
6566   finishCheck.CheckSignalNotReceived();
6567   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6568
6569   application.SendNotification();
6570   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6571
6572   // We did expect the animation to finish
6573   application.SendNotification();
6574   finishCheck.CheckSignalReceived();
6575   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6576   END_TEST;
6577 }
6578
6579 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6580 {
6581   TestApplication application;
6582
6583   Actor actor = Actor::New();
6584
6585   // Register a Vector4 property
6586   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6587   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6588   Stage::GetCurrent().Add(actor);
6589   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6590   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6591
6592   // Build the animation
6593   float durationSeconds(1.0f);
6594   Animation animation = Animation::New(durationSeconds);
6595   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6596   Vector4 relativeValue(targetValue - startValue);
6597   float delay = 0.5f;
6598   animation.AnimateTo(Property(actor, index),
6599                       targetValue,
6600                       AlphaFunction::LINEAR,
6601                       TimePeriod(delay, durationSeconds - delay));
6602
6603   // Start the animation
6604   animation.Play();
6605
6606   bool signalReceived(false);
6607   AnimationFinishCheck finishCheck(signalReceived);
6608   animation.FinishedSignal().Connect(&application, finishCheck);
6609
6610   application.SendNotification();
6611   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6612
6613   // We didn't expect the animation to finish yet
6614   application.SendNotification();
6615   finishCheck.CheckSignalNotReceived();
6616   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6617
6618   application.SendNotification();
6619   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6620
6621   // We didn't expect the animation to finish yet
6622   application.SendNotification();
6623   finishCheck.CheckSignalNotReceived();
6624   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6625
6626   application.SendNotification();
6627   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6628
6629   // We did expect the animation to finish
6630   application.SendNotification();
6631   finishCheck.CheckSignalReceived();
6632   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6633   END_TEST;
6634 }
6635
6636 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6637 {
6638   TestApplication application;
6639
6640   Actor actor = Actor::New();
6641   Stage::GetCurrent().Add(actor);
6642   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6643
6644   // Build the animation
6645   float durationSeconds(1.0f);
6646   Animation animation = Animation::New(durationSeconds);
6647   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6648
6649   try
6650   {
6651     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6652   }
6653   catch (Dali::DaliException& e)
6654   {
6655     DALI_TEST_PRINT_ASSERT( e );
6656     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6657   }
6658   END_TEST;
6659 }
6660
6661 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
6662 {
6663   TestApplication application;
6664
6665   Actor actor = Actor::New();
6666   Stage::GetCurrent().Add(actor);
6667   float startValue(0.0f);
6668   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6669   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6670
6671   // Build the animation
6672   float durationSeconds(1.0f);
6673   Animation animation = Animation::New(durationSeconds);
6674   float targetX(1.0f);
6675
6676   try
6677   {
6678     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6679   }
6680   catch (Dali::DaliException& e)
6681   {
6682     DALI_TEST_PRINT_ASSERT( e );
6683     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6684   }
6685   END_TEST;
6686 }
6687
6688 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
6689 {
6690   TestApplication application;
6691
6692   Actor actor = Actor::New();
6693   Stage::GetCurrent().Add(actor);
6694   float startValue(0.0f);
6695   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6696   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6697
6698   // Build the animation
6699   float durationSeconds(1.0f);
6700   Animation animation = Animation::New(durationSeconds);
6701   float targetY(1.0f);
6702
6703   try
6704   {
6705     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6706   }
6707   catch (Dali::DaliException& e)
6708   {
6709     DALI_TEST_PRINT_ASSERT( e );
6710     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6711   }
6712   END_TEST;
6713 }
6714
6715 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
6716 {
6717   TestApplication application;
6718
6719   Actor actor = Actor::New();
6720   Stage::GetCurrent().Add(actor);
6721   float startValue(0.5f);
6722   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6723   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6724
6725   // Build the animation
6726   float durationSeconds(1.0f);
6727   Animation animation = Animation::New(durationSeconds);
6728   float targetZ(1.0f);
6729
6730   try
6731   {
6732     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6733   }
6734   catch (Dali::DaliException& e)
6735   {
6736     DALI_TEST_PRINT_ASSERT( e );
6737     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6738   }
6739   END_TEST;
6740 }
6741
6742 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
6743 {
6744   TestApplication application;
6745
6746   Actor actor = Actor::New();
6747   Stage::GetCurrent().Add(actor);
6748   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6749
6750   // Build the animation
6751   float durationSeconds(1.0f);
6752   Animation animation = Animation::New(durationSeconds);
6753   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6754
6755   try
6756   {
6757     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6758   }
6759   catch (Dali::DaliException& e)
6760   {
6761     DALI_TEST_PRINT_ASSERT( e );
6762     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6763   }
6764   END_TEST;
6765 }
6766
6767 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
6768 {
6769   TestApplication application;
6770
6771   Actor actor = Actor::New();
6772   Stage::GetCurrent().Add(actor);
6773   float startValue(0.5f);
6774   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6775   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6776
6777   // Build the animation
6778   float durationSeconds(1.0f);
6779   Animation animation = Animation::New(durationSeconds);
6780   float targetX(1.0f);
6781
6782   try
6783   {
6784     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6785   }
6786   catch (Dali::DaliException& e)
6787   {
6788     DALI_TEST_PRINT_ASSERT( e );
6789     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6790   }
6791   END_TEST;
6792 }
6793
6794 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
6795 {
6796   TestApplication application;
6797
6798   Actor actor = Actor::New();
6799   Stage::GetCurrent().Add(actor);
6800   float startValue(0.5f);
6801   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6802   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6803
6804   // Build the animation
6805   float durationSeconds(1.0f);
6806   Animation animation = Animation::New(durationSeconds);
6807   float targetY(0.0f);
6808
6809   try
6810   {
6811     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6812   }
6813   catch (Dali::DaliException& e)
6814   {
6815     DALI_TEST_PRINT_ASSERT( e );
6816     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6817   }
6818   END_TEST;
6819 }
6820
6821 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
6822 {
6823   TestApplication application;
6824
6825   Actor actor = Actor::New();
6826   Stage::GetCurrent().Add(actor);
6827   float startValue(0.5f);
6828   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6829   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6830
6831   // Build the animation
6832   float durationSeconds(1.0f);
6833   Animation animation = Animation::New(durationSeconds);
6834   float targetZ(100.0f);
6835
6836   try
6837   {
6838     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6839   }
6840   catch (Dali::DaliException& e)
6841   {
6842     DALI_TEST_PRINT_ASSERT( e );
6843     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6844   }
6845   END_TEST;
6846 }
6847
6848 int UtcDaliAnimationAnimateToActorSizeP(void)
6849 {
6850   TestApplication application;
6851
6852   Actor actor = Actor::New();
6853   Stage::GetCurrent().Add(actor);
6854   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6855
6856   // Build the animation
6857   float durationSeconds(1.0f);
6858   Animation animation = Animation::New(durationSeconds);
6859   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6860   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6861
6862   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6863
6864   // Should return the initial properties before play
6865   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6866   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6867   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6868   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6869
6870   // Start the animation
6871   animation.Play();
6872
6873   // Should return the target property after play
6874   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6875   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6876   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6877   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6878
6879   bool signalReceived(false);
6880   AnimationFinishCheck finishCheck(signalReceived);
6881   animation.FinishedSignal().Connect(&application, finishCheck);
6882
6883   application.SendNotification();
6884   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6885
6886   // We didn't expect the animation to finish yet
6887   application.SendNotification();
6888   finishCheck.CheckSignalNotReceived();
6889   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6890
6891   application.SendNotification();
6892   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6893
6894   // We did expect the animation to finish
6895   application.SendNotification();
6896   finishCheck.CheckSignalReceived();
6897   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6898
6899   // Reset everything
6900   finishCheck.Reset();
6901   actor.SetSize(Vector3::ZERO);
6902   application.SendNotification();
6903   application.Render(0);
6904   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6905
6906   // Repeat with a different (ease-in) alpha function
6907   animation = Animation::New(durationSeconds);
6908   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6909   animation.FinishedSignal().Connect(&application, finishCheck);
6910   animation.Play();
6911
6912   application.SendNotification();
6913   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6914
6915   // We didn't expect the animation to finish yet
6916   application.SendNotification();
6917   finishCheck.CheckSignalNotReceived();
6918
6919   // The size should have travelled less, than with a linear alpha function
6920   Vector3 current(actor.GetCurrentSize());
6921   DALI_TEST_CHECK( current.x > 0.0f );
6922   DALI_TEST_CHECK( current.y > 0.0f );
6923   DALI_TEST_CHECK( current.z > 0.0f );
6924   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6925   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6926   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6927
6928   application.SendNotification();
6929   application.Render(static_cast<unsigned int>(durationSeconds*10.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.GetCurrentSize(), targetSize, TEST_LOCATION );
6935
6936   // Reset everything
6937   finishCheck.Reset();
6938   actor.SetSize(Vector3::ZERO);
6939   application.SendNotification();
6940   application.Render(0);
6941   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6942
6943   // Repeat with a delay
6944   float delay = 0.5f;
6945   animation = Animation::New(durationSeconds);
6946   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6947   animation.FinishedSignal().Connect(&application, finishCheck);
6948   animation.Play();
6949
6950   application.SendNotification();
6951   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6952
6953   // We didn't expect the animation to finish yet
6954   application.SendNotification();
6955   finishCheck.CheckSignalNotReceived();
6956   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6957
6958   application.SendNotification();
6959   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6960
6961   // We did expect the animation to finish
6962   application.SendNotification();
6963   finishCheck.CheckSignalReceived();
6964   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6965   END_TEST;
6966 }
6967
6968 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6969 {
6970   TestApplication application;
6971
6972   Actor actor = Actor::New();
6973   Stage::GetCurrent().Add(actor);
6974   float startValue(0.0f);
6975   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6976   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6977
6978   // Build the animation
6979   float durationSeconds(1.0f);
6980   Animation animation = Animation::New(durationSeconds);
6981   float targetWidth(10.0f);
6982   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
6983
6984   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
6985
6986   // Should return the initial properties before play
6987   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6988   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
6989
6990   // Start the animation
6991   animation.Play();
6992
6993   // Should return the target property after play
6994   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
6995   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
6996
6997   bool signalReceived(false);
6998   AnimationFinishCheck finishCheck(signalReceived);
6999   animation.FinishedSignal().Connect(&application, finishCheck);
7000
7001   application.SendNotification();
7002   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7003
7004   // We didn't expect the animation to finish yet
7005   application.SendNotification();
7006   finishCheck.CheckSignalNotReceived();
7007   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
7008
7009   application.SendNotification();
7010   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7011
7012   // We did expect the animation to finish
7013   application.SendNotification();
7014   finishCheck.CheckSignalReceived();
7015   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
7016   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7017   END_TEST;
7018 }
7019
7020 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7021 {
7022   TestApplication application;
7023
7024   Actor actor = Actor::New();
7025   Stage::GetCurrent().Add(actor);
7026   float startValue(0.0f);
7027   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
7028   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7029
7030   // Build the animation
7031   float durationSeconds(1.0f);
7032   Animation animation = Animation::New(durationSeconds);
7033   float targetHeight(-10.0f);
7034   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7035
7036   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7037
7038   // Should return the initial properties before play
7039   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7040   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7041
7042   // Start the animation
7043   animation.Play();
7044
7045   // Should return the target property after play
7046   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7047   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7048
7049   bool signalReceived(false);
7050   AnimationFinishCheck finishCheck(signalReceived);
7051   animation.FinishedSignal().Connect(&application, finishCheck);
7052
7053   application.SendNotification();
7054   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7055
7056   // We didn't expect the animation to finish yet
7057   application.SendNotification();
7058   finishCheck.CheckSignalNotReceived();
7059   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
7060
7061   application.SendNotification();
7062   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7063
7064   // We did expect the animation to finish
7065   application.SendNotification();
7066   finishCheck.CheckSignalReceived();
7067   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
7068   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7069   END_TEST;
7070 }
7071
7072 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7073 {
7074   TestApplication application;
7075
7076   Actor actor = Actor::New();
7077   Stage::GetCurrent().Add(actor);
7078   float startValue(0.0f);
7079   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
7080   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7081
7082   // Build the animation
7083   float durationSeconds(1.0f);
7084   Animation animation = Animation::New(durationSeconds);
7085   float targetDepth(-10.0f);
7086   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7087
7088   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7089
7090   // Should return the initial properties before play
7091   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7092   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7093
7094   // Start the animation
7095   animation.Play();
7096
7097   // Should return the target property after play
7098   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7099   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7100
7101   bool signalReceived(false);
7102   AnimationFinishCheck finishCheck(signalReceived);
7103   animation.FinishedSignal().Connect(&application, finishCheck);
7104
7105   application.SendNotification();
7106   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7107
7108   // We didn't expect the animation to finish yet
7109   application.SendNotification();
7110   finishCheck.CheckSignalNotReceived();
7111   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
7112
7113   application.SendNotification();
7114   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7115
7116   // We did expect the animation to finish
7117   application.SendNotification();
7118   finishCheck.CheckSignalReceived();
7119   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
7120   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7121   END_TEST;
7122 }
7123
7124 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7125 {
7126   TestApplication application;
7127
7128   Actor actor = Actor::New();
7129   Stage::GetCurrent().Add(actor);
7130   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7131
7132   // Build the animation
7133   float durationSeconds(1.0f);
7134   Animation animation = Animation::New(durationSeconds);
7135   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7136   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7137
7138   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7139
7140   // Start the animation
7141   animation.Play();
7142
7143   bool signalReceived(false);
7144   AnimationFinishCheck finishCheck(signalReceived);
7145   animation.FinishedSignal().Connect(&application, finishCheck);
7146
7147   application.SendNotification();
7148   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7149
7150   // We didn't expect the animation to finish yet
7151   application.SendNotification();
7152   finishCheck.CheckSignalNotReceived();
7153   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
7154
7155   application.SendNotification();
7156   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7157
7158   // We did expect the animation to finish
7159   application.SendNotification();
7160   finishCheck.CheckSignalReceived();
7161   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7162
7163   // Reset everything
7164   finishCheck.Reset();
7165   actor.SetSize(Vector3::ZERO);
7166   application.SendNotification();
7167   application.Render(0);
7168   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7169
7170   // Repeat with a different (ease-in) alpha function
7171   animation = Animation::New(durationSeconds);
7172   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7173   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7174   animation.FinishedSignal().Connect(&application, finishCheck);
7175   animation.Play();
7176
7177   application.SendNotification();
7178   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7179
7180   // We didn't expect the animation to finish yet
7181   application.SendNotification();
7182   finishCheck.CheckSignalNotReceived();
7183
7184   // The size should have travelled less, than with a linear alpha function
7185   Vector3 current(actor.GetCurrentSize());
7186   DALI_TEST_CHECK( current.x > 0.0f );
7187   DALI_TEST_CHECK( current.y > 0.0f );
7188   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7189   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7190
7191   application.SendNotification();
7192   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7193
7194   // We did expect the animation to finish
7195   application.SendNotification();
7196   finishCheck.CheckSignalReceived();
7197   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7198   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7199
7200   // Reset everything
7201   finishCheck.Reset();
7202   actor.SetSize(Vector3::ZERO);
7203   application.SendNotification();
7204   application.Render(0);
7205   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7206
7207   // Repeat with a delay
7208   float delay = 0.5f;
7209   animation = Animation::New(durationSeconds);
7210   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7211   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7212   animation.FinishedSignal().Connect(&application, finishCheck);
7213   animation.Play();
7214
7215   application.SendNotification();
7216   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7217
7218   // We didn't expect the animation to finish yet
7219   application.SendNotification();
7220   finishCheck.CheckSignalNotReceived();
7221   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7222
7223   application.SendNotification();
7224   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7225
7226   // We did expect the animation to finish
7227   application.SendNotification();
7228   finishCheck.CheckSignalReceived();
7229   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7230   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7231   END_TEST;
7232 }
7233
7234 int UtcDaliAnimationAnimateToActorPositionP(void)
7235 {
7236   TestApplication application;
7237
7238   Actor actor = Actor::New();
7239   Stage::GetCurrent().Add(actor);
7240   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7241
7242   // Build the animation
7243   float durationSeconds(1.0f);
7244   Animation animation = Animation::New(durationSeconds);
7245   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7246   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7247
7248   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7249
7250   // Should return the initial properties before play
7251   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7252   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7253   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7254   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7255
7256   // Start the animation
7257   animation.Play();
7258
7259   // Should return the target property after play
7260   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7261   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7262   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7263   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
7264
7265   bool signalReceived(false);
7266   AnimationFinishCheck finishCheck(signalReceived);
7267   animation.FinishedSignal().Connect(&application, finishCheck);
7268
7269   application.SendNotification();
7270   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7271
7272   // We didn't expect the animation to finish yet
7273   application.SendNotification();
7274   finishCheck.CheckSignalNotReceived();
7275   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7276
7277   application.SendNotification();
7278   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7279
7280   // We did expect the animation to finish
7281   application.SendNotification();
7282   finishCheck.CheckSignalReceived();
7283   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7284   END_TEST;
7285 }
7286
7287 int UtcDaliAnimationAnimateToActorPositionXP(void)
7288 {
7289   TestApplication application;
7290
7291   Actor actor = Actor::New();
7292   Stage::GetCurrent().Add(actor);
7293   float startValue(0.0f);
7294   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
7295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7296   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7297   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7298
7299   // Build the animation
7300   float durationSeconds(1.0f);
7301   Animation animation = Animation::New(durationSeconds);
7302   float targetX(1.0f);
7303   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7304
7305   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7306
7307   // Should return the initial properties before play
7308   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7309   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7310
7311   // Start the animation
7312   animation.Play();
7313
7314   // Should return the target property after play
7315   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7316   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
7317
7318   bool signalReceived(false);
7319   AnimationFinishCheck finishCheck(signalReceived);
7320   animation.FinishedSignal().Connect(&application, finishCheck);
7321
7322   application.SendNotification();
7323   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7324
7325   // We didn't expect the animation to finish yet
7326   application.SendNotification();
7327   finishCheck.CheckSignalNotReceived();
7328   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
7329
7330   application.SendNotification();
7331   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7332
7333   // We did expect the animation to finish
7334   application.SendNotification();
7335   finishCheck.CheckSignalReceived();
7336   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
7337   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7338   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7339   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7340   END_TEST;
7341 }
7342
7343 int UtcDaliAnimationAnimateToActorPositionYP(void)
7344 {
7345   TestApplication application;
7346
7347   Actor actor = Actor::New();
7348   Stage::GetCurrent().Add(actor);
7349   float startValue(0.0f);
7350   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7351   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7352   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7353   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7354
7355   // Build the animation
7356   float durationSeconds(1.0f);
7357   Animation animation = Animation::New(durationSeconds);
7358   float targetY(10.0f);
7359   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7360
7361   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7362
7363   // Should return the initial properties before play
7364   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7365   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7366
7367   // Start the animation
7368   animation.Play();
7369
7370   // Should return the target property after play
7371   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7372   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7373
7374   bool signalReceived(false);
7375   AnimationFinishCheck finishCheck(signalReceived);
7376   animation.FinishedSignal().Connect(&application, finishCheck);
7377
7378   application.SendNotification();
7379   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7380
7381   // We didn't expect the animation to finish yet
7382   application.SendNotification();
7383   finishCheck.CheckSignalNotReceived();
7384   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7385
7386   application.SendNotification();
7387   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7388
7389   // We did expect the animation to finish
7390   application.SendNotification();
7391   finishCheck.CheckSignalReceived();
7392   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7393   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7394   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7395   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7396   END_TEST;
7397 }
7398
7399 int UtcDaliAnimationAnimateToActorPositionZP(void)
7400 {
7401   TestApplication application;
7402
7403   Actor actor = Actor::New();
7404   Stage::GetCurrent().Add(actor);
7405   float startValue(0.0f);
7406   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7407   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7408   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7409   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7410
7411   // Build the animation
7412   float durationSeconds(1.0f);
7413   Animation animation = Animation::New(durationSeconds);
7414   float targetZ(-5.0f);
7415   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7416
7417   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7418
7419   // Should return the initial properties before play
7420   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7421   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7422
7423   // Start the animation
7424   animation.Play();
7425
7426   // Should return the target property after play
7427   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7428   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7429
7430   bool signalReceived(false);
7431   AnimationFinishCheck finishCheck(signalReceived);
7432   animation.FinishedSignal().Connect(&application, finishCheck);
7433
7434   application.SendNotification();
7435   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7436
7437   // We didn't expect the animation to finish yet
7438   application.SendNotification();
7439   finishCheck.CheckSignalNotReceived();
7440   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7441
7442   application.SendNotification();
7443   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7444
7445   // We did expect the animation to finish
7446   application.SendNotification();
7447   finishCheck.CheckSignalReceived();
7448   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7449   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7450   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7451   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7452   END_TEST;
7453 }
7454
7455 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7456 {
7457   TestApplication application;
7458
7459   Actor actor = Actor::New();
7460   Stage::GetCurrent().Add(actor);
7461   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7462
7463   // Build the animation
7464   float durationSeconds(1.0f);
7465   Animation animation = Animation::New(durationSeconds);
7466   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7467   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7468
7469   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7470
7471   // Start the animation
7472   animation.Play();
7473
7474   bool signalReceived(false);
7475   AnimationFinishCheck finishCheck(signalReceived);
7476   animation.FinishedSignal().Connect(&application, finishCheck);
7477
7478   application.SendNotification();
7479   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7480
7481   // We didn't expect the animation to finish yet
7482   application.SendNotification();
7483   finishCheck.CheckSignalNotReceived();
7484
7485   // The position should have moved less, than with a linear alpha function
7486   Vector3 current(actor.GetCurrentPosition());
7487   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7488   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7489   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7490   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7491   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7492   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7493
7494   application.SendNotification();
7495   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7496
7497   // We did expect the animation to finish
7498   application.SendNotification();
7499   finishCheck.CheckSignalReceived();
7500   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7501   END_TEST;
7502 }
7503
7504 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7505 {
7506   TestApplication application;
7507
7508   Actor actor = Actor::New();
7509   Stage::GetCurrent().Add(actor);
7510   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7511
7512   // Build the animation
7513   float durationSeconds(1.0f);
7514   Animation animation = Animation::New(durationSeconds);
7515   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7516   float delay = 0.5f;
7517   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7518                        targetPosition,
7519                        TimePeriod( delay, durationSeconds - delay ) );
7520
7521   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7522
7523   // Start the animation
7524   animation.Play();
7525
7526   bool signalReceived(false);
7527   AnimationFinishCheck finishCheck(signalReceived);
7528   animation.FinishedSignal().Connect(&application, finishCheck);
7529
7530   application.SendNotification();
7531   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7532
7533   // We didn't expect the animation to finish yet
7534   application.SendNotification();
7535   finishCheck.CheckSignalNotReceived();
7536   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7537
7538   application.SendNotification();
7539   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7540
7541   // We didn't expect the animation to finish yet
7542   application.SendNotification();
7543   finishCheck.CheckSignalNotReceived();
7544   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7545
7546   application.SendNotification();
7547   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7548
7549   // We did expect the animation to finish
7550   application.SendNotification();
7551   finishCheck.CheckSignalReceived();
7552   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7553   END_TEST;
7554 }
7555
7556 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7557 {
7558   TestApplication application;
7559
7560   Actor actor = Actor::New();
7561   Stage::GetCurrent().Add(actor);
7562   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7563
7564   // Build the animation
7565   float durationSeconds(1.0f);
7566   Animation animation = Animation::New(durationSeconds);
7567   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7568   float delay = 0.5f;
7569   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7570                        targetPosition,
7571                        AlphaFunction::LINEAR,
7572                        TimePeriod( delay, durationSeconds - delay ) );
7573
7574   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7575
7576   // Start the animation
7577   animation.Play();
7578
7579   bool signalReceived(false);
7580   AnimationFinishCheck finishCheck(signalReceived);
7581   animation.FinishedSignal().Connect(&application, finishCheck);
7582
7583   application.SendNotification();
7584   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7585
7586   // We didn't expect the animation to finish yet
7587   application.SendNotification();
7588   finishCheck.CheckSignalNotReceived();
7589   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7590
7591   application.SendNotification();
7592   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7593
7594   // We didn't expect the animation to finish yet
7595   application.SendNotification();
7596   finishCheck.CheckSignalNotReceived();
7597   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7598
7599   application.SendNotification();
7600   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7601
7602   // We did expect the animation to finish
7603   application.SendNotification();
7604   finishCheck.CheckSignalReceived();
7605   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7606   END_TEST;
7607 }
7608
7609 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7610 {
7611   TestApplication application;
7612
7613   Actor actor = Actor::New();
7614   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7615   Stage::GetCurrent().Add(actor);
7616   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7617
7618   // Build the animation
7619   float durationSeconds(1.0f);
7620   Animation animation = Animation::New(durationSeconds);
7621   Degree targetRotationDegrees(90.0f);
7622   Radian targetRotationRadians(targetRotationDegrees);
7623   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7624
7625   // Start the animation
7626   animation.Play();
7627
7628   // Target value should be retrievable straight away
7629   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7630
7631   bool signalReceived(false);
7632   AnimationFinishCheck finishCheck(signalReceived);
7633   animation.FinishedSignal().Connect(&application, finishCheck);
7634
7635   application.SendNotification();
7636   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7637
7638   // We didn't expect the animation to finish yet
7639   application.SendNotification();
7640   finishCheck.CheckSignalNotReceived();
7641   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7642
7643   application.SendNotification();
7644   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7645
7646   // We didn't expect the animation to finish yet
7647   application.SendNotification();
7648   finishCheck.CheckSignalNotReceived();
7649   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7650
7651   application.SendNotification();
7652   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7653
7654   // We didn't expect the animation to finish yet
7655   application.SendNotification();
7656   finishCheck.CheckSignalNotReceived();
7657   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7658
7659   application.SendNotification();
7660   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7661
7662   // We did expect the animation to finish
7663   application.SendNotification();
7664   finishCheck.CheckSignalReceived();
7665   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7666   END_TEST;
7667 }
7668
7669 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7670 {
7671   TestApplication application;
7672
7673   Actor actor = Actor::New();
7674   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7675   Stage::GetCurrent().Add(actor);
7676   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7677
7678   // Build the animation
7679   float durationSeconds(1.0f);
7680   Animation animation = Animation::New(durationSeconds);
7681   Degree targetRotationDegrees(90.0f);
7682   Radian targetRotationRadians(targetRotationDegrees);
7683   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7684   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7685
7686   // Start the animation
7687   animation.Play();
7688
7689   bool signalReceived(false);
7690   AnimationFinishCheck finishCheck(signalReceived);
7691   animation.FinishedSignal().Connect(&application, finishCheck);
7692
7693   application.SendNotification();
7694   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7695
7696   // We didn't expect the animation to finish yet
7697   application.SendNotification();
7698   finishCheck.CheckSignalNotReceived();
7699   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7700
7701   application.SendNotification();
7702   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7703
7704   // We didn't expect the animation to finish yet
7705   application.SendNotification();
7706   finishCheck.CheckSignalNotReceived();
7707   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7708
7709   application.SendNotification();
7710   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7711
7712   // We didn't expect the animation to finish yet
7713   application.SendNotification();
7714   finishCheck.CheckSignalNotReceived();
7715   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7716
7717   application.SendNotification();
7718   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7719
7720   // We did expect the animation to finish
7721   application.SendNotification();
7722   finishCheck.CheckSignalReceived();
7723   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7724   END_TEST;
7725 }
7726
7727 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7728 {
7729   TestApplication application;
7730
7731   Actor actor = Actor::New();
7732   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7733   Stage::GetCurrent().Add(actor);
7734   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7735
7736   // Build the animation
7737   float durationSeconds(1.0f);
7738   Animation animation = Animation::New(durationSeconds);
7739   Degree targetRotationDegrees(90.0f);
7740   Radian targetRotationRadians(targetRotationDegrees);
7741   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7742
7743   // Start the animation
7744   animation.Play();
7745
7746   bool signalReceived(false);
7747   AnimationFinishCheck finishCheck(signalReceived);
7748   animation.FinishedSignal().Connect(&application, finishCheck);
7749
7750   application.SendNotification();
7751   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7752
7753   // We didn't expect the animation to finish yet
7754   application.SendNotification();
7755   finishCheck.CheckSignalNotReceived();
7756   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7757
7758   application.SendNotification();
7759   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7760
7761   // We didn't expect the animation to finish yet
7762   application.SendNotification();
7763   finishCheck.CheckSignalNotReceived();
7764   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7765
7766   application.SendNotification();
7767   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7768
7769   // We didn't expect the animation to finish yet
7770   application.SendNotification();
7771   finishCheck.CheckSignalNotReceived();
7772   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7773
7774   application.SendNotification();
7775   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7776
7777   // We did expect the animation to finish
7778   application.SendNotification();
7779   finishCheck.CheckSignalReceived();
7780   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7781   END_TEST;
7782 }
7783
7784 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7785 {
7786   TestApplication application;
7787
7788   Actor actor = Actor::New();
7789   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7790   Stage::GetCurrent().Add(actor);
7791   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7792
7793   // Build the animation
7794   float durationSeconds(1.0f);
7795   Animation animation = Animation::New(durationSeconds);
7796   Degree targetRotationDegrees(90.0f);
7797   Radian targetRotationRadians(targetRotationDegrees);
7798   float delay(0.1f);
7799   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7800
7801   // Start the animation
7802   animation.Play();
7803
7804   bool signalReceived(false);
7805   AnimationFinishCheck finishCheck(signalReceived);
7806   animation.FinishedSignal().Connect(&application, finishCheck);
7807
7808   application.SendNotification();
7809   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7810
7811   // We didn't expect the animation to finish yet
7812   application.SendNotification();
7813   finishCheck.CheckSignalNotReceived();
7814   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7815   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7816
7817   application.SendNotification();
7818   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7819
7820   // We didn't expect the animation to finish yet
7821   application.SendNotification();
7822   finishCheck.CheckSignalNotReceived();
7823   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7824   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7825
7826   application.SendNotification();
7827   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7828
7829   // We didn't expect the animation to finish yet
7830   application.SendNotification();
7831   finishCheck.CheckSignalNotReceived();
7832   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7833   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7834
7835   application.SendNotification();
7836   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7837
7838   // We did expect the animation to finish
7839   application.SendNotification();
7840   finishCheck.CheckSignalReceived();
7841   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7842   END_TEST;
7843 }
7844
7845 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7846 {
7847   TestApplication application;
7848
7849   Actor actor = Actor::New();
7850   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7851   Stage::GetCurrent().Add(actor);
7852   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7853
7854   // Build the animation
7855   float durationSeconds(1.0f);
7856   Animation animation = Animation::New(durationSeconds);
7857   Degree targetRotationDegrees(90.0f);
7858   Radian targetRotationRadians(targetRotationDegrees);
7859   float delay(0.1f);
7860   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7861
7862   // Start the animation
7863   animation.Play();
7864
7865   bool signalReceived(false);
7866   AnimationFinishCheck finishCheck(signalReceived);
7867   animation.FinishedSignal().Connect(&application, finishCheck);
7868
7869   application.SendNotification();
7870   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7871
7872   // We didn't expect the animation to finish yet
7873   application.SendNotification();
7874   finishCheck.CheckSignalNotReceived();
7875   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7876   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7877
7878   application.SendNotification();
7879   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7880
7881   // We didn't expect the animation to finish yet
7882   application.SendNotification();
7883   finishCheck.CheckSignalNotReceived();
7884   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7885   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7886
7887   application.SendNotification();
7888   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7889
7890   // We didn't expect the animation to finish yet
7891   application.SendNotification();
7892   finishCheck.CheckSignalNotReceived();
7893   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7894   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7895
7896   application.SendNotification();
7897   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7898
7899   // We did expect the animation to finish
7900   application.SendNotification();
7901   finishCheck.CheckSignalReceived();
7902   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7903   END_TEST;
7904 }
7905
7906 int UtcDaliAnimationAnimateToActorScaleP(void)
7907 {
7908   TestApplication application;
7909
7910   Actor actor = Actor::New();
7911   Stage::GetCurrent().Add(actor);
7912   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7913
7914   // Build the animation
7915   float durationSeconds(1.0f);
7916   Animation animation = Animation::New(durationSeconds);
7917   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7918   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7919
7920   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7921
7922   // Start the animation
7923   animation.Play();
7924
7925   // Target value should be retrievable straight away
7926   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7927   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7928   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7929   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
7930
7931   bool signalReceived(false);
7932   AnimationFinishCheck finishCheck(signalReceived);
7933   animation.FinishedSignal().Connect(&application, finishCheck);
7934
7935   application.SendNotification();
7936   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7937
7938   // We didn't expect the animation to finish yet
7939   application.SendNotification();
7940   finishCheck.CheckSignalNotReceived();
7941   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7942
7943   application.SendNotification();
7944   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7945
7946   // We did expect the animation to finish
7947   application.SendNotification();
7948   finishCheck.CheckSignalReceived();
7949   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7950
7951   // Reset everything
7952   finishCheck.Reset();
7953   actor.SetScale(Vector3::ONE);
7954   application.SendNotification();
7955   application.Render(0);
7956   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7957
7958   // Repeat with a different (ease-in) alpha function
7959   animation = Animation::New(durationSeconds);
7960   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7961   animation.FinishedSignal().Connect(&application, finishCheck);
7962   animation.Play();
7963
7964   application.SendNotification();
7965   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7966
7967   // We didn't expect the animation to finish yet
7968   application.SendNotification();
7969   finishCheck.CheckSignalNotReceived();
7970
7971   // The scale should have grown less, than with a linear alpha function
7972   Vector3 current(actor.GetCurrentScale());
7973   DALI_TEST_CHECK( current.x > 1.0f );
7974   DALI_TEST_CHECK( current.y > 1.0f );
7975   DALI_TEST_CHECK( current.z > 1.0f );
7976   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7977   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7978   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7979
7980   application.SendNotification();
7981   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7982
7983   // We did expect the animation to finish
7984   application.SendNotification();
7985   finishCheck.CheckSignalReceived();
7986   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7987
7988   // Reset everything
7989   finishCheck.Reset();
7990   actor.SetScale(Vector3::ONE);
7991   application.SendNotification();
7992   application.Render(0);
7993   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7994
7995   // Repeat with a delay
7996   float delay = 0.5f;
7997   animation = Animation::New(durationSeconds);
7998   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
7999   animation.FinishedSignal().Connect(&application, finishCheck);
8000   animation.Play();
8001
8002   application.SendNotification();
8003   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8004
8005   // We didn't expect the animation to finish yet
8006   application.SendNotification();
8007   finishCheck.CheckSignalNotReceived();
8008   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8009
8010   application.SendNotification();
8011   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8012
8013   // We did expect the animation to finish
8014   application.SendNotification();
8015   finishCheck.CheckSignalReceived();
8016   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8017   END_TEST;
8018 }
8019
8020 int UtcDaliAnimationAnimateToActorScaleXP(void)
8021 {
8022   TestApplication application;
8023
8024   Actor actor = Actor::New();
8025   Stage::GetCurrent().Add(actor);
8026   float startValue(1.0f);
8027   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
8028   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8029   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8030   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8031   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8032   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8033   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8034
8035   // Build the animation
8036   float durationSeconds(1.0f);
8037   Animation animation = Animation::New(durationSeconds);
8038   float targetX(10.0f);
8039   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8040
8041   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8042
8043   // Start the animation
8044   animation.Play();
8045
8046   // Target value should be retrievable straight away
8047   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8048   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8049
8050   bool signalReceived(false);
8051   AnimationFinishCheck finishCheck(signalReceived);
8052   animation.FinishedSignal().Connect(&application, finishCheck);
8053
8054   application.SendNotification();
8055   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8056
8057   // We didn't expect the animation to finish yet
8058   application.SendNotification();
8059   finishCheck.CheckSignalNotReceived();
8060   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
8061   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8062   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8063   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8064
8065   application.SendNotification();
8066   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8067
8068   // We did expect the animation to finish
8069   application.SendNotification();
8070   finishCheck.CheckSignalReceived();
8071   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
8072   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8073   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8074   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8075   END_TEST;
8076 }
8077
8078 int UtcDaliAnimationAnimateToActorScaleYP(void)
8079 {
8080   TestApplication application;
8081
8082   Actor actor = Actor::New();
8083   Stage::GetCurrent().Add(actor);
8084   float startValue(1.0f);
8085   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
8086   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8087   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8088   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8089   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8090   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8091   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8092
8093   // Build the animation
8094   float durationSeconds(1.0f);
8095   Animation animation = Animation::New(durationSeconds);
8096   float targetY(1000.0f);
8097   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8098
8099   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8100
8101   // Start the animation
8102   animation.Play();
8103
8104   // Target value should be retrievable straight away
8105   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8106   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8107
8108   bool signalReceived(false);
8109   AnimationFinishCheck finishCheck(signalReceived);
8110   animation.FinishedSignal().Connect(&application, finishCheck);
8111
8112   application.SendNotification();
8113   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8114
8115   // We didn't expect the animation to finish yet
8116   application.SendNotification();
8117   finishCheck.CheckSignalNotReceived();
8118   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
8119   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8120   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8121   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8122
8123   application.SendNotification();
8124   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8125
8126   // We did expect the animation to finish
8127   application.SendNotification();
8128   finishCheck.CheckSignalReceived();
8129   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
8130   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8131   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8132   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8133   END_TEST;
8134 }
8135
8136 int UtcDaliAnimationAnimateToActorScaleZP(void)
8137 {
8138   TestApplication application;
8139
8140   Actor actor = Actor::New();
8141   Stage::GetCurrent().Add(actor);
8142   float startValue(1.0f);
8143   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
8144   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8145   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8146   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8147   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8148   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8149   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8150
8151   // Build the animation
8152   float durationSeconds(1.0f);
8153   Animation animation = Animation::New(durationSeconds);
8154   float targetZ(-1000.0f);
8155   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8156
8157   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8158
8159   // Start the animation
8160   animation.Play();
8161
8162   // Target value should be retrievable straight away
8163   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8164   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8165
8166   bool signalReceived(false);
8167   AnimationFinishCheck finishCheck(signalReceived);
8168   animation.FinishedSignal().Connect(&application, finishCheck);
8169
8170   application.SendNotification();
8171   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8172
8173   // We didn't expect the animation to finish yet
8174   application.SendNotification();
8175   finishCheck.CheckSignalNotReceived();
8176   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
8177   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8178   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8179   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8180
8181   application.SendNotification();
8182   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8183
8184   // We did expect the animation to finish
8185   application.SendNotification();
8186   finishCheck.CheckSignalReceived();
8187   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
8188   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8189   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8190   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8191   END_TEST;
8192 }
8193
8194 int UtcDaliAnimationAnimateToActorColorP(void)
8195 {
8196   TestApplication application;
8197
8198   Actor actor = Actor::New();
8199   Stage::GetCurrent().Add(actor);
8200   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8201
8202   // Build the animation
8203   float durationSeconds(1.0f);
8204   Animation animation = Animation::New(durationSeconds);
8205   Vector4 targetColor(Color::RED);
8206   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8207
8208   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8209   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8210
8211   // Start the animation
8212   animation.Play();
8213
8214   // Target value should be retrievable straight away
8215   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8216   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8217   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8218   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8219   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8220   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8221
8222   bool signalReceived(false);
8223   AnimationFinishCheck finishCheck(signalReceived);
8224   animation.FinishedSignal().Connect(&application, finishCheck);
8225
8226   application.SendNotification();
8227   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8228
8229   // We didn't expect the animation to finish yet
8230   application.SendNotification();
8231   finishCheck.CheckSignalNotReceived();
8232   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8233
8234   application.SendNotification();
8235   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8236
8237   // We did expect the animation to finish
8238   application.SendNotification();
8239   finishCheck.CheckSignalReceived();
8240   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8241
8242   // Reset everything
8243   finishCheck.Reset();
8244   actor.SetColor(Color::WHITE);
8245   application.SendNotification();
8246   application.Render(0);
8247   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8248
8249   // Repeat with a different (ease-in) alpha function
8250   animation = Animation::New(durationSeconds);
8251   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8252   animation.FinishedSignal().Connect(&application, finishCheck);
8253   animation.Play();
8254
8255   application.SendNotification();
8256   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8257
8258   // We didn't expect the animation to finish yet
8259   application.SendNotification();
8260   finishCheck.CheckSignalNotReceived();
8261
8262   // The color should have changed less, than with a linear alpha function
8263   Vector4 current(actor.GetCurrentColor());
8264   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8265   DALI_TEST_CHECK( current.y < 1.0f );
8266   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8267   DALI_TEST_CHECK( current.z  < 1.0f );
8268   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8269   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8270
8271   application.SendNotification();
8272   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8273
8274   // We did expect the animation to finish
8275   application.SendNotification();
8276   finishCheck.CheckSignalReceived();
8277   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8278
8279   // Reset everything
8280   finishCheck.Reset();
8281   actor.SetColor(Color::WHITE);
8282   application.SendNotification();
8283   application.Render(0);
8284   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8285
8286   // Repeat with a shorter animator duration
8287   float animatorDuration = 0.5f;
8288   animation = Animation::New(durationSeconds);
8289   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8290   animation.FinishedSignal().Connect(&application, finishCheck);
8291   animation.Play();
8292
8293   application.SendNotification();
8294   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8295
8296   // We didn't expect the animation to finish yet
8297   application.SendNotification();
8298   finishCheck.CheckSignalNotReceived();
8299   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8300
8301   application.SendNotification();
8302   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8303
8304   // We didn't expect the animation to finish yet
8305   application.SendNotification();
8306   finishCheck.CheckSignalNotReceived();
8307   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8308
8309   application.SendNotification();
8310   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8311
8312   // We did expect the animation to finish
8313   application.SendNotification();
8314   finishCheck.CheckSignalReceived();
8315   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8316   END_TEST;
8317 }
8318
8319 int UtcDaliAnimationAnimateToActorColorRedP(void)
8320 {
8321   TestApplication application;
8322
8323   Actor actor = Actor::New();
8324   Stage::GetCurrent().Add(actor);
8325   float startValue(1.0f);
8326   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
8327   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8328   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8329   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8330   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8331   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8332   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8333   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8334   DALI_TEST_EQUALS( actor.GetCurrentProperty< 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   float targetRed(0.5f);
8340   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8341
8342   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8343
8344   // Start the animation
8345   animation.Play();
8346
8347   // Target value should be retrievable straight away
8348   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8349   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8350
8351   bool signalReceived(false);
8352   AnimationFinishCheck finishCheck(signalReceived);
8353   animation.FinishedSignal().Connect(&application, finishCheck);
8354
8355   application.SendNotification();
8356   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8357
8358   // We didn't expect the animation to finish yet
8359   application.SendNotification();
8360   finishCheck.CheckSignalNotReceived();
8361   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8362   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8363   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8364   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8365   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8366
8367   application.SendNotification();
8368   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8369
8370   // We did expect the animation to finish
8371   application.SendNotification();
8372   finishCheck.CheckSignalReceived();
8373   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8374   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8375   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8376   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8377   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8378   END_TEST;
8379 }
8380
8381 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8382 {
8383   TestApplication application;
8384
8385   Actor actor = Actor::New();
8386   Stage::GetCurrent().Add(actor);
8387   float startValue(1.0f);
8388   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8389   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8390   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8391   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8392   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8393   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8394   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8395   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8396   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8397
8398   // Build the animation
8399   float durationSeconds(1.0f);
8400   Animation animation = Animation::New(durationSeconds);
8401   float targetGreen(0.5f);
8402   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8403
8404   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8405
8406   // Start the animation
8407   animation.Play();
8408
8409   // Target value should be retrievable straight away
8410   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8411   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8412
8413   bool signalReceived(false);
8414   AnimationFinishCheck finishCheck(signalReceived);
8415   animation.FinishedSignal().Connect(&application, finishCheck);
8416
8417   application.SendNotification();
8418   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8419
8420   // We didn't expect the animation to finish yet
8421   application.SendNotification();
8422   finishCheck.CheckSignalNotReceived();
8423   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8424   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8425   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8426   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8427   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8428
8429   application.SendNotification();
8430   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8431
8432   // We did expect the animation to finish
8433   application.SendNotification();
8434   finishCheck.CheckSignalReceived();
8435   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8436   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8437   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8438   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8439   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8440   END_TEST;
8441 }
8442
8443 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8444 {
8445   TestApplication application;
8446
8447   Actor actor = Actor::New();
8448   Stage::GetCurrent().Add(actor);
8449   float startValue(1.0f);
8450   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8451   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8452   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8453   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8454   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8455   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8456   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8457   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8458   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8459
8460   // Build the animation
8461   float durationSeconds(1.0f);
8462   Animation animation = Animation::New(durationSeconds);
8463   float targetBlue(0.5f);
8464   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8465
8466   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8467
8468   // Start the animation
8469   animation.Play();
8470
8471   // Target value should be retrievable straight away
8472   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8473   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8474
8475   bool signalReceived(false);
8476   AnimationFinishCheck finishCheck(signalReceived);
8477   animation.FinishedSignal().Connect(&application, finishCheck);
8478
8479   application.SendNotification();
8480   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8481
8482   // We didn't expect the animation to finish yet
8483   application.SendNotification();
8484   finishCheck.CheckSignalNotReceived();
8485   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8488   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8489   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8490
8491   application.SendNotification();
8492   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8493
8494   // We did expect the animation to finish
8495   application.SendNotification();
8496   finishCheck.CheckSignalReceived();
8497   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8498   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8499   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8500   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8502   END_TEST;
8503 }
8504
8505 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8506 {
8507   TestApplication application;
8508
8509   Actor actor = Actor::New();
8510   Stage::GetCurrent().Add(actor);
8511   float startValue(1.0f);
8512   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8513   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8514   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8515   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8516   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8517   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8518   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8519   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8520   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8521
8522   // Build the animation
8523   float durationSeconds(1.0f);
8524   Animation animation = Animation::New(durationSeconds);
8525   float targetAlpha(0.5f);
8526   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8527
8528   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8529
8530   // Start the animation
8531   animation.Play();
8532
8533   // Target value should be retrievable straight away
8534   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8535   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8536   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8537
8538   bool signalReceived(false);
8539   AnimationFinishCheck finishCheck(signalReceived);
8540   animation.FinishedSignal().Connect(&application, finishCheck);
8541
8542   application.SendNotification();
8543   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8544
8545   // We didn't expect the animation to finish yet
8546   application.SendNotification();
8547   finishCheck.CheckSignalNotReceived();
8548   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8549   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8550   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8552   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8553
8554   application.SendNotification();
8555   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8556
8557   // We did expect the animation to finish
8558   application.SendNotification();
8559   finishCheck.CheckSignalReceived();
8560   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8561   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8562   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8563   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8564   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8565   END_TEST;
8566 }
8567
8568 int UtcDaliAnimationKeyFrames01P(void)
8569 {
8570   TestApplication application;
8571
8572   KeyFrames keyFrames = KeyFrames::New();
8573   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8574
8575   keyFrames.Add(0.0f, 0.1f);
8576
8577   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8578
8579   KeyFrames keyFrames2( keyFrames);
8580   DALI_TEST_CHECK( keyFrames2 );
8581   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8582
8583   KeyFrames keyFrames3 = KeyFrames::New();
8584   keyFrames3.Add(0.6f, true);
8585   DALI_TEST_CHECK( keyFrames3 );
8586   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8587
8588   keyFrames3 = keyFrames;
8589   DALI_TEST_CHECK( keyFrames3 );
8590   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8591
8592   END_TEST;
8593 }
8594
8595 int UtcDaliAnimationKeyFrames02P(void)
8596 {
8597   TestApplication application;
8598
8599   KeyFrames keyFrames = KeyFrames::New();
8600   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8601
8602   keyFrames.Add(0.0f, 0.1f);
8603   keyFrames.Add(0.2f, 0.5f);
8604   keyFrames.Add(0.4f, 0.0f);
8605   keyFrames.Add(0.6f, 1.0f);
8606   keyFrames.Add(0.8f, 0.7f);
8607   keyFrames.Add(1.0f, 0.9f);
8608
8609   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8610
8611   try
8612   {
8613     keyFrames.Add(1.9f, false);
8614   }
8615   catch (Dali::DaliException& e)
8616   {
8617     DALI_TEST_PRINT_ASSERT( e );
8618     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8619   }
8620   END_TEST;
8621 }
8622
8623 int UtcDaliAnimationKeyFrames03P(void)
8624 {
8625   TestApplication application;
8626
8627   KeyFrames keyFrames = KeyFrames::New();
8628   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8629
8630   keyFrames.Add(0.0f, true);
8631   keyFrames.Add(0.2f, false);
8632   keyFrames.Add(0.4f, false);
8633   keyFrames.Add(0.6f, true);
8634   keyFrames.Add(0.8f, true);
8635   keyFrames.Add(1.0f, false);
8636
8637   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8638
8639   try
8640   {
8641     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8642   }
8643   catch (Dali::DaliException& e)
8644   {
8645     DALI_TEST_PRINT_ASSERT( e );
8646     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8647   }
8648   END_TEST;
8649 }
8650
8651 int UtcDaliAnimationKeyFrames04P(void)
8652 {
8653   TestApplication application;
8654
8655   KeyFrames keyFrames = KeyFrames::New();
8656   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8657
8658   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8659   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8660   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8661   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8662   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8663   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8664
8665   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8666
8667   try
8668   {
8669     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8670   }
8671   catch (Dali::DaliException& e)
8672   {
8673     DALI_TEST_PRINT_ASSERT( e );
8674     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8675   }
8676   END_TEST;
8677 }
8678
8679 int UtcDaliAnimationKeyFrames05P(void)
8680 {
8681   TestApplication application;
8682
8683   KeyFrames keyFrames = KeyFrames::New();
8684   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8685
8686   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8687   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8688   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8689   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8690   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8691   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8692
8693   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8694
8695   try
8696   {
8697     keyFrames.Add(0.7f, 1.0f);
8698   }
8699   catch (Dali::DaliException& e)
8700   {
8701     DALI_TEST_PRINT_ASSERT( e );
8702     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8703   }
8704   END_TEST;
8705 }
8706
8707 int UtcDaliAnimationKeyFrames06P(void)
8708 {
8709   TestApplication application;
8710
8711   KeyFrames keyFrames = KeyFrames::New();
8712   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8713
8714   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8715   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8716   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8717   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8718   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8719   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8720
8721   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8722
8723   try
8724   {
8725     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8726   }
8727   catch (Dali::DaliException& e)
8728   {
8729     DALI_TEST_PRINT_ASSERT( e );
8730     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8731   }
8732   END_TEST;
8733 }
8734
8735 int UtcDaliAnimationKeyFrames07P(void)
8736 {
8737   TestApplication application;
8738
8739   KeyFrames keyFrames = KeyFrames::New();
8740   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8741
8742   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8743   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8744   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8745   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8746   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8747   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8748
8749   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8750
8751   try
8752   {
8753     keyFrames.Add(0.7f, 1.1f);
8754   }
8755   catch (Dali::DaliException& e)
8756   {
8757     DALI_TEST_PRINT_ASSERT( e );
8758     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8759   }
8760   END_TEST;
8761 }
8762
8763 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8764 {
8765   TestApplication application;
8766
8767   float startValue(1.0f);
8768   Actor actor = Actor::New();
8769   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8770   Stage::GetCurrent().Add(actor);
8771
8772   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8773   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8774   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8775   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8776   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8777   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8778   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8779   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8780   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8781
8782   // Build the animation
8783   float durationSeconds(1.0f);
8784   Animation animation = Animation::New(durationSeconds);
8785
8786   KeyFrames keyFrames = KeyFrames::New();
8787   keyFrames.Add(0.0f, 0.1f);
8788   keyFrames.Add(0.2f, 0.5f);
8789   keyFrames.Add(0.4f, 0.0f);
8790   keyFrames.Add(0.6f, 1.0f);
8791   keyFrames.Add(0.8f, 0.7f);
8792   keyFrames.Add(1.0f, 0.9f);
8793
8794   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8795
8796   // Start the animation
8797   animation.Play();
8798
8799   // Final key frame value should be retrievable straight away
8800   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8801
8802   bool signalReceived(false);
8803   AnimationFinishCheck finishCheck(signalReceived);
8804   animation.FinishedSignal().Connect(&application, finishCheck);
8805   application.SendNotification();
8806   application.Render(0);
8807   application.SendNotification();
8808   finishCheck.CheckSignalNotReceived();
8809   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8810
8811   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8812   application.SendNotification();
8813   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8814   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8815   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8817   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8818
8819   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8820   application.SendNotification();
8821   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8825   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8826
8827   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8828   application.SendNotification();
8829   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8830   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8831   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8832   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8833   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8834
8835   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8836   application.SendNotification();
8837   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8838   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8839   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8840   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8841   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8842
8843   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8844   application.SendNotification();
8845   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8846   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8847   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8849   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8850
8851   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8852   application.SendNotification();
8853   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8854   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8855   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8856   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8857   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8858
8859   // We did expect the animation to finish
8860
8861   finishCheck.CheckSignalReceived();
8862   END_TEST;
8863 }
8864
8865 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8866 {
8867   TestApplication application;
8868
8869   float startValue(1.0f);
8870   Actor actor = Actor::New();
8871   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8872   Stage::GetCurrent().Add(actor);
8873
8874   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8875   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8876   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8877   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8878   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8879   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8880   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8881   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8882   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8883
8884   // Build the animation
8885   float durationSeconds(1.0f);
8886   Animation animation = Animation::New(durationSeconds);
8887
8888   KeyFrames keyFrames = KeyFrames::New();
8889   keyFrames.Add(0.0f, 0.1f);
8890   keyFrames.Add(0.2f, 0.5f);
8891   keyFrames.Add(0.4f, 0.0f);
8892   keyFrames.Add(0.6f, 1.0f);
8893   keyFrames.Add(0.8f, 0.7f);
8894   keyFrames.Add(1.0f, 0.9f);
8895
8896   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8897
8898   // Start the animation
8899   animation.Play();
8900
8901   bool signalReceived(false);
8902   AnimationFinishCheck finishCheck(signalReceived);
8903   animation.FinishedSignal().Connect(&application, finishCheck);
8904   application.SendNotification();
8905   application.Render(0);
8906   application.SendNotification();
8907   finishCheck.CheckSignalNotReceived();
8908   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8909
8910   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8911   application.SendNotification();
8912   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8913   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8914   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8915   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8916   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8917
8918   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8919   application.SendNotification();
8920   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8921   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8922   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8923   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8924   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8925
8926   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8927   application.SendNotification();
8928   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8929   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8930   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8932   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8933
8934   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8935   application.SendNotification();
8936   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8937   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8938   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8939   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8940   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8941
8942   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8943   application.SendNotification();
8944   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8945   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8946   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8947   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8948   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8949
8950   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8951   application.SendNotification();
8952   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8953   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8954   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8955   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
8956   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8957
8958   // We did expect the animation to finish
8959
8960   finishCheck.CheckSignalReceived();
8961   END_TEST;
8962 }
8963
8964 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8965 {
8966   TestApplication application;
8967
8968   float startValue(1.0f);
8969   Actor actor = Actor::New();
8970   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8971   Stage::GetCurrent().Add(actor);
8972
8973   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8974   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8975   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8976   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8977   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8978   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8979   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8980   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8981   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8982
8983   // Build the animation
8984   float durationSeconds(1.0f);
8985   Animation animation = Animation::New(durationSeconds);
8986
8987   KeyFrames keyFrames = KeyFrames::New();
8988   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8989   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8990   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8991
8992   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8993
8994   // Start the animation
8995   animation.Play();
8996
8997   bool signalReceived(false);
8998   AnimationFinishCheck finishCheck(signalReceived);
8999   animation.FinishedSignal().Connect(&application, finishCheck);
9000   application.SendNotification();
9001   application.Render(0);
9002   application.SendNotification();
9003   finishCheck.CheckSignalNotReceived();
9004   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9005   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9006   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9007   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9008
9009   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9010   application.SendNotification();
9011   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9012   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9013   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9014   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9015
9016   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9017   application.SendNotification();
9018   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9019   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9022
9023   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9024   application.SendNotification();
9025   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9026   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9027   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9028   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9029
9030   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9031   application.SendNotification();
9032   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9033   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9034   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9035   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9036
9037   // We did expect the animation to finish
9038
9039   finishCheck.CheckSignalReceived();
9040   END_TEST;
9041 }
9042
9043 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9044 {
9045   TestApplication application;
9046
9047   float startValue(1.0f);
9048   Actor actor = Actor::New();
9049   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9050   Stage::GetCurrent().Add(actor);
9051
9052   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9053   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9054   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9055   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9056   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9057   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9058   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9059   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9060   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9061
9062   // Build the animation
9063   float durationSeconds(1.0f);
9064   Animation animation = Animation::New(durationSeconds);
9065
9066   KeyFrames keyFrames = KeyFrames::New();
9067   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9068   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9069   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9070
9071   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9072
9073   // Start the animation
9074   animation.Play();
9075
9076   bool signalReceived(false);
9077   AnimationFinishCheck finishCheck(signalReceived);
9078   animation.FinishedSignal().Connect(&application, finishCheck);
9079   application.SendNotification();
9080   application.Render(0);
9081   application.SendNotification();
9082   finishCheck.CheckSignalNotReceived();
9083   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9084   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9086   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9087
9088   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9089   application.SendNotification();
9090   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9091   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9092   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9093   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9094
9095   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9096   application.SendNotification();
9097   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9098   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9099   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9100   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9101
9102   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9103   application.SendNotification();
9104   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9105   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9106   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9107   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9108
9109   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9110   application.SendNotification();
9111   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9112   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9113   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9114   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9115
9116   // We did expect the animation to finish
9117
9118   finishCheck.CheckSignalReceived();
9119   END_TEST;
9120 }
9121
9122 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9123 {
9124   TestApplication application;
9125
9126   Actor actor = Actor::New();
9127   AngleAxis aa(Degree(90), Vector3::XAXIS);
9128   actor.SetOrientation(aa.angle, aa.axis);
9129   Stage::GetCurrent().Add(actor);
9130
9131   application.SendNotification();
9132   application.Render(0);
9133
9134   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9135
9136   // Build the animation
9137   float durationSeconds(1.0f);
9138   Animation animation = Animation::New(durationSeconds);
9139
9140   KeyFrames keyFrames = KeyFrames::New();
9141   keyFrames.Add(0.0f, false);
9142   keyFrames.Add(0.2f, true);
9143   keyFrames.Add(0.4f, true);
9144   keyFrames.Add(0.8f, false);
9145   keyFrames.Add(1.0f, true);
9146
9147   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9148
9149   // Start the animation
9150   animation.Play();
9151
9152   // Final key frame value should be retrievable straight away
9153   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9154
9155   bool signalReceived(false);
9156   AnimationFinishCheck finishCheck(signalReceived);
9157   animation.FinishedSignal().Connect(&application, finishCheck);
9158   application.SendNotification();
9159   application.SendNotification();
9160   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9161   application.SendNotification();
9162   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9163   application.SendNotification();
9164
9165   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9166   finishCheck.CheckSignalReceived();
9167   END_TEST;
9168 }
9169
9170 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9171 {
9172   TestApplication application;
9173
9174   Actor actor = Actor::New();
9175   AngleAxis aa(Degree(90), Vector3::XAXIS);
9176   actor.SetOrientation(aa.angle, aa.axis);
9177   Stage::GetCurrent().Add(actor);
9178
9179   application.SendNotification();
9180   application.Render(0);
9181
9182   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9183
9184   // Build the animation
9185   float durationSeconds(1.0f);
9186   Animation animation = Animation::New(durationSeconds);
9187
9188   KeyFrames keyFrames = KeyFrames::New();
9189   keyFrames.Add(0.0f, false);
9190   keyFrames.Add(0.2f, true);
9191   keyFrames.Add(0.4f, true);
9192   keyFrames.Add(0.8f, false);
9193   keyFrames.Add(1.0f, true);
9194
9195   //Cubic interpolation for boolean values should be ignored
9196   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9197
9198   // Start the animation
9199   animation.Play();
9200
9201   bool signalReceived(false);
9202   AnimationFinishCheck finishCheck(signalReceived);
9203   animation.FinishedSignal().Connect(&application, finishCheck);
9204   application.SendNotification();
9205   application.SendNotification();
9206   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9207   application.SendNotification();
9208   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9209   application.SendNotification();
9210
9211   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9212   finishCheck.CheckSignalReceived();
9213   END_TEST;
9214 }
9215
9216 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9217 {
9218   TestApplication application;
9219
9220   Actor actor = Actor::New();
9221   AngleAxis aa(Degree(90), Vector3::XAXIS);
9222   actor.SetOrientation(aa.angle, aa.axis);
9223   Stage::GetCurrent().Add(actor);
9224
9225   application.SendNotification();
9226   application.Render(0);
9227   Quaternion start(Radian(aa.angle), aa.axis);
9228   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9229
9230   // Build the animation
9231   float durationSeconds(1.0f);
9232   Animation animation = Animation::New(durationSeconds);
9233
9234   KeyFrames keyFrames = KeyFrames::New();
9235   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9236
9237   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9238
9239   // Start the animation
9240   animation.Play();
9241
9242   // Final key frame value should be retrievable straight away
9243   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9244
9245   bool signalReceived(false);
9246   AnimationFinishCheck finishCheck(signalReceived);
9247   animation.FinishedSignal().Connect(&application, finishCheck);
9248   application.SendNotification();
9249   application.SendNotification();
9250   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9251   application.SendNotification();
9252   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9253   application.SendNotification();
9254
9255   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9256
9257   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9258   finishCheck.CheckSignalReceived();
9259   END_TEST;
9260 }
9261
9262 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9263 {
9264   TestApplication application;
9265
9266   Actor actor = Actor::New();
9267   AngleAxis aa(Degree(90), Vector3::XAXIS);
9268   actor.SetOrientation(aa.angle, aa.axis);
9269   application.SendNotification();
9270   application.Render(0);
9271   Stage::GetCurrent().Add(actor);
9272
9273   Quaternion start(Radian(aa.angle), aa.axis);
9274   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9275
9276   // Build the animation
9277   float durationSeconds(1.0f);
9278   Animation animation = Animation::New(durationSeconds);
9279
9280   KeyFrames keyFrames = KeyFrames::New();
9281   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9282   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9283   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9284
9285   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9286
9287   // Start the animation
9288   animation.Play();
9289
9290   bool signalReceived(false);
9291   AnimationFinishCheck finishCheck(signalReceived);
9292   animation.FinishedSignal().Connect(&application, finishCheck);
9293   application.SendNotification();
9294   application.Render(0);
9295   application.SendNotification();
9296   finishCheck.CheckSignalNotReceived();
9297
9298   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9299   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9300
9301   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9302   application.SendNotification();
9303   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9304   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9305
9306   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9307   application.SendNotification();
9308   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9309   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9310
9311   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9312   application.SendNotification();
9313   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9314   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9315
9316   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9317   application.SendNotification();
9318   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9319   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9320
9321   // We did expect the animation to finish
9322
9323   finishCheck.CheckSignalReceived();
9324   END_TEST;
9325 }
9326
9327 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9328 {
9329   TestApplication application;
9330
9331   Actor actor = Actor::New();
9332   AngleAxis aa(Degree(90), Vector3::XAXIS);
9333   actor.SetOrientation(aa.angle, aa.axis);
9334   Stage::GetCurrent().Add(actor);
9335
9336   application.SendNotification();
9337   application.Render(0);
9338   Quaternion start(Radian(aa.angle), aa.axis);
9339   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9340
9341   // Build the animation
9342   float durationSeconds(1.0f);
9343   Animation animation = Animation::New(durationSeconds);
9344
9345   KeyFrames keyFrames = KeyFrames::New();
9346   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9347
9348   //Cubic interpolation should be ignored for quaternions
9349   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9350
9351   // Start the animation
9352   animation.Play();
9353
9354   bool signalReceived(false);
9355   AnimationFinishCheck finishCheck(signalReceived);
9356   animation.FinishedSignal().Connect(&application, finishCheck);
9357   application.SendNotification();
9358   application.SendNotification();
9359   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9360   application.SendNotification();
9361   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9362   application.SendNotification();
9363
9364   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9365
9366   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9367   finishCheck.CheckSignalReceived();
9368   END_TEST;
9369 }
9370
9371 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9372 {
9373   TestApplication application;
9374
9375   Actor actor = Actor::New();
9376   AngleAxis aa(Degree(90), Vector3::XAXIS);
9377   actor.SetOrientation(aa.angle, aa.axis);
9378   application.SendNotification();
9379   application.Render(0);
9380   Stage::GetCurrent().Add(actor);
9381
9382   Quaternion start(Radian(aa.angle), aa.axis);
9383   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9384
9385   // Build the animation
9386   float durationSeconds(1.0f);
9387   Animation animation = Animation::New(durationSeconds);
9388
9389   KeyFrames keyFrames = KeyFrames::New();
9390   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9391   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9392   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9393
9394   //Cubic interpolation should be ignored for quaternions
9395   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9396
9397   // Start the animation
9398   animation.Play();
9399
9400   bool signalReceived(false);
9401   AnimationFinishCheck finishCheck(signalReceived);
9402   animation.FinishedSignal().Connect(&application, finishCheck);
9403   application.SendNotification();
9404   application.Render(0);
9405   application.SendNotification();
9406   finishCheck.CheckSignalNotReceived();
9407
9408   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9409   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9410
9411   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9412   application.SendNotification();
9413   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9414   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9415
9416   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9417   application.SendNotification();
9418   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9419   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9420
9421   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9422   application.SendNotification();
9423   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9424   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9425
9426   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9427   application.SendNotification();
9428   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9429   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9430
9431   // We did expect the animation to finish
9432
9433   finishCheck.CheckSignalReceived();
9434   END_TEST;
9435 }
9436
9437 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9438 {
9439   TestApplication application;
9440
9441   float startValue(1.0f);
9442   Actor actor = Actor::New();
9443   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9444   Stage::GetCurrent().Add(actor);
9445
9446   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9447   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9448   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9449   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9450   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9451   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9452   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9453   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9454   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9455
9456   // Build the animation
9457   float durationSeconds(1.0f);
9458   Animation animation = Animation::New(durationSeconds);
9459
9460   KeyFrames keyFrames = KeyFrames::New();
9461   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9462   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9463   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9464
9465   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9466
9467   // Start the animation
9468   animation.Play();
9469
9470   bool signalReceived(false);
9471   AnimationFinishCheck finishCheck(signalReceived);
9472   animation.FinishedSignal().Connect(&application, finishCheck);
9473   application.SendNotification();
9474   application.Render(0);
9475   application.SendNotification();
9476   finishCheck.CheckSignalNotReceived();
9477   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9478   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9480   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9481
9482   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9483   application.SendNotification();
9484   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9485   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9488
9489   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9490   application.SendNotification();
9491   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9492   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9493   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9494   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9495
9496   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9497   application.SendNotification();
9498   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9499   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9500   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9502
9503   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9504   application.SendNotification();
9505   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9506   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9507   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9508   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9509
9510   // We did expect the animation to finish
9511
9512   finishCheck.CheckSignalReceived();
9513   END_TEST;
9514 }
9515
9516 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9517 {
9518   TestApplication application;
9519
9520   float startValue(1.0f);
9521   Actor actor = Actor::New();
9522   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9523   Stage::GetCurrent().Add(actor);
9524
9525   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9526   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9527   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9528   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9529   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9530   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9531   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9532   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9533   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9534
9535   // Build the animation
9536   float durationSeconds(1.0f);
9537   Animation animation = Animation::New(durationSeconds);
9538
9539   KeyFrames keyFrames = KeyFrames::New();
9540   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9541   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9542   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9543
9544   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9545
9546   // Start the animation
9547   animation.Play();
9548
9549   bool signalReceived(false);
9550   AnimationFinishCheck finishCheck(signalReceived);
9551   animation.FinishedSignal().Connect(&application, finishCheck);
9552   application.SendNotification();
9553   application.Render(0);
9554   application.SendNotification();
9555   finishCheck.CheckSignalNotReceived();
9556   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9557   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9559   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9560
9561   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9562   application.SendNotification();
9563   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9564   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9565   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9566   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9567
9568   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9569   application.SendNotification();
9570   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9571   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9572   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9573   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9574
9575   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9576   application.SendNotification();
9577   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9579   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9581
9582   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9583   application.SendNotification();
9584   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9585   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9586   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9587   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9588
9589   // We did expect the animation to finish
9590
9591   finishCheck.CheckSignalReceived();
9592   END_TEST;
9593 }
9594
9595 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9596 {
9597   TestApplication application;
9598
9599   float startValue(1.0f);
9600   Actor actor = Actor::New();
9601   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9602   Stage::GetCurrent().Add(actor);
9603
9604   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9605   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9606   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9607   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9608   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9609   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9610   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9611   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9612   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9613
9614   // Build the animation
9615   float durationSeconds(1.0f);
9616   float delay = 0.5f;
9617   Animation animation = Animation::New(durationSeconds);
9618
9619   KeyFrames keyFrames = KeyFrames::New();
9620   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9621   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9622   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9623
9624   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9625
9626   // Start the animation
9627   animation.Play();
9628
9629   bool signalReceived(false);
9630   AnimationFinishCheck finishCheck(signalReceived);
9631   animation.FinishedSignal().Connect(&application, finishCheck);
9632   application.SendNotification();
9633
9634   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9635   application.SendNotification();
9636   finishCheck.CheckSignalNotReceived();
9637   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9638   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9639   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9640   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9641
9642   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9643   application.SendNotification();
9644   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9645   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9646   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9647   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9648
9649   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9650   application.SendNotification();
9651   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9652   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9653   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9654   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9655
9656   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9657   application.SendNotification();
9658   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9659   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9662
9663   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9664   application.SendNotification();
9665   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9666   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9667   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9668   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9669
9670   // We did expect the animation to finish
9671
9672   finishCheck.CheckSignalReceived();
9673   END_TEST;
9674 }
9675
9676 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9677 {
9678   TestApplication application;
9679
9680   float startValue(1.0f);
9681   Actor actor = Actor::New();
9682   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9683   Stage::GetCurrent().Add(actor);
9684
9685   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9686   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9687   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9688   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9689   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9690   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9691   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9692   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9693   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9694
9695   // Build the animation
9696   float durationSeconds(1.0f);
9697   float delay = 0.5f;
9698   Animation animation = Animation::New(durationSeconds);
9699
9700   KeyFrames keyFrames = KeyFrames::New();
9701   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9702   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9703   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9704
9705   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9706
9707   // Start the animation
9708   animation.Play();
9709
9710   bool signalReceived(false);
9711   AnimationFinishCheck finishCheck(signalReceived);
9712   animation.FinishedSignal().Connect(&application, finishCheck);
9713   application.SendNotification();
9714
9715   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9716   application.SendNotification();
9717   finishCheck.CheckSignalNotReceived();
9718   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9719   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9720   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9722
9723   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9724   application.SendNotification();
9725   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9726   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9727   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9728   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9729
9730   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9731   application.SendNotification();
9732   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9733   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9734   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9735   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9736
9737   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9738   application.SendNotification();
9739   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9740   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9741   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9742   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9743
9744   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9745   application.SendNotification();
9746   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9747   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9748   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9749   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9750
9751   // We did expect the animation to finish
9752
9753   finishCheck.CheckSignalReceived();
9754   END_TEST;
9755 }
9756
9757 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9758 {
9759   TestApplication application;
9760
9761   float startValue(1.0f);
9762   float delay = 0.5f;
9763   Actor actor = Actor::New();
9764   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9765   Stage::GetCurrent().Add(actor);
9766
9767   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9771   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9772   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9773   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9774   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9775   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9776
9777   // Build the animation
9778   float durationSeconds(1.0f);
9779   Animation animation = Animation::New(durationSeconds);
9780
9781   KeyFrames keyFrames = KeyFrames::New();
9782   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9783   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9784   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9785
9786   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9787
9788   // Start the animation
9789   animation.Play();
9790
9791   bool signalReceived(false);
9792   AnimationFinishCheck finishCheck(signalReceived);
9793   animation.FinishedSignal().Connect(&application, finishCheck);
9794   application.SendNotification();
9795
9796   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9797   application.SendNotification();
9798   finishCheck.CheckSignalNotReceived();
9799   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9800   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9801   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9802   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9803
9804   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9805   application.SendNotification();
9806   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9807   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9808   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9809   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9810
9811   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9812   application.SendNotification();
9813   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9814   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9815   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9817
9818   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9819   application.SendNotification();
9820   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9821   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9824
9825   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9826   application.SendNotification();
9827   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9828   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9829   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9830   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9831
9832   // We did expect the animation to finish
9833
9834   finishCheck.CheckSignalReceived();
9835   END_TEST;
9836 }
9837
9838 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9839 {
9840   TestApplication application;
9841
9842   float startValue(1.0f);
9843   Actor actor = Actor::New();
9844   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9845   Stage::GetCurrent().Add(actor);
9846
9847   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9848   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9849   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9850   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9851   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9852   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9853   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9854   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9855   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9856
9857
9858   // Build the animation
9859   float durationSeconds(1.0f);
9860   float delay = 0.5f;
9861   Animation animation = Animation::New(durationSeconds);
9862
9863   KeyFrames keyFrames = KeyFrames::New();
9864   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9865   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9866   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9867
9868   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9869
9870   // Start the animation
9871   animation.Play();
9872
9873   bool signalReceived(false);
9874   AnimationFinishCheck finishCheck(signalReceived);
9875   animation.FinishedSignal().Connect(&application, finishCheck);
9876   application.SendNotification();
9877
9878   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9879   application.SendNotification();
9880   finishCheck.CheckSignalNotReceived();
9881   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9882   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9883   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9884   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9885
9886   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9887   application.SendNotification();
9888   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9889   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9890   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9891   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9892
9893   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9894   application.SendNotification();
9895   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9896   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9897   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9898   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9899
9900   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9901   application.SendNotification();
9902   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9903   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9904   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9906
9907   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9908   application.SendNotification();
9909   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9910   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9911   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9912   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9913
9914   // We did expect the animation to finish
9915
9916   finishCheck.CheckSignalReceived();
9917   END_TEST;
9918 }
9919
9920 int UtcDaliAnimationAnimateP(void)
9921 {
9922   TestApplication application;
9923
9924   Actor actor = Actor::New();
9925   Stage::GetCurrent().Add(actor);
9926
9927   //Build the path
9928   Vector3 position0( 30.0,  80.0,  0.0);
9929   Vector3 position1( 70.0,  120.0, 0.0);
9930   Vector3 position2( 100.0, 100.0, 0.0);
9931
9932   Dali::Path path = Dali::Path::New();
9933   path.AddPoint(position0);
9934   path.AddPoint(position1);
9935   path.AddPoint(position2);
9936
9937   //Control points for first segment
9938   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9939   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9940
9941   //Control points for second segment
9942   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9943   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9944
9945   // Build the animation
9946   float durationSeconds( 1.0f );
9947   Animation animation = Animation::New(durationSeconds);
9948   animation.Animate(actor, path, Vector3::XAXIS);
9949
9950   // Start the animation
9951   animation.Play();
9952
9953   bool signalReceived(false);
9954   AnimationFinishCheck finishCheck(signalReceived);
9955   animation.FinishedSignal().Connect(&application, finishCheck);
9956   application.SendNotification();
9957   application.Render(0);
9958   application.SendNotification();
9959   finishCheck.CheckSignalNotReceived();
9960   Vector3 position, tangent;
9961   Quaternion rotation;
9962   path.Sample( 0.0f, position, tangent );
9963   rotation = Quaternion( Vector3::XAXIS, tangent );
9964   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9965   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9966
9967   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9968   application.SendNotification();
9969   path.Sample( 0.25f, position, tangent );
9970   rotation = Quaternion( Vector3::XAXIS, tangent );
9971   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9972   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9973
9974   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9975   application.SendNotification();
9976   path.Sample( 0.5f, position, tangent );
9977   rotation = Quaternion( Vector3::XAXIS, tangent );
9978   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9979   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9980
9981   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9982   application.SendNotification();
9983   path.Sample( 0.75f, position, tangent );
9984   rotation = Quaternion( Vector3::XAXIS, tangent );
9985   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9986   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9987
9988   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9989   application.SendNotification();
9990   path.Sample( 1.0f, position, tangent );
9991   rotation = Quaternion( Vector3::XAXIS, tangent );
9992   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9993   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9994
9995   finishCheck.CheckSignalReceived();
9996   END_TEST;
9997 }
9998
9999 int UtcDaliAnimationAnimateAlphaFunctionP(void)
10000 {
10001   TestApplication application;
10002
10003   Actor actor = Actor::New();
10004   Stage::GetCurrent().Add(actor);
10005
10006   //Build the path
10007   Vector3 position0( 30.0,  80.0,  0.0);
10008   Vector3 position1( 70.0,  120.0, 0.0);
10009   Vector3 position2( 100.0, 100.0, 0.0);
10010
10011   Dali::Path path = Dali::Path::New();
10012   path.AddPoint(position0);
10013   path.AddPoint(position1);
10014   path.AddPoint(position2);
10015
10016   //Control points for first segment
10017   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10018   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10019
10020   //Control points for second segment
10021   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10022   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10023
10024   // Build the animation
10025   float durationSeconds( 1.0f );
10026   Animation animation = Animation::New(durationSeconds);
10027   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10028
10029   // Start the animation
10030   animation.Play();
10031
10032   bool signalReceived(false);
10033   AnimationFinishCheck finishCheck(signalReceived);
10034   animation.FinishedSignal().Connect(&application, finishCheck);
10035   application.SendNotification();
10036   application.Render(0);
10037   application.SendNotification();
10038   finishCheck.CheckSignalNotReceived();
10039   Vector3 position, tangent;
10040   Quaternion rotation;
10041   path.Sample( 0.0f, position, tangent );
10042   rotation = Quaternion( Vector3::XAXIS, tangent );
10043   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10044   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10045
10046   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10047   application.SendNotification();
10048   path.Sample( 0.25f, position, tangent );
10049   rotation = Quaternion( Vector3::XAXIS, tangent );
10050   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10051   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10052
10053   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10054   application.SendNotification();
10055   path.Sample( 0.5f, position, tangent );
10056   rotation = Quaternion( Vector3::XAXIS, tangent );
10057   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10058   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10059
10060   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10061   application.SendNotification();
10062   path.Sample( 0.75f, position, tangent );
10063   rotation = Quaternion( Vector3::XAXIS, tangent );
10064   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10065   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10066
10067   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10068   application.SendNotification();
10069   path.Sample( 1.0f, position, tangent );
10070   rotation = Quaternion( Vector3::XAXIS, tangent );
10071   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10072   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10073
10074   finishCheck.CheckSignalReceived();
10075   END_TEST;
10076 }
10077
10078 int UtcDaliAnimationAnimateTimePeriodP(void)
10079 {
10080   TestApplication application;
10081
10082   Actor actor = Actor::New();
10083   Stage::GetCurrent().Add(actor);
10084
10085   //Build the path
10086   Vector3 position0( 30.0,  80.0,  0.0);
10087   Vector3 position1( 70.0,  120.0, 0.0);
10088   Vector3 position2( 100.0, 100.0, 0.0);
10089
10090   Dali::Path path = Dali::Path::New();
10091   path.AddPoint(position0);
10092   path.AddPoint(position1);
10093   path.AddPoint(position2);
10094
10095   //Control points for first segment
10096   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10097   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10098
10099   //Control points for second segment
10100   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10101   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10102
10103   // Build the animation
10104   float durationSeconds( 1.0f );
10105   Animation animation = Animation::New(durationSeconds);
10106   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10107
10108   // Start the animation
10109   animation.Play();
10110
10111   bool signalReceived(false);
10112   AnimationFinishCheck finishCheck(signalReceived);
10113   animation.FinishedSignal().Connect(&application, finishCheck);
10114   application.SendNotification();
10115   application.Render(0);
10116   application.SendNotification();
10117   finishCheck.CheckSignalNotReceived();
10118   Vector3 position, tangent;
10119   Quaternion rotation;
10120   path.Sample( 0.0f, position, tangent );
10121   rotation = Quaternion( Vector3::XAXIS, tangent );
10122   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10123   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10124
10125   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10126   application.SendNotification();
10127   path.Sample( 0.25f, position, tangent );
10128   rotation = Quaternion( Vector3::XAXIS, tangent );
10129   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10130   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10131
10132   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10133   application.SendNotification();
10134   path.Sample( 0.5f, position, tangent );
10135   rotation = Quaternion( Vector3::XAXIS, tangent );
10136   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10137   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10138
10139   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10140   application.SendNotification();
10141   path.Sample( 0.75f, position, tangent );
10142   rotation = Quaternion( Vector3::XAXIS, tangent );
10143   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10144   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10145
10146   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10147   application.SendNotification();
10148   path.Sample( 1.0f, position, tangent );
10149   rotation = Quaternion( Vector3::XAXIS, tangent );
10150   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10151   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10152
10153   finishCheck.CheckSignalReceived();
10154   END_TEST;
10155 }
10156
10157 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10158 {
10159   TestApplication application;
10160
10161   Actor actor = Actor::New();
10162   Stage::GetCurrent().Add(actor);
10163
10164   //Build the path
10165   Vector3 position0( 30.0,  80.0,  0.0);
10166   Vector3 position1( 70.0,  120.0, 0.0);
10167   Vector3 position2( 100.0, 100.0, 0.0);
10168
10169   Dali::Path path = Dali::Path::New();
10170   path.AddPoint(position0);
10171   path.AddPoint(position1);
10172   path.AddPoint(position2);
10173
10174   //Control points for first segment
10175   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10176   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10177
10178   //Control points for second segment
10179   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10180   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10181
10182   // Build the animation
10183   float durationSeconds( 1.0f );
10184   Animation animation = Animation::New(durationSeconds);
10185   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10186
10187   // Start the animation
10188   animation.Play();
10189
10190   bool signalReceived(false);
10191   AnimationFinishCheck finishCheck(signalReceived);
10192   animation.FinishedSignal().Connect(&application, finishCheck);
10193   application.SendNotification();
10194   application.Render(0);
10195   application.SendNotification();
10196   finishCheck.CheckSignalNotReceived();
10197   Vector3 position, tangent;
10198   Quaternion rotation;
10199   path.Sample( 0.0f, position, tangent );
10200   rotation = Quaternion( Vector3::XAXIS, tangent );
10201   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10202   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10203
10204   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10205   application.SendNotification();
10206   path.Sample( 0.25f, position, tangent );
10207   rotation = Quaternion( Vector3::XAXIS, tangent );
10208   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10209   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10210
10211   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10212   application.SendNotification();
10213   path.Sample( 0.5f, position, tangent );
10214   rotation = Quaternion( Vector3::XAXIS, tangent );
10215   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10216   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10217
10218   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10219   application.SendNotification();
10220   path.Sample( 0.75f, position, tangent );
10221   rotation = Quaternion( Vector3::XAXIS, tangent );
10222   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10223   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10224
10225   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10226   application.SendNotification();
10227   path.Sample( 1.0f, position, tangent );
10228   rotation = Quaternion( Vector3::XAXIS, tangent );
10229   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10230   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10231
10232   finishCheck.CheckSignalReceived();
10233   END_TEST;
10234 }
10235
10236 int UtcDaliAnimationShowP(void)
10237 {
10238   TestApplication application;
10239
10240   Actor actor = Actor::New();
10241   actor.SetVisible(false);
10242   application.SendNotification();
10243   application.Render(0);
10244   DALI_TEST_CHECK( !actor.IsVisible() );
10245   Stage::GetCurrent().Add(actor);
10246
10247   // Start the animation
10248   float durationSeconds(10.0f);
10249   Animation animation = Animation::New(durationSeconds);
10250   animation.Show(actor, durationSeconds*0.5f);
10251   animation.Play();
10252
10253   bool signalReceived(false);
10254   AnimationFinishCheck finishCheck(signalReceived);
10255   animation.FinishedSignal().Connect(&application, finishCheck);
10256
10257   application.SendNotification();
10258   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10259
10260   // We didn't expect the animation to finish yet
10261   application.SendNotification();
10262   finishCheck.CheckSignalNotReceived();
10263   DALI_TEST_CHECK( !actor.IsVisible() );
10264
10265   application.SendNotification();
10266   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10267
10268   // We didn't expect the animation to finish yet
10269   application.SendNotification();
10270   finishCheck.CheckSignalNotReceived();
10271   DALI_TEST_CHECK( actor.IsVisible() );
10272
10273   application.SendNotification();
10274   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10275
10276   // We did expect the animation to finish
10277   application.SendNotification();
10278   finishCheck.CheckSignalReceived();
10279   DALI_TEST_CHECK( actor.IsVisible() );
10280   END_TEST;
10281 }
10282
10283 int UtcDaliAnimationHideP(void)
10284 {
10285   TestApplication application;
10286
10287   Actor actor = Actor::New();
10288   DALI_TEST_CHECK( actor.IsVisible() );
10289   Stage::GetCurrent().Add(actor);
10290
10291   // Start the animation
10292   float durationSeconds(10.0f);
10293   Animation animation = Animation::New(durationSeconds);
10294   animation.Hide(actor, durationSeconds*0.5f);
10295   animation.Play();
10296
10297   bool signalReceived(false);
10298   AnimationFinishCheck finishCheck(signalReceived);
10299   animation.FinishedSignal().Connect(&application, finishCheck);
10300
10301   application.SendNotification();
10302   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10303
10304   // We didn't expect the animation to finish yet
10305   application.SendNotification();
10306   finishCheck.CheckSignalNotReceived();
10307   DALI_TEST_CHECK( actor.IsVisible() );
10308
10309   application.SendNotification();
10310   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10311
10312   // We didn't expect the animation to finish yet
10313   application.SendNotification();
10314   finishCheck.CheckSignalNotReceived();
10315   DALI_TEST_CHECK( !actor.IsVisible() );
10316
10317   application.SendNotification();
10318   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10319
10320   // We did expect the animation to finish
10321   application.SendNotification();
10322   finishCheck.CheckSignalReceived();
10323   DALI_TEST_CHECK( !actor.IsVisible() );
10324   END_TEST;
10325 }
10326
10327 int UtcDaliAnimationShowHideAtEndP(void)
10328 {
10329   // Test that show/hide delay can be the same as animation duration
10330   // i.e. to show/hide at the end of the animation
10331
10332   TestApplication application;
10333
10334   Actor actor = Actor::New();
10335   DALI_TEST_CHECK( actor.IsVisible() );
10336   Stage::GetCurrent().Add(actor);
10337
10338   // Start Hide animation
10339   float durationSeconds(10.0f);
10340   Animation animation = Animation::New(durationSeconds);
10341   animation.Hide(actor, durationSeconds/*Hide at end*/);
10342   animation.Play();
10343
10344   bool signalReceived(false);
10345   AnimationFinishCheck finishCheck(signalReceived);
10346   animation.FinishedSignal().Connect(&application, finishCheck);
10347
10348   application.SendNotification();
10349   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10350
10351   // We did expect the animation to finish
10352   application.SendNotification();
10353   finishCheck.CheckSignalReceived();
10354   DALI_TEST_CHECK( !actor.IsVisible() );
10355
10356   // Start Show animation
10357   animation = Animation::New(durationSeconds);
10358   animation.Show(actor, durationSeconds/*Show at end*/);
10359   animation.FinishedSignal().Connect(&application, finishCheck);
10360   animation.Play();
10361
10362   application.SendNotification();
10363   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10364
10365   // We did expect the animation to finish
10366   application.SendNotification();
10367   finishCheck.CheckSignalReceived();
10368   DALI_TEST_CHECK( actor.IsVisible() );
10369   END_TEST;
10370 }
10371
10372 int UtcDaliKeyFramesCreateDestroyP(void)
10373 {
10374   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10375
10376   KeyFrames* keyFrames = new KeyFrames;
10377   delete keyFrames;
10378   DALI_TEST_CHECK( true );
10379   END_TEST;
10380 }
10381
10382 int UtcDaliKeyFramesDownCastP(void)
10383 {
10384   TestApplication application;
10385   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10386
10387   KeyFrames keyFrames = KeyFrames::New();
10388   BaseHandle object(keyFrames);
10389
10390   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10391   DALI_TEST_CHECK(keyFrames2);
10392
10393   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10394   DALI_TEST_CHECK(keyFrames3);
10395
10396   BaseHandle unInitializedObject;
10397   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10398   DALI_TEST_CHECK(!keyFrames4);
10399
10400   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10401   DALI_TEST_CHECK(!keyFrames5);
10402   END_TEST;
10403 }
10404
10405 int UtcDaliAnimationCreateDestroyP(void)
10406 {
10407   TestApplication application;
10408   Animation* animation = new Animation;
10409   DALI_TEST_CHECK( animation );
10410   delete animation;
10411   END_TEST;
10412 }
10413
10414 struct UpdateManagerTestConstraint
10415 {
10416   UpdateManagerTestConstraint(TestApplication& application)
10417   : mApplication(application)
10418   {
10419   }
10420
10421   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10422   {
10423     mApplication.SendNotification();  // Process events
10424   }
10425
10426   TestApplication& mApplication;
10427 };
10428
10429 int UtcDaliAnimationUpdateManagerP(void)
10430 {
10431   TestApplication application;
10432
10433   Actor actor = Actor::New();
10434   Stage::GetCurrent().Add( actor );
10435
10436   // Build the animation
10437   Animation animation = Animation::New( 0.0f );
10438
10439   bool signalReceived = false;
10440   AnimationFinishCheck finishCheck( signalReceived );
10441   animation.FinishedSignal().Connect( &application, finishCheck );
10442
10443   Vector3 startValue(1.0f, 1.0f, 1.0f);
10444   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10445   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10446   constraint.Apply();
10447
10448   // Apply animation to actor
10449   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10450   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10451
10452   animation.Play();
10453
10454   application.SendNotification();
10455   application.UpdateOnly( 16 );
10456
10457   finishCheck.CheckSignalNotReceived();
10458
10459   application.SendNotification();   // Process events
10460
10461   finishCheck.CheckSignalReceived();
10462
10463   END_TEST;
10464 }
10465
10466 int UtcDaliAnimationSignalOrderP(void)
10467 {
10468   TestApplication application;
10469
10470   Actor actor = Actor::New();
10471   Stage::GetCurrent().Add( actor );
10472
10473   // Build the animations
10474   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10475   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10476
10477   bool signal1Received = false;
10478   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10479
10480   bool signal2Received = false;
10481   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10482
10483   // Apply animations to actor
10484   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10485   animation1.Play();
10486   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10487   animation2.Play();
10488
10489   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10490   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10491
10492   application.SendNotification();
10493   application.UpdateOnly( 10 ); // 10ms progress
10494
10495   // no notifications yet
10496   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10497   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10498
10499   application.SendNotification();
10500
10501   // first completed
10502   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10503   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10504   signal1Received = false;
10505
10506   // 1st animation is complete now, do another update with no ProcessEvents in between
10507   application.UpdateOnly( 20 ); // 20ms progress
10508
10509   // ProcessEvents
10510   application.SendNotification();
10511
10512   // 2nd should complete now
10513   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10514   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10515
10516   END_TEST;
10517 }
10518
10519 int UtcDaliAnimationExtendDurationP(void)
10520 {
10521   TestApplication application;
10522
10523   Actor actor = Actor::New();
10524
10525   // Register a float property
10526   float startValue(10.0f);
10527   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10528   Stage::GetCurrent().Add(actor);
10529   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10530   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10531
10532   // Build the animation
10533   float initialDurationSeconds(1.0f);
10534   float animatorDelay = 5.0f;
10535   float animatorDurationSeconds(5.0f);
10536   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10537   Animation animation = Animation::New(initialDurationSeconds);
10538   float targetValue(30.0f);
10539   float relativeValue(targetValue - startValue);
10540
10541   animation.AnimateTo(Property(actor, index),
10542                       targetValue,
10543                       TimePeriod(animatorDelay, animatorDurationSeconds));
10544
10545   // The duration should have been extended
10546   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10547
10548   // Start the animation
10549   animation.Play();
10550
10551   bool signalReceived(false);
10552   AnimationFinishCheck finishCheck(signalReceived);
10553   animation.FinishedSignal().Connect(&application, finishCheck);
10554
10555   application.SendNotification();
10556   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10557
10558   // We didn't expect the animation to finish yet, but cached value should be the final one
10559   application.SendNotification();
10560   finishCheck.CheckSignalNotReceived();
10561   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10562   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10563
10564   application.SendNotification();
10565   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10566
10567   // We didn't expect the animation to finish yet
10568   application.SendNotification();
10569   finishCheck.CheckSignalNotReceived();
10570   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10571
10572   application.SendNotification();
10573   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10574
10575   // We did expect the animation to finish
10576   application.SendNotification();
10577   finishCheck.CheckSignalReceived();
10578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10579   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10580   END_TEST;
10581 }
10582
10583 int UtcDaliAnimationCustomIntProperty(void)
10584 {
10585   TestApplication application;
10586
10587   Actor actor = Actor::New();
10588   Stage::GetCurrent().Add(actor);
10589   int startValue(0u);
10590
10591   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10592   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10593   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10594
10595   // Build the animation
10596   float durationSeconds(1.0f);
10597   Animation animation = Animation::New(durationSeconds);
10598   animation.AnimateTo( Property(actor, index), 20 );
10599
10600   // Start the animation
10601   animation.Play();
10602
10603   // Target value should be retrievable straight away
10604   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10605
10606   bool signalReceived(false);
10607   AnimationFinishCheck finishCheck(signalReceived);
10608   animation.FinishedSignal().Connect(&application, finishCheck);
10609
10610   application.SendNotification();
10611   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10612
10613   // We didn't expect the animation to finish yet
10614   application.SendNotification();
10615   finishCheck.CheckSignalNotReceived();
10616   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10617
10618   application.SendNotification();
10619   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10620
10621   // We did expect the animation to finish
10622   application.SendNotification();
10623   finishCheck.CheckSignalReceived();
10624   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10625   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10626   END_TEST;
10627 }
10628
10629 int UtcDaliAnimationDuration(void)
10630 {
10631   TestApplication application;
10632
10633   Actor actor = Actor::New();
10634   Stage::GetCurrent().Add(actor);
10635
10636   Animation animation = Animation::New( 0.0f );
10637   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10638
10639   // The animation duration should automatically increase depending on the animator time period
10640
10641   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10642   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10643
10644   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10645   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10646
10647   END_TEST;
10648 }
10649
10650 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10651 {
10652   TestApplication application;
10653
10654   Actor actor = Actor::New();
10655
10656   // Register an integer property
10657   int startValue(1);
10658   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10659   Stage::GetCurrent().Add(actor);
10660   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10661
10662   try
10663   {
10664     // Build the animation
10665     Animation animation = Animation::New( 2.0f );
10666     std::string relativeValue = "relative string";
10667     animation.AnimateBy( Property(actor, index), relativeValue );
10668     tet_result(TET_FAIL);
10669   }
10670   catch ( Dali::DaliException& e )
10671   {
10672     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10673   }
10674
10675
10676   END_TEST;
10677 }
10678
10679
10680 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10681 {
10682   TestApplication application;
10683
10684   Actor actor = Actor::New();
10685
10686   // Register an integer property
10687   int startValue(1);
10688   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10689   Stage::GetCurrent().Add(actor);
10690   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10691
10692   try
10693   {
10694     // Build the animation
10695     Animation animation = Animation::New( 2.0f );
10696     std::string relativeValue = "relative string";
10697     animation.AnimateTo( Property(actor, index), relativeValue );
10698
10699     tet_result(TET_FAIL);
10700   }
10701   catch ( Dali::DaliException& e )
10702   {
10703    DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10704   }
10705
10706   END_TEST;
10707 }
10708
10709 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10710 {
10711   TestApplication application;
10712
10713   Actor actor = Actor::New();
10714
10715   // Register an integer property
10716   int startValue(1);
10717   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10718   Stage::GetCurrent().Add(actor);
10719   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10720
10721   try
10722   {
10723     // Build the animation
10724     KeyFrames keyFrames = KeyFrames::New();
10725     keyFrames.Add( 0.0f, std::string("relative string1") );
10726     keyFrames.Add( 1.0f, std::string("relative string2") );
10727     // no need to really create the animation as keyframes do the check
10728
10729     tet_result(TET_FAIL);
10730   }
10731   catch ( Dali::DaliException& e )
10732   {
10733     DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
10734   }
10735
10736   END_TEST;
10737 }
10738
10739 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10740 {
10741   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10742
10743   TestApplication application;
10744
10745   tet_infoline("Set initial position and set up animation to re-position actor");
10746
10747   Actor actor = Actor::New();
10748   Stage::GetCurrent().Add(actor);
10749   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10750   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10751
10752   // Build the animation
10753   Animation animation = Animation::New(2.0f);
10754
10755   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10756   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10757   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10758
10759   tet_infoline("Set target position in animation without intiating play");
10760
10761   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10762   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10763
10764   application.SendNotification();
10765   application.Render();
10766
10767   tet_infoline("Ensure position of actor is still at intial value");
10768
10769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10771   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10772
10773   tet_infoline("Play animation and ensure actor position is now target");
10774
10775   animation.Play();
10776   application.SendNotification();
10777   application.Render(1000u);
10778
10779   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10780
10781   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10782   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10783   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10784
10785   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10786
10787   application.Render(2000u);
10788
10789   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10790
10791   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10792   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10793   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10794
10795   END_TEST;
10796 }
10797
10798 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10799 {
10800   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10801
10802   TestApplication application;
10803
10804   std::vector<Vector3> targetPositions;
10805
10806   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10807   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10808   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10809
10810   tet_infoline("Set initial position and set up animation to re-position actor");
10811
10812   Actor actor = Actor::New();
10813   Stage::GetCurrent().Add(actor);
10814   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10815   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10816
10817   // Build the animation
10818   Animation animation = Animation::New(2.0f);
10819
10820   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10821   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10822   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10823
10824   tet_infoline("Set target position in animation without intiating play");
10825
10826   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10827   {
10828     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10829   }
10830
10831   application.SendNotification();
10832   application.Render();
10833
10834   tet_infoline("Ensure position of actor is still at intial value");
10835
10836   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10837   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10838   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10839
10840   tet_infoline("Play animation and ensure actor position is now target");
10841
10842   animation.Play();
10843   application.SendNotification();
10844   application.Render(1000u);
10845
10846   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10847
10848   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10849   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10850   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10851
10852   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10853
10854   application.Render(2000u);
10855
10856   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10857
10858   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10859   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10860   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10861
10862   END_TEST;
10863 }
10864
10865 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10866 {
10867   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even with mulitple animators of different Property Indexes");
10868
10869   TestApplication application;
10870
10871   std::vector<Vector3> targetSizes;
10872   std::vector<Vector3> targetPositions;
10873
10874   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10875   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10876
10877   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10878
10879   tet_infoline("Set initial position and set up animation to re-position actor");
10880
10881   Actor actor = Actor::New();
10882   Stage::GetCurrent().Add(actor);
10883   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10884   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10885
10886   actor.SetProperty( Actor::Property::SIZE, initialSize );
10887   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10888
10889   // Build the animation
10890   Animation animation = Animation::New(2.0f);
10891
10892   tet_infoline("Set target size in animation without intiating play");
10893   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10894   tet_infoline("Set target position in animation without intiating play");
10895   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10896   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10897
10898   application.SendNotification();
10899   application.Render();
10900
10901   tet_infoline("Ensure position of actor is still at intial size and position");
10902
10903   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10904   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10905   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10906
10907   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10908   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10909   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10910
10911   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10912
10913   animation.Play();
10914   application.SendNotification();
10915   application.Render(2000u);
10916
10917   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10918
10919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10920   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10921   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10922
10923   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10924   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10925   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10926
10927   END_TEST;
10928 }
10929
10930 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10931 {
10932   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10933
10934   TestApplication application;
10935
10936   std::vector<Vector3> targetSizes;
10937   std::vector<float> targetColors;
10938
10939   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10940   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10941
10942   targetColors.push_back( 1.0f );
10943
10944   tet_infoline("Set initial position and set up animation to re-position actor");
10945
10946   Actor actor = Actor::New();
10947   Stage::GetCurrent().Add(actor);
10948   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10949
10950   actor.SetProperty( Actor::Property::SIZE, initialSize );
10951
10952   // Build the animation
10953   Animation animation = Animation::New(2.0f);
10954
10955   tet_infoline("Set target size in animation without initiating play");
10956   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10957   tet_infoline("Set target position in animation without intiating play");
10958   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
10959   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10960
10961   application.SendNotification();
10962   application.Render();
10963
10964   tet_infoline("Ensure position of actor is still at initial size and position");
10965
10966   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10967   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10968   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10969
10970   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10971
10972   animation.Play();
10973   application.SendNotification();
10974   application.Render(2000u);
10975
10976   tet_infoline("Ensure position and size of actor is at target value when animation playing");
10977
10978   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10979   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10980   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10981
10982   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
10983
10984   END_TEST;
10985 }
10986
10987 int UtcDaliAnimationTimePeriodOrder(void)
10988 {
10989   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
10990
10991   TestApplication application;
10992
10993   Actor actor = Actor::New();
10994   Stage::GetCurrent().Add( actor );
10995
10996   application.SendNotification();
10997   application.Render();
10998
10999   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11000   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11001   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11002   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11003   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11004
11005   //////////////////////////////////////////////////////////////////////////////////
11006
11007   tet_infoline( "With two AnimateTo calls" );
11008
11009   Animation animation = Animation::New( 0.0f );
11010   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11011   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11012   animation.Play();
11013
11014   tet_infoline( "The target position should change instantly" );
11015   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11016   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11017
11018   application.SendNotification();
11019   application.Render(5000); // After the animation is complete
11020
11021   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11022   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11023   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11024
11025   //////////////////////////////////////////////////////////////////////////////////
11026
11027   tet_infoline( "Same animation again but in a different order - should yield the same result" );
11028
11029   actor.SetX( 0.0f );
11030   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11031   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11032
11033   application.SendNotification();
11034   application.Render();
11035
11036   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11037   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11038   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11039
11040   animation = Animation::New( 0.0f );
11041   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11042   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11043   animation.Play();
11044
11045   tet_infoline( "The target position should change instantly" );
11046   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11047   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11048
11049   application.SendNotification();
11050   application.Render(5000); // After the animation is complete
11051
11052   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11053   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11054   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11055
11056   END_TEST;
11057 }
11058
11059 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11060 {
11061   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place with several AnimateTo calls" );
11062
11063   TestApplication application;
11064
11065   Actor actor = Actor::New();
11066   Stage::GetCurrent().Add( actor );
11067
11068   application.SendNotification();
11069   application.Render();
11070
11071   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11072   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11073   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11074   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11075   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11076
11077   //////////////////////////////////////////////////////////////////////////////////
11078
11079   tet_infoline( "" );
11080
11081   Animation animation = Animation::New( 0.0f );
11082   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11083   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11084   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11085   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11086   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11087   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11088   animation.Play();
11089
11090   tet_infoline( "The target position should change instantly" );
11091   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11092   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11093
11094   application.SendNotification();
11095   application.Render(14000); // After the animation is complete
11096
11097   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11098   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11099   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11100
11101   //////////////////////////////////////////////////////////////////////////////////
11102
11103   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11104
11105   actor.SetX( 0.0f );
11106
11107   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11108   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11109
11110   application.SendNotification();
11111   application.Render();
11112
11113   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11114   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11115   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11116
11117   animation = Animation::New( 0.0f );
11118   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11119   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11120   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11121   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11122   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11123   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11124   animation.Play();
11125
11126   tet_infoline( "The target position should change instantly" );
11127   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11128   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11129
11130   application.SendNotification();
11131   application.Render(14000); // After the animation is complete
11132
11133   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11134   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11135   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11136
11137   END_TEST;
11138 }
11139
11140 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11141 {
11142   TestApplication application;
11143
11144   int startValue(1);
11145   Actor actor = Actor::New();
11146   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11147   Stage::GetCurrent().Add(actor);
11148
11149   application.Render();
11150   application.SendNotification();
11151
11152   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11153
11154   // Build the animation
11155   float durationSeconds(1.0f);
11156   Animation animation = Animation::New(durationSeconds);
11157
11158   KeyFrames keyFrames = KeyFrames::New();
11159   keyFrames.Add(0.0f, 10);
11160   keyFrames.Add(0.2f, 20);
11161   keyFrames.Add(0.4f, 30);
11162   keyFrames.Add(0.6f, 40);
11163   keyFrames.Add(0.8f, 50);
11164   keyFrames.Add(1.0f, 60);
11165
11166   animation.AnimateBetween( Property(actor, index ), keyFrames );
11167
11168   // Start the animation
11169   animation.Play();
11170
11171   // Target value should change to the last key-frame's value straight away
11172   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11173
11174   END_TEST;
11175 }
11176
11177 int UtcDaliAnimationAnimateBetweenVector2P(void)
11178 {
11179   TestApplication application;
11180
11181   Vector2 startValue( 10.0f, 20.0f );
11182   Actor actor = Actor::New();
11183   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11184   Stage::GetCurrent().Add(actor);
11185
11186   application.Render();
11187   application.SendNotification();
11188
11189   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11190
11191   // Build the animation
11192   float durationSeconds(1.0f);
11193   Animation animation = Animation::New(durationSeconds);
11194
11195   KeyFrames keyFrames = KeyFrames::New();
11196   keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11197   keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11198   keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11199   keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11200   keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11201   keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11202
11203   animation.AnimateBetween( Property(actor, index ), keyFrames );
11204
11205   // Start the animation
11206   animation.Play();
11207
11208   // Target value should change to the last key-frame's value straight away
11209   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11210
11211   END_TEST;
11212 }