Merge "(Animation) Ensure AnimateBetween updates the cached event-side properties...
[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   // Build the animation
2366   float durationSeconds(1.0f);
2367   Animation animation = Animation::New(durationSeconds);
2368   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2369   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2370
2371   // Start the animation from 40% progress
2372   animation.PlayFrom( 0.4f );
2373
2374   bool signalReceived(false);
2375   AnimationFinishCheck finishCheck(signalReceived);
2376   animation.FinishedSignal().Connect(&application, finishCheck);
2377
2378   application.SendNotification();
2379   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2380
2381   // We didn't expect the animation to finish yet
2382   application.SendNotification();
2383   finishCheck.CheckSignalNotReceived();
2384   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2385
2386   animation.Play(); // Test that calling play has no effect, when animation is already playing
2387   application.SendNotification();
2388   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2389
2390   // We didn't expect the animation to finish yet
2391   application.SendNotification();
2392   finishCheck.CheckSignalNotReceived();
2393   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2394
2395   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2396   // We did expect the animation to finish
2397   application.SendNotification();
2398   finishCheck.CheckSignalReceived();
2399   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2400
2401   // Check that nothing has changed after a couple of buffer swaps
2402   application.Render(0);
2403   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2404   application.Render(0);
2405   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2406   END_TEST;
2407 }
2408
2409 int UtcDaliAnimationPlayFromN(void)
2410 {
2411   TestApplication application;
2412
2413   Actor actor = Actor::New();
2414   Stage::GetCurrent().Add(actor);
2415
2416   // Build the animation
2417   float durationSeconds(1.0f);
2418   Animation animation = Animation::New(durationSeconds);
2419   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2420   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2421
2422   //PlayFrom with an argument outside the range [0..1] will be ignored
2423   animation.PlayFrom(-1.0f);
2424   application.SendNotification();
2425   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2426
2427   animation.PlayFrom(100.0f);
2428   application.SendNotification();
2429   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2430   END_TEST;
2431 }
2432
2433 int UtcDaliAnimationPauseP(void)
2434 {
2435   TestApplication application;
2436
2437   Actor actor = Actor::New();
2438   Stage::GetCurrent().Add(actor);
2439
2440   // Build the animation
2441   float durationSeconds(1.0f);
2442   Animation animation = Animation::New(durationSeconds);
2443   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2444   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2445
2446   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2447
2448   // Start the animation
2449   animation.Play();
2450
2451   bool signalReceived(false);
2452   AnimationFinishCheck finishCheck(signalReceived);
2453   animation.FinishedSignal().Connect(&application, finishCheck);
2454
2455   application.SendNotification();
2456   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2457
2458   // We didn't expect the animation to finish yet
2459   application.SendNotification();
2460   finishCheck.CheckSignalNotReceived();
2461   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2462
2463   // Pause the animation
2464   animation.Pause();
2465   application.SendNotification();
2466
2467   // Loop 5 times
2468   for (int i=0; i<5; ++i)
2469   {
2470     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2471
2472     // We didn't expect the animation to finish yet
2473     application.SendNotification();
2474     finishCheck.CheckSignalNotReceived();
2475     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2476   }
2477
2478   // Keep going
2479   animation.Play();
2480   application.SendNotification();
2481   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2482
2483   // We didn't expect the animation to finish yet
2484   application.SendNotification();
2485   finishCheck.CheckSignalNotReceived();
2486
2487   application.SendNotification();
2488   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2489
2490   // We did expect the animation to finish
2491   application.SendNotification();
2492   finishCheck.CheckSignalReceived();
2493   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2494
2495   // Check that nothing has changed after a couple of buffer swaps
2496   application.Render(0);
2497   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2498   application.Render(0);
2499   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2500   END_TEST;
2501 }
2502
2503
2504 int UtcDaliAnimationGetStateP(void)
2505 {
2506   TestApplication application;
2507
2508   Actor actor = Actor::New();
2509   Stage::GetCurrent().Add(actor);
2510
2511   // Build the animation
2512   float durationSeconds(1.0f);
2513   Animation animation = Animation::New(durationSeconds);
2514   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2515   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2516   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2517
2518   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2519
2520   // Start the animation
2521   animation.Play();
2522
2523   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2524
2525   bool signalReceived(false);
2526   AnimationFinishCheck finishCheck(signalReceived);
2527   animation.FinishedSignal().Connect(&application, finishCheck);
2528
2529   application.SendNotification();
2530   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2531
2532   // We didn't expect the animation to finish yet
2533   application.SendNotification();
2534   finishCheck.CheckSignalNotReceived();
2535   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2536   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2537
2538   // Pause the animation
2539   animation.Pause();
2540   DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2541   application.SendNotification();
2542   application.Render(0.f);
2543
2544   // Loop 5 times
2545   for (int i=0; i<5; ++i)
2546   {
2547     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2548
2549     // We didn't expect the animation to finish yet
2550     application.SendNotification();
2551     finishCheck.CheckSignalNotReceived();
2552     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2553     DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2554   }
2555
2556   // Keep going
2557   finishCheck.Reset();
2558   animation.Play();
2559   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2560   application.SendNotification();
2561   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2562   // We didn't expect the animation to finish yet
2563   application.SendNotification();
2564   finishCheck.CheckSignalNotReceived();
2565   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2566
2567   application.SendNotification();
2568   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2569
2570   // We did expect the animation to finish
2571   application.SendNotification();
2572   finishCheck.CheckSignalReceived();
2573   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2574   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2575
2576   // Check that nothing has changed after a couple of buffer swaps
2577   application.Render(0);
2578   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2579   application.Render(0);
2580   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2581   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2582
2583   // re-play
2584   finishCheck.Reset();
2585   animation.Play();
2586   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2587   application.SendNotification();
2588   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2589   application.SendNotification();
2590   finishCheck.CheckSignalNotReceived();
2591   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2592
2593
2594   END_TEST;
2595 }
2596
2597 int UtcDaliAnimationStopP(void)
2598 {
2599   TestApplication application;
2600
2601   Actor actor = Actor::New();
2602   Stage::GetCurrent().Add(actor);
2603
2604   // Build the animation
2605   float durationSeconds(1.0f);
2606   Animation animation = Animation::New(durationSeconds);
2607   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2608   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2609
2610   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2611
2612   // Start the animation
2613   animation.Play();
2614
2615   bool signalReceived(false);
2616   AnimationFinishCheck finishCheck(signalReceived);
2617   animation.FinishedSignal().Connect(&application, finishCheck);
2618
2619   application.SendNotification();
2620   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2621
2622   // We didn't expect the animation to finish yet
2623   application.SendNotification();
2624   finishCheck.CheckSignalNotReceived();
2625   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2626
2627   // Stop the animation
2628   animation.Stop();
2629   application.SendNotification();
2630
2631   // Loop 5 times
2632   for (int i=0; i<5; ++i)
2633   {
2634     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2635
2636     // We did expect the animation to finish
2637     application.SendNotification();
2638     finishCheck.CheckSignalReceived();
2639     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2640   }
2641   END_TEST;
2642 }
2643
2644 int UtcDaliAnimationStopSetPositionP(void)
2645 {
2646   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2647   // i.e. to check that the animation does not interfere with the position set.
2648
2649   TestApplication application;
2650
2651   Actor actor = Actor::New();
2652   Stage::GetCurrent().Add(actor);
2653
2654   // Build the animation
2655   float durationSeconds(1.0f);
2656   Animation animation = Animation::New(durationSeconds);
2657   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2658   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2659
2660   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2661
2662   // Start the animation
2663   animation.Play();
2664
2665   bool signalReceived(false);
2666   AnimationFinishCheck finishCheck(signalReceived);
2667   animation.FinishedSignal().Connect(&application, finishCheck);
2668
2669   application.SendNotification();
2670   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2671
2672   // We didn't expect the animation to finish yet
2673   application.SendNotification();
2674   finishCheck.CheckSignalNotReceived();
2675   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2676
2677   // Stop the animation
2678   animation.Stop();
2679   Vector3 positionSet(2.0f, 3.0f, 4.0f);
2680   actor.SetPosition(positionSet);
2681   application.SendNotification();
2682
2683   // Loop 5 times
2684   for (int i=0; i<5; ++i)
2685   {
2686     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2687
2688     // We did expect the animation to finish
2689     application.SendNotification();
2690     finishCheck.CheckSignalReceived();
2691     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2692   }
2693   END_TEST;
2694 }
2695
2696 int UtcDaliAnimationClearP(void)
2697 {
2698   TestApplication application;
2699
2700   Actor actor = Actor::New();
2701   Stage::GetCurrent().Add(actor);
2702
2703   // Build the animation
2704   float durationSeconds(1.0f);
2705   Animation animation = Animation::New(durationSeconds);
2706   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2707   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2708
2709   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2710
2711   // Start the animation
2712   animation.Play();
2713
2714   bool signalReceived(false);
2715   AnimationFinishCheck finishCheck(signalReceived);
2716   animation.FinishedSignal().Connect(&application, finishCheck);
2717
2718   application.SendNotification();
2719   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2720
2721   // We didn't expect the animation to finish yet
2722   application.SendNotification();
2723   finishCheck.CheckSignalNotReceived();
2724   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2725
2726   // Clear the animation
2727   animation.Clear();
2728   application.SendNotification();
2729
2730   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2731
2732   // We don't expect the animation to finish now
2733   application.SendNotification();
2734   finishCheck.CheckSignalNotReceived();
2735   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2736
2737   // Restart as a scale animation; this should not move the actor's position
2738   finishCheck.Reset();
2739   actor.SetPosition(Vector3::ZERO);
2740   Vector3 targetScale(3.0f, 3.0f, 3.0f);
2741   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2742   animation.Play();
2743
2744   application.SendNotification();
2745   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2746
2747   // We didn't expect the animation to finish yet
2748   application.SendNotification();
2749   finishCheck.CheckSignalNotReceived();
2750   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2751   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2752
2753   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2754
2755   // We did expect the animation to finish
2756   application.SendNotification();
2757   finishCheck.CheckSignalReceived();
2758   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2759   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2760   END_TEST;
2761 }
2762
2763 int UtcDaliAnimationFinishedSignalP(void)
2764 {
2765   TestApplication application;
2766
2767   // Start the empty animation
2768   float durationSeconds(1.0f);
2769   Animation animation = Animation::New(durationSeconds);
2770   animation.Play();
2771
2772   bool signalReceived(false);
2773   AnimationFinishCheck finishCheck(signalReceived);
2774   animation.FinishedSignal().Connect(&application, finishCheck);
2775
2776   application.SendNotification();
2777   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2778
2779   // We did expect the animation to finish
2780   application.SendNotification();
2781   finishCheck.CheckSignalReceived();
2782   END_TEST;
2783 }
2784
2785 int UtcDaliAnimationAnimateByBooleanP(void)
2786 {
2787   TestApplication application;
2788
2789   Actor actor = Actor::New();
2790
2791   // Register a boolean property
2792   bool startValue(false);
2793   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2794   Stage::GetCurrent().Add(actor);
2795   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2796   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2797
2798   // Build the animation
2799   float durationSeconds(2.0f);
2800   Animation animation = Animation::New(durationSeconds);
2801   const bool relativeValue(true);
2802   const bool finalValue( false || relativeValue );
2803   animation.AnimateBy(Property(actor, index), relativeValue);
2804
2805   // Start the animation
2806   animation.Play();
2807
2808   // Target value should be retrievable straight away
2809   DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
2810
2811   bool signalReceived(false);
2812   AnimationFinishCheck finishCheck(signalReceived);
2813   animation.FinishedSignal().Connect(&application, finishCheck);
2814
2815   application.SendNotification();
2816   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2817
2818   // We didn't expect the animation to finish yet
2819   application.SendNotification();
2820   finishCheck.CheckSignalNotReceived();
2821   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2822
2823   application.SendNotification();
2824   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2825
2826   // We did expect the animation to finish
2827   application.SendNotification();
2828   finishCheck.CheckSignalReceived();
2829   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2830
2831   // Check that nothing has changed after a couple of buffer swaps
2832   application.Render(0);
2833   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2834   application.Render(0);
2835   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2836
2837   // Repeat with relative value "false" - this should be an NOOP
2838   animation = Animation::New(durationSeconds);
2839   bool noOpValue(false);
2840   animation.AnimateBy(Property(actor, index), noOpValue);
2841
2842   // Start the animation
2843   animation.Play();
2844
2845   finishCheck.Reset();
2846   animation.FinishedSignal().Connect(&application, finishCheck);
2847
2848   application.SendNotification();
2849   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2850
2851   // We didn't expect the animation to finish yet
2852   application.SendNotification();
2853   finishCheck.CheckSignalNotReceived();
2854   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2855
2856   application.SendNotification();
2857   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2858
2859   // We did expect the animation to finish
2860   application.SendNotification();
2861   finishCheck.CheckSignalReceived();
2862   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2863
2864   // Check that nothing has changed after a couple of buffer swaps
2865   application.Render(0);
2866   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2867   application.Render(0);
2868   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2869   END_TEST;
2870 }
2871
2872 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
2873 {
2874   TestApplication application;
2875
2876   Actor actor = Actor::New();
2877
2878   // Register a boolean property
2879   bool startValue(false);
2880   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2881   Stage::GetCurrent().Add(actor);
2882   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2883   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2884
2885   // Build the animation
2886   float durationSeconds(2.0f);
2887   Animation animation = Animation::New(durationSeconds);
2888   bool relativeValue(true);
2889   bool finalValue( false || relativeValue );
2890   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2891
2892   // Start the animation
2893   animation.Play();
2894
2895   bool signalReceived(false);
2896   AnimationFinishCheck finishCheck(signalReceived);
2897   animation.FinishedSignal().Connect(&application, finishCheck);
2898
2899   application.SendNotification();
2900   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2901
2902   // We didn't expect the animation to finish yet
2903   application.SendNotification();
2904   finishCheck.CheckSignalNotReceived();
2905   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2906
2907   application.SendNotification();
2908   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2909
2910   // We did expect the animation to finish
2911   application.SendNotification();
2912   finishCheck.CheckSignalReceived();
2913   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2914
2915   // Check that nothing has changed after a couple of buffer swaps
2916   application.Render(0);
2917   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2918   application.Render(0);
2919   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2920
2921   // Repeat with relative value "false" - this should be an NOOP
2922   animation = Animation::New(durationSeconds);
2923   bool noOpValue(false);
2924   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2925
2926   // Start the animation
2927   animation.Play();
2928
2929   finishCheck.Reset();
2930   animation.FinishedSignal().Connect(&application, finishCheck);
2931
2932   application.SendNotification();
2933   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2934
2935   // We didn't expect the animation to finish yet
2936   application.SendNotification();
2937   finishCheck.CheckSignalNotReceived();
2938   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2939
2940   application.SendNotification();
2941   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2942
2943   // We did expect the animation to finish
2944   application.SendNotification();
2945   finishCheck.CheckSignalReceived();
2946   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2947   END_TEST;
2948 }
2949
2950 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
2951 {
2952   TestApplication application;
2953
2954   Actor actor = Actor::New();
2955
2956   // Register a boolean property
2957   bool startValue(false);
2958   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2959   Stage::GetCurrent().Add(actor);
2960   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2961   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2962
2963   // Build the animation
2964   float durationSeconds(2.0f);
2965   Animation animation = Animation::New(durationSeconds);
2966   bool relativeValue(true);
2967   bool finalValue( false || relativeValue );
2968   float animatorDurationSeconds(durationSeconds * 0.5f);
2969   animation.AnimateBy( Property(actor, index),
2970                        relativeValue,
2971                        TimePeriod( animatorDurationSeconds ) );
2972
2973   // Start the animation
2974   animation.Play();
2975
2976   bool signalReceived(false);
2977   AnimationFinishCheck finishCheck(signalReceived);
2978   animation.FinishedSignal().Connect(&application, finishCheck);
2979
2980   application.SendNotification();
2981   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2982
2983   // We didn't expect the animation to finish yet
2984   application.SendNotification();
2985   finishCheck.CheckSignalNotReceived();
2986   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2987
2988   application.SendNotification();
2989   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2990
2991   // We didn't expect the animation to finish yet...
2992   application.SendNotification();
2993   finishCheck.CheckSignalNotReceived();
2994
2995   // ...however we should have reached the final value
2996   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2997
2998   application.SendNotification();
2999   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3000
3001   // We did expect the animation to finish
3002   application.SendNotification();
3003   finishCheck.CheckSignalReceived();
3004   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3005
3006   // Check that nothing has changed after a couple of buffer swaps
3007   application.Render(0);
3008   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3009   application.Render(0);
3010   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3011   END_TEST;
3012 }
3013
3014 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3015 {
3016   TestApplication application;
3017
3018   Actor actor = Actor::New();
3019
3020   // Register a boolean property
3021   bool startValue(false);
3022   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3023   Stage::GetCurrent().Add(actor);
3024   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3025   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3026
3027   // Build the animation
3028   float durationSeconds(2.0f);
3029   Animation animation = Animation::New(durationSeconds);
3030   bool relativeValue(true);
3031   bool finalValue( false || relativeValue );
3032   float animatorDurationSeconds(durationSeconds * 0.5f);
3033   animation.AnimateBy( Property(actor, index),
3034                        relativeValue,
3035                        AlphaFunction::EASE_IN_OUT,
3036                        TimePeriod( animatorDurationSeconds ) );
3037
3038   // Start the animation
3039   animation.Play();
3040
3041   bool signalReceived(false);
3042   AnimationFinishCheck finishCheck(signalReceived);
3043   animation.FinishedSignal().Connect(&application, finishCheck);
3044
3045   application.SendNotification();
3046   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3047
3048   // We didn't expect the animation to finish yet
3049   application.SendNotification();
3050   finishCheck.CheckSignalNotReceived();
3051   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3052
3053   application.SendNotification();
3054   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3055
3056   // We didn't expect the animation to finish yet...
3057   application.SendNotification();
3058   finishCheck.CheckSignalNotReceived();
3059
3060   // ...however we should have reached the final value
3061   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3062
3063   application.SendNotification();
3064   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3065
3066   // We did expect the animation to finish
3067   application.SendNotification();
3068   finishCheck.CheckSignalReceived();
3069   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3070
3071   // Check that nothing has changed after a couple of buffer swaps
3072   application.Render(0);
3073   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3074   application.Render(0);
3075   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3076   END_TEST;
3077 }
3078
3079 int UtcDaliAnimationAnimateByFloatP(void)
3080 {
3081   TestApplication application;
3082
3083   Actor actor = Actor::New();
3084
3085   // Register a float property
3086   float startValue(10.0f);
3087   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3088   Stage::GetCurrent().Add(actor);
3089   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3090   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3091
3092   // Build the animation
3093   float durationSeconds(2.0f);
3094   Animation animation = Animation::New(durationSeconds);
3095   float targetValue(50.0f);
3096   float relativeValue(targetValue - startValue);
3097   animation.AnimateBy(Property(actor, index), relativeValue);
3098
3099   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3100
3101   // Start the animation
3102   animation.Play();
3103
3104   // Target value should be retrievable straight away
3105   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
3106
3107   bool signalReceived(false);
3108   AnimationFinishCheck finishCheck(signalReceived);
3109   animation.FinishedSignal().Connect(&application, finishCheck);
3110
3111   application.SendNotification();
3112   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3113
3114   // We didn't expect the animation to finish yet
3115   application.SendNotification();
3116   finishCheck.CheckSignalNotReceived();
3117   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3118
3119   application.SendNotification();
3120   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3121
3122   // We did expect the animation to finish
3123   application.SendNotification();
3124   finishCheck.CheckSignalReceived();
3125   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3126
3127   // Check that nothing has changed after a couple of buffer swaps
3128   application.Render(0);
3129   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3130   application.Render(0);
3131   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3132   END_TEST;
3133 }
3134
3135 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3136 {
3137   TestApplication application;
3138
3139   Actor actor = Actor::New();
3140
3141   // Register a float property
3142   float startValue(10.0f);
3143   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3144   Stage::GetCurrent().Add(actor);
3145   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3146   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3147
3148   // Build the animation
3149   float durationSeconds(1.0f);
3150   Animation animation = Animation::New(durationSeconds);
3151   float targetValue(90.0f);
3152   float relativeValue(targetValue - startValue);
3153   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3154
3155   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3156
3157   // Start the animation
3158   animation.Play();
3159
3160   bool signalReceived(false);
3161   AnimationFinishCheck finishCheck(signalReceived);
3162   animation.FinishedSignal().Connect(&application, finishCheck);
3163
3164   application.SendNotification();
3165   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3166
3167   // We didn't expect the animation to finish yet
3168   application.SendNotification();
3169   finishCheck.CheckSignalNotReceived();
3170
3171   // The position should have moved more, than with a linear alpha function
3172   float current( actor.GetCurrentProperty< float >( index ) );
3173   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3174
3175   application.SendNotification();
3176   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3177
3178   // We did expect the animation to finish
3179   application.SendNotification();
3180   finishCheck.CheckSignalReceived();
3181   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3182
3183   // Check that nothing has changed after a couple of buffer swaps
3184   application.Render(0);
3185   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3186   application.Render(0);
3187   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3188   END_TEST;
3189 }
3190
3191 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3192 {
3193   TestApplication application;
3194
3195   Actor actor = Actor::New();
3196
3197   // Register a float property
3198   float startValue(10.0f);
3199   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3200   Stage::GetCurrent().Add(actor);
3201   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3202   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3203
3204   // Build the animation
3205   float durationSeconds(1.0f);
3206   Animation animation = Animation::New(durationSeconds);
3207   float targetValue(30.0f);
3208   float relativeValue(targetValue - startValue);
3209   float delay = 0.5f;
3210   animation.AnimateBy(Property(actor, index),
3211                       relativeValue,
3212                       TimePeriod(delay, durationSeconds - delay));
3213
3214   // Start the animation
3215   animation.Play();
3216
3217   bool signalReceived(false);
3218   AnimationFinishCheck finishCheck(signalReceived);
3219   animation.FinishedSignal().Connect(&application, finishCheck);
3220
3221   application.SendNotification();
3222   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3223
3224   // We didn't expect the animation to finish yet
3225   application.SendNotification();
3226   finishCheck.CheckSignalNotReceived();
3227   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3228
3229   application.SendNotification();
3230   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3231
3232   // We didn't expect the animation to finish yet
3233   application.SendNotification();
3234   finishCheck.CheckSignalNotReceived();
3235   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3236
3237   application.SendNotification();
3238   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3239
3240   // We did expect the animation to finish
3241   application.SendNotification();
3242   finishCheck.CheckSignalReceived();
3243   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3244
3245   // Check that nothing has changed after a couple of buffer swaps
3246   application.Render(0);
3247   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3248   application.Render(0);
3249   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3250   END_TEST;
3251 }
3252
3253 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3254 {
3255   TestApplication application;
3256
3257   Actor actor = Actor::New();
3258
3259   // Register a float property
3260   float startValue(10.0f);
3261   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3262   Stage::GetCurrent().Add(actor);
3263   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3264   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3265
3266   // Build the animation
3267   float durationSeconds(1.0f);
3268   Animation animation = Animation::New(durationSeconds);
3269   float targetValue(30.0f);
3270   float relativeValue(targetValue - startValue);
3271   float delay = 0.5f;
3272   animation.AnimateBy(Property(actor, index),
3273                       relativeValue,
3274                       AlphaFunction::LINEAR,
3275                       TimePeriod(delay, durationSeconds - delay));
3276
3277   // Start the animation
3278   animation.Play();
3279
3280   bool signalReceived(false);
3281   AnimationFinishCheck finishCheck(signalReceived);
3282   animation.FinishedSignal().Connect(&application, finishCheck);
3283
3284   application.SendNotification();
3285   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3286
3287   // We didn't expect the animation to finish yet
3288   application.SendNotification();
3289   finishCheck.CheckSignalNotReceived();
3290   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3291
3292   application.SendNotification();
3293   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3294
3295   // We didn't expect the animation to finish yet
3296   application.SendNotification();
3297   finishCheck.CheckSignalNotReceived();
3298   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3299
3300   application.SendNotification();
3301   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3302
3303   // We did expect the animation to finish
3304   application.SendNotification();
3305   finishCheck.CheckSignalReceived();
3306   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3307
3308   // Check that nothing has changed after a couple of buffer swaps
3309   application.Render(0);
3310   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3311   application.Render(0);
3312   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3313   END_TEST;
3314 }
3315
3316 int UtcDaliAnimationAnimateByIntegerP(void)
3317 {
3318   TestApplication application;
3319
3320   Actor actor = Actor::New();
3321
3322   // Register an integer property
3323   int startValue(1);
3324   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3325   Stage::GetCurrent().Add(actor);
3326   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3327   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3328
3329   // Build the animation
3330   float durationSeconds(2.0f);
3331   Animation animation = Animation::New(durationSeconds);
3332   int targetValue(50);
3333   int relativeValue(targetValue - startValue);
3334   animation.AnimateBy(Property(actor, index), relativeValue);
3335
3336   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3337
3338   // Start the animation
3339   animation.Play();
3340
3341   // Target value should be retrievable straight away
3342   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
3343
3344   bool signalReceived(false);
3345   AnimationFinishCheck finishCheck(signalReceived);
3346   animation.FinishedSignal().Connect(&application, finishCheck);
3347
3348   application.SendNotification();
3349   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3350
3351   // We didn't expect the animation to finish yet
3352   application.SendNotification();
3353   finishCheck.CheckSignalNotReceived();
3354   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3355
3356   application.SendNotification();
3357   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3358
3359   // We did expect the animation to finish
3360   application.SendNotification();
3361   finishCheck.CheckSignalReceived();
3362   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3363
3364   // Check that nothing has changed after a couple of buffer swaps
3365   application.Render(0);
3366   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3367   application.Render(0);
3368   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3369   END_TEST;
3370 }
3371
3372 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3373 {
3374   TestApplication application;
3375
3376   Actor actor = Actor::New();
3377
3378   // Register an integer property
3379   int startValue(1);
3380   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3381   Stage::GetCurrent().Add(actor);
3382   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3383   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3384
3385   // Build the animation
3386   float durationSeconds(1.0f);
3387   Animation animation = Animation::New(durationSeconds);
3388   int targetValue(90);
3389   int relativeValue(targetValue - startValue);
3390   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3391
3392   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3393
3394   // Start the animation
3395   animation.Play();
3396
3397   bool signalReceived(false);
3398   AnimationFinishCheck finishCheck(signalReceived);
3399   animation.FinishedSignal().Connect(&application, finishCheck);
3400
3401   application.SendNotification();
3402   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3403
3404   // We didn't expect the animation to finish yet
3405   application.SendNotification();
3406   finishCheck.CheckSignalNotReceived();
3407
3408   // The position should have moved more, than with a linear alpha function
3409   int current( actor.GetCurrentProperty< int >( index ) );
3410   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3411
3412   application.SendNotification();
3413   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3414
3415   // We did expect the animation to finish
3416   application.SendNotification();
3417   finishCheck.CheckSignalReceived();
3418   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3419
3420   // Check that nothing has changed after a couple of buffer swaps
3421   application.Render(0);
3422   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3423   application.Render(0);
3424   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3425   END_TEST;
3426 }
3427
3428 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3429 {
3430   TestApplication application;
3431
3432   Actor actor = Actor::New();
3433
3434   // Register an integer property
3435   int startValue(10);
3436   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3437   Stage::GetCurrent().Add(actor);
3438   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3439   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3440
3441   // Build the animation
3442   float durationSeconds(1.0f);
3443   Animation animation = Animation::New(durationSeconds);
3444   int targetValue(30);
3445   int relativeValue(targetValue - startValue);
3446   float delay = 0.5f;
3447   animation.AnimateBy(Property(actor, index),
3448                       relativeValue,
3449                       TimePeriod(delay, durationSeconds - delay));
3450
3451   // Start the animation
3452   animation.Play();
3453
3454   bool signalReceived(false);
3455   AnimationFinishCheck finishCheck(signalReceived);
3456   animation.FinishedSignal().Connect(&application, finishCheck);
3457
3458   application.SendNotification();
3459   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3460
3461   // We didn't expect the animation to finish yet
3462   application.SendNotification();
3463   finishCheck.CheckSignalNotReceived();
3464   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3465
3466   application.SendNotification();
3467   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3468
3469   // We didn't expect the animation to finish yet
3470   application.SendNotification();
3471   finishCheck.CheckSignalNotReceived();
3472   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3473
3474   application.SendNotification();
3475   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3476
3477   // We did expect the animation to finish
3478   application.SendNotification();
3479   finishCheck.CheckSignalReceived();
3480   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3481
3482   // Check that nothing has changed after a couple of buffer swaps
3483   application.Render(0);
3484   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3485   application.Render(0);
3486   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3487   END_TEST;
3488 }
3489
3490 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3491 {
3492   TestApplication application;
3493
3494   Actor actor = Actor::New();
3495
3496   // Register an integer property
3497   int startValue(10);
3498   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3499   Stage::GetCurrent().Add(actor);
3500   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3501   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3502
3503   // Build the animation
3504   float durationSeconds(1.0f);
3505   Animation animation = Animation::New(durationSeconds);
3506   int targetValue(30);
3507   int relativeValue(targetValue - startValue);
3508   float delay = 0.5f;
3509   animation.AnimateBy(Property(actor, index),
3510                       relativeValue,
3511                       AlphaFunction::LINEAR,
3512                       TimePeriod(delay, durationSeconds - delay));
3513
3514   // Start the animation
3515   animation.Play();
3516
3517   bool signalReceived(false);
3518   AnimationFinishCheck finishCheck(signalReceived);
3519   animation.FinishedSignal().Connect(&application, finishCheck);
3520
3521   application.SendNotification();
3522   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3523
3524   // We didn't expect the animation to finish yet
3525   application.SendNotification();
3526   finishCheck.CheckSignalNotReceived();
3527   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3528
3529   application.SendNotification();
3530   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3531
3532   // We didn't expect the animation to finish yet
3533   application.SendNotification();
3534   finishCheck.CheckSignalNotReceived();
3535   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3536
3537   application.SendNotification();
3538   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3539
3540   // We did expect the animation to finish
3541   application.SendNotification();
3542   finishCheck.CheckSignalReceived();
3543   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3544
3545   // Check that nothing has changed after a couple of buffer swaps
3546   application.Render(0);
3547   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3548   application.Render(0);
3549   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3550   END_TEST;
3551 }
3552
3553 int UtcDaliAnimationAnimateByQuaternionP(void)
3554 {
3555   TestApplication application;
3556
3557   Actor actor = Actor::New();
3558
3559   // Register a quaternion property
3560   const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
3561   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3562   Stage::GetCurrent().Add(actor);
3563   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3564   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3565
3566   // Build the animation
3567   float durationSeconds(2.0f);
3568   Animation animation = Animation::New(durationSeconds);
3569   const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
3570   const Quaternion finalValue( startValue * relativeValue );
3571   animation.AnimateBy(Property(actor, index), relativeValue);
3572
3573   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3574   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3575
3576   // Start the animation
3577   animation.Play();
3578
3579   // Target value should be retrievable straight away
3580   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3581
3582   application.SendNotification();
3583   application.Render( 2000 ); // animation complete
3584
3585   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3586   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
3587
3588   END_TEST;
3589 }
3590
3591 int UtcDaliAnimationAnimateByVector2P(void)
3592 {
3593   TestApplication application;
3594
3595   Actor actor = Actor::New();
3596
3597   // Register a Vector2 property
3598   Vector2 startValue(10.0f, 10.0f);
3599   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3600   Stage::GetCurrent().Add(actor);
3601   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3602   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3603
3604   // Build the animation
3605   float durationSeconds(2.0f);
3606   Animation animation = Animation::New(durationSeconds);
3607   Vector2 targetValue(60.0f, 60.0f);
3608   Vector2 relativeValue(targetValue - startValue);
3609   animation.AnimateBy(Property(actor, index), relativeValue);
3610
3611   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3612
3613   // Start the animation
3614   animation.Play();
3615
3616   // Target value should be retrievable straight away
3617   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3618
3619   bool signalReceived(false);
3620   AnimationFinishCheck finishCheck(signalReceived);
3621   animation.FinishedSignal().Connect(&application, finishCheck);
3622
3623   application.SendNotification();
3624   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3625
3626   // We didn't expect the animation to finish yet
3627   application.SendNotification();
3628   finishCheck.CheckSignalNotReceived();
3629   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3630
3631   application.SendNotification();
3632   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3633
3634   // We did expect the animation to finish
3635   application.SendNotification();
3636   finishCheck.CheckSignalReceived();
3637   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3638
3639   // Check that nothing has changed after a couple of buffer swaps
3640   application.Render(0);
3641   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3642   application.Render(0);
3643   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3644   END_TEST;
3645 }
3646
3647 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3648 {
3649   TestApplication application;
3650
3651   Actor actor = Actor::New();
3652
3653   // Register a Vector2 property
3654   Vector2 startValue(100.0f, 100.0f);
3655   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3656   Stage::GetCurrent().Add(actor);
3657   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3658   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3659
3660   // Build the animation
3661   float durationSeconds(1.0f);
3662   Animation animation = Animation::New(durationSeconds);
3663   Vector2 targetValue(20.0f, 20.0f);
3664   Vector2 relativeValue(targetValue - startValue);
3665   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3666
3667   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3668
3669   // Start the animation
3670   animation.Play();
3671
3672   bool signalReceived(false);
3673   AnimationFinishCheck finishCheck(signalReceived);
3674   animation.FinishedSignal().Connect(&application, finishCheck);
3675
3676   application.SendNotification();
3677   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3678
3679   // We didn't expect the animation to finish yet
3680   application.SendNotification();
3681   finishCheck.CheckSignalNotReceived();
3682
3683   // The position should have moved more, than with a linear alpha function
3684   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3685   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3686   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3687
3688   application.SendNotification();
3689   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3690
3691   // We did expect the animation to finish
3692   application.SendNotification();
3693   finishCheck.CheckSignalReceived();
3694   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3695
3696   // Check that nothing has changed after a couple of buffer swaps
3697   application.Render(0);
3698   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3699   application.Render(0);
3700   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3701   END_TEST;
3702 }
3703
3704 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3705 {
3706   TestApplication application;
3707
3708   Actor actor = Actor::New();
3709
3710   // Register a Vector2 property
3711   Vector2 startValue(10.0f, 10.0f);
3712   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3713   Stage::GetCurrent().Add(actor);
3714   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3715   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3716
3717   // Build the animation
3718   float durationSeconds(1.0f);
3719   Animation animation = Animation::New(durationSeconds);
3720   Vector2 targetValue(30.0f, 30.0f);
3721   Vector2 relativeValue(targetValue - startValue);
3722   float delay = 0.5f;
3723   animation.AnimateBy(Property(actor, index),
3724                       relativeValue,
3725                       TimePeriod(delay, durationSeconds - delay));
3726
3727   // Start the animation
3728   animation.Play();
3729
3730   bool signalReceived(false);
3731   AnimationFinishCheck finishCheck(signalReceived);
3732   animation.FinishedSignal().Connect(&application, finishCheck);
3733
3734   application.SendNotification();
3735   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3736
3737   // We didn't expect the animation to finish yet
3738   application.SendNotification();
3739   finishCheck.CheckSignalNotReceived();
3740   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3741
3742   application.SendNotification();
3743   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3744
3745   // We didn't expect the animation to finish yet
3746   application.SendNotification();
3747   finishCheck.CheckSignalNotReceived();
3748   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3749
3750   application.SendNotification();
3751   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3752
3753   // We did expect the animation to finish
3754   application.SendNotification();
3755   finishCheck.CheckSignalReceived();
3756   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3757
3758   // Check that nothing has changed after a couple of buffer swaps
3759   application.Render(0);
3760   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3761   application.Render(0);
3762   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3763   END_TEST;
3764 }
3765
3766 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
3767 {
3768   TestApplication application;
3769
3770   Actor actor = Actor::New();
3771
3772   // Register a Vector2 property
3773   Vector2 startValue(5.0f, 5.0f);
3774   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3775   Stage::GetCurrent().Add(actor);
3776   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3777   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3778
3779   // Build the animation
3780   float durationSeconds(1.0f);
3781   Animation animation = Animation::New(durationSeconds);
3782   Vector2 targetValue(10.0f, 10.0f);
3783   Vector2 relativeValue(targetValue - startValue);
3784   float delay = 0.5f;
3785   animation.AnimateBy(Property(actor, index),
3786                       relativeValue,
3787                       AlphaFunction::LINEAR,
3788                       TimePeriod(delay, durationSeconds - delay));
3789
3790   // Start the animation
3791   animation.Play();
3792
3793   bool signalReceived(false);
3794   AnimationFinishCheck finishCheck(signalReceived);
3795   animation.FinishedSignal().Connect(&application, finishCheck);
3796
3797   application.SendNotification();
3798   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3799
3800   // We didn't expect the animation to finish yet
3801   application.SendNotification();
3802   finishCheck.CheckSignalNotReceived();
3803   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3804
3805   application.SendNotification();
3806   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3807
3808   // We didn't expect the animation to finish yet
3809   application.SendNotification();
3810   finishCheck.CheckSignalNotReceived();
3811   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3812
3813   application.SendNotification();
3814   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3815
3816   // We did expect the animation to finish
3817   application.SendNotification();
3818   finishCheck.CheckSignalReceived();
3819   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3820
3821   // Check that nothing has changed after a couple of buffer swaps
3822   application.Render(0);
3823   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3824   application.Render(0);
3825   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3826   END_TEST;
3827 }
3828
3829 int UtcDaliAnimationAnimateByVector3P(void)
3830 {
3831   TestApplication application;
3832
3833   Actor actor = Actor::New();
3834
3835   // Register a Vector3 property
3836   Vector3 startValue(10.0f, 10.0f, 10.0f);
3837   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3838   Stage::GetCurrent().Add(actor);
3839   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3840   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3841
3842   // Build the animation
3843   float durationSeconds(2.0f);
3844   Animation animation = Animation::New(durationSeconds);
3845   Vector3 targetValue(60.0f, 60.0f, 60.0f);
3846   Vector3 relativeValue(targetValue - startValue);
3847   animation.AnimateBy(Property(actor, index), relativeValue);
3848
3849   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3850
3851   // Start the animation
3852   animation.Play();
3853
3854   // Target value should be retrievable straight away
3855   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3856
3857   bool signalReceived(false);
3858   AnimationFinishCheck finishCheck(signalReceived);
3859   animation.FinishedSignal().Connect(&application, finishCheck);
3860
3861   application.SendNotification();
3862   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3863
3864   // We didn't expect the animation to finish yet
3865   application.SendNotification();
3866   finishCheck.CheckSignalNotReceived();
3867   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3868
3869   application.SendNotification();
3870   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3871
3872   // We did expect the animation to finish
3873   application.SendNotification();
3874   finishCheck.CheckSignalReceived();
3875   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3876
3877   // Check that nothing has changed after a couple of buffer swaps
3878   application.Render(0);
3879   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3880   application.Render(0);
3881   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3882   END_TEST;
3883 }
3884
3885 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
3886 {
3887   TestApplication application;
3888
3889   Actor actor = Actor::New();
3890
3891   // Register a Vector3 property
3892   Vector3 startValue(100.0f, 100.0f, 100.0f);
3893   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3894   Stage::GetCurrent().Add(actor);
3895   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3896   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3897
3898   // Build the animation
3899   float durationSeconds(1.0f);
3900   Animation animation = Animation::New(durationSeconds);
3901   Vector3 targetValue(20.0f, 20.0f, 20.0f);
3902   Vector3 relativeValue(targetValue - startValue);
3903   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3904
3905   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3906
3907   // Start the animation
3908   animation.Play();
3909
3910   bool signalReceived(false);
3911   AnimationFinishCheck finishCheck(signalReceived);
3912   animation.FinishedSignal().Connect(&application, finishCheck);
3913
3914   application.SendNotification();
3915   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3916
3917   // We didn't expect the animation to finish yet
3918   application.SendNotification();
3919   finishCheck.CheckSignalNotReceived();
3920
3921   // The position should have moved more, than with a linear alpha function
3922   Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
3923   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3924   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3925   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3926
3927   application.SendNotification();
3928   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3929
3930   // We did expect the animation to finish
3931   application.SendNotification();
3932   finishCheck.CheckSignalReceived();
3933   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3934
3935   // Check that nothing has changed after a couple of buffer swaps
3936   application.Render(0);
3937   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3938   application.Render(0);
3939   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3940   END_TEST;
3941 }
3942
3943 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
3944 {
3945   TestApplication application;
3946
3947   Actor actor = Actor::New();
3948
3949   // Register a Vector3 property
3950   Vector3 startValue(10.0f, 10.0f, 10.0f);
3951   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3952   Stage::GetCurrent().Add(actor);
3953   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3954   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3955
3956   // Build the animation
3957   float durationSeconds(1.0f);
3958   Animation animation = Animation::New(durationSeconds);
3959   Vector3 targetValue(30.0f, 30.0f, 30.0f);
3960   Vector3 relativeValue(targetValue - startValue);
3961   float delay = 0.5f;
3962   animation.AnimateBy(Property(actor, index),
3963                       relativeValue,
3964                       TimePeriod(delay, durationSeconds - delay));
3965
3966   // Start the animation
3967   animation.Play();
3968
3969   bool signalReceived(false);
3970   AnimationFinishCheck finishCheck(signalReceived);
3971   animation.FinishedSignal().Connect(&application, finishCheck);
3972
3973   application.SendNotification();
3974   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3975
3976   // We didn't expect the animation to finish yet
3977   application.SendNotification();
3978   finishCheck.CheckSignalNotReceived();
3979   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3980
3981   application.SendNotification();
3982   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3983
3984   // We didn't expect the animation to finish yet
3985   application.SendNotification();
3986   finishCheck.CheckSignalNotReceived();
3987   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3988
3989   application.SendNotification();
3990   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3991
3992   // We did expect the animation to finish
3993   application.SendNotification();
3994   finishCheck.CheckSignalReceived();
3995   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3996
3997   // Check that nothing has changed after a couple of buffer swaps
3998   application.Render(0);
3999   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4000   application.Render(0);
4001   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4002   END_TEST;
4003 }
4004
4005 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
4006 {
4007   TestApplication application;
4008
4009   Actor actor = Actor::New();
4010
4011   // Register a Vector3 property
4012   Vector3 startValue(5.0f, 5.0f, 5.0f);
4013   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4014   Stage::GetCurrent().Add(actor);
4015   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4016   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4017
4018   // Build the animation
4019   float durationSeconds(1.0f);
4020   Animation animation = Animation::New(durationSeconds);
4021   Vector3 targetValue(10.0f, 10.0f, 10.0f);
4022   Vector3 relativeValue(targetValue - startValue);
4023   float delay = 0.5f;
4024   animation.AnimateBy(Property(actor, index),
4025                       relativeValue,
4026                       AlphaFunction::LINEAR,
4027                       TimePeriod(delay, durationSeconds - delay));
4028
4029   // Start the animation
4030   animation.Play();
4031
4032   bool signalReceived(false);
4033   AnimationFinishCheck finishCheck(signalReceived);
4034   animation.FinishedSignal().Connect(&application, finishCheck);
4035
4036   application.SendNotification();
4037   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4038
4039   // We didn't expect the animation to finish yet
4040   application.SendNotification();
4041   finishCheck.CheckSignalNotReceived();
4042   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4043
4044   application.SendNotification();
4045   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4046
4047   // We didn't expect the animation to finish yet
4048   application.SendNotification();
4049   finishCheck.CheckSignalNotReceived();
4050   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4051
4052   application.SendNotification();
4053   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4054
4055   // We did expect the animation to finish
4056   application.SendNotification();
4057   finishCheck.CheckSignalReceived();
4058   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4059
4060   // Check that nothing has changed after a couple of buffer swaps
4061   application.Render(0);
4062   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4063   application.Render(0);
4064   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4065   END_TEST;
4066 }
4067
4068 int UtcDaliAnimationAnimateByVector4P(void)
4069 {
4070   TestApplication application;
4071
4072   Actor actor = Actor::New();
4073
4074   // Register a Vector4 property
4075   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4076   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4077   Stage::GetCurrent().Add(actor);
4078   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4079   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4080
4081   // Build the animation
4082   float durationSeconds(2.0f);
4083   Animation animation = Animation::New(durationSeconds);
4084   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4085   Vector4 relativeValue(targetValue - startValue);
4086   animation.AnimateBy(Property(actor, index), relativeValue);
4087
4088   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4089
4090   // Start the animation
4091   animation.Play();
4092
4093   // Target value should be retrievable straight away
4094   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4095
4096   bool signalReceived(false);
4097   AnimationFinishCheck finishCheck(signalReceived);
4098   animation.FinishedSignal().Connect(&application, finishCheck);
4099
4100   application.SendNotification();
4101   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4102
4103   // We didn't expect the animation to finish yet
4104   application.SendNotification();
4105   finishCheck.CheckSignalNotReceived();
4106   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4107
4108   application.SendNotification();
4109   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4110
4111   // We did expect the animation to finish
4112   application.SendNotification();
4113   finishCheck.CheckSignalReceived();
4114   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4115
4116   // Check that nothing has changed after a couple of buffer swaps
4117   application.Render(0);
4118   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4119   application.Render(0);
4120   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4121   END_TEST;
4122 }
4123
4124 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4125 {
4126   TestApplication application;
4127
4128   Actor actor = Actor::New();
4129
4130   // Register a Vector4 property
4131   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4132   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4133   Stage::GetCurrent().Add(actor);
4134   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4135   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4136
4137   // Build the animation
4138   float durationSeconds(1.0f);
4139   Animation animation = Animation::New(durationSeconds);
4140   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4141   Vector4 relativeValue(targetValue - startValue);
4142   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4143
4144   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4145
4146   // Start the animation
4147   animation.Play();
4148
4149   bool signalReceived(false);
4150   AnimationFinishCheck finishCheck(signalReceived);
4151   animation.FinishedSignal().Connect(&application, finishCheck);
4152
4153   application.SendNotification();
4154   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4155
4156   // We didn't expect the animation to finish yet
4157   application.SendNotification();
4158   finishCheck.CheckSignalNotReceived();
4159
4160   // The position should have moved more, than with a linear alpha function
4161   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4162   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4163   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4164   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4165   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4166
4167   application.SendNotification();
4168   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4169
4170   // We did expect the animation to finish
4171   application.SendNotification();
4172   finishCheck.CheckSignalReceived();
4173   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4174
4175   // Check that nothing has changed after a couple of buffer swaps
4176   application.Render(0);
4177   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4178   application.Render(0);
4179   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4180   END_TEST;
4181 }
4182
4183 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4184 {
4185   TestApplication application;
4186
4187   Actor actor = Actor::New();
4188
4189   // Register a Vector4 property
4190   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4191   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4192   Stage::GetCurrent().Add(actor);
4193   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4194   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4195
4196   // Build the animation
4197   float durationSeconds(1.0f);
4198   Animation animation = Animation::New(durationSeconds);
4199   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4200   Vector4 relativeValue(targetValue - startValue);
4201   float delay = 0.5f;
4202   animation.AnimateBy(Property(actor, index),
4203                       relativeValue,
4204                       TimePeriod(delay, durationSeconds - delay));
4205
4206   // Start the animation
4207   animation.Play();
4208
4209   bool signalReceived(false);
4210   AnimationFinishCheck finishCheck(signalReceived);
4211   animation.FinishedSignal().Connect(&application, finishCheck);
4212
4213   application.SendNotification();
4214   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4215
4216   // We didn't expect the animation to finish yet
4217   application.SendNotification();
4218   finishCheck.CheckSignalNotReceived();
4219   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4220
4221   application.SendNotification();
4222   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4223
4224   // We didn't expect the animation to finish yet
4225   application.SendNotification();
4226   finishCheck.CheckSignalNotReceived();
4227   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4228
4229   application.SendNotification();
4230   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4231
4232   // We did expect the animation to finish
4233   application.SendNotification();
4234   finishCheck.CheckSignalReceived();
4235   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4236
4237   // Check that nothing has changed after a couple of buffer swaps
4238   application.Render(0);
4239   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4240   application.Render(0);
4241   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4242   END_TEST;
4243 }
4244
4245 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4246 {
4247   TestApplication application;
4248
4249   Actor actor = Actor::New();
4250
4251   // Register a Vector4 property
4252   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4253   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4254   Stage::GetCurrent().Add(actor);
4255   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4256   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4257
4258   // Build the animation
4259   float durationSeconds(1.0f);
4260   Animation animation = Animation::New(durationSeconds);
4261   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4262   Vector4 relativeValue(targetValue - startValue);
4263   float delay = 0.5f;
4264   animation.AnimateBy(Property(actor, index),
4265                       relativeValue,
4266                       AlphaFunction::LINEAR,
4267                       TimePeriod(delay, durationSeconds - delay));
4268
4269   // Start the animation
4270   animation.Play();
4271
4272   bool signalReceived(false);
4273   AnimationFinishCheck finishCheck(signalReceived);
4274   animation.FinishedSignal().Connect(&application, finishCheck);
4275
4276   application.SendNotification();
4277   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4278
4279   // We didn't expect the animation to finish yet
4280   application.SendNotification();
4281   finishCheck.CheckSignalNotReceived();
4282   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4283
4284   application.SendNotification();
4285   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4286
4287   // We didn't expect the animation to finish yet
4288   application.SendNotification();
4289   finishCheck.CheckSignalNotReceived();
4290   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4291
4292   application.SendNotification();
4293   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4294
4295   // We did expect the animation to finish
4296   application.SendNotification();
4297   finishCheck.CheckSignalReceived();
4298   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4299
4300   // Check that nothing has changed after a couple of buffer swaps
4301   application.Render(0);
4302   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4303   application.Render(0);
4304   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4305   END_TEST;
4306 }
4307
4308 int UtcDaliAnimationAnimateByActorPositionP(void)
4309 {
4310   TestApplication application;
4311
4312   Actor actor = Actor::New();
4313   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4314   actor.SetPosition(startPosition);
4315   Stage::GetCurrent().Add(actor);
4316   application.SendNotification();
4317   application.Render(0);
4318   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4319
4320   // Build the animation
4321   float durationSeconds(1.0f);
4322   Animation animation = Animation::New(durationSeconds);
4323   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4324   Vector3 relativePosition(targetPosition - startPosition);
4325   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4326
4327   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4328
4329   // Start the animation
4330   animation.Play();
4331
4332   // Target value should be retrievable straight away
4333   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4334
4335   bool signalReceived(false);
4336   AnimationFinishCheck finishCheck(signalReceived);
4337   animation.FinishedSignal().Connect(&application, finishCheck);
4338
4339   application.SendNotification();
4340   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4341
4342   // We didn't expect the animation to finish yet
4343   application.SendNotification();
4344   finishCheck.CheckSignalNotReceived();
4345   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4346
4347   application.SendNotification();
4348   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4349
4350   // We did expect the animation to finish
4351   application.SendNotification();
4352   finishCheck.CheckSignalReceived();
4353   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4354
4355   // Check that nothing has changed after a couple of buffer swaps
4356   application.Render(0);
4357   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4358   application.Render(0);
4359   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4360   END_TEST;
4361 }
4362
4363 int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
4364 {
4365   TestApplication application;
4366
4367   Actor actor = Actor::New();
4368   Stage::GetCurrent().Add(actor);
4369   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4370
4371   // Build the animation
4372   float durationSeconds(1.0f);
4373   Animation animation = Animation::New(durationSeconds);
4374   Vector3 targetPosition(200.0f, 300.0f, 400.0f);
4375   Vector3 relativePosition(targetPosition - Vector3::ZERO);
4376   animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
4377   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
4378   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
4379
4380   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4381   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4382
4383   // Start the animation
4384   animation.Play();
4385
4386   // Target value should be retrievable straight away
4387   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4388   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
4389   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
4390   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
4391
4392   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
4393
4394   application.SendNotification();
4395   application.Render( 1000 ); // 1 second progress
4396
4397   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4398
4399   END_TEST;
4400 }
4401
4402 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4403 {
4404   TestApplication application;
4405
4406   Actor actor = Actor::New();
4407   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4408   actor.SetPosition(startPosition);
4409   Stage::GetCurrent().Add(actor);
4410   application.SendNotification();
4411   application.Render(0);
4412   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4413
4414   // Build the animation
4415   float durationSeconds(1.0f);
4416   Animation animation = Animation::New(durationSeconds);
4417   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4418   Vector3 relativePosition(targetPosition - startPosition);
4419   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4420
4421   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4422
4423   // Start the animation
4424   animation.Play();
4425
4426   bool signalReceived(false);
4427   AnimationFinishCheck finishCheck(signalReceived);
4428   animation.FinishedSignal().Connect(&application, finishCheck);
4429
4430   application.SendNotification();
4431   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4432
4433   // We didn't expect the animation to finish yet
4434   application.SendNotification();
4435   finishCheck.CheckSignalNotReceived();
4436
4437   // The position should have moved more, than with a linear alpha function
4438   Vector3 current(actor.GetCurrentPosition());
4439   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4440   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4441   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4442
4443   application.SendNotification();
4444   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4445
4446   // We did expect the animation to finish
4447   application.SendNotification();
4448   finishCheck.CheckSignalReceived();
4449   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4450
4451   // Check that nothing has changed after a couple of buffer swaps
4452   application.Render(0);
4453   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4454   application.Render(0);
4455   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4456   END_TEST;
4457 }
4458
4459 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4460 {
4461   TestApplication application;
4462
4463   Actor actor = Actor::New();
4464   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4465   actor.SetPosition(startPosition);
4466   Stage::GetCurrent().Add(actor);
4467   application.SendNotification();
4468   application.Render(0);
4469   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4470
4471   // Build the animation
4472   float durationSeconds(1.0f);
4473   Animation animation = Animation::New(durationSeconds);
4474   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4475   Vector3 relativePosition(targetPosition - startPosition);
4476   float delay = 0.5f;
4477   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4478                       relativePosition,
4479                       TimePeriod(delay, durationSeconds - delay));
4480
4481   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4482
4483   // Start the animation
4484   animation.Play();
4485
4486   bool signalReceived(false);
4487   AnimationFinishCheck finishCheck(signalReceived);
4488   animation.FinishedSignal().Connect(&application, finishCheck);
4489
4490   application.SendNotification();
4491   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4492
4493   // We didn't expect the animation to finish yet
4494   application.SendNotification();
4495   finishCheck.CheckSignalNotReceived();
4496   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4497
4498   application.SendNotification();
4499   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4500
4501   // We did expect the animation to finish
4502   application.SendNotification();
4503   finishCheck.CheckSignalReceived();
4504   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4505
4506   // Check that nothing has changed after a couple of buffer swaps
4507   application.Render(0);
4508   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4509   application.Render(0);
4510   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4511   END_TEST;
4512 }
4513
4514 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4515 {
4516   TestApplication application;
4517
4518   Actor actor = Actor::New();
4519   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4520   actor.SetPosition(startPosition);
4521   Stage::GetCurrent().Add(actor);
4522   application.SendNotification();
4523   application.Render(0);
4524   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4525
4526   // Build the animation
4527   float durationSeconds(1.0f);
4528   Animation animation = Animation::New(durationSeconds);
4529   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4530   Vector3 relativePosition(targetPosition - startPosition);
4531   float delay = 0.5f;
4532   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4533                       relativePosition,
4534                       AlphaFunction::LINEAR,
4535                       TimePeriod(delay, durationSeconds - delay));
4536
4537   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4538
4539   // Start the animation
4540   animation.Play();
4541
4542   bool signalReceived(false);
4543   AnimationFinishCheck finishCheck(signalReceived);
4544   animation.FinishedSignal().Connect(&application, finishCheck);
4545
4546   application.SendNotification();
4547   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4548
4549   // We didn't expect the animation to finish yet
4550   application.SendNotification();
4551   finishCheck.CheckSignalNotReceived();
4552   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4553
4554   application.SendNotification();
4555   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4556
4557   // We did expect the animation to finish
4558   application.SendNotification();
4559   finishCheck.CheckSignalReceived();
4560   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4561
4562   // Check that nothing has changed after a couple of buffer swaps
4563   application.Render(0);
4564   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4565   application.Render(0);
4566   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4567   END_TEST;
4568 }
4569
4570 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4571 {
4572   TestApplication application;
4573
4574   Actor actor = Actor::New();
4575   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4576   Stage::GetCurrent().Add(actor);
4577   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4578
4579   // Build the animation
4580   float durationSeconds(1.0f);
4581   Animation animation = Animation::New(durationSeconds);
4582   Degree relativeRotationDegrees(360.0f);
4583   Radian relativeRotationRadians(relativeRotationDegrees);
4584   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4585
4586   // Start the animation
4587   animation.Play();
4588
4589   // Target value should be retrievable straight away
4590   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
4591
4592   bool signalReceived(false);
4593   AnimationFinishCheck finishCheck(signalReceived);
4594   animation.FinishedSignal().Connect(&application, finishCheck);
4595
4596   application.SendNotification();
4597   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4598
4599   // We didn't expect the animation to finish yet
4600   application.SendNotification();
4601   finishCheck.CheckSignalNotReceived();
4602   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4603
4604   application.SendNotification();
4605   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4606
4607   // We didn't expect the animation to finish yet
4608   application.SendNotification();
4609   finishCheck.CheckSignalNotReceived();
4610   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4611
4612   application.SendNotification();
4613   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4614
4615   // We didn't expect the animation to finish yet
4616   application.SendNotification();
4617   finishCheck.CheckSignalNotReceived();
4618   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4619
4620   application.SendNotification();
4621   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4622
4623   // We did expect the animation to finish
4624   application.SendNotification();
4625   finishCheck.CheckSignalReceived();
4626   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4627   END_TEST;
4628 }
4629
4630 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4631 {
4632   TestApplication application;
4633
4634   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4635
4636   Actor actor = Actor::New();
4637   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4638   Stage::GetCurrent().Add(actor);
4639   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4640
4641   // Build the animation
4642   float durationSeconds(1.0f);
4643   Animation animation = Animation::New(durationSeconds);
4644   Degree relativeRotationDegrees(710.0f);
4645   Radian relativeRotationRadians(relativeRotationDegrees);
4646
4647   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4648
4649   // Start the animation
4650   animation.Play();
4651
4652   bool signalReceived(false);
4653   AnimationFinishCheck finishCheck(signalReceived);
4654   animation.FinishedSignal().Connect(&application, finishCheck);
4655
4656   application.SendNotification();
4657   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4658
4659   // We didn't expect the animation to finish yet
4660   application.SendNotification();
4661   finishCheck.CheckSignalNotReceived();
4662   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4663
4664   application.SendNotification();
4665   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4666
4667   // We didn't expect the animation to finish yet
4668   application.SendNotification();
4669   finishCheck.CheckSignalNotReceived();
4670   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4671
4672   application.SendNotification();
4673   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4674
4675   // We didn't expect the animation to finish yet
4676   application.SendNotification();
4677   finishCheck.CheckSignalNotReceived();
4678   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4679
4680   application.SendNotification();
4681   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4682
4683   // We did expect the animation to finish
4684   application.SendNotification();
4685   finishCheck.CheckSignalReceived();
4686   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4687   END_TEST;
4688 }
4689
4690
4691 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4692 {
4693   TestApplication application;
4694
4695   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4696
4697   Actor actor = Actor::New();
4698   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4699   Stage::GetCurrent().Add(actor);
4700   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4701
4702   // Build the animation
4703   float durationSeconds(1.0f);
4704   Animation animation = Animation::New(durationSeconds);
4705   Degree relativeRotationDegrees(730.0f);
4706   Radian relativeRotationRadians(relativeRotationDegrees);
4707
4708   Radian actualRotationRadians( Degree(10.0f) );
4709
4710   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4711
4712   // Start the animation
4713   animation.Play();
4714
4715   bool signalReceived(false);
4716   AnimationFinishCheck finishCheck(signalReceived);
4717   animation.FinishedSignal().Connect(&application, finishCheck);
4718
4719   application.SendNotification();
4720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4721
4722   // We didn't expect the animation to finish yet
4723   application.SendNotification();
4724   finishCheck.CheckSignalNotReceived();
4725   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4726
4727   application.SendNotification();
4728   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4729
4730   // We didn't expect the animation to finish yet
4731   application.SendNotification();
4732   finishCheck.CheckSignalNotReceived();
4733   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4734
4735   application.SendNotification();
4736   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4737
4738   // We didn't expect the animation to finish yet
4739   application.SendNotification();
4740   finishCheck.CheckSignalNotReceived();
4741   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4742
4743   application.SendNotification();
4744   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4745
4746   // We did expect the animation to finish
4747   application.SendNotification();
4748   finishCheck.CheckSignalReceived();
4749   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4750   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4751   END_TEST;
4752 }
4753
4754
4755 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4756 {
4757   TestApplication application;
4758
4759   Actor actor = Actor::New();
4760   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4761   Stage::GetCurrent().Add(actor);
4762   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4763
4764   // Build the animation
4765   float durationSeconds(1.0f);
4766   Animation animation = Animation::New(durationSeconds);
4767   Degree relativeRotationDegrees(360.0f);
4768   Radian relativeRotationRadians(relativeRotationDegrees);
4769   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4770
4771   // Start the animation
4772   animation.Play();
4773
4774   bool signalReceived(false);
4775   AnimationFinishCheck finishCheck(signalReceived);
4776   animation.FinishedSignal().Connect(&application, finishCheck);
4777
4778   application.SendNotification();
4779   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4780
4781   // We didn't expect the animation to finish yet
4782   application.SendNotification();
4783   finishCheck.CheckSignalNotReceived();
4784   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4785
4786   application.SendNotification();
4787   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4788
4789   // We didn't expect the animation to finish yet
4790   application.SendNotification();
4791   finishCheck.CheckSignalNotReceived();
4792   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4793
4794   application.SendNotification();
4795   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4796
4797   // We didn't expect the animation to finish yet
4798   application.SendNotification();
4799   finishCheck.CheckSignalNotReceived();
4800   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4801
4802   application.SendNotification();
4803   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4804
4805   // We did expect the animation to finish
4806   application.SendNotification();
4807   finishCheck.CheckSignalReceived();
4808   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4809   END_TEST;
4810 }
4811
4812 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4813 {
4814   TestApplication application;
4815
4816   Actor actor = Actor::New();
4817   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4818   Stage::GetCurrent().Add(actor);
4819   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4820
4821   // Build the animation
4822   float durationSeconds(1.0f);
4823   Animation animation = Animation::New(durationSeconds);
4824   Degree relativeRotationDegrees(360.0f);
4825   Radian relativeRotationRadians(relativeRotationDegrees);
4826   float delay = 0.3f;
4827   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4828                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4829
4830   // Start the animation
4831   animation.Play();
4832
4833   bool signalReceived(false);
4834   AnimationFinishCheck finishCheck(signalReceived);
4835   animation.FinishedSignal().Connect(&application, finishCheck);
4836
4837   application.SendNotification();
4838   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4839
4840   // We didn't expect the animation to finish yet
4841   application.SendNotification();
4842   finishCheck.CheckSignalNotReceived();
4843   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4844   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4845
4846   application.SendNotification();
4847   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4848
4849   // We didn't expect the animation to finish yet
4850   application.SendNotification();
4851   finishCheck.CheckSignalNotReceived();
4852   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4853   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4854
4855   application.SendNotification();
4856   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4857
4858   // We didn't expect the animation to finish yet
4859   application.SendNotification();
4860   finishCheck.CheckSignalNotReceived();
4861   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4862   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4863
4864   application.SendNotification();
4865   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4866
4867   // We did expect the animation to finish
4868   application.SendNotification();
4869   finishCheck.CheckSignalReceived();
4870   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4871   END_TEST;
4872 }
4873
4874 int UtcDaliAnimationAnimateByActorScaleP(void)
4875 {
4876   TestApplication application;
4877
4878   Actor actor = Actor::New();
4879   Stage::GetCurrent().Add(actor);
4880   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4881
4882   // Build the animation
4883   float durationSeconds(1.0f);
4884   Animation animation = Animation::New(durationSeconds);
4885   Vector3 targetScale(2.0f, 2.0f, 2.0f);
4886   Vector3 relativeScale(targetScale - Vector3::ONE);
4887   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4888
4889   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4890
4891   // Start the animation
4892   animation.Play();
4893
4894   // Target value should be retrievable straight away
4895   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
4896
4897   bool signalReceived(false);
4898   AnimationFinishCheck finishCheck(signalReceived);
4899   animation.FinishedSignal().Connect(&application, finishCheck);
4900
4901   application.SendNotification();
4902   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4903
4904   // We didn't expect the animation to finish yet
4905   application.SendNotification();
4906   finishCheck.CheckSignalNotReceived();
4907   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4908
4909   application.SendNotification();
4910   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4911
4912   // We did expect the animation to finish
4913   application.SendNotification();
4914   finishCheck.CheckSignalReceived();
4915   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4916
4917   // Reset everything
4918   finishCheck.Reset();
4919   actor.SetScale(Vector3::ONE);
4920   application.SendNotification();
4921   application.Render(0);
4922   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4923
4924   // Repeat with a different (ease-in) alpha function
4925   animation = Animation::New(durationSeconds);
4926   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4927   animation.FinishedSignal().Connect(&application, finishCheck);
4928   animation.Play();
4929
4930   application.SendNotification();
4931   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4932
4933   // We didn't expect the animation to finish yet
4934   application.SendNotification();
4935   finishCheck.CheckSignalNotReceived();
4936
4937   // The scale should have grown less, than with a linear alpha function
4938   Vector3 current(actor.GetCurrentScale());
4939   DALI_TEST_CHECK( current.x > 1.0f );
4940   DALI_TEST_CHECK( current.y > 1.0f );
4941   DALI_TEST_CHECK( current.z > 1.0f );
4942   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4943   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4944   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4945
4946   application.SendNotification();
4947   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4948
4949   // We did expect the animation to finish
4950   application.SendNotification();
4951   finishCheck.CheckSignalReceived();
4952   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4953
4954   // Reset everything
4955   finishCheck.Reset();
4956   actor.SetScale(Vector3::ONE);
4957   application.SendNotification();
4958   application.Render(0);
4959   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4960
4961   // Repeat with a delay
4962   float delay = 0.5f;
4963   animation = Animation::New(durationSeconds);
4964   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
4965   animation.FinishedSignal().Connect(&application, finishCheck);
4966   animation.Play();
4967
4968   application.SendNotification();
4969   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4970
4971   // We didn't expect the animation to finish yet
4972   application.SendNotification();
4973   finishCheck.CheckSignalNotReceived();
4974   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4975
4976   application.SendNotification();
4977   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4978
4979   // We did expect the animation to finish
4980   application.SendNotification();
4981   finishCheck.CheckSignalReceived();
4982   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4983   END_TEST;
4984 }
4985
4986 int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
4987 {
4988   TestApplication application;
4989
4990   Actor actor = Actor::New();
4991   Stage::GetCurrent().Add(actor);
4992   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4993
4994   // Build the animation
4995   float durationSeconds(1.0f);
4996   Animation animation = Animation::New(durationSeconds);
4997   Vector3 targetScale(2.0f, 3.0f, 4.0f);
4998   Vector3 relativeScale(targetScale - Vector3::ONE);
4999   animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
5000   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
5001   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
5002
5003   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5004   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5005
5006   // Start the animation
5007   animation.Play();
5008
5009   // Target value should be retrievable straight away
5010   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5011   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
5012   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
5013   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
5014
5015   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet
5016
5017   application.SendNotification();
5018   application.Render( 1000 ); // 1 second progress
5019
5020   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5021
5022   END_TEST;
5023 }
5024
5025 int UtcDaliAnimationAnimateByActorColorP(void)
5026 {
5027   TestApplication application;
5028
5029   Actor actor = Actor::New();
5030   Stage::GetCurrent().Add(actor);
5031   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5032
5033   // Build the animation
5034   float durationSeconds(1.0f);
5035   Animation animation = Animation::New(durationSeconds);
5036   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5037   Vector4 relativeColor( targetColor - Color::WHITE );
5038   animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
5039
5040   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5041   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5042
5043   // Start the animation
5044   animation.Play();
5045
5046   // Target value should be retrievable straight away
5047   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5048   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5049   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5050   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5051   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5052
5053   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5054
5055   application.SendNotification();
5056   application.Render( 1000 ); // 1 second progress
5057
5058   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5059
5060   END_TEST;
5061 }
5062
5063 int UtcDaliAnimationAnimateByActorColorComponentsP(void)
5064 {
5065   TestApplication application;
5066
5067   Actor actor = Actor::New();
5068   Stage::GetCurrent().Add(actor);
5069   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5070
5071   // Build the animation
5072   float durationSeconds(1.0f);
5073   Animation animation = Animation::New(durationSeconds);
5074   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5075   Vector4 relativeColor( targetColor - Color::WHITE );
5076   animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
5077   animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
5078   animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
5079   animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
5080
5081   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5082   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5083
5084   // Start the animation
5085   animation.Play();
5086
5087   // Target value should be retrievable straight away
5088   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5089   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5090   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5091   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5092   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5093
5094   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5095
5096   application.SendNotification();
5097   application.Render( 1000 ); // 1 second progress
5098
5099   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5100
5101   END_TEST;
5102 }
5103
5104 int UtcDaliAnimationAnimateByActorSizeP(void)
5105 {
5106   TestApplication application;
5107
5108   Actor actor = Actor::New();
5109   Stage::GetCurrent().Add(actor);
5110   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5111
5112   // Build the animation
5113   float durationSeconds(1.0f);
5114   Animation animation = Animation::New(durationSeconds);
5115   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5116   Vector3 relativeSize( targetSize - Vector3::ZERO );
5117   animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
5118
5119   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5120   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5121
5122   // Start the animation
5123   animation.Play();
5124
5125   // Target value should be retrievable straight away
5126   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5127   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5128   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5129   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5130
5131   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5132
5133   application.SendNotification();
5134   application.Render( 1000 ); // 1 second progress
5135
5136   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5137
5138   END_TEST;
5139 }
5140
5141 int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
5142 {
5143   TestApplication application;
5144
5145   Actor actor = Actor::New();
5146   Stage::GetCurrent().Add(actor);
5147   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5148
5149   // Build the animation
5150   float durationSeconds(1.0f);
5151   Animation animation = Animation::New(durationSeconds);
5152   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5153   Vector3 relativeSize( targetSize - Vector3::ZERO );
5154   animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
5155   animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
5156   animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
5157
5158   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5159   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5160
5161   // Start the animation
5162   animation.Play();
5163
5164   // Target value should be retrievable straight away
5165   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5166   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5167   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5168   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5169
5170   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5171
5172   application.SendNotification();
5173   application.Render( 1000 ); // 1 second progress
5174
5175   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5176
5177   END_TEST;
5178 }
5179
5180 int UtcDaliAnimationAnimateByActorVisibilityP(void)
5181 {
5182   TestApplication application;
5183
5184   Actor actor = Actor::New();
5185   Stage::GetCurrent().Add(actor);
5186   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5187
5188   actor.SetVisible( false );
5189
5190   application.SendNotification();
5191   application.Render();
5192
5193   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
5194
5195   // Build the animation
5196   float durationSeconds(1.0f);
5197   Animation animation = Animation::New(durationSeconds);
5198   bool targetVisibility( true );
5199   bool relativeVisibility( targetVisibility );
5200   animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
5201
5202   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5203
5204   // Start the animation
5205   animation.Play();
5206
5207   // Target value should be retrievable straight away
5208   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
5209   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet
5210
5211   application.SendNotification();
5212   application.Render( 1000 ); // 1 second progress
5213
5214   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5215
5216   END_TEST;
5217 }
5218
5219 int UtcDaliAnimationAnimateToBooleanP(void)
5220 {
5221   TestApplication application;
5222
5223   Actor actor = Actor::New();
5224
5225   // Register a boolean property
5226   const bool startValue(false);
5227   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5228   Stage::GetCurrent().Add(actor);
5229   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5230   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5231
5232   // Build the animation
5233   float durationSeconds(2.0f);
5234   Animation animation = Animation::New(durationSeconds);
5235   const bool targetValue( !startValue );
5236   animation.AnimateTo(Property(actor, index), targetValue);
5237
5238   // Start the animation
5239   animation.Play();
5240
5241   bool signalReceived(false);
5242   AnimationFinishCheck finishCheck(signalReceived);
5243   animation.FinishedSignal().Connect(&application, finishCheck);
5244
5245   application.SendNotification();
5246   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5247
5248   // We didn't expect the animation to finish yet
5249   application.SendNotification();
5250   finishCheck.CheckSignalNotReceived();
5251   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5252
5253   application.SendNotification();
5254   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5255
5256   // We did expect the animation to finish
5257   application.SendNotification();
5258   finishCheck.CheckSignalReceived();
5259   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5260
5261   // Check that nothing has changed after a couple of buffer swaps
5262   application.Render(0);
5263   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5264   application.Render(0);
5265   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5266
5267   // Repeat with target value "false"
5268   animation = Animation::New(durationSeconds);
5269   const bool finalValue( !targetValue );
5270   animation.AnimateTo(Property(actor, index), finalValue);
5271
5272   // Start the animation
5273   animation.Play();
5274
5275   finishCheck.Reset();
5276   animation.FinishedSignal().Connect(&application, finishCheck);
5277
5278   application.SendNotification();
5279   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5280
5281   // We didn't expect the animation to finish yet
5282   application.SendNotification();
5283   finishCheck.CheckSignalNotReceived();
5284   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5285
5286   application.SendNotification();
5287   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5288
5289   // We did expect the animation to finish
5290   application.SendNotification();
5291   finishCheck.CheckSignalReceived();
5292   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5293
5294   // Check that nothing has changed after a couple of buffer swaps
5295   application.Render(0);
5296   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5297   application.Render(0);
5298   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5299   END_TEST;
5300 }
5301
5302 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
5303 {
5304   TestApplication application;
5305
5306   Actor actor = Actor::New();
5307
5308   // Register a boolean property
5309   const bool startValue(false);
5310   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5311   Stage::GetCurrent().Add(actor);
5312   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5313   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5314
5315   // Build the animation
5316   float durationSeconds(2.0f);
5317   Animation animation = Animation::New(durationSeconds);
5318   const bool targetValue( !startValue );
5319   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5320
5321   // Start the animation
5322   animation.Play();
5323
5324   bool signalReceived(false);
5325   AnimationFinishCheck finishCheck(signalReceived);
5326   animation.FinishedSignal().Connect(&application, finishCheck);
5327
5328   application.SendNotification();
5329   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5330
5331   // We didn't expect the animation to finish yet
5332   application.SendNotification();
5333   finishCheck.CheckSignalNotReceived();
5334   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5335
5336   application.SendNotification();
5337   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5338
5339   // We did expect the animation to finish
5340   application.SendNotification();
5341   finishCheck.CheckSignalReceived();
5342   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5343
5344   // Check that nothing has changed after a couple of buffer swaps
5345   application.Render(0);
5346   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5347   application.Render(0);
5348   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5349
5350   // Repeat with target value "false"
5351   animation = Animation::New(durationSeconds);
5352   const bool finalValue( !targetValue );
5353   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5354
5355   // Start the animation
5356   animation.Play();
5357
5358   finishCheck.Reset();
5359   animation.FinishedSignal().Connect(&application, finishCheck);
5360
5361   application.SendNotification();
5362   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5363
5364   // We didn't expect the animation to finish yet
5365   application.SendNotification();
5366   finishCheck.CheckSignalNotReceived();
5367   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5368
5369   application.SendNotification();
5370   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5371
5372   // We did expect the animation to finish
5373   application.SendNotification();
5374   finishCheck.CheckSignalReceived();
5375   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5376
5377   // Check that nothing has changed after a couple of buffer swaps
5378   application.Render(0);
5379   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5380   application.Render(0);
5381   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5382   END_TEST;
5383 }
5384
5385 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5386 {
5387   TestApplication application;
5388
5389   Actor actor = Actor::New();
5390
5391   // Register a boolean property
5392   bool startValue(false);
5393   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5394   Stage::GetCurrent().Add(actor);
5395   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5396   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5397
5398   // Build the animation
5399   float durationSeconds(2.0f);
5400   Animation animation = Animation::New(durationSeconds);
5401   bool finalValue( !startValue );
5402   float animatorDurationSeconds(durationSeconds * 0.5f);
5403   animation.AnimateTo( Property(actor, index),
5404                        finalValue,
5405                        TimePeriod( animatorDurationSeconds ) );
5406
5407   // Start the animation
5408   animation.Play();
5409
5410   bool signalReceived(false);
5411   AnimationFinishCheck finishCheck(signalReceived);
5412   animation.FinishedSignal().Connect(&application, finishCheck);
5413
5414   application.SendNotification();
5415   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5416
5417   // We didn't expect the animation to finish yet
5418   application.SendNotification();
5419   finishCheck.CheckSignalNotReceived();
5420   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5421
5422   application.SendNotification();
5423   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5424
5425   // We didn't expect the animation to finish yet...
5426   application.SendNotification();
5427   finishCheck.CheckSignalNotReceived();
5428
5429   // ...however we should have reached the final value
5430   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5431
5432   application.SendNotification();
5433   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5434
5435   // We did expect the animation to finish
5436   application.SendNotification();
5437   finishCheck.CheckSignalReceived();
5438   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5439
5440   // Check that nothing has changed after a couple of buffer swaps
5441   application.Render(0);
5442   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5443   application.Render(0);
5444   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5445   END_TEST;
5446 }
5447
5448 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5449 {
5450   TestApplication application;
5451
5452   Actor actor = Actor::New();
5453
5454   // Register a boolean property
5455   bool startValue(false);
5456   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5457   Stage::GetCurrent().Add(actor);
5458   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5459   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5460
5461   // Build the animation
5462   float durationSeconds(2.0f);
5463   Animation animation = Animation::New(durationSeconds);
5464   bool finalValue( !startValue );
5465   float animatorDurationSeconds(durationSeconds * 0.5f);
5466   animation.AnimateTo( Property(actor, index),
5467                        finalValue,
5468                        AlphaFunction::LINEAR,
5469                        TimePeriod( animatorDurationSeconds ) );
5470
5471   // Start the animation
5472   animation.Play();
5473
5474   bool signalReceived(false);
5475   AnimationFinishCheck finishCheck(signalReceived);
5476   animation.FinishedSignal().Connect(&application, finishCheck);
5477
5478   application.SendNotification();
5479   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5480
5481   // We didn't expect the animation to finish yet
5482   application.SendNotification();
5483   finishCheck.CheckSignalNotReceived();
5484   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5485
5486   application.SendNotification();
5487   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5488
5489   // We didn't expect the animation to finish yet...
5490   application.SendNotification();
5491   finishCheck.CheckSignalNotReceived();
5492
5493   // ...however we should have reached the final value
5494   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5495
5496   application.SendNotification();
5497   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5498
5499   // We did expect the animation to finish
5500   application.SendNotification();
5501   finishCheck.CheckSignalReceived();
5502   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5503
5504   // Check that nothing has changed after a couple of buffer swaps
5505   application.Render(0);
5506   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5507   application.Render(0);
5508   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5509   END_TEST;
5510 }
5511
5512 int UtcDaliAnimationAnimateToFloatP(void)
5513 {
5514   TestApplication application;
5515
5516   Actor actor = Actor::New();
5517
5518   // Register a float property
5519   float startValue(10.0f);
5520   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5521   Stage::GetCurrent().Add(actor);
5522   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5523   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5524
5525   // Build the animation
5526   float durationSeconds(2.0f);
5527   Animation animation = Animation::New(durationSeconds);
5528   float targetValue(50.0f);
5529   float relativeValue(targetValue - startValue);
5530   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5531
5532   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5533
5534   // Start the animation
5535   animation.Play();
5536
5537   bool signalReceived(false);
5538   AnimationFinishCheck finishCheck(signalReceived);
5539   animation.FinishedSignal().Connect(&application, finishCheck);
5540
5541   application.SendNotification();
5542   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5543
5544   // We didn't expect the animation to finish yet
5545   application.SendNotification();
5546   finishCheck.CheckSignalNotReceived();
5547   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5548
5549   application.SendNotification();
5550   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5551
5552   // We did expect the animation to finish
5553   application.SendNotification();
5554   finishCheck.CheckSignalReceived();
5555   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5556   END_TEST;
5557 }
5558
5559 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5560 {
5561   TestApplication application;
5562
5563   Actor actor = Actor::New();
5564
5565   // Register a float property
5566   float startValue(10.0f);
5567   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5568   Stage::GetCurrent().Add(actor);
5569   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5570   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5571
5572   // Build the animation
5573   float durationSeconds(1.0f);
5574   Animation animation = Animation::New(durationSeconds);
5575   float targetValue(90.0f);
5576   float relativeValue(targetValue - startValue);
5577   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5578
5579   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5580
5581   // Start the animation
5582   animation.Play();
5583
5584   bool signalReceived(false);
5585   AnimationFinishCheck finishCheck(signalReceived);
5586   animation.FinishedSignal().Connect(&application, finishCheck);
5587
5588   application.SendNotification();
5589   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5590
5591   // We didn't expect the animation to finish yet
5592   application.SendNotification();
5593   finishCheck.CheckSignalNotReceived();
5594
5595   // The position should have moved more, than with a linear alpha function
5596   float current( actor.GetCurrentProperty< float >( index ) );
5597   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5598
5599   application.SendNotification();
5600   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5601
5602   // We did expect the animation to finish
5603   application.SendNotification();
5604   finishCheck.CheckSignalReceived();
5605   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5606   END_TEST;
5607 }
5608
5609 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5610 {
5611   TestApplication application;
5612
5613   Actor actor = Actor::New();
5614
5615   // Register a float property
5616   float startValue(10.0f);
5617   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5618   Stage::GetCurrent().Add(actor);
5619   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5620   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5621
5622   // Build the animation
5623   float durationSeconds(1.0f);
5624   Animation animation = Animation::New(durationSeconds);
5625   float targetValue(30.0f);
5626   float relativeValue(targetValue - startValue);
5627   float delay = 0.5f;
5628   animation.AnimateTo(Property(actor, index),
5629                       targetValue,
5630                       TimePeriod(delay, durationSeconds - delay));
5631
5632   // Start the animation
5633   animation.Play();
5634
5635   bool signalReceived(false);
5636   AnimationFinishCheck finishCheck(signalReceived);
5637   animation.FinishedSignal().Connect(&application, finishCheck);
5638
5639   application.SendNotification();
5640   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5641
5642   // We didn't expect the animation to finish yet
5643   application.SendNotification();
5644   finishCheck.CheckSignalNotReceived();
5645   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5646
5647   application.SendNotification();
5648   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5649
5650   // We didn't expect the animation to finish yet
5651   application.SendNotification();
5652   finishCheck.CheckSignalNotReceived();
5653   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5654
5655   application.SendNotification();
5656   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5657
5658   // We did expect the animation to finish
5659   application.SendNotification();
5660   finishCheck.CheckSignalReceived();
5661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5662   END_TEST;
5663 }
5664
5665 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5666 {
5667   TestApplication application;
5668
5669   Actor actor = Actor::New();
5670
5671   // Register a float property
5672   float startValue(10.0f);
5673   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5674   Stage::GetCurrent().Add(actor);
5675   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5676   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5677
5678   // Build the animation
5679   float durationSeconds(1.0f);
5680   Animation animation = Animation::New(durationSeconds);
5681   float targetValue(30.0f);
5682   float relativeValue(targetValue - startValue);
5683   float delay = 0.5f;
5684   animation.AnimateTo(Property(actor, index),
5685                       targetValue,
5686                       AlphaFunction::LINEAR,
5687                       TimePeriod(delay, durationSeconds - delay));
5688
5689   // Start the animation
5690   animation.Play();
5691
5692   bool signalReceived(false);
5693   AnimationFinishCheck finishCheck(signalReceived);
5694   animation.FinishedSignal().Connect(&application, finishCheck);
5695
5696   application.SendNotification();
5697   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5698
5699   // We didn't expect the animation to finish yet
5700   application.SendNotification();
5701   finishCheck.CheckSignalNotReceived();
5702   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5703
5704   application.SendNotification();
5705   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5706
5707   // We didn't expect the animation to finish yet
5708   application.SendNotification();
5709   finishCheck.CheckSignalNotReceived();
5710   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5711
5712   application.SendNotification();
5713   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5714
5715   // We did expect the animation to finish
5716   application.SendNotification();
5717   finishCheck.CheckSignalReceived();
5718   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5719   END_TEST;
5720 }
5721
5722 int UtcDaliAnimationAnimateToIntegerP(void)
5723 {
5724   TestApplication application;
5725
5726   Actor actor = Actor::New();
5727
5728   // Register an integer property
5729   int startValue(10);
5730   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5731   Stage::GetCurrent().Add(actor);
5732   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5733   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5734
5735   // Build the animation
5736   float durationSeconds(2.0f);
5737   Animation animation = Animation::New(durationSeconds);
5738   int targetValue(50);
5739   int relativeValue(targetValue - startValue);
5740   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5741
5742   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5743
5744   // Start the animation
5745   animation.Play();
5746
5747   bool signalReceived(false);
5748   AnimationFinishCheck finishCheck(signalReceived);
5749   animation.FinishedSignal().Connect(&application, finishCheck);
5750
5751   application.SendNotification();
5752   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5753
5754   // We didn't expect the animation to finish yet
5755   application.SendNotification();
5756   finishCheck.CheckSignalNotReceived();
5757   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5758
5759   application.SendNotification();
5760   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5761
5762   // We did expect the animation to finish
5763   application.SendNotification();
5764   finishCheck.CheckSignalReceived();
5765   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5766   END_TEST;
5767 }
5768
5769 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5770 {
5771   TestApplication application;
5772
5773   Actor actor = Actor::New();
5774
5775   // Register an integer property
5776   int startValue(10);
5777   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5778   Stage::GetCurrent().Add(actor);
5779   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5780   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5781
5782   // Build the animation
5783   float durationSeconds(1.0f);
5784   Animation animation = Animation::New(durationSeconds);
5785   int targetValue(90);
5786   int relativeValue(targetValue - startValue);
5787   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5788
5789   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5790
5791   // Start the animation
5792   animation.Play();
5793
5794   bool signalReceived(false);
5795   AnimationFinishCheck finishCheck(signalReceived);
5796   animation.FinishedSignal().Connect(&application, finishCheck);
5797
5798   application.SendNotification();
5799   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5800
5801   // We didn't expect the animation to finish yet
5802   application.SendNotification();
5803   finishCheck.CheckSignalNotReceived();
5804
5805   // The position should have moved more, than with a linear alpha function
5806   int current( actor.GetCurrentProperty< int >( index ) );
5807   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5808
5809   application.SendNotification();
5810   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5811
5812   // We did expect the animation to finish
5813   application.SendNotification();
5814   finishCheck.CheckSignalReceived();
5815   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5816   END_TEST;
5817 }
5818
5819 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5820 {
5821   TestApplication application;
5822
5823   Actor actor = Actor::New();
5824
5825   // Register an integer property
5826   int startValue(10);
5827   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5828   Stage::GetCurrent().Add(actor);
5829   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5830   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5831
5832   // Build the animation
5833   float durationSeconds(1.0f);
5834   Animation animation = Animation::New(durationSeconds);
5835   int targetValue(30);
5836   int relativeValue(targetValue - startValue);
5837   float delay = 0.5f;
5838   animation.AnimateTo(Property(actor, index),
5839                       targetValue,
5840                       TimePeriod(delay, durationSeconds - delay));
5841
5842   // Start the animation
5843   animation.Play();
5844
5845   bool signalReceived(false);
5846   AnimationFinishCheck finishCheck(signalReceived);
5847   animation.FinishedSignal().Connect(&application, finishCheck);
5848
5849   application.SendNotification();
5850   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5851
5852   // We didn't expect the animation to finish yet
5853   application.SendNotification();
5854   finishCheck.CheckSignalNotReceived();
5855   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5856
5857   application.SendNotification();
5858   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5859
5860   // We didn't expect the animation to finish yet
5861   application.SendNotification();
5862   finishCheck.CheckSignalNotReceived();
5863   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5864
5865   application.SendNotification();
5866   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5867
5868   // We did expect the animation to finish
5869   application.SendNotification();
5870   finishCheck.CheckSignalReceived();
5871   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5872   END_TEST;
5873 }
5874
5875 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5876 {
5877   TestApplication application;
5878
5879   Actor actor = Actor::New();
5880
5881   // Register an integer property
5882   int startValue(10);
5883   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5884   Stage::GetCurrent().Add(actor);
5885   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5886   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5887
5888   // Build the animation
5889   float durationSeconds(1.0f);
5890   Animation animation = Animation::New(durationSeconds);
5891   int targetValue(30);
5892   int relativeValue(targetValue - startValue);
5893   float delay = 0.5f;
5894   animation.AnimateTo(Property(actor, index),
5895                       targetValue,
5896                       AlphaFunction::LINEAR,
5897                       TimePeriod(delay, durationSeconds - delay));
5898
5899   // Start the animation
5900   animation.Play();
5901
5902   bool signalReceived(false);
5903   AnimationFinishCheck finishCheck(signalReceived);
5904   animation.FinishedSignal().Connect(&application, finishCheck);
5905
5906   application.SendNotification();
5907   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5908
5909   // We didn't expect the animation to finish yet
5910   application.SendNotification();
5911   finishCheck.CheckSignalNotReceived();
5912   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5913
5914   application.SendNotification();
5915   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5916
5917   // We didn't expect the animation to finish yet
5918   application.SendNotification();
5919   finishCheck.CheckSignalNotReceived();
5920   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5921
5922   application.SendNotification();
5923   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5924
5925   // We did expect the animation to finish
5926   application.SendNotification();
5927   finishCheck.CheckSignalReceived();
5928   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5929   END_TEST;
5930 }
5931
5932 int UtcDaliAnimationAnimateToVector2P(void)
5933 {
5934   TestApplication application;
5935
5936   Actor actor = Actor::New();
5937
5938   // Register a Vector2 property
5939   Vector2 startValue(-50.0f, -50.0f);
5940   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5941   Stage::GetCurrent().Add(actor);
5942   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5943   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5944
5945   // Build the animation
5946   float durationSeconds(2.0f);
5947   Animation animation = Animation::New(durationSeconds);
5948   Vector2 targetValue(50.0f, 50.0f);
5949   Vector2 relativeValue(targetValue - startValue);
5950   animation.AnimateTo(Property(actor, index), targetValue);
5951
5952   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5953
5954   // Start the animation
5955   animation.Play();
5956
5957   bool signalReceived(false);
5958   AnimationFinishCheck finishCheck(signalReceived);
5959   animation.FinishedSignal().Connect(&application, finishCheck);
5960
5961   application.SendNotification();
5962   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5963
5964   // We didn't expect the animation to finish yet
5965   application.SendNotification();
5966   finishCheck.CheckSignalNotReceived();
5967   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5968
5969   application.SendNotification();
5970   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5971
5972   // We did expect the animation to finish
5973   application.SendNotification();
5974   finishCheck.CheckSignalReceived();
5975   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5976   END_TEST;
5977 }
5978
5979 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
5980 {
5981   TestApplication application;
5982
5983   Actor actor = Actor::New();
5984
5985   // Register a Vector2 property
5986   Vector2 startValue(1000.0f, 1000.0f);
5987   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5988   Stage::GetCurrent().Add(actor);
5989   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5990   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5991
5992   // Build the animation
5993   float durationSeconds(1.0f);
5994   Animation animation = Animation::New(durationSeconds);
5995   Vector2 targetValue(9000.0f, 9000.0f);
5996   Vector2 relativeValue(targetValue - startValue);
5997   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5998
5999   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6000
6001   // Start the animation
6002   animation.Play();
6003
6004   bool signalReceived(false);
6005   AnimationFinishCheck finishCheck(signalReceived);
6006   animation.FinishedSignal().Connect(&application, finishCheck);
6007
6008   application.SendNotification();
6009   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6010
6011   // We didn't expect the animation to finish yet
6012   application.SendNotification();
6013   finishCheck.CheckSignalNotReceived();
6014
6015   // The position should have moved more, than with a linear alpha function
6016   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
6017   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6018   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6019
6020   application.SendNotification();
6021   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6022
6023   // We did expect the animation to finish
6024   application.SendNotification();
6025   finishCheck.CheckSignalReceived();
6026   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6027   END_TEST;
6028 }
6029
6030 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
6031 {
6032   TestApplication application;
6033
6034   Actor actor = Actor::New();
6035
6036   // Register a Vector2 property
6037   Vector2 startValue(10.0f, 10.0f);
6038   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6039   Stage::GetCurrent().Add(actor);
6040   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6041   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6042
6043   // Build the animation
6044   float durationSeconds(1.0f);
6045   Animation animation = Animation::New(durationSeconds);
6046   Vector2 targetValue(-10.0f, 20.0f);
6047   Vector2 relativeValue(targetValue - startValue);
6048   float delay = 0.5f;
6049   animation.AnimateTo(Property(actor, index),
6050                       targetValue,
6051                       TimePeriod(delay, durationSeconds - delay));
6052
6053   // Start the animation
6054   animation.Play();
6055
6056   bool signalReceived(false);
6057   AnimationFinishCheck finishCheck(signalReceived);
6058   animation.FinishedSignal().Connect(&application, finishCheck);
6059
6060   application.SendNotification();
6061   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6062
6063   // We didn't expect the animation to finish yet
6064   application.SendNotification();
6065   finishCheck.CheckSignalNotReceived();
6066   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6067
6068   application.SendNotification();
6069   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6070
6071   // We didn't expect the animation to finish yet
6072   application.SendNotification();
6073   finishCheck.CheckSignalNotReceived();
6074   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6075
6076   application.SendNotification();
6077   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6078
6079   // We did expect the animation to finish
6080   application.SendNotification();
6081   finishCheck.CheckSignalReceived();
6082   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6083   END_TEST;
6084 }
6085
6086 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
6087 {
6088   TestApplication application;
6089
6090   Actor actor = Actor::New();
6091
6092   // Register a Vector2 property
6093   Vector2 startValue(10.0f, 10.0f);
6094   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6095   Stage::GetCurrent().Add(actor);
6096   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6097   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6098
6099   // Build the animation
6100   float durationSeconds(1.0f);
6101   Animation animation = Animation::New(durationSeconds);
6102   Vector2 targetValue(30.0f, 30.0f);
6103   Vector2 relativeValue(targetValue - startValue);
6104   float delay = 0.5f;
6105   animation.AnimateTo(Property(actor, index),
6106                       targetValue,
6107                       AlphaFunction::LINEAR,
6108                       TimePeriod(delay, durationSeconds - delay));
6109
6110   // Start the animation
6111   animation.Play();
6112
6113   bool signalReceived(false);
6114   AnimationFinishCheck finishCheck(signalReceived);
6115   animation.FinishedSignal().Connect(&application, finishCheck);
6116
6117   application.SendNotification();
6118   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6119
6120   // We didn't expect the animation to finish yet, but cached value should be the final one
6121   application.SendNotification();
6122   finishCheck.CheckSignalNotReceived();
6123   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6124   DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
6125
6126   application.SendNotification();
6127   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6128
6129   // We didn't expect the animation to finish yet
6130   application.SendNotification();
6131   finishCheck.CheckSignalNotReceived();
6132   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6133
6134   application.SendNotification();
6135   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6136
6137   // We did expect the animation to finish
6138   application.SendNotification();
6139   finishCheck.CheckSignalReceived();
6140   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6141   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6142   END_TEST;
6143 }
6144
6145 int UtcDaliAnimationAnimateToVector3P(void)
6146 {
6147   TestApplication application;
6148
6149   Actor actor = Actor::New();
6150
6151   // Register a Vector3 property
6152   Vector3 startValue(-50.0f, -50.0f, -50.0f);
6153   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6154   Stage::GetCurrent().Add(actor);
6155   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
6156   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6157
6158   // Build the animation
6159   float durationSeconds(2.0f);
6160   Animation animation = Animation::New(durationSeconds);
6161   Vector3 targetValue(50.0f, 50.0f, 50.0f);
6162   Vector3 relativeValue(targetValue - startValue);
6163   animation.AnimateTo(Property(actor, index), targetValue);
6164
6165   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6166
6167   // Start the animation
6168   animation.Play();
6169
6170   bool signalReceived(false);
6171   AnimationFinishCheck finishCheck(signalReceived);
6172   animation.FinishedSignal().Connect(&application, finishCheck);
6173
6174   application.SendNotification();
6175   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6176
6177   // We didn't expect the animation to finish yet
6178   application.SendNotification();
6179   finishCheck.CheckSignalNotReceived();
6180   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6181
6182   application.SendNotification();
6183   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6184
6185   // We did expect the animation to finish
6186   application.SendNotification();
6187   finishCheck.CheckSignalReceived();
6188   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6189   END_TEST;
6190 }
6191
6192 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
6193 {
6194   TestApplication application;
6195
6196   Actor actor = Actor::New();
6197
6198   // Register a Vector3 property
6199   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
6200   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6201   Stage::GetCurrent().Add(actor);
6202   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6203   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6204
6205   // Build the animation
6206   float durationSeconds(1.0f);
6207   Animation animation = Animation::New(durationSeconds);
6208   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
6209   Vector3 relativeValue(targetValue - startValue);
6210   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6211
6212   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6213
6214   // Start the animation
6215   animation.Play();
6216
6217   bool signalReceived(false);
6218   AnimationFinishCheck finishCheck(signalReceived);
6219   animation.FinishedSignal().Connect(&application, finishCheck);
6220
6221   application.SendNotification();
6222   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6223
6224   // We didn't expect the animation to finish yet
6225   application.SendNotification();
6226   finishCheck.CheckSignalNotReceived();
6227
6228   // The position should have moved more, than with a linear alpha function
6229   Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
6230   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6231   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6232   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6233
6234   application.SendNotification();
6235   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6236
6237   // We did expect the animation to finish
6238   application.SendNotification();
6239   finishCheck.CheckSignalReceived();
6240   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6241   END_TEST;
6242 }
6243
6244 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
6245 {
6246   TestApplication application;
6247
6248   Actor actor = Actor::New();
6249
6250   // Register a Vector3 property
6251   Vector3 startValue(10.0f, 10.0f, 10.0f);
6252   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6253   Stage::GetCurrent().Add(actor);
6254   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6255   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6256
6257   // Build the animation
6258   float durationSeconds(1.0f);
6259   Animation animation = Animation::New(durationSeconds);
6260   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
6261   Vector3 relativeValue(targetValue - startValue);
6262   float delay = 0.5f;
6263   animation.AnimateTo(Property(actor, index),
6264                       targetValue,
6265                       TimePeriod(delay, durationSeconds - delay));
6266
6267   // Start the animation
6268   animation.Play();
6269
6270   bool signalReceived(false);
6271   AnimationFinishCheck finishCheck(signalReceived);
6272   animation.FinishedSignal().Connect(&application, finishCheck);
6273
6274   application.SendNotification();
6275   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6276
6277   // We didn't expect the animation to finish yet
6278   application.SendNotification();
6279   finishCheck.CheckSignalNotReceived();
6280   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6281
6282   application.SendNotification();
6283   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6284
6285   // We didn't expect the animation to finish yet
6286   application.SendNotification();
6287   finishCheck.CheckSignalNotReceived();
6288   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6289
6290   application.SendNotification();
6291   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6292
6293   // We did expect the animation to finish
6294   application.SendNotification();
6295   finishCheck.CheckSignalReceived();
6296   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6297   END_TEST;
6298 }
6299
6300 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
6301 {
6302   TestApplication application;
6303
6304   Actor actor = Actor::New();
6305
6306   // Register a Vector3 property
6307   Vector3 startValue(10.0f, 10.0f, 10.0f);
6308   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6309   Stage::GetCurrent().Add(actor);
6310   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6311   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6312
6313   // Build the animation
6314   float durationSeconds(1.0f);
6315   Animation animation = Animation::New(durationSeconds);
6316   Vector3 targetValue(30.0f, 30.0f, 30.0f);
6317   Vector3 relativeValue(targetValue - startValue);
6318   float delay = 0.5f;
6319   animation.AnimateTo(Property(actor, "testProperty"),
6320                       targetValue,
6321                       AlphaFunction::LINEAR,
6322                       TimePeriod(delay, durationSeconds - delay));
6323
6324   // Start the animation
6325   animation.Play();
6326
6327   bool signalReceived(false);
6328   AnimationFinishCheck finishCheck(signalReceived);
6329   animation.FinishedSignal().Connect(&application, finishCheck);
6330
6331   application.SendNotification();
6332   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6333
6334   // We didn't expect the animation to finish yet
6335   application.SendNotification();
6336   finishCheck.CheckSignalNotReceived();
6337   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6338
6339   application.SendNotification();
6340   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6341
6342   // We didn't expect the animation to finish yet
6343   application.SendNotification();
6344   finishCheck.CheckSignalNotReceived();
6345   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6346
6347   application.SendNotification();
6348   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6349
6350   // We did expect the animation to finish
6351   application.SendNotification();
6352   finishCheck.CheckSignalReceived();
6353   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6354   END_TEST;
6355 }
6356
6357 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6358 {
6359   TestApplication application;
6360
6361   Actor actor = Actor::New();
6362
6363   // Register a Vector3 property
6364   Vector3 startValue(10.0f, 10.0f, 10.0f);
6365   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6366   Stage::GetCurrent().Add(actor);
6367   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6368   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6369
6370   // Build the animation
6371   float durationSeconds(1.0f);
6372   Animation animation = Animation::New(durationSeconds);
6373   Vector3 targetValue(30.0f, 30.0f, 10.0f);
6374   Vector3 relativeValue(targetValue - startValue);
6375   float delay = 0.5f;
6376   animation.AnimateTo(Property(actor, "testProperty",  0),
6377                       30.0f,
6378                       AlphaFunction::LINEAR,
6379                       TimePeriod(delay, durationSeconds - delay));
6380   animation.AnimateTo(Property(actor, index, 1),
6381                       30.0f,
6382                       AlphaFunction::LINEAR,
6383                       TimePeriod(delay, durationSeconds - delay));
6384
6385   // Start the animation
6386   animation.Play();
6387
6388   bool signalReceived(false);
6389   AnimationFinishCheck finishCheck(signalReceived);
6390   animation.FinishedSignal().Connect(&application, finishCheck);
6391
6392   application.SendNotification();
6393   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6394
6395   // We didn't expect the animation to finish yet
6396   application.SendNotification();
6397   finishCheck.CheckSignalNotReceived();
6398   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6399
6400   application.SendNotification();
6401   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6402
6403   // We didn't expect the animation to finish yet
6404   application.SendNotification();
6405   finishCheck.CheckSignalNotReceived();
6406   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6407
6408   application.SendNotification();
6409   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6410
6411   // We did expect the animation to finish
6412   application.SendNotification();
6413   finishCheck.CheckSignalReceived();
6414   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6415   END_TEST;
6416 }
6417
6418 int UtcDaliAnimationAnimateToVector4P(void)
6419 {
6420   TestApplication application;
6421
6422   Actor actor = Actor::New();
6423
6424   // Register a Vector4 property
6425   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6426   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6427   Stage::GetCurrent().Add(actor);
6428   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6429   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6430
6431   // Build the animation
6432   float durationSeconds(2.0f);
6433   Animation animation = Animation::New(durationSeconds);
6434   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6435   Vector4 relativeValue(targetValue - startValue);
6436   animation.AnimateTo(Property(actor, index), targetValue);
6437
6438   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6439
6440   // Start the animation
6441   animation.Play();
6442
6443   bool signalReceived(false);
6444   AnimationFinishCheck finishCheck(signalReceived);
6445   animation.FinishedSignal().Connect(&application, finishCheck);
6446
6447   application.SendNotification();
6448   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6449
6450   // We didn't expect the animation to finish yet
6451   application.SendNotification();
6452   finishCheck.CheckSignalNotReceived();
6453   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6454
6455   application.SendNotification();
6456   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6457
6458   // We did expect the animation to finish
6459   application.SendNotification();
6460   finishCheck.CheckSignalReceived();
6461   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6462   END_TEST;
6463 }
6464
6465 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6466 {
6467   TestApplication application;
6468
6469   Actor actor = Actor::New();
6470
6471   // Register a Vector4 property
6472   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6473   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6474   Stage::GetCurrent().Add(actor);
6475   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6476   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6477
6478   // Build the animation
6479   float durationSeconds(1.0f);
6480   Animation animation = Animation::New(durationSeconds);
6481   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6482   Vector4 relativeValue(targetValue - startValue);
6483   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6484
6485   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6486
6487   // Start the animation
6488   animation.Play();
6489
6490   bool signalReceived(false);
6491   AnimationFinishCheck finishCheck(signalReceived);
6492   animation.FinishedSignal().Connect(&application, finishCheck);
6493
6494   application.SendNotification();
6495   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6496
6497   // We didn't expect the animation to finish yet
6498   application.SendNotification();
6499   finishCheck.CheckSignalNotReceived();
6500
6501   // The position should have moved more, than with a linear alpha function
6502   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6503   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6504   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6505   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6506   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6507
6508   application.SendNotification();
6509   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6510
6511   // We did expect the animation to finish
6512   application.SendNotification();
6513   finishCheck.CheckSignalReceived();
6514   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6515   END_TEST;
6516 }
6517
6518 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6519 {
6520   TestApplication application;
6521
6522   Actor actor = Actor::New();
6523
6524   // Register a Vector4 property
6525   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6526   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6527   Stage::GetCurrent().Add(actor);
6528   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6529   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6530
6531   // Build the animation
6532   float durationSeconds(1.0f);
6533   Animation animation = Animation::New(durationSeconds);
6534   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6535   Vector4 relativeValue(targetValue - startValue);
6536   float delay = 0.5f;
6537   animation.AnimateTo(Property(actor, index),
6538                       targetValue,
6539                       TimePeriod(delay, durationSeconds - delay));
6540
6541   // Start the animation
6542   animation.Play();
6543
6544   bool signalReceived(false);
6545   AnimationFinishCheck finishCheck(signalReceived);
6546   animation.FinishedSignal().Connect(&application, finishCheck);
6547
6548   application.SendNotification();
6549   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6550
6551   // We didn't expect the animation to finish yet
6552   application.SendNotification();
6553   finishCheck.CheckSignalNotReceived();
6554   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6555
6556   application.SendNotification();
6557   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6558
6559   // We didn't expect the animation to finish yet
6560   application.SendNotification();
6561   finishCheck.CheckSignalNotReceived();
6562   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6563
6564   application.SendNotification();
6565   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6566
6567   // We did expect the animation to finish
6568   application.SendNotification();
6569   finishCheck.CheckSignalReceived();
6570   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6571   END_TEST;
6572 }
6573
6574 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6575 {
6576   TestApplication application;
6577
6578   Actor actor = Actor::New();
6579
6580   // Register a Vector4 property
6581   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6582   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6583   Stage::GetCurrent().Add(actor);
6584   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6585   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6586
6587   // Build the animation
6588   float durationSeconds(1.0f);
6589   Animation animation = Animation::New(durationSeconds);
6590   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6591   Vector4 relativeValue(targetValue - startValue);
6592   float delay = 0.5f;
6593   animation.AnimateTo(Property(actor, index),
6594                       targetValue,
6595                       AlphaFunction::LINEAR,
6596                       TimePeriod(delay, durationSeconds - delay));
6597
6598   // Start the animation
6599   animation.Play();
6600
6601   bool signalReceived(false);
6602   AnimationFinishCheck finishCheck(signalReceived);
6603   animation.FinishedSignal().Connect(&application, finishCheck);
6604
6605   application.SendNotification();
6606   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6607
6608   // We didn't expect the animation to finish yet
6609   application.SendNotification();
6610   finishCheck.CheckSignalNotReceived();
6611   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6612
6613   application.SendNotification();
6614   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6615
6616   // We didn't expect the animation to finish yet
6617   application.SendNotification();
6618   finishCheck.CheckSignalNotReceived();
6619   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6620
6621   application.SendNotification();
6622   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6623
6624   // We did expect the animation to finish
6625   application.SendNotification();
6626   finishCheck.CheckSignalReceived();
6627   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6628   END_TEST;
6629 }
6630
6631 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6632 {
6633   TestApplication application;
6634
6635   Actor actor = Actor::New();
6636   Stage::GetCurrent().Add(actor);
6637   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6638
6639   // Build the animation
6640   float durationSeconds(1.0f);
6641   Animation animation = Animation::New(durationSeconds);
6642   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6643
6644   try
6645   {
6646     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6647   }
6648   catch (Dali::DaliException& e)
6649   {
6650     DALI_TEST_PRINT_ASSERT( e );
6651     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6652   }
6653   END_TEST;
6654 }
6655
6656 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
6657 {
6658   TestApplication application;
6659
6660   Actor actor = Actor::New();
6661   Stage::GetCurrent().Add(actor);
6662   float startValue(0.0f);
6663   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6664   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6665
6666   // Build the animation
6667   float durationSeconds(1.0f);
6668   Animation animation = Animation::New(durationSeconds);
6669   float targetX(1.0f);
6670
6671   try
6672   {
6673     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6674   }
6675   catch (Dali::DaliException& e)
6676   {
6677     DALI_TEST_PRINT_ASSERT( e );
6678     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6679   }
6680   END_TEST;
6681 }
6682
6683 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
6684 {
6685   TestApplication application;
6686
6687   Actor actor = Actor::New();
6688   Stage::GetCurrent().Add(actor);
6689   float startValue(0.0f);
6690   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6691   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6692
6693   // Build the animation
6694   float durationSeconds(1.0f);
6695   Animation animation = Animation::New(durationSeconds);
6696   float targetY(1.0f);
6697
6698   try
6699   {
6700     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6701   }
6702   catch (Dali::DaliException& e)
6703   {
6704     DALI_TEST_PRINT_ASSERT( e );
6705     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6706   }
6707   END_TEST;
6708 }
6709
6710 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
6711 {
6712   TestApplication application;
6713
6714   Actor actor = Actor::New();
6715   Stage::GetCurrent().Add(actor);
6716   float startValue(0.5f);
6717   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6718   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6719
6720   // Build the animation
6721   float durationSeconds(1.0f);
6722   Animation animation = Animation::New(durationSeconds);
6723   float targetZ(1.0f);
6724
6725   try
6726   {
6727     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6728   }
6729   catch (Dali::DaliException& e)
6730   {
6731     DALI_TEST_PRINT_ASSERT( e );
6732     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6733   }
6734   END_TEST;
6735 }
6736
6737 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
6738 {
6739   TestApplication application;
6740
6741   Actor actor = Actor::New();
6742   Stage::GetCurrent().Add(actor);
6743   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6744
6745   // Build the animation
6746   float durationSeconds(1.0f);
6747   Animation animation = Animation::New(durationSeconds);
6748   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6749
6750   try
6751   {
6752     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6753   }
6754   catch (Dali::DaliException& e)
6755   {
6756     DALI_TEST_PRINT_ASSERT( e );
6757     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6758   }
6759   END_TEST;
6760 }
6761
6762 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
6763 {
6764   TestApplication application;
6765
6766   Actor actor = Actor::New();
6767   Stage::GetCurrent().Add(actor);
6768   float startValue(0.5f);
6769   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6771
6772   // Build the animation
6773   float durationSeconds(1.0f);
6774   Animation animation = Animation::New(durationSeconds);
6775   float targetX(1.0f);
6776
6777   try
6778   {
6779     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6780   }
6781   catch (Dali::DaliException& e)
6782   {
6783     DALI_TEST_PRINT_ASSERT( e );
6784     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6785   }
6786   END_TEST;
6787 }
6788
6789 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
6790 {
6791   TestApplication application;
6792
6793   Actor actor = Actor::New();
6794   Stage::GetCurrent().Add(actor);
6795   float startValue(0.5f);
6796   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6797   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6798
6799   // Build the animation
6800   float durationSeconds(1.0f);
6801   Animation animation = Animation::New(durationSeconds);
6802   float targetY(0.0f);
6803
6804   try
6805   {
6806     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6807   }
6808   catch (Dali::DaliException& e)
6809   {
6810     DALI_TEST_PRINT_ASSERT( e );
6811     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6812   }
6813   END_TEST;
6814 }
6815
6816 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
6817 {
6818   TestApplication application;
6819
6820   Actor actor = Actor::New();
6821   Stage::GetCurrent().Add(actor);
6822   float startValue(0.5f);
6823   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6824   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6825
6826   // Build the animation
6827   float durationSeconds(1.0f);
6828   Animation animation = Animation::New(durationSeconds);
6829   float targetZ(100.0f);
6830
6831   try
6832   {
6833     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6834   }
6835   catch (Dali::DaliException& e)
6836   {
6837     DALI_TEST_PRINT_ASSERT( e );
6838     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6839   }
6840   END_TEST;
6841 }
6842
6843 int UtcDaliAnimationAnimateToActorSizeP(void)
6844 {
6845   TestApplication application;
6846
6847   Actor actor = Actor::New();
6848   Stage::GetCurrent().Add(actor);
6849   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6850
6851   // Build the animation
6852   float durationSeconds(1.0f);
6853   Animation animation = Animation::New(durationSeconds);
6854   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6855   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6856
6857   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6858
6859   // Should return the initial properties before play
6860   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6861   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6862   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6863   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6864
6865   // Start the animation
6866   animation.Play();
6867
6868   // Should return the target property after play
6869   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6870   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6871   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6872   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6873
6874   bool signalReceived(false);
6875   AnimationFinishCheck finishCheck(signalReceived);
6876   animation.FinishedSignal().Connect(&application, finishCheck);
6877
6878   application.SendNotification();
6879   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6880
6881   // We didn't expect the animation to finish yet
6882   application.SendNotification();
6883   finishCheck.CheckSignalNotReceived();
6884   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6885
6886   application.SendNotification();
6887   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6888
6889   // We did expect the animation to finish
6890   application.SendNotification();
6891   finishCheck.CheckSignalReceived();
6892   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6893
6894   // Reset everything
6895   finishCheck.Reset();
6896   actor.SetSize(Vector3::ZERO);
6897   application.SendNotification();
6898   application.Render(0);
6899   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6900
6901   // Repeat with a different (ease-in) alpha function
6902   animation = Animation::New(durationSeconds);
6903   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6904   animation.FinishedSignal().Connect(&application, finishCheck);
6905   animation.Play();
6906
6907   application.SendNotification();
6908   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6909
6910   // We didn't expect the animation to finish yet
6911   application.SendNotification();
6912   finishCheck.CheckSignalNotReceived();
6913
6914   // The size should have travelled less, than with a linear alpha function
6915   Vector3 current(actor.GetCurrentSize());
6916   DALI_TEST_CHECK( current.x > 0.0f );
6917   DALI_TEST_CHECK( current.y > 0.0f );
6918   DALI_TEST_CHECK( current.z > 0.0f );
6919   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6920   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6921   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6922
6923   application.SendNotification();
6924   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6925
6926   // We did expect the animation to finish
6927   application.SendNotification();
6928   finishCheck.CheckSignalReceived();
6929   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6930
6931   // Reset everything
6932   finishCheck.Reset();
6933   actor.SetSize(Vector3::ZERO);
6934   application.SendNotification();
6935   application.Render(0);
6936   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6937
6938   // Repeat with a delay
6939   float delay = 0.5f;
6940   animation = Animation::New(durationSeconds);
6941   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6942   animation.FinishedSignal().Connect(&application, finishCheck);
6943   animation.Play();
6944
6945   application.SendNotification();
6946   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6947
6948   // We didn't expect the animation to finish yet
6949   application.SendNotification();
6950   finishCheck.CheckSignalNotReceived();
6951   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6952
6953   application.SendNotification();
6954   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6955
6956   // We did expect the animation to finish
6957   application.SendNotification();
6958   finishCheck.CheckSignalReceived();
6959   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6960   END_TEST;
6961 }
6962
6963 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6964 {
6965   TestApplication application;
6966
6967   Actor actor = Actor::New();
6968   Stage::GetCurrent().Add(actor);
6969   float startValue(0.0f);
6970   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6971   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6972
6973   // Build the animation
6974   float durationSeconds(1.0f);
6975   Animation animation = Animation::New(durationSeconds);
6976   float targetWidth(10.0f);
6977   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
6978
6979   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
6980
6981   // Should return the initial properties before play
6982   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6983   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
6984
6985   // Start the animation
6986   animation.Play();
6987
6988   // Should return the target property after play
6989   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
6990   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
6991
6992   bool signalReceived(false);
6993   AnimationFinishCheck finishCheck(signalReceived);
6994   animation.FinishedSignal().Connect(&application, finishCheck);
6995
6996   application.SendNotification();
6997   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6998
6999   // We didn't expect the animation to finish yet
7000   application.SendNotification();
7001   finishCheck.CheckSignalNotReceived();
7002   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
7003
7004   application.SendNotification();
7005   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7006
7007   // We did expect the animation to finish
7008   application.SendNotification();
7009   finishCheck.CheckSignalReceived();
7010   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
7011   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7012   END_TEST;
7013 }
7014
7015 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7016 {
7017   TestApplication application;
7018
7019   Actor actor = Actor::New();
7020   Stage::GetCurrent().Add(actor);
7021   float startValue(0.0f);
7022   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
7023   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7024
7025   // Build the animation
7026   float durationSeconds(1.0f);
7027   Animation animation = Animation::New(durationSeconds);
7028   float targetHeight(-10.0f);
7029   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7030
7031   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7032
7033   // Should return the initial properties before play
7034   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7035   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7036
7037   // Start the animation
7038   animation.Play();
7039
7040   // Should return the target property after play
7041   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7042   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7043
7044   bool signalReceived(false);
7045   AnimationFinishCheck finishCheck(signalReceived);
7046   animation.FinishedSignal().Connect(&application, finishCheck);
7047
7048   application.SendNotification();
7049   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7050
7051   // We didn't expect the animation to finish yet
7052   application.SendNotification();
7053   finishCheck.CheckSignalNotReceived();
7054   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
7055
7056   application.SendNotification();
7057   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7058
7059   // We did expect the animation to finish
7060   application.SendNotification();
7061   finishCheck.CheckSignalReceived();
7062   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
7063   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7064   END_TEST;
7065 }
7066
7067 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7068 {
7069   TestApplication application;
7070
7071   Actor actor = Actor::New();
7072   Stage::GetCurrent().Add(actor);
7073   float startValue(0.0f);
7074   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
7075   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7076
7077   // Build the animation
7078   float durationSeconds(1.0f);
7079   Animation animation = Animation::New(durationSeconds);
7080   float targetDepth(-10.0f);
7081   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7082
7083   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7084
7085   // Should return the initial properties before play
7086   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7087   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7088
7089   // Start the animation
7090   animation.Play();
7091
7092   // Should return the target property after play
7093   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7094   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7095
7096   bool signalReceived(false);
7097   AnimationFinishCheck finishCheck(signalReceived);
7098   animation.FinishedSignal().Connect(&application, finishCheck);
7099
7100   application.SendNotification();
7101   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7102
7103   // We didn't expect the animation to finish yet
7104   application.SendNotification();
7105   finishCheck.CheckSignalNotReceived();
7106   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
7107
7108   application.SendNotification();
7109   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7110
7111   // We did expect the animation to finish
7112   application.SendNotification();
7113   finishCheck.CheckSignalReceived();
7114   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
7115   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7116   END_TEST;
7117 }
7118
7119 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7120 {
7121   TestApplication application;
7122
7123   Actor actor = Actor::New();
7124   Stage::GetCurrent().Add(actor);
7125   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7126
7127   // Build the animation
7128   float durationSeconds(1.0f);
7129   Animation animation = Animation::New(durationSeconds);
7130   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7131   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7132
7133   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7134
7135   // Start the animation
7136   animation.Play();
7137
7138   bool signalReceived(false);
7139   AnimationFinishCheck finishCheck(signalReceived);
7140   animation.FinishedSignal().Connect(&application, finishCheck);
7141
7142   application.SendNotification();
7143   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7144
7145   // We didn't expect the animation to finish yet
7146   application.SendNotification();
7147   finishCheck.CheckSignalNotReceived();
7148   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
7149
7150   application.SendNotification();
7151   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7152
7153   // We did expect the animation to finish
7154   application.SendNotification();
7155   finishCheck.CheckSignalReceived();
7156   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7157
7158   // Reset everything
7159   finishCheck.Reset();
7160   actor.SetSize(Vector3::ZERO);
7161   application.SendNotification();
7162   application.Render(0);
7163   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7164
7165   // Repeat with a different (ease-in) alpha function
7166   animation = Animation::New(durationSeconds);
7167   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7168   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7169   animation.FinishedSignal().Connect(&application, finishCheck);
7170   animation.Play();
7171
7172   application.SendNotification();
7173   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7174
7175   // We didn't expect the animation to finish yet
7176   application.SendNotification();
7177   finishCheck.CheckSignalNotReceived();
7178
7179   // The size should have travelled less, than with a linear alpha function
7180   Vector3 current(actor.GetCurrentSize());
7181   DALI_TEST_CHECK( current.x > 0.0f );
7182   DALI_TEST_CHECK( current.y > 0.0f );
7183   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7184   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7185
7186   application.SendNotification();
7187   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7188
7189   // We did expect the animation to finish
7190   application.SendNotification();
7191   finishCheck.CheckSignalReceived();
7192   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7193   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7194
7195   // Reset everything
7196   finishCheck.Reset();
7197   actor.SetSize(Vector3::ZERO);
7198   application.SendNotification();
7199   application.Render(0);
7200   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7201
7202   // Repeat with a delay
7203   float delay = 0.5f;
7204   animation = Animation::New(durationSeconds);
7205   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7206   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7207   animation.FinishedSignal().Connect(&application, finishCheck);
7208   animation.Play();
7209
7210   application.SendNotification();
7211   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7212
7213   // We didn't expect the animation to finish yet
7214   application.SendNotification();
7215   finishCheck.CheckSignalNotReceived();
7216   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7217
7218   application.SendNotification();
7219   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7220
7221   // We did expect the animation to finish
7222   application.SendNotification();
7223   finishCheck.CheckSignalReceived();
7224   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7225   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7226   END_TEST;
7227 }
7228
7229 int UtcDaliAnimationAnimateToActorPositionP(void)
7230 {
7231   TestApplication application;
7232
7233   Actor actor = Actor::New();
7234   Stage::GetCurrent().Add(actor);
7235   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7236
7237   // Build the animation
7238   float durationSeconds(1.0f);
7239   Animation animation = Animation::New(durationSeconds);
7240   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7241   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7242
7243   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7244
7245   // Should return the initial properties before play
7246   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7247   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7248   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7249   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7250
7251   // Start the animation
7252   animation.Play();
7253
7254   // Should return the target property after play
7255   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7256   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7257   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7258   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
7259
7260   bool signalReceived(false);
7261   AnimationFinishCheck finishCheck(signalReceived);
7262   animation.FinishedSignal().Connect(&application, finishCheck);
7263
7264   application.SendNotification();
7265   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7266
7267   // We didn't expect the animation to finish yet
7268   application.SendNotification();
7269   finishCheck.CheckSignalNotReceived();
7270   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7271
7272   application.SendNotification();
7273   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7274
7275   // We did expect the animation to finish
7276   application.SendNotification();
7277   finishCheck.CheckSignalReceived();
7278   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7279   END_TEST;
7280 }
7281
7282 int UtcDaliAnimationAnimateToActorPositionXP(void)
7283 {
7284   TestApplication application;
7285
7286   Actor actor = Actor::New();
7287   Stage::GetCurrent().Add(actor);
7288   float startValue(0.0f);
7289   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
7290   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7291   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7292   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7293
7294   // Build the animation
7295   float durationSeconds(1.0f);
7296   Animation animation = Animation::New(durationSeconds);
7297   float targetX(1.0f);
7298   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7299
7300   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7301
7302   // Should return the initial properties before play
7303   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7304   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7305
7306   // Start the animation
7307   animation.Play();
7308
7309   // Should return the target property after play
7310   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7311   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
7312
7313   bool signalReceived(false);
7314   AnimationFinishCheck finishCheck(signalReceived);
7315   animation.FinishedSignal().Connect(&application, finishCheck);
7316
7317   application.SendNotification();
7318   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7319
7320   // We didn't expect the animation to finish yet
7321   application.SendNotification();
7322   finishCheck.CheckSignalNotReceived();
7323   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
7324
7325   application.SendNotification();
7326   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7327
7328   // We did expect the animation to finish
7329   application.SendNotification();
7330   finishCheck.CheckSignalReceived();
7331   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
7332   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7333   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7334   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7335   END_TEST;
7336 }
7337
7338 int UtcDaliAnimationAnimateToActorPositionYP(void)
7339 {
7340   TestApplication application;
7341
7342   Actor actor = Actor::New();
7343   Stage::GetCurrent().Add(actor);
7344   float startValue(0.0f);
7345   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7346   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7349
7350   // Build the animation
7351   float durationSeconds(1.0f);
7352   Animation animation = Animation::New(durationSeconds);
7353   float targetY(10.0f);
7354   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7355
7356   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7357
7358   // Should return the initial properties before play
7359   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7360   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7361
7362   // Start the animation
7363   animation.Play();
7364
7365   // Should return the target property after play
7366   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7367   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7368
7369   bool signalReceived(false);
7370   AnimationFinishCheck finishCheck(signalReceived);
7371   animation.FinishedSignal().Connect(&application, finishCheck);
7372
7373   application.SendNotification();
7374   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7375
7376   // We didn't expect the animation to finish yet
7377   application.SendNotification();
7378   finishCheck.CheckSignalNotReceived();
7379   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7380
7381   application.SendNotification();
7382   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7383
7384   // We did expect the animation to finish
7385   application.SendNotification();
7386   finishCheck.CheckSignalReceived();
7387   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7388   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7389   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7390   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7391   END_TEST;
7392 }
7393
7394 int UtcDaliAnimationAnimateToActorPositionZP(void)
7395 {
7396   TestApplication application;
7397
7398   Actor actor = Actor::New();
7399   Stage::GetCurrent().Add(actor);
7400   float startValue(0.0f);
7401   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7402   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7403   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7404   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7405
7406   // Build the animation
7407   float durationSeconds(1.0f);
7408   Animation animation = Animation::New(durationSeconds);
7409   float targetZ(-5.0f);
7410   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7411
7412   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7413
7414   // Should return the initial properties before play
7415   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7416   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7417
7418   // Start the animation
7419   animation.Play();
7420
7421   // Should return the target property after play
7422   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7423   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7424
7425   bool signalReceived(false);
7426   AnimationFinishCheck finishCheck(signalReceived);
7427   animation.FinishedSignal().Connect(&application, finishCheck);
7428
7429   application.SendNotification();
7430   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7431
7432   // We didn't expect the animation to finish yet
7433   application.SendNotification();
7434   finishCheck.CheckSignalNotReceived();
7435   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7436
7437   application.SendNotification();
7438   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7439
7440   // We did expect the animation to finish
7441   application.SendNotification();
7442   finishCheck.CheckSignalReceived();
7443   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7444   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7445   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7446   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7447   END_TEST;
7448 }
7449
7450 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7451 {
7452   TestApplication application;
7453
7454   Actor actor = Actor::New();
7455   Stage::GetCurrent().Add(actor);
7456   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7457
7458   // Build the animation
7459   float durationSeconds(1.0f);
7460   Animation animation = Animation::New(durationSeconds);
7461   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7462   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7463
7464   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7465
7466   // Start the animation
7467   animation.Play();
7468
7469   bool signalReceived(false);
7470   AnimationFinishCheck finishCheck(signalReceived);
7471   animation.FinishedSignal().Connect(&application, finishCheck);
7472
7473   application.SendNotification();
7474   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7475
7476   // We didn't expect the animation to finish yet
7477   application.SendNotification();
7478   finishCheck.CheckSignalNotReceived();
7479
7480   // The position should have moved less, than with a linear alpha function
7481   Vector3 current(actor.GetCurrentPosition());
7482   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7483   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7484   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7485   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7486   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7487   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7488
7489   application.SendNotification();
7490   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7491
7492   // We did expect the animation to finish
7493   application.SendNotification();
7494   finishCheck.CheckSignalReceived();
7495   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7496   END_TEST;
7497 }
7498
7499 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7500 {
7501   TestApplication application;
7502
7503   Actor actor = Actor::New();
7504   Stage::GetCurrent().Add(actor);
7505   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7506
7507   // Build the animation
7508   float durationSeconds(1.0f);
7509   Animation animation = Animation::New(durationSeconds);
7510   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7511   float delay = 0.5f;
7512   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7513                        targetPosition,
7514                        TimePeriod( delay, durationSeconds - delay ) );
7515
7516   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7517
7518   // Start the animation
7519   animation.Play();
7520
7521   bool signalReceived(false);
7522   AnimationFinishCheck finishCheck(signalReceived);
7523   animation.FinishedSignal().Connect(&application, finishCheck);
7524
7525   application.SendNotification();
7526   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7527
7528   // We didn't expect the animation to finish yet
7529   application.SendNotification();
7530   finishCheck.CheckSignalNotReceived();
7531   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7532
7533   application.SendNotification();
7534   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7535
7536   // We didn't expect the animation to finish yet
7537   application.SendNotification();
7538   finishCheck.CheckSignalNotReceived();
7539   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7540
7541   application.SendNotification();
7542   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7543
7544   // We did expect the animation to finish
7545   application.SendNotification();
7546   finishCheck.CheckSignalReceived();
7547   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7548   END_TEST;
7549 }
7550
7551 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7552 {
7553   TestApplication application;
7554
7555   Actor actor = Actor::New();
7556   Stage::GetCurrent().Add(actor);
7557   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7558
7559   // Build the animation
7560   float durationSeconds(1.0f);
7561   Animation animation = Animation::New(durationSeconds);
7562   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7563   float delay = 0.5f;
7564   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7565                        targetPosition,
7566                        AlphaFunction::LINEAR,
7567                        TimePeriod( delay, durationSeconds - delay ) );
7568
7569   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7570
7571   // Start the animation
7572   animation.Play();
7573
7574   bool signalReceived(false);
7575   AnimationFinishCheck finishCheck(signalReceived);
7576   animation.FinishedSignal().Connect(&application, finishCheck);
7577
7578   application.SendNotification();
7579   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7580
7581   // We didn't expect the animation to finish yet
7582   application.SendNotification();
7583   finishCheck.CheckSignalNotReceived();
7584   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7585
7586   application.SendNotification();
7587   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7588
7589   // We didn't expect the animation to finish yet
7590   application.SendNotification();
7591   finishCheck.CheckSignalNotReceived();
7592   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7593
7594   application.SendNotification();
7595   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7596
7597   // We did expect the animation to finish
7598   application.SendNotification();
7599   finishCheck.CheckSignalReceived();
7600   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7601   END_TEST;
7602 }
7603
7604 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7605 {
7606   TestApplication application;
7607
7608   Actor actor = Actor::New();
7609   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7610   Stage::GetCurrent().Add(actor);
7611   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7612
7613   // Build the animation
7614   float durationSeconds(1.0f);
7615   Animation animation = Animation::New(durationSeconds);
7616   Degree targetRotationDegrees(90.0f);
7617   Radian targetRotationRadians(targetRotationDegrees);
7618   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7619
7620   // Start the animation
7621   animation.Play();
7622
7623   // Target value should be retrievable straight away
7624   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7625
7626   bool signalReceived(false);
7627   AnimationFinishCheck finishCheck(signalReceived);
7628   animation.FinishedSignal().Connect(&application, finishCheck);
7629
7630   application.SendNotification();
7631   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7632
7633   // We didn't expect the animation to finish yet
7634   application.SendNotification();
7635   finishCheck.CheckSignalNotReceived();
7636   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7637
7638   application.SendNotification();
7639   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7640
7641   // We didn't expect the animation to finish yet
7642   application.SendNotification();
7643   finishCheck.CheckSignalNotReceived();
7644   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7645
7646   application.SendNotification();
7647   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7648
7649   // We didn't expect the animation to finish yet
7650   application.SendNotification();
7651   finishCheck.CheckSignalNotReceived();
7652   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7653
7654   application.SendNotification();
7655   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7656
7657   // We did expect the animation to finish
7658   application.SendNotification();
7659   finishCheck.CheckSignalReceived();
7660   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7661   END_TEST;
7662 }
7663
7664 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7665 {
7666   TestApplication application;
7667
7668   Actor actor = Actor::New();
7669   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7670   Stage::GetCurrent().Add(actor);
7671   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7672
7673   // Build the animation
7674   float durationSeconds(1.0f);
7675   Animation animation = Animation::New(durationSeconds);
7676   Degree targetRotationDegrees(90.0f);
7677   Radian targetRotationRadians(targetRotationDegrees);
7678   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7679   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7680
7681   // Start the animation
7682   animation.Play();
7683
7684   bool signalReceived(false);
7685   AnimationFinishCheck finishCheck(signalReceived);
7686   animation.FinishedSignal().Connect(&application, finishCheck);
7687
7688   application.SendNotification();
7689   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7690
7691   // We didn't expect the animation to finish yet
7692   application.SendNotification();
7693   finishCheck.CheckSignalNotReceived();
7694   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7695
7696   application.SendNotification();
7697   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7698
7699   // We didn't expect the animation to finish yet
7700   application.SendNotification();
7701   finishCheck.CheckSignalNotReceived();
7702   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7703
7704   application.SendNotification();
7705   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7706
7707   // We didn't expect the animation to finish yet
7708   application.SendNotification();
7709   finishCheck.CheckSignalNotReceived();
7710   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7711
7712   application.SendNotification();
7713   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7714
7715   // We did expect the animation to finish
7716   application.SendNotification();
7717   finishCheck.CheckSignalReceived();
7718   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7719   END_TEST;
7720 }
7721
7722 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7723 {
7724   TestApplication application;
7725
7726   Actor actor = Actor::New();
7727   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7728   Stage::GetCurrent().Add(actor);
7729   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7730
7731   // Build the animation
7732   float durationSeconds(1.0f);
7733   Animation animation = Animation::New(durationSeconds);
7734   Degree targetRotationDegrees(90.0f);
7735   Radian targetRotationRadians(targetRotationDegrees);
7736   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7737
7738   // Start the animation
7739   animation.Play();
7740
7741   bool signalReceived(false);
7742   AnimationFinishCheck finishCheck(signalReceived);
7743   animation.FinishedSignal().Connect(&application, finishCheck);
7744
7745   application.SendNotification();
7746   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7747
7748   // We didn't expect the animation to finish yet
7749   application.SendNotification();
7750   finishCheck.CheckSignalNotReceived();
7751   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7752
7753   application.SendNotification();
7754   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7755
7756   // We didn't expect the animation to finish yet
7757   application.SendNotification();
7758   finishCheck.CheckSignalNotReceived();
7759   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7760
7761   application.SendNotification();
7762   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7763
7764   // We didn't expect the animation to finish yet
7765   application.SendNotification();
7766   finishCheck.CheckSignalNotReceived();
7767   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7768
7769   application.SendNotification();
7770   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7771
7772   // We did expect the animation to finish
7773   application.SendNotification();
7774   finishCheck.CheckSignalReceived();
7775   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7776   END_TEST;
7777 }
7778
7779 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7780 {
7781   TestApplication application;
7782
7783   Actor actor = Actor::New();
7784   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7785   Stage::GetCurrent().Add(actor);
7786   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7787
7788   // Build the animation
7789   float durationSeconds(1.0f);
7790   Animation animation = Animation::New(durationSeconds);
7791   Degree targetRotationDegrees(90.0f);
7792   Radian targetRotationRadians(targetRotationDegrees);
7793   float delay(0.1f);
7794   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7795
7796   // Start the animation
7797   animation.Play();
7798
7799   bool signalReceived(false);
7800   AnimationFinishCheck finishCheck(signalReceived);
7801   animation.FinishedSignal().Connect(&application, finishCheck);
7802
7803   application.SendNotification();
7804   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7805
7806   // We didn't expect the animation to finish yet
7807   application.SendNotification();
7808   finishCheck.CheckSignalNotReceived();
7809   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7810   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7811
7812   application.SendNotification();
7813   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7814
7815   // We didn't expect the animation to finish yet
7816   application.SendNotification();
7817   finishCheck.CheckSignalNotReceived();
7818   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7819   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7820
7821   application.SendNotification();
7822   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7823
7824   // We didn't expect the animation to finish yet
7825   application.SendNotification();
7826   finishCheck.CheckSignalNotReceived();
7827   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7828   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7829
7830   application.SendNotification();
7831   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7832
7833   // We did expect the animation to finish
7834   application.SendNotification();
7835   finishCheck.CheckSignalReceived();
7836   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7837   END_TEST;
7838 }
7839
7840 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7841 {
7842   TestApplication application;
7843
7844   Actor actor = Actor::New();
7845   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7846   Stage::GetCurrent().Add(actor);
7847   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7848
7849   // Build the animation
7850   float durationSeconds(1.0f);
7851   Animation animation = Animation::New(durationSeconds);
7852   Degree targetRotationDegrees(90.0f);
7853   Radian targetRotationRadians(targetRotationDegrees);
7854   float delay(0.1f);
7855   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7856
7857   // Start the animation
7858   animation.Play();
7859
7860   bool signalReceived(false);
7861   AnimationFinishCheck finishCheck(signalReceived);
7862   animation.FinishedSignal().Connect(&application, finishCheck);
7863
7864   application.SendNotification();
7865   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7866
7867   // We didn't expect the animation to finish yet
7868   application.SendNotification();
7869   finishCheck.CheckSignalNotReceived();
7870   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7871   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7872
7873   application.SendNotification();
7874   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7875
7876   // We didn't expect the animation to finish yet
7877   application.SendNotification();
7878   finishCheck.CheckSignalNotReceived();
7879   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7880   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7881
7882   application.SendNotification();
7883   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7884
7885   // We didn't expect the animation to finish yet
7886   application.SendNotification();
7887   finishCheck.CheckSignalNotReceived();
7888   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7889   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7890
7891   application.SendNotification();
7892   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7893
7894   // We did expect the animation to finish
7895   application.SendNotification();
7896   finishCheck.CheckSignalReceived();
7897   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7898   END_TEST;
7899 }
7900
7901 int UtcDaliAnimationAnimateToActorScaleP(void)
7902 {
7903   TestApplication application;
7904
7905   Actor actor = Actor::New();
7906   Stage::GetCurrent().Add(actor);
7907   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7908
7909   // Build the animation
7910   float durationSeconds(1.0f);
7911   Animation animation = Animation::New(durationSeconds);
7912   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7913   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7914
7915   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7916
7917   // Start the animation
7918   animation.Play();
7919
7920   // Target value should be retrievable straight away
7921   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7922   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7923   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7924   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
7925
7926   bool signalReceived(false);
7927   AnimationFinishCheck finishCheck(signalReceived);
7928   animation.FinishedSignal().Connect(&application, finishCheck);
7929
7930   application.SendNotification();
7931   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7932
7933   // We didn't expect the animation to finish yet
7934   application.SendNotification();
7935   finishCheck.CheckSignalNotReceived();
7936   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7937
7938   application.SendNotification();
7939   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7940
7941   // We did expect the animation to finish
7942   application.SendNotification();
7943   finishCheck.CheckSignalReceived();
7944   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7945
7946   // Reset everything
7947   finishCheck.Reset();
7948   actor.SetScale(Vector3::ONE);
7949   application.SendNotification();
7950   application.Render(0);
7951   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7952
7953   // Repeat with a different (ease-in) alpha function
7954   animation = Animation::New(durationSeconds);
7955   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7956   animation.FinishedSignal().Connect(&application, finishCheck);
7957   animation.Play();
7958
7959   application.SendNotification();
7960   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7961
7962   // We didn't expect the animation to finish yet
7963   application.SendNotification();
7964   finishCheck.CheckSignalNotReceived();
7965
7966   // The scale should have grown less, than with a linear alpha function
7967   Vector3 current(actor.GetCurrentScale());
7968   DALI_TEST_CHECK( current.x > 1.0f );
7969   DALI_TEST_CHECK( current.y > 1.0f );
7970   DALI_TEST_CHECK( current.z > 1.0f );
7971   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7972   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7973   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7974
7975   application.SendNotification();
7976   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7977
7978   // We did expect the animation to finish
7979   application.SendNotification();
7980   finishCheck.CheckSignalReceived();
7981   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7982
7983   // Reset everything
7984   finishCheck.Reset();
7985   actor.SetScale(Vector3::ONE);
7986   application.SendNotification();
7987   application.Render(0);
7988   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7989
7990   // Repeat with a delay
7991   float delay = 0.5f;
7992   animation = Animation::New(durationSeconds);
7993   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
7994   animation.FinishedSignal().Connect(&application, finishCheck);
7995   animation.Play();
7996
7997   application.SendNotification();
7998   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7999
8000   // We didn't expect the animation to finish yet
8001   application.SendNotification();
8002   finishCheck.CheckSignalNotReceived();
8003   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8004
8005   application.SendNotification();
8006   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8007
8008   // We did expect the animation to finish
8009   application.SendNotification();
8010   finishCheck.CheckSignalReceived();
8011   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8012   END_TEST;
8013 }
8014
8015 int UtcDaliAnimationAnimateToActorScaleXP(void)
8016 {
8017   TestApplication application;
8018
8019   Actor actor = Actor::New();
8020   Stage::GetCurrent().Add(actor);
8021   float startValue(1.0f);
8022   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
8023   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8024   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8025   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8026   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8027   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8028   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8029
8030   // Build the animation
8031   float durationSeconds(1.0f);
8032   Animation animation = Animation::New(durationSeconds);
8033   float targetX(10.0f);
8034   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8035
8036   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8037
8038   // Start the animation
8039   animation.Play();
8040
8041   // Target value should be retrievable straight away
8042   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8043   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8044
8045   bool signalReceived(false);
8046   AnimationFinishCheck finishCheck(signalReceived);
8047   animation.FinishedSignal().Connect(&application, finishCheck);
8048
8049   application.SendNotification();
8050   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8051
8052   // We didn't expect the animation to finish yet
8053   application.SendNotification();
8054   finishCheck.CheckSignalNotReceived();
8055   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
8056   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8057   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8058   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8059
8060   application.SendNotification();
8061   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8062
8063   // We did expect the animation to finish
8064   application.SendNotification();
8065   finishCheck.CheckSignalReceived();
8066   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
8067   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8068   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8069   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8070   END_TEST;
8071 }
8072
8073 int UtcDaliAnimationAnimateToActorScaleYP(void)
8074 {
8075   TestApplication application;
8076
8077   Actor actor = Actor::New();
8078   Stage::GetCurrent().Add(actor);
8079   float startValue(1.0f);
8080   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
8081   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8082   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8083   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8084   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8086   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8087
8088   // Build the animation
8089   float durationSeconds(1.0f);
8090   Animation animation = Animation::New(durationSeconds);
8091   float targetY(1000.0f);
8092   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8093
8094   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8095
8096   // Start the animation
8097   animation.Play();
8098
8099   // Target value should be retrievable straight away
8100   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8101   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8102
8103   bool signalReceived(false);
8104   AnimationFinishCheck finishCheck(signalReceived);
8105   animation.FinishedSignal().Connect(&application, finishCheck);
8106
8107   application.SendNotification();
8108   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8109
8110   // We didn't expect the animation to finish yet
8111   application.SendNotification();
8112   finishCheck.CheckSignalNotReceived();
8113   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
8114   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8115   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8116   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8117
8118   application.SendNotification();
8119   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8120
8121   // We did expect the animation to finish
8122   application.SendNotification();
8123   finishCheck.CheckSignalReceived();
8124   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
8125   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8126   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8127   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8128   END_TEST;
8129 }
8130
8131 int UtcDaliAnimationAnimateToActorScaleZP(void)
8132 {
8133   TestApplication application;
8134
8135   Actor actor = Actor::New();
8136   Stage::GetCurrent().Add(actor);
8137   float startValue(1.0f);
8138   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
8139   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8140   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8141   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8142   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8143   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8144   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8145
8146   // Build the animation
8147   float durationSeconds(1.0f);
8148   Animation animation = Animation::New(durationSeconds);
8149   float targetZ(-1000.0f);
8150   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8151
8152   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8153
8154   // Start the animation
8155   animation.Play();
8156
8157   // Target value should be retrievable straight away
8158   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8159   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8160
8161   bool signalReceived(false);
8162   AnimationFinishCheck finishCheck(signalReceived);
8163   animation.FinishedSignal().Connect(&application, finishCheck);
8164
8165   application.SendNotification();
8166   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8167
8168   // We didn't expect the animation to finish yet
8169   application.SendNotification();
8170   finishCheck.CheckSignalNotReceived();
8171   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
8172   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8173   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8174   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8175
8176   application.SendNotification();
8177   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8178
8179   // We did expect the animation to finish
8180   application.SendNotification();
8181   finishCheck.CheckSignalReceived();
8182   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
8183   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8184   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8185   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8186   END_TEST;
8187 }
8188
8189 int UtcDaliAnimationAnimateToActorColorP(void)
8190 {
8191   TestApplication application;
8192
8193   Actor actor = Actor::New();
8194   Stage::GetCurrent().Add(actor);
8195   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8196
8197   // Build the animation
8198   float durationSeconds(1.0f);
8199   Animation animation = Animation::New(durationSeconds);
8200   Vector4 targetColor(Color::RED);
8201   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8202
8203   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8204   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8205
8206   // Start the animation
8207   animation.Play();
8208
8209   // Target value should be retrievable straight away
8210   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8211   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8212   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8213   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8214   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8215   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8216
8217   bool signalReceived(false);
8218   AnimationFinishCheck finishCheck(signalReceived);
8219   animation.FinishedSignal().Connect(&application, finishCheck);
8220
8221   application.SendNotification();
8222   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8223
8224   // We didn't expect the animation to finish yet
8225   application.SendNotification();
8226   finishCheck.CheckSignalNotReceived();
8227   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8228
8229   application.SendNotification();
8230   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8231
8232   // We did expect the animation to finish
8233   application.SendNotification();
8234   finishCheck.CheckSignalReceived();
8235   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8236
8237   // Reset everything
8238   finishCheck.Reset();
8239   actor.SetColor(Color::WHITE);
8240   application.SendNotification();
8241   application.Render(0);
8242   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8243
8244   // Repeat with a different (ease-in) alpha function
8245   animation = Animation::New(durationSeconds);
8246   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8247   animation.FinishedSignal().Connect(&application, finishCheck);
8248   animation.Play();
8249
8250   application.SendNotification();
8251   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8252
8253   // We didn't expect the animation to finish yet
8254   application.SendNotification();
8255   finishCheck.CheckSignalNotReceived();
8256
8257   // The color should have changed less, than with a linear alpha function
8258   Vector4 current(actor.GetCurrentColor());
8259   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8260   DALI_TEST_CHECK( current.y < 1.0f );
8261   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8262   DALI_TEST_CHECK( current.z  < 1.0f );
8263   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8264   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8265
8266   application.SendNotification();
8267   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8268
8269   // We did expect the animation to finish
8270   application.SendNotification();
8271   finishCheck.CheckSignalReceived();
8272   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8273
8274   // Reset everything
8275   finishCheck.Reset();
8276   actor.SetColor(Color::WHITE);
8277   application.SendNotification();
8278   application.Render(0);
8279   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8280
8281   // Repeat with a shorter animator duration
8282   float animatorDuration = 0.5f;
8283   animation = Animation::New(durationSeconds);
8284   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8285   animation.FinishedSignal().Connect(&application, finishCheck);
8286   animation.Play();
8287
8288   application.SendNotification();
8289   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8290
8291   // We didn't expect the animation to finish yet
8292   application.SendNotification();
8293   finishCheck.CheckSignalNotReceived();
8294   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8295
8296   application.SendNotification();
8297   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8298
8299   // We didn't expect the animation to finish yet
8300   application.SendNotification();
8301   finishCheck.CheckSignalNotReceived();
8302   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8303
8304   application.SendNotification();
8305   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8306
8307   // We did expect the animation to finish
8308   application.SendNotification();
8309   finishCheck.CheckSignalReceived();
8310   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8311   END_TEST;
8312 }
8313
8314 int UtcDaliAnimationAnimateToActorColorRedP(void)
8315 {
8316   TestApplication application;
8317
8318   Actor actor = Actor::New();
8319   Stage::GetCurrent().Add(actor);
8320   float startValue(1.0f);
8321   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
8322   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8323   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8324   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8325   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8326   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8327   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8328   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8329   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8330
8331   // Build the animation
8332   float durationSeconds(1.0f);
8333   Animation animation = Animation::New(durationSeconds);
8334   float targetRed(0.5f);
8335   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8336
8337   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8338
8339   // Start the animation
8340   animation.Play();
8341
8342   // Target value should be retrievable straight away
8343   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8344   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8345
8346   bool signalReceived(false);
8347   AnimationFinishCheck finishCheck(signalReceived);
8348   animation.FinishedSignal().Connect(&application, finishCheck);
8349
8350   application.SendNotification();
8351   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8352
8353   // We didn't expect the animation to finish yet
8354   application.SendNotification();
8355   finishCheck.CheckSignalNotReceived();
8356   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8357   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8358   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8359   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8360   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8361
8362   application.SendNotification();
8363   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8364
8365   // We did expect the animation to finish
8366   application.SendNotification();
8367   finishCheck.CheckSignalReceived();
8368   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8369   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8370   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8371   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8372   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8373   END_TEST;
8374 }
8375
8376 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8377 {
8378   TestApplication application;
8379
8380   Actor actor = Actor::New();
8381   Stage::GetCurrent().Add(actor);
8382   float startValue(1.0f);
8383   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8384   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8385   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8386   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8387   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8388   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8389   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8390   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8391   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8392
8393   // Build the animation
8394   float durationSeconds(1.0f);
8395   Animation animation = Animation::New(durationSeconds);
8396   float targetGreen(0.5f);
8397   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8398
8399   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8400
8401   // Start the animation
8402   animation.Play();
8403
8404   // Target value should be retrievable straight away
8405   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8406   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8407
8408   bool signalReceived(false);
8409   AnimationFinishCheck finishCheck(signalReceived);
8410   animation.FinishedSignal().Connect(&application, finishCheck);
8411
8412   application.SendNotification();
8413   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8414
8415   // We didn't expect the animation to finish yet
8416   application.SendNotification();
8417   finishCheck.CheckSignalNotReceived();
8418   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8419   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8420   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8421   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8422   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8423
8424   application.SendNotification();
8425   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8426
8427   // We did expect the animation to finish
8428   application.SendNotification();
8429   finishCheck.CheckSignalReceived();
8430   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8431   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8432   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8433   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8434   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8435   END_TEST;
8436 }
8437
8438 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8439 {
8440   TestApplication application;
8441
8442   Actor actor = Actor::New();
8443   Stage::GetCurrent().Add(actor);
8444   float startValue(1.0f);
8445   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8446   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8447   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8448   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8449   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8450   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8451   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8452   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8453   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8454
8455   // Build the animation
8456   float durationSeconds(1.0f);
8457   Animation animation = Animation::New(durationSeconds);
8458   float targetBlue(0.5f);
8459   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8460
8461   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8462
8463   // Start the animation
8464   animation.Play();
8465
8466   // Target value should be retrievable straight away
8467   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8468   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8469
8470   bool signalReceived(false);
8471   AnimationFinishCheck finishCheck(signalReceived);
8472   animation.FinishedSignal().Connect(&application, finishCheck);
8473
8474   application.SendNotification();
8475   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8476
8477   // We didn't expect the animation to finish yet
8478   application.SendNotification();
8479   finishCheck.CheckSignalNotReceived();
8480   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8481   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8482   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8483   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8484   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8485
8486   application.SendNotification();
8487   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8488
8489   // We did expect the animation to finish
8490   application.SendNotification();
8491   finishCheck.CheckSignalReceived();
8492   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8493   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8494   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8495   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8496   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8497   END_TEST;
8498 }
8499
8500 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8501 {
8502   TestApplication application;
8503
8504   Actor actor = Actor::New();
8505   Stage::GetCurrent().Add(actor);
8506   float startValue(1.0f);
8507   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8508   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8509   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8510   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8511   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8512   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8513   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8514   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8515   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8516
8517   // Build the animation
8518   float durationSeconds(1.0f);
8519   Animation animation = Animation::New(durationSeconds);
8520   float targetAlpha(0.5f);
8521   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8522
8523   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8524
8525   // Start the animation
8526   animation.Play();
8527
8528   // Target value should be retrievable straight away
8529   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8530   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8531   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8532
8533   bool signalReceived(false);
8534   AnimationFinishCheck finishCheck(signalReceived);
8535   animation.FinishedSignal().Connect(&application, finishCheck);
8536
8537   application.SendNotification();
8538   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8539
8540   // We didn't expect the animation to finish yet
8541   application.SendNotification();
8542   finishCheck.CheckSignalNotReceived();
8543   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8544   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8545   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8546   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8547   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8548
8549   application.SendNotification();
8550   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8551
8552   // We did expect the animation to finish
8553   application.SendNotification();
8554   finishCheck.CheckSignalReceived();
8555   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8556   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8557   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8559   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8560   END_TEST;
8561 }
8562
8563 int UtcDaliAnimationKeyFrames01P(void)
8564 {
8565   TestApplication application;
8566
8567   KeyFrames keyFrames = KeyFrames::New();
8568   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8569
8570   keyFrames.Add(0.0f, 0.1f);
8571
8572   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8573
8574   KeyFrames keyFrames2( keyFrames);
8575   DALI_TEST_CHECK( keyFrames2 );
8576   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8577
8578   KeyFrames keyFrames3 = KeyFrames::New();
8579   keyFrames3.Add(0.6f, true);
8580   DALI_TEST_CHECK( keyFrames3 );
8581   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8582
8583   keyFrames3 = keyFrames;
8584   DALI_TEST_CHECK( keyFrames3 );
8585   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8586
8587   END_TEST;
8588 }
8589
8590 int UtcDaliAnimationKeyFrames02P(void)
8591 {
8592   TestApplication application;
8593
8594   KeyFrames keyFrames = KeyFrames::New();
8595   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8596
8597   keyFrames.Add(0.0f, 0.1f);
8598   keyFrames.Add(0.2f, 0.5f);
8599   keyFrames.Add(0.4f, 0.0f);
8600   keyFrames.Add(0.6f, 1.0f);
8601   keyFrames.Add(0.8f, 0.7f);
8602   keyFrames.Add(1.0f, 0.9f);
8603
8604   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8605
8606   try
8607   {
8608     keyFrames.Add(1.9f, false);
8609   }
8610   catch (Dali::DaliException& e)
8611   {
8612     DALI_TEST_PRINT_ASSERT( e );
8613     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8614   }
8615   END_TEST;
8616 }
8617
8618 int UtcDaliAnimationKeyFrames03P(void)
8619 {
8620   TestApplication application;
8621
8622   KeyFrames keyFrames = KeyFrames::New();
8623   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8624
8625   keyFrames.Add(0.0f, true);
8626   keyFrames.Add(0.2f, false);
8627   keyFrames.Add(0.4f, false);
8628   keyFrames.Add(0.6f, true);
8629   keyFrames.Add(0.8f, true);
8630   keyFrames.Add(1.0f, false);
8631
8632   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8633
8634   try
8635   {
8636     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8637   }
8638   catch (Dali::DaliException& e)
8639   {
8640     DALI_TEST_PRINT_ASSERT( e );
8641     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8642   }
8643   END_TEST;
8644 }
8645
8646 int UtcDaliAnimationKeyFrames04P(void)
8647 {
8648   TestApplication application;
8649
8650   KeyFrames keyFrames = KeyFrames::New();
8651   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8652
8653   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8654   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8655   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8656   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8657   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8658   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8659
8660   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8661
8662   try
8663   {
8664     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8665   }
8666   catch (Dali::DaliException& e)
8667   {
8668     DALI_TEST_PRINT_ASSERT( e );
8669     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8670   }
8671   END_TEST;
8672 }
8673
8674 int UtcDaliAnimationKeyFrames05P(void)
8675 {
8676   TestApplication application;
8677
8678   KeyFrames keyFrames = KeyFrames::New();
8679   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8680
8681   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8682   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8683   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8684   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8685   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8686   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8687
8688   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8689
8690   try
8691   {
8692     keyFrames.Add(0.7f, 1.0f);
8693   }
8694   catch (Dali::DaliException& e)
8695   {
8696     DALI_TEST_PRINT_ASSERT( e );
8697     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8698   }
8699   END_TEST;
8700 }
8701
8702 int UtcDaliAnimationKeyFrames06P(void)
8703 {
8704   TestApplication application;
8705
8706   KeyFrames keyFrames = KeyFrames::New();
8707   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8708
8709   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8710   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8711   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8712   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8713   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8714   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8715
8716   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8717
8718   try
8719   {
8720     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8721   }
8722   catch (Dali::DaliException& e)
8723   {
8724     DALI_TEST_PRINT_ASSERT( e );
8725     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8726   }
8727   END_TEST;
8728 }
8729
8730 int UtcDaliAnimationKeyFrames07P(void)
8731 {
8732   TestApplication application;
8733
8734   KeyFrames keyFrames = KeyFrames::New();
8735   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8736
8737   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8738   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8739   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8740   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8741   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8742   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8743
8744   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8745
8746   try
8747   {
8748     keyFrames.Add(0.7f, 1.1f);
8749   }
8750   catch (Dali::DaliException& e)
8751   {
8752     DALI_TEST_PRINT_ASSERT( e );
8753     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8754   }
8755   END_TEST;
8756 }
8757
8758 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8759 {
8760   TestApplication application;
8761
8762   float startValue(1.0f);
8763   Actor actor = Actor::New();
8764   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8765   Stage::GetCurrent().Add(actor);
8766
8767   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8771   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8772   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8773   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8774   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8775   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8776
8777   // Build the animation
8778   float durationSeconds(1.0f);
8779   Animation animation = Animation::New(durationSeconds);
8780
8781   KeyFrames keyFrames = KeyFrames::New();
8782   keyFrames.Add(0.0f, 0.1f);
8783   keyFrames.Add(0.2f, 0.5f);
8784   keyFrames.Add(0.4f, 0.0f);
8785   keyFrames.Add(0.6f, 1.0f);
8786   keyFrames.Add(0.8f, 0.7f);
8787   keyFrames.Add(1.0f, 0.9f);
8788
8789   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8790
8791   // Start the animation
8792   animation.Play();
8793
8794   // Final key frame value should be retrievable straight away
8795   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8796
8797   bool signalReceived(false);
8798   AnimationFinishCheck finishCheck(signalReceived);
8799   animation.FinishedSignal().Connect(&application, finishCheck);
8800   application.SendNotification();
8801   application.Render(0);
8802   application.SendNotification();
8803   finishCheck.CheckSignalNotReceived();
8804   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8805
8806   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8807   application.SendNotification();
8808   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8809   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8810   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8811   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8812   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8813
8814   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8815   application.SendNotification();
8816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8817   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8818   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8819   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8820   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8821
8822   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8823   application.SendNotification();
8824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8825   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8826   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8827   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8828   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8829
8830   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8831   application.SendNotification();
8832   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8833   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8834   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8835   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8836   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8837
8838   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8839   application.SendNotification();
8840   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8841   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8842   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8843   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8844   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8845
8846   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8847   application.SendNotification();
8848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8850   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8851   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8852   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8853
8854   // We did expect the animation to finish
8855
8856   finishCheck.CheckSignalReceived();
8857   END_TEST;
8858 }
8859
8860 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8861 {
8862   TestApplication application;
8863
8864   float startValue(1.0f);
8865   Actor actor = Actor::New();
8866   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8867   Stage::GetCurrent().Add(actor);
8868
8869   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8870   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8871   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8872   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8873   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8874   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8875   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8876   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8877   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8878
8879   // Build the animation
8880   float durationSeconds(1.0f);
8881   Animation animation = Animation::New(durationSeconds);
8882
8883   KeyFrames keyFrames = KeyFrames::New();
8884   keyFrames.Add(0.0f, 0.1f);
8885   keyFrames.Add(0.2f, 0.5f);
8886   keyFrames.Add(0.4f, 0.0f);
8887   keyFrames.Add(0.6f, 1.0f);
8888   keyFrames.Add(0.8f, 0.7f);
8889   keyFrames.Add(1.0f, 0.9f);
8890
8891   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8892
8893   // Start the animation
8894   animation.Play();
8895
8896   bool signalReceived(false);
8897   AnimationFinishCheck finishCheck(signalReceived);
8898   animation.FinishedSignal().Connect(&application, finishCheck);
8899   application.SendNotification();
8900   application.Render(0);
8901   application.SendNotification();
8902   finishCheck.CheckSignalNotReceived();
8903   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8904
8905   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8906   application.SendNotification();
8907   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8908   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8909   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8910   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8911   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8912
8913   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8914   application.SendNotification();
8915   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8916   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8917   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8918   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8919   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8920
8921   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8922   application.SendNotification();
8923   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8924   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8925   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8926   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8927   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8928
8929   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8930   application.SendNotification();
8931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8932   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8933   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8934   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8935   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8936
8937   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8938   application.SendNotification();
8939   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8940   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8941   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8942   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8943   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8944
8945   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8946   application.SendNotification();
8947   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8948   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8949   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8950   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
8951   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8952
8953   // We did expect the animation to finish
8954
8955   finishCheck.CheckSignalReceived();
8956   END_TEST;
8957 }
8958
8959 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8960 {
8961   TestApplication application;
8962
8963   float startValue(1.0f);
8964   Actor actor = Actor::New();
8965   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8966   Stage::GetCurrent().Add(actor);
8967
8968   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8969   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8970   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8971   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8972   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8973   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8974   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8975   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8976   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8977
8978   // Build the animation
8979   float durationSeconds(1.0f);
8980   Animation animation = Animation::New(durationSeconds);
8981
8982   KeyFrames keyFrames = KeyFrames::New();
8983   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8984   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8985   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8986
8987   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8988
8989   // Start the animation
8990   animation.Play();
8991
8992   bool signalReceived(false);
8993   AnimationFinishCheck finishCheck(signalReceived);
8994   animation.FinishedSignal().Connect(&application, finishCheck);
8995   application.SendNotification();
8996   application.Render(0);
8997   application.SendNotification();
8998   finishCheck.CheckSignalNotReceived();
8999   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9000   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9001   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9002   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9003
9004   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9005   application.SendNotification();
9006   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9007   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9008   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9009   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9010
9011   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9012   application.SendNotification();
9013   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9014   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9015   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9016   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9017
9018   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9019   application.SendNotification();
9020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9022   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9023   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9024
9025   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9026   application.SendNotification();
9027   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9028   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9029   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9030   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9031
9032   // We did expect the animation to finish
9033
9034   finishCheck.CheckSignalReceived();
9035   END_TEST;
9036 }
9037
9038 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9039 {
9040   TestApplication application;
9041
9042   float startValue(1.0f);
9043   Actor actor = Actor::New();
9044   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9045   Stage::GetCurrent().Add(actor);
9046
9047   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9048   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9049   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9050   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9051   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9052   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9053   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9054   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9055   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9056
9057   // Build the animation
9058   float durationSeconds(1.0f);
9059   Animation animation = Animation::New(durationSeconds);
9060
9061   KeyFrames keyFrames = KeyFrames::New();
9062   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9063   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9064   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9065
9066   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9067
9068   // Start the animation
9069   animation.Play();
9070
9071   bool signalReceived(false);
9072   AnimationFinishCheck finishCheck(signalReceived);
9073   animation.FinishedSignal().Connect(&application, finishCheck);
9074   application.SendNotification();
9075   application.Render(0);
9076   application.SendNotification();
9077   finishCheck.CheckSignalNotReceived();
9078   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9079   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9080   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9081   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9082
9083   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9084   application.SendNotification();
9085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9086   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9087   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9088   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9089
9090   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9091   application.SendNotification();
9092   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9093   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9094   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9095   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9096
9097   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9098   application.SendNotification();
9099   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9100   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9101   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9102   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9103
9104   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9105   application.SendNotification();
9106   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9107   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9108   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9109   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9110
9111   // We did expect the animation to finish
9112
9113   finishCheck.CheckSignalReceived();
9114   END_TEST;
9115 }
9116
9117 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9118 {
9119   TestApplication application;
9120
9121   Actor actor = Actor::New();
9122   AngleAxis aa(Degree(90), Vector3::XAXIS);
9123   actor.SetOrientation(aa.angle, aa.axis);
9124   Stage::GetCurrent().Add(actor);
9125
9126   application.SendNotification();
9127   application.Render(0);
9128
9129   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9130
9131   // Build the animation
9132   float durationSeconds(1.0f);
9133   Animation animation = Animation::New(durationSeconds);
9134
9135   KeyFrames keyFrames = KeyFrames::New();
9136   keyFrames.Add(0.0f, false);
9137   keyFrames.Add(0.2f, true);
9138   keyFrames.Add(0.4f, true);
9139   keyFrames.Add(0.8f, false);
9140   keyFrames.Add(1.0f, true);
9141
9142   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9143
9144   // Start the animation
9145   animation.Play();
9146
9147   // Final key frame value should be retrievable straight away
9148   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9149
9150   bool signalReceived(false);
9151   AnimationFinishCheck finishCheck(signalReceived);
9152   animation.FinishedSignal().Connect(&application, finishCheck);
9153   application.SendNotification();
9154   application.SendNotification();
9155   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9156   application.SendNotification();
9157   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9158   application.SendNotification();
9159
9160   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9161   finishCheck.CheckSignalReceived();
9162   END_TEST;
9163 }
9164
9165 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9166 {
9167   TestApplication application;
9168
9169   Actor actor = Actor::New();
9170   AngleAxis aa(Degree(90), Vector3::XAXIS);
9171   actor.SetOrientation(aa.angle, aa.axis);
9172   Stage::GetCurrent().Add(actor);
9173
9174   application.SendNotification();
9175   application.Render(0);
9176
9177   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9178
9179   // Build the animation
9180   float durationSeconds(1.0f);
9181   Animation animation = Animation::New(durationSeconds);
9182
9183   KeyFrames keyFrames = KeyFrames::New();
9184   keyFrames.Add(0.0f, false);
9185   keyFrames.Add(0.2f, true);
9186   keyFrames.Add(0.4f, true);
9187   keyFrames.Add(0.8f, false);
9188   keyFrames.Add(1.0f, true);
9189
9190   //Cubic interpolation for boolean values should be ignored
9191   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9192
9193   // Start the animation
9194   animation.Play();
9195
9196   bool signalReceived(false);
9197   AnimationFinishCheck finishCheck(signalReceived);
9198   animation.FinishedSignal().Connect(&application, finishCheck);
9199   application.SendNotification();
9200   application.SendNotification();
9201   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9202   application.SendNotification();
9203   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9204   application.SendNotification();
9205
9206   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9207   finishCheck.CheckSignalReceived();
9208   END_TEST;
9209 }
9210
9211 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9212 {
9213   TestApplication application;
9214
9215   Actor actor = Actor::New();
9216   AngleAxis aa(Degree(90), Vector3::XAXIS);
9217   actor.SetOrientation(aa.angle, aa.axis);
9218   Stage::GetCurrent().Add(actor);
9219
9220   application.SendNotification();
9221   application.Render(0);
9222   Quaternion start(Radian(aa.angle), aa.axis);
9223   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9224
9225   // Build the animation
9226   float durationSeconds(1.0f);
9227   Animation animation = Animation::New(durationSeconds);
9228
9229   KeyFrames keyFrames = KeyFrames::New();
9230   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9231
9232   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9233
9234   // Start the animation
9235   animation.Play();
9236
9237   // Final key frame value should be retrievable straight away
9238   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9239
9240   bool signalReceived(false);
9241   AnimationFinishCheck finishCheck(signalReceived);
9242   animation.FinishedSignal().Connect(&application, finishCheck);
9243   application.SendNotification();
9244   application.SendNotification();
9245   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9246   application.SendNotification();
9247   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9248   application.SendNotification();
9249
9250   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9251
9252   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9253   finishCheck.CheckSignalReceived();
9254   END_TEST;
9255 }
9256
9257 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9258 {
9259   TestApplication application;
9260
9261   Actor actor = Actor::New();
9262   AngleAxis aa(Degree(90), Vector3::XAXIS);
9263   actor.SetOrientation(aa.angle, aa.axis);
9264   application.SendNotification();
9265   application.Render(0);
9266   Stage::GetCurrent().Add(actor);
9267
9268   Quaternion start(Radian(aa.angle), aa.axis);
9269   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9270
9271   // Build the animation
9272   float durationSeconds(1.0f);
9273   Animation animation = Animation::New(durationSeconds);
9274
9275   KeyFrames keyFrames = KeyFrames::New();
9276   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9277   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9278   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9279
9280   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9281
9282   // Start the animation
9283   animation.Play();
9284
9285   bool signalReceived(false);
9286   AnimationFinishCheck finishCheck(signalReceived);
9287   animation.FinishedSignal().Connect(&application, finishCheck);
9288   application.SendNotification();
9289   application.Render(0);
9290   application.SendNotification();
9291   finishCheck.CheckSignalNotReceived();
9292
9293   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9294   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9295
9296   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9297   application.SendNotification();
9298   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9299   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9300
9301   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9302   application.SendNotification();
9303   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9304   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9305
9306   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9307   application.SendNotification();
9308   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9309   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9310
9311   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9312   application.SendNotification();
9313   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9314   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9315
9316   // We did expect the animation to finish
9317
9318   finishCheck.CheckSignalReceived();
9319   END_TEST;
9320 }
9321
9322 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9323 {
9324   TestApplication application;
9325
9326   Actor actor = Actor::New();
9327   AngleAxis aa(Degree(90), Vector3::XAXIS);
9328   actor.SetOrientation(aa.angle, aa.axis);
9329   Stage::GetCurrent().Add(actor);
9330
9331   application.SendNotification();
9332   application.Render(0);
9333   Quaternion start(Radian(aa.angle), aa.axis);
9334   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9335
9336   // Build the animation
9337   float durationSeconds(1.0f);
9338   Animation animation = Animation::New(durationSeconds);
9339
9340   KeyFrames keyFrames = KeyFrames::New();
9341   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9342
9343   //Cubic interpolation should be ignored for quaternions
9344   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9345
9346   // Start the animation
9347   animation.Play();
9348
9349   bool signalReceived(false);
9350   AnimationFinishCheck finishCheck(signalReceived);
9351   animation.FinishedSignal().Connect(&application, finishCheck);
9352   application.SendNotification();
9353   application.SendNotification();
9354   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9355   application.SendNotification();
9356   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9357   application.SendNotification();
9358
9359   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9360
9361   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9362   finishCheck.CheckSignalReceived();
9363   END_TEST;
9364 }
9365
9366 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9367 {
9368   TestApplication application;
9369
9370   Actor actor = Actor::New();
9371   AngleAxis aa(Degree(90), Vector3::XAXIS);
9372   actor.SetOrientation(aa.angle, aa.axis);
9373   application.SendNotification();
9374   application.Render(0);
9375   Stage::GetCurrent().Add(actor);
9376
9377   Quaternion start(Radian(aa.angle), aa.axis);
9378   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9379
9380   // Build the animation
9381   float durationSeconds(1.0f);
9382   Animation animation = Animation::New(durationSeconds);
9383
9384   KeyFrames keyFrames = KeyFrames::New();
9385   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9386   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9387   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9388
9389   //Cubic interpolation should be ignored for quaternions
9390   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9391
9392   // Start the animation
9393   animation.Play();
9394
9395   bool signalReceived(false);
9396   AnimationFinishCheck finishCheck(signalReceived);
9397   animation.FinishedSignal().Connect(&application, finishCheck);
9398   application.SendNotification();
9399   application.Render(0);
9400   application.SendNotification();
9401   finishCheck.CheckSignalNotReceived();
9402
9403   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9404   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9405
9406   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9407   application.SendNotification();
9408   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9409   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9410
9411   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9412   application.SendNotification();
9413   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9414   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9415
9416   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9417   application.SendNotification();
9418   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9419   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9420
9421   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9422   application.SendNotification();
9423   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9424   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9425
9426   // We did expect the animation to finish
9427
9428   finishCheck.CheckSignalReceived();
9429   END_TEST;
9430 }
9431
9432 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9433 {
9434   TestApplication application;
9435
9436   float startValue(1.0f);
9437   Actor actor = Actor::New();
9438   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9439   Stage::GetCurrent().Add(actor);
9440
9441   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9442   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9443   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9444   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9445   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9446   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9447   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9448   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9449   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9450
9451   // Build the animation
9452   float durationSeconds(1.0f);
9453   Animation animation = Animation::New(durationSeconds);
9454
9455   KeyFrames keyFrames = KeyFrames::New();
9456   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9457   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9458   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9459
9460   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9461
9462   // Start the animation
9463   animation.Play();
9464
9465   bool signalReceived(false);
9466   AnimationFinishCheck finishCheck(signalReceived);
9467   animation.FinishedSignal().Connect(&application, finishCheck);
9468   application.SendNotification();
9469   application.Render(0);
9470   application.SendNotification();
9471   finishCheck.CheckSignalNotReceived();
9472   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9473   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9474   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9475   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9476
9477   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9478   application.SendNotification();
9479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9480   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9481   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9482   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9483
9484   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9485   application.SendNotification();
9486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9488   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9489   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9490
9491   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9492   application.SendNotification();
9493   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9494   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9495   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9496   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9497
9498   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9499   application.SendNotification();
9500   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9502   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9503   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9504
9505   // We did expect the animation to finish
9506
9507   finishCheck.CheckSignalReceived();
9508   END_TEST;
9509 }
9510
9511 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9512 {
9513   TestApplication application;
9514
9515   float startValue(1.0f);
9516   Actor actor = Actor::New();
9517   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9518   Stage::GetCurrent().Add(actor);
9519
9520   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9521   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9522   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9523   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9524   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9525   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9526   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9527   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9528   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9529
9530   // Build the animation
9531   float durationSeconds(1.0f);
9532   Animation animation = Animation::New(durationSeconds);
9533
9534   KeyFrames keyFrames = KeyFrames::New();
9535   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9536   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9537   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9538
9539   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9540
9541   // Start the animation
9542   animation.Play();
9543
9544   bool signalReceived(false);
9545   AnimationFinishCheck finishCheck(signalReceived);
9546   animation.FinishedSignal().Connect(&application, finishCheck);
9547   application.SendNotification();
9548   application.Render(0);
9549   application.SendNotification();
9550   finishCheck.CheckSignalNotReceived();
9551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9552   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9553   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9554   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9555
9556   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9557   application.SendNotification();
9558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9559   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9560   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9561   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9562
9563   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9564   application.SendNotification();
9565   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9566   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9567   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9568   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9569
9570   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9571   application.SendNotification();
9572   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9573   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9574   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9575   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9576
9577   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9578   application.SendNotification();
9579   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9581   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9582   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9583
9584   // We did expect the animation to finish
9585
9586   finishCheck.CheckSignalReceived();
9587   END_TEST;
9588 }
9589
9590 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9591 {
9592   TestApplication application;
9593
9594   float startValue(1.0f);
9595   Actor actor = Actor::New();
9596   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9597   Stage::GetCurrent().Add(actor);
9598
9599   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9600   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9601   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9602   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9603   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9604   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9605   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9606   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9607   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9608
9609   // Build the animation
9610   float durationSeconds(1.0f);
9611   float delay = 0.5f;
9612   Animation animation = Animation::New(durationSeconds);
9613
9614   KeyFrames keyFrames = KeyFrames::New();
9615   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9616   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9617   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9618
9619   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9620
9621   // Start the animation
9622   animation.Play();
9623
9624   bool signalReceived(false);
9625   AnimationFinishCheck finishCheck(signalReceived);
9626   animation.FinishedSignal().Connect(&application, finishCheck);
9627   application.SendNotification();
9628
9629   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9630   application.SendNotification();
9631   finishCheck.CheckSignalNotReceived();
9632   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9633   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9634   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9635   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9636
9637   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9638   application.SendNotification();
9639   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9640   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9641   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9642   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9643
9644   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9645   application.SendNotification();
9646   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9647   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9648   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9649   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9650
9651   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9652   application.SendNotification();
9653   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9654   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9655   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9656   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9657
9658   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9659   application.SendNotification();
9660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9662   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9663   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9664
9665   // We did expect the animation to finish
9666
9667   finishCheck.CheckSignalReceived();
9668   END_TEST;
9669 }
9670
9671 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9672 {
9673   TestApplication application;
9674
9675   float startValue(1.0f);
9676   Actor actor = Actor::New();
9677   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9678   Stage::GetCurrent().Add(actor);
9679
9680   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9681   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9682   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9683   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9684   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9685   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9686   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9687   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9688   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9689
9690   // Build the animation
9691   float durationSeconds(1.0f);
9692   float delay = 0.5f;
9693   Animation animation = Animation::New(durationSeconds);
9694
9695   KeyFrames keyFrames = KeyFrames::New();
9696   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9697   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9698   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9699
9700   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9701
9702   // Start the animation
9703   animation.Play();
9704
9705   bool signalReceived(false);
9706   AnimationFinishCheck finishCheck(signalReceived);
9707   animation.FinishedSignal().Connect(&application, finishCheck);
9708   application.SendNotification();
9709
9710   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9711   application.SendNotification();
9712   finishCheck.CheckSignalNotReceived();
9713   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9714   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9716   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9717
9718   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9719   application.SendNotification();
9720   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9722   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9723   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9724
9725   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9726   application.SendNotification();
9727   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9728   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9729   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9730   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9731
9732   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9733   application.SendNotification();
9734   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9735   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9736   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9737   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9738
9739   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9740   application.SendNotification();
9741   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9742   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9743   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9744   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9745
9746   // We did expect the animation to finish
9747
9748   finishCheck.CheckSignalReceived();
9749   END_TEST;
9750 }
9751
9752 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9753 {
9754   TestApplication application;
9755
9756   float startValue(1.0f);
9757   float delay = 0.5f;
9758   Actor actor = Actor::New();
9759   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9760   Stage::GetCurrent().Add(actor);
9761
9762   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9763   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9764   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9765   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9766   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9767   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9768   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9770   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9771
9772   // Build the animation
9773   float durationSeconds(1.0f);
9774   Animation animation = Animation::New(durationSeconds);
9775
9776   KeyFrames keyFrames = KeyFrames::New();
9777   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9778   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9779   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9780
9781   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9782
9783   // Start the animation
9784   animation.Play();
9785
9786   bool signalReceived(false);
9787   AnimationFinishCheck finishCheck(signalReceived);
9788   animation.FinishedSignal().Connect(&application, finishCheck);
9789   application.SendNotification();
9790
9791   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9792   application.SendNotification();
9793   finishCheck.CheckSignalNotReceived();
9794   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9795   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9796   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9797   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9798
9799   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9800   application.SendNotification();
9801   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9802   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9803   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9804   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9805
9806   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9807   application.SendNotification();
9808   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9809   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9810   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9811   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9812
9813   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9814   application.SendNotification();
9815   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9817   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9818   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9819
9820   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9821   application.SendNotification();
9822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9825   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9826
9827   // We did expect the animation to finish
9828
9829   finishCheck.CheckSignalReceived();
9830   END_TEST;
9831 }
9832
9833 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9834 {
9835   TestApplication application;
9836
9837   float startValue(1.0f);
9838   Actor actor = Actor::New();
9839   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9840   Stage::GetCurrent().Add(actor);
9841
9842   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9843   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9844   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9845   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9846   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9847   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9850   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9851
9852
9853   // Build the animation
9854   float durationSeconds(1.0f);
9855   float delay = 0.5f;
9856   Animation animation = Animation::New(durationSeconds);
9857
9858   KeyFrames keyFrames = KeyFrames::New();
9859   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9860   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9861   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9862
9863   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9864
9865   // Start the animation
9866   animation.Play();
9867
9868   bool signalReceived(false);
9869   AnimationFinishCheck finishCheck(signalReceived);
9870   animation.FinishedSignal().Connect(&application, finishCheck);
9871   application.SendNotification();
9872
9873   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9874   application.SendNotification();
9875   finishCheck.CheckSignalNotReceived();
9876   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9877   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9878   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9879   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9880
9881   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9882   application.SendNotification();
9883   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9884   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9885   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9886   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9887
9888   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9889   application.SendNotification();
9890   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9891   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9892   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9893   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9894
9895   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9896   application.SendNotification();
9897   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9898   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9899   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9900   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9901
9902   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9903   application.SendNotification();
9904   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9906   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9907   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9908
9909   // We did expect the animation to finish
9910
9911   finishCheck.CheckSignalReceived();
9912   END_TEST;
9913 }
9914
9915 int UtcDaliAnimationAnimateP(void)
9916 {
9917   TestApplication application;
9918
9919   Actor actor = Actor::New();
9920   Stage::GetCurrent().Add(actor);
9921
9922   //Build the path
9923   Vector3 position0( 30.0,  80.0,  0.0);
9924   Vector3 position1( 70.0,  120.0, 0.0);
9925   Vector3 position2( 100.0, 100.0, 0.0);
9926
9927   Dali::Path path = Dali::Path::New();
9928   path.AddPoint(position0);
9929   path.AddPoint(position1);
9930   path.AddPoint(position2);
9931
9932   //Control points for first segment
9933   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9934   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9935
9936   //Control points for second segment
9937   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9938   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9939
9940   // Build the animation
9941   float durationSeconds( 1.0f );
9942   Animation animation = Animation::New(durationSeconds);
9943   animation.Animate(actor, path, Vector3::XAXIS);
9944
9945   // Start the animation
9946   animation.Play();
9947
9948   bool signalReceived(false);
9949   AnimationFinishCheck finishCheck(signalReceived);
9950   animation.FinishedSignal().Connect(&application, finishCheck);
9951   application.SendNotification();
9952   application.Render(0);
9953   application.SendNotification();
9954   finishCheck.CheckSignalNotReceived();
9955   Vector3 position, tangent;
9956   Quaternion rotation;
9957   path.Sample( 0.0f, position, tangent );
9958   rotation = Quaternion( Vector3::XAXIS, tangent );
9959   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9960   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9961
9962   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9963   application.SendNotification();
9964   path.Sample( 0.25f, position, tangent );
9965   rotation = Quaternion( Vector3::XAXIS, tangent );
9966   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9967   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9968
9969   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9970   application.SendNotification();
9971   path.Sample( 0.5f, position, tangent );
9972   rotation = Quaternion( Vector3::XAXIS, tangent );
9973   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9974   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9975
9976   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9977   application.SendNotification();
9978   path.Sample( 0.75f, position, tangent );
9979   rotation = Quaternion( Vector3::XAXIS, tangent );
9980   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9981   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9982
9983   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9984   application.SendNotification();
9985   path.Sample( 1.0f, position, tangent );
9986   rotation = Quaternion( Vector3::XAXIS, tangent );
9987   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9988   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9989
9990   finishCheck.CheckSignalReceived();
9991   END_TEST;
9992 }
9993
9994 int UtcDaliAnimationAnimateAlphaFunctionP(void)
9995 {
9996   TestApplication application;
9997
9998   Actor actor = Actor::New();
9999   Stage::GetCurrent().Add(actor);
10000
10001   //Build the path
10002   Vector3 position0( 30.0,  80.0,  0.0);
10003   Vector3 position1( 70.0,  120.0, 0.0);
10004   Vector3 position2( 100.0, 100.0, 0.0);
10005
10006   Dali::Path path = Dali::Path::New();
10007   path.AddPoint(position0);
10008   path.AddPoint(position1);
10009   path.AddPoint(position2);
10010
10011   //Control points for first segment
10012   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10013   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10014
10015   //Control points for second segment
10016   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10017   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10018
10019   // Build the animation
10020   float durationSeconds( 1.0f );
10021   Animation animation = Animation::New(durationSeconds);
10022   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10023
10024   // Start the animation
10025   animation.Play();
10026
10027   bool signalReceived(false);
10028   AnimationFinishCheck finishCheck(signalReceived);
10029   animation.FinishedSignal().Connect(&application, finishCheck);
10030   application.SendNotification();
10031   application.Render(0);
10032   application.SendNotification();
10033   finishCheck.CheckSignalNotReceived();
10034   Vector3 position, tangent;
10035   Quaternion rotation;
10036   path.Sample( 0.0f, position, tangent );
10037   rotation = Quaternion( Vector3::XAXIS, tangent );
10038   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10039   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10040
10041   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10042   application.SendNotification();
10043   path.Sample( 0.25f, position, tangent );
10044   rotation = Quaternion( Vector3::XAXIS, tangent );
10045   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10046   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10047
10048   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10049   application.SendNotification();
10050   path.Sample( 0.5f, position, tangent );
10051   rotation = Quaternion( Vector3::XAXIS, tangent );
10052   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10053   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10054
10055   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10056   application.SendNotification();
10057   path.Sample( 0.75f, position, tangent );
10058   rotation = Quaternion( Vector3::XAXIS, tangent );
10059   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10060   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10061
10062   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10063   application.SendNotification();
10064   path.Sample( 1.0f, position, tangent );
10065   rotation = Quaternion( Vector3::XAXIS, tangent );
10066   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10067   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10068
10069   finishCheck.CheckSignalReceived();
10070   END_TEST;
10071 }
10072
10073 int UtcDaliAnimationAnimateTimePeriodP(void)
10074 {
10075   TestApplication application;
10076
10077   Actor actor = Actor::New();
10078   Stage::GetCurrent().Add(actor);
10079
10080   //Build the path
10081   Vector3 position0( 30.0,  80.0,  0.0);
10082   Vector3 position1( 70.0,  120.0, 0.0);
10083   Vector3 position2( 100.0, 100.0, 0.0);
10084
10085   Dali::Path path = Dali::Path::New();
10086   path.AddPoint(position0);
10087   path.AddPoint(position1);
10088   path.AddPoint(position2);
10089
10090   //Control points for first segment
10091   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10092   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10093
10094   //Control points for second segment
10095   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10096   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10097
10098   // Build the animation
10099   float durationSeconds( 1.0f );
10100   Animation animation = Animation::New(durationSeconds);
10101   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10102
10103   // Start the animation
10104   animation.Play();
10105
10106   bool signalReceived(false);
10107   AnimationFinishCheck finishCheck(signalReceived);
10108   animation.FinishedSignal().Connect(&application, finishCheck);
10109   application.SendNotification();
10110   application.Render(0);
10111   application.SendNotification();
10112   finishCheck.CheckSignalNotReceived();
10113   Vector3 position, tangent;
10114   Quaternion rotation;
10115   path.Sample( 0.0f, position, tangent );
10116   rotation = Quaternion( Vector3::XAXIS, tangent );
10117   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10118   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10119
10120   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10121   application.SendNotification();
10122   path.Sample( 0.25f, position, tangent );
10123   rotation = Quaternion( Vector3::XAXIS, tangent );
10124   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10125   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10126
10127   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10128   application.SendNotification();
10129   path.Sample( 0.5f, position, tangent );
10130   rotation = Quaternion( Vector3::XAXIS, tangent );
10131   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10132   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10133
10134   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10135   application.SendNotification();
10136   path.Sample( 0.75f, position, tangent );
10137   rotation = Quaternion( Vector3::XAXIS, tangent );
10138   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10139   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10140
10141   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10142   application.SendNotification();
10143   path.Sample( 1.0f, position, tangent );
10144   rotation = Quaternion( Vector3::XAXIS, tangent );
10145   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10146   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10147
10148   finishCheck.CheckSignalReceived();
10149   END_TEST;
10150 }
10151
10152 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10153 {
10154   TestApplication application;
10155
10156   Actor actor = Actor::New();
10157   Stage::GetCurrent().Add(actor);
10158
10159   //Build the path
10160   Vector3 position0( 30.0,  80.0,  0.0);
10161   Vector3 position1( 70.0,  120.0, 0.0);
10162   Vector3 position2( 100.0, 100.0, 0.0);
10163
10164   Dali::Path path = Dali::Path::New();
10165   path.AddPoint(position0);
10166   path.AddPoint(position1);
10167   path.AddPoint(position2);
10168
10169   //Control points for first segment
10170   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10171   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10172
10173   //Control points for second segment
10174   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10175   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10176
10177   // Build the animation
10178   float durationSeconds( 1.0f );
10179   Animation animation = Animation::New(durationSeconds);
10180   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10181
10182   // Start the animation
10183   animation.Play();
10184
10185   bool signalReceived(false);
10186   AnimationFinishCheck finishCheck(signalReceived);
10187   animation.FinishedSignal().Connect(&application, finishCheck);
10188   application.SendNotification();
10189   application.Render(0);
10190   application.SendNotification();
10191   finishCheck.CheckSignalNotReceived();
10192   Vector3 position, tangent;
10193   Quaternion rotation;
10194   path.Sample( 0.0f, position, tangent );
10195   rotation = Quaternion( Vector3::XAXIS, tangent );
10196   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10197   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10198
10199   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10200   application.SendNotification();
10201   path.Sample( 0.25f, position, tangent );
10202   rotation = Quaternion( Vector3::XAXIS, tangent );
10203   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10204   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10205
10206   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10207   application.SendNotification();
10208   path.Sample( 0.5f, position, tangent );
10209   rotation = Quaternion( Vector3::XAXIS, tangent );
10210   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10211   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10212
10213   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10214   application.SendNotification();
10215   path.Sample( 0.75f, position, tangent );
10216   rotation = Quaternion( Vector3::XAXIS, tangent );
10217   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10218   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10219
10220   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10221   application.SendNotification();
10222   path.Sample( 1.0f, position, tangent );
10223   rotation = Quaternion( Vector3::XAXIS, tangent );
10224   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10225   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10226
10227   finishCheck.CheckSignalReceived();
10228   END_TEST;
10229 }
10230
10231 int UtcDaliAnimationShowP(void)
10232 {
10233   TestApplication application;
10234
10235   Actor actor = Actor::New();
10236   actor.SetVisible(false);
10237   application.SendNotification();
10238   application.Render(0);
10239   DALI_TEST_CHECK( !actor.IsVisible() );
10240   Stage::GetCurrent().Add(actor);
10241
10242   // Start the animation
10243   float durationSeconds(10.0f);
10244   Animation animation = Animation::New(durationSeconds);
10245   animation.Show(actor, durationSeconds*0.5f);
10246   animation.Play();
10247
10248   bool signalReceived(false);
10249   AnimationFinishCheck finishCheck(signalReceived);
10250   animation.FinishedSignal().Connect(&application, finishCheck);
10251
10252   application.SendNotification();
10253   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10254
10255   // We didn't expect the animation to finish yet
10256   application.SendNotification();
10257   finishCheck.CheckSignalNotReceived();
10258   DALI_TEST_CHECK( !actor.IsVisible() );
10259
10260   application.SendNotification();
10261   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10262
10263   // We didn't expect the animation to finish yet
10264   application.SendNotification();
10265   finishCheck.CheckSignalNotReceived();
10266   DALI_TEST_CHECK( actor.IsVisible() );
10267
10268   application.SendNotification();
10269   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10270
10271   // We did expect the animation to finish
10272   application.SendNotification();
10273   finishCheck.CheckSignalReceived();
10274   DALI_TEST_CHECK( actor.IsVisible() );
10275   END_TEST;
10276 }
10277
10278 int UtcDaliAnimationHideP(void)
10279 {
10280   TestApplication application;
10281
10282   Actor actor = Actor::New();
10283   DALI_TEST_CHECK( actor.IsVisible() );
10284   Stage::GetCurrent().Add(actor);
10285
10286   // Start the animation
10287   float durationSeconds(10.0f);
10288   Animation animation = Animation::New(durationSeconds);
10289   animation.Hide(actor, durationSeconds*0.5f);
10290   animation.Play();
10291
10292   bool signalReceived(false);
10293   AnimationFinishCheck finishCheck(signalReceived);
10294   animation.FinishedSignal().Connect(&application, finishCheck);
10295
10296   application.SendNotification();
10297   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10298
10299   // We didn't expect the animation to finish yet
10300   application.SendNotification();
10301   finishCheck.CheckSignalNotReceived();
10302   DALI_TEST_CHECK( actor.IsVisible() );
10303
10304   application.SendNotification();
10305   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10306
10307   // We didn't expect the animation to finish yet
10308   application.SendNotification();
10309   finishCheck.CheckSignalNotReceived();
10310   DALI_TEST_CHECK( !actor.IsVisible() );
10311
10312   application.SendNotification();
10313   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10314
10315   // We did expect the animation to finish
10316   application.SendNotification();
10317   finishCheck.CheckSignalReceived();
10318   DALI_TEST_CHECK( !actor.IsVisible() );
10319   END_TEST;
10320 }
10321
10322 int UtcDaliAnimationShowHideAtEndP(void)
10323 {
10324   // Test that show/hide delay can be the same as animation duration
10325   // i.e. to show/hide at the end of the animation
10326
10327   TestApplication application;
10328
10329   Actor actor = Actor::New();
10330   DALI_TEST_CHECK( actor.IsVisible() );
10331   Stage::GetCurrent().Add(actor);
10332
10333   // Start Hide animation
10334   float durationSeconds(10.0f);
10335   Animation animation = Animation::New(durationSeconds);
10336   animation.Hide(actor, durationSeconds/*Hide at end*/);
10337   animation.Play();
10338
10339   bool signalReceived(false);
10340   AnimationFinishCheck finishCheck(signalReceived);
10341   animation.FinishedSignal().Connect(&application, finishCheck);
10342
10343   application.SendNotification();
10344   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10345
10346   // We did expect the animation to finish
10347   application.SendNotification();
10348   finishCheck.CheckSignalReceived();
10349   DALI_TEST_CHECK( !actor.IsVisible() );
10350
10351   // Start Show animation
10352   animation = Animation::New(durationSeconds);
10353   animation.Show(actor, durationSeconds/*Show at end*/);
10354   animation.FinishedSignal().Connect(&application, finishCheck);
10355   animation.Play();
10356
10357   application.SendNotification();
10358   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10359
10360   // We did expect the animation to finish
10361   application.SendNotification();
10362   finishCheck.CheckSignalReceived();
10363   DALI_TEST_CHECK( actor.IsVisible() );
10364   END_TEST;
10365 }
10366
10367 int UtcDaliKeyFramesCreateDestroyP(void)
10368 {
10369   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10370
10371   KeyFrames* keyFrames = new KeyFrames;
10372   delete keyFrames;
10373   DALI_TEST_CHECK( true );
10374   END_TEST;
10375 }
10376
10377 int UtcDaliKeyFramesDownCastP(void)
10378 {
10379   TestApplication application;
10380   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10381
10382   KeyFrames keyFrames = KeyFrames::New();
10383   BaseHandle object(keyFrames);
10384
10385   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10386   DALI_TEST_CHECK(keyFrames2);
10387
10388   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10389   DALI_TEST_CHECK(keyFrames3);
10390
10391   BaseHandle unInitializedObject;
10392   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10393   DALI_TEST_CHECK(!keyFrames4);
10394
10395   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10396   DALI_TEST_CHECK(!keyFrames5);
10397   END_TEST;
10398 }
10399
10400 int UtcDaliAnimationCreateDestroyP(void)
10401 {
10402   TestApplication application;
10403   Animation* animation = new Animation;
10404   DALI_TEST_CHECK( animation );
10405   delete animation;
10406   END_TEST;
10407 }
10408
10409 struct UpdateManagerTestConstraint
10410 {
10411   UpdateManagerTestConstraint(TestApplication& application)
10412   : mApplication(application)
10413   {
10414   }
10415
10416   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10417   {
10418     mApplication.SendNotification();  // Process events
10419   }
10420
10421   TestApplication& mApplication;
10422 };
10423
10424 int UtcDaliAnimationUpdateManagerP(void)
10425 {
10426   TestApplication application;
10427
10428   Actor actor = Actor::New();
10429   Stage::GetCurrent().Add( actor );
10430
10431   // Build the animation
10432   Animation animation = Animation::New( 0.0f );
10433
10434   bool signalReceived = false;
10435   AnimationFinishCheck finishCheck( signalReceived );
10436   animation.FinishedSignal().Connect( &application, finishCheck );
10437
10438   Vector3 startValue(1.0f, 1.0f, 1.0f);
10439   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10440   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10441   constraint.Apply();
10442
10443   // Apply animation to actor
10444   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10445   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10446
10447   animation.Play();
10448
10449   application.SendNotification();
10450   application.UpdateOnly( 16 );
10451
10452   finishCheck.CheckSignalNotReceived();
10453
10454   application.SendNotification();   // Process events
10455
10456   finishCheck.CheckSignalReceived();
10457
10458   END_TEST;
10459 }
10460
10461 int UtcDaliAnimationSignalOrderP(void)
10462 {
10463   TestApplication application;
10464
10465   Actor actor = Actor::New();
10466   Stage::GetCurrent().Add( actor );
10467
10468   // Build the animations
10469   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10470   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10471
10472   bool signal1Received = false;
10473   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10474
10475   bool signal2Received = false;
10476   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10477
10478   // Apply animations to actor
10479   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10480   animation1.Play();
10481   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10482   animation2.Play();
10483
10484   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10485   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10486
10487   application.SendNotification();
10488   application.UpdateOnly( 10 ); // 10ms progress
10489
10490   // no notifications yet
10491   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10492   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10493
10494   application.SendNotification();
10495
10496   // first completed
10497   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10498   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10499   signal1Received = false;
10500
10501   // 1st animation is complete now, do another update with no ProcessEvents in between
10502   application.UpdateOnly( 20 ); // 20ms progress
10503
10504   // ProcessEvents
10505   application.SendNotification();
10506
10507   // 2nd should complete now
10508   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10509   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10510
10511   END_TEST;
10512 }
10513
10514 int UtcDaliAnimationExtendDurationP(void)
10515 {
10516   TestApplication application;
10517
10518   Actor actor = Actor::New();
10519
10520   // Register a float property
10521   float startValue(10.0f);
10522   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10523   Stage::GetCurrent().Add(actor);
10524   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10525   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10526
10527   // Build the animation
10528   float initialDurationSeconds(1.0f);
10529   float animatorDelay = 5.0f;
10530   float animatorDurationSeconds(5.0f);
10531   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10532   Animation animation = Animation::New(initialDurationSeconds);
10533   float targetValue(30.0f);
10534   float relativeValue(targetValue - startValue);
10535
10536   animation.AnimateTo(Property(actor, index),
10537                       targetValue,
10538                       TimePeriod(animatorDelay, animatorDurationSeconds));
10539
10540   // The duration should have been extended
10541   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10542
10543   // Start the animation
10544   animation.Play();
10545
10546   bool signalReceived(false);
10547   AnimationFinishCheck finishCheck(signalReceived);
10548   animation.FinishedSignal().Connect(&application, finishCheck);
10549
10550   application.SendNotification();
10551   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10552
10553   // We didn't expect the animation to finish yet, but cached value should be the final one
10554   application.SendNotification();
10555   finishCheck.CheckSignalNotReceived();
10556   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10557   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10558
10559   application.SendNotification();
10560   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10561
10562   // We didn't expect the animation to finish yet
10563   application.SendNotification();
10564   finishCheck.CheckSignalNotReceived();
10565   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10566
10567   application.SendNotification();
10568   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10569
10570   // We did expect the animation to finish
10571   application.SendNotification();
10572   finishCheck.CheckSignalReceived();
10573   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10574   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10575   END_TEST;
10576 }
10577
10578 int UtcDaliAnimationCustomIntProperty(void)
10579 {
10580   TestApplication application;
10581
10582   Actor actor = Actor::New();
10583   Stage::GetCurrent().Add(actor);
10584   int startValue(0u);
10585
10586   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10587   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10588   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10589
10590   // Build the animation
10591   float durationSeconds(1.0f);
10592   Animation animation = Animation::New(durationSeconds);
10593   animation.AnimateTo( Property(actor, index), 20 );
10594
10595   // Start the animation
10596   animation.Play();
10597
10598   // Target value should be retrievable straight away
10599   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10600
10601   bool signalReceived(false);
10602   AnimationFinishCheck finishCheck(signalReceived);
10603   animation.FinishedSignal().Connect(&application, finishCheck);
10604
10605   application.SendNotification();
10606   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10607
10608   // We didn't expect the animation to finish yet
10609   application.SendNotification();
10610   finishCheck.CheckSignalNotReceived();
10611   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10612
10613   application.SendNotification();
10614   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10615
10616   // We did expect the animation to finish
10617   application.SendNotification();
10618   finishCheck.CheckSignalReceived();
10619   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10620   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10621   END_TEST;
10622 }
10623
10624 int UtcDaliAnimationDuration(void)
10625 {
10626   TestApplication application;
10627
10628   Actor actor = Actor::New();
10629   Stage::GetCurrent().Add(actor);
10630
10631   Animation animation = Animation::New( 0.0f );
10632   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10633
10634   // The animation duration should automatically increase depending on the animator time period
10635
10636   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10637   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10638
10639   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10640   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10641
10642   END_TEST;
10643 }
10644
10645 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10646 {
10647   TestApplication application;
10648
10649   Actor actor = Actor::New();
10650
10651   // Register an integer property
10652   int startValue(1);
10653   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10654   Stage::GetCurrent().Add(actor);
10655   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10656
10657   try
10658   {
10659     // Build the animation
10660     Animation animation = Animation::New( 2.0f );
10661     std::string relativeValue = "relative string";
10662     animation.AnimateBy( Property(actor, index), relativeValue );
10663     tet_result(TET_FAIL);
10664   }
10665   catch ( Dali::DaliException& e )
10666   {
10667     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10668   }
10669
10670
10671   END_TEST;
10672 }
10673
10674
10675 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10676 {
10677   TestApplication application;
10678
10679   Actor actor = Actor::New();
10680
10681   // Register an integer property
10682   int startValue(1);
10683   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10684   Stage::GetCurrent().Add(actor);
10685   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10686
10687   try
10688   {
10689     // Build the animation
10690     Animation animation = Animation::New( 2.0f );
10691     std::string relativeValue = "relative string";
10692     animation.AnimateTo( Property(actor, index), relativeValue );
10693
10694     tet_result(TET_FAIL);
10695   }
10696   catch ( Dali::DaliException& e )
10697   {
10698    DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10699   }
10700
10701   END_TEST;
10702 }
10703
10704 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10705 {
10706   TestApplication application;
10707
10708   Actor actor = Actor::New();
10709
10710   // Register an integer property
10711   int startValue(1);
10712   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10713   Stage::GetCurrent().Add(actor);
10714   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10715
10716   try
10717   {
10718     // Build the animation
10719     KeyFrames keyFrames = KeyFrames::New();
10720     keyFrames.Add( 0.0f, std::string("relative string1") );
10721     keyFrames.Add( 1.0f, std::string("relative string2") );
10722     // no need to really create the animation as keyframes do the check
10723
10724     tet_result(TET_FAIL);
10725   }
10726   catch ( Dali::DaliException& e )
10727   {
10728     DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
10729   }
10730
10731   END_TEST;
10732 }
10733
10734 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10735 {
10736   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10737
10738   TestApplication application;
10739
10740   tet_infoline("Set initial position and set up animation to re-position actor");
10741
10742   Actor actor = Actor::New();
10743   Stage::GetCurrent().Add(actor);
10744   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10745   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10746
10747   // Build the animation
10748   Animation animation = Animation::New(2.0f);
10749
10750   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10751   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10752   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10753
10754   tet_infoline("Set target position in animation without intiating play");
10755
10756   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10757   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10758
10759   application.SendNotification();
10760   application.Render();
10761
10762   tet_infoline("Ensure position of actor is still at intial value");
10763
10764   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10765   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10766   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10767
10768   tet_infoline("Play animation and ensure actor position is now target");
10769
10770   animation.Play();
10771   application.SendNotification();
10772   application.Render(1000u);
10773
10774   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10775
10776   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10777   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10778   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10779
10780   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10781
10782   application.Render(2000u);
10783
10784   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10785
10786   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10787   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10788   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10789
10790   END_TEST;
10791 }
10792
10793 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10794 {
10795   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10796
10797   TestApplication application;
10798
10799   std::vector<Vector3> targetPositions;
10800
10801   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10802   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10803   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10804
10805   tet_infoline("Set initial position and set up animation to re-position actor");
10806
10807   Actor actor = Actor::New();
10808   Stage::GetCurrent().Add(actor);
10809   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10810   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10811
10812   // Build the animation
10813   Animation animation = Animation::New(2.0f);
10814
10815   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10816   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10817   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10818
10819   tet_infoline("Set target position in animation without intiating play");
10820
10821   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10822   {
10823     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10824   }
10825
10826   application.SendNotification();
10827   application.Render();
10828
10829   tet_infoline("Ensure position of actor is still at intial value");
10830
10831   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10832   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10833   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10834
10835   tet_infoline("Play animation and ensure actor position is now target");
10836
10837   animation.Play();
10838   application.SendNotification();
10839   application.Render(1000u);
10840
10841   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10842
10843   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10844   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10845   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10846
10847   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10848
10849   application.Render(2000u);
10850
10851   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10852
10853   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10854   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10855   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10856
10857   END_TEST;
10858 }
10859
10860 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10861 {
10862   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");
10863
10864   TestApplication application;
10865
10866   std::vector<Vector3> targetSizes;
10867   std::vector<Vector3> targetPositions;
10868
10869   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10870   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10871
10872   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10873
10874   tet_infoline("Set initial position and set up animation to re-position actor");
10875
10876   Actor actor = Actor::New();
10877   Stage::GetCurrent().Add(actor);
10878   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10879   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10880
10881   actor.SetProperty( Actor::Property::SIZE, initialSize );
10882   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10883
10884   // Build the animation
10885   Animation animation = Animation::New(2.0f);
10886
10887   tet_infoline("Set target size in animation without intiating play");
10888   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10889   tet_infoline("Set target position in animation without intiating play");
10890   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10891   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10892
10893   application.SendNotification();
10894   application.Render();
10895
10896   tet_infoline("Ensure position of actor is still at intial size and position");
10897
10898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10899   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10900   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10901
10902   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10903   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10904   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10905
10906   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10907
10908   animation.Play();
10909   application.SendNotification();
10910   application.Render(2000u);
10911
10912   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10913
10914   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10915   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10916   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10917
10918   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10920   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10921
10922   END_TEST;
10923 }
10924
10925 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10926 {
10927   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10928
10929   TestApplication application;
10930
10931   std::vector<Vector3> targetSizes;
10932   std::vector<float> targetColors;
10933
10934   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10935   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10936
10937   targetColors.push_back( 1.0f );
10938
10939   tet_infoline("Set initial position and set up animation to re-position actor");
10940
10941   Actor actor = Actor::New();
10942   Stage::GetCurrent().Add(actor);
10943   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10944
10945   actor.SetProperty( Actor::Property::SIZE, initialSize );
10946
10947   // Build the animation
10948   Animation animation = Animation::New(2.0f);
10949
10950   tet_infoline("Set target size in animation without initiating play");
10951   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10952   tet_infoline("Set target position in animation without intiating play");
10953   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
10954   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10955
10956   application.SendNotification();
10957   application.Render();
10958
10959   tet_infoline("Ensure position of actor is still at initial size and position");
10960
10961   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10962   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10963   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10964
10965   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10966
10967   animation.Play();
10968   application.SendNotification();
10969   application.Render(2000u);
10970
10971   tet_infoline("Ensure position and size of actor is at target value when animation playing");
10972
10973   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10974   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10975   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10976
10977   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
10978
10979   END_TEST;
10980 }
10981
10982 int UtcDaliAnimationTimePeriodOrder(void)
10983 {
10984   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
10985
10986   TestApplication application;
10987
10988   Actor actor = Actor::New();
10989   Stage::GetCurrent().Add( actor );
10990
10991   application.SendNotification();
10992   application.Render();
10993
10994   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10995   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10996   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10997   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10998   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10999
11000   //////////////////////////////////////////////////////////////////////////////////
11001
11002   tet_infoline( "With two AnimateTo calls" );
11003
11004   Animation animation = Animation::New( 0.0f );
11005   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11006   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11007   animation.Play();
11008
11009   tet_infoline( "The target position should change instantly" );
11010   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11011   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11012
11013   application.SendNotification();
11014   application.Render(5000); // After the animation is complete
11015
11016   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11017   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11018   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11019
11020   //////////////////////////////////////////////////////////////////////////////////
11021
11022   tet_infoline( "Same animation again but in a different order - should yield the same result" );
11023
11024   actor.SetX( 0.0f );
11025   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11026   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11027
11028   application.SendNotification();
11029   application.Render();
11030
11031   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11032   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11033   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11034
11035   animation = Animation::New( 0.0f );
11036   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11037   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11038   animation.Play();
11039
11040   tet_infoline( "The target position should change instantly" );
11041   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11042   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11043
11044   application.SendNotification();
11045   application.Render(5000); // After the animation is complete
11046
11047   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11048   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11049   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11050
11051   END_TEST;
11052 }
11053
11054 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11055 {
11056   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" );
11057
11058   TestApplication application;
11059
11060   Actor actor = Actor::New();
11061   Stage::GetCurrent().Add( actor );
11062
11063   application.SendNotification();
11064   application.Render();
11065
11066   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11067   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11068   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11069   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11070   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11071
11072   //////////////////////////////////////////////////////////////////////////////////
11073
11074   tet_infoline( "" );
11075
11076   Animation animation = Animation::New( 0.0f );
11077   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11078   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11079   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11080   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11081   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11082   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11083   animation.Play();
11084
11085   tet_infoline( "The target position should change instantly" );
11086   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11087   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11088
11089   application.SendNotification();
11090   application.Render(14000); // After the animation is complete
11091
11092   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11093   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11094   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11095
11096   //////////////////////////////////////////////////////////////////////////////////
11097
11098   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11099
11100   actor.SetX( 0.0f );
11101
11102   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11103   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11104
11105   application.SendNotification();
11106   application.Render();
11107
11108   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11109   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11110   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11111
11112   animation = Animation::New( 0.0f );
11113   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11114   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11115   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11116   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11117   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11118   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11119   animation.Play();
11120
11121   tet_infoline( "The target position should change instantly" );
11122   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11123   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11124
11125   application.SendNotification();
11126   application.Render(14000); // After the animation is complete
11127
11128   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11129   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11130   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11131
11132   END_TEST;
11133 }
11134
11135 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11136 {
11137   TestApplication application;
11138
11139   int startValue(1);
11140   Actor actor = Actor::New();
11141   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11142   Stage::GetCurrent().Add(actor);
11143
11144   application.Render();
11145   application.SendNotification();
11146
11147   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11148
11149   // Build the animation
11150   float durationSeconds(1.0f);
11151   Animation animation = Animation::New(durationSeconds);
11152
11153   KeyFrames keyFrames = KeyFrames::New();
11154   keyFrames.Add(0.0f, 10);
11155   keyFrames.Add(0.2f, 20);
11156   keyFrames.Add(0.4f, 30);
11157   keyFrames.Add(0.6f, 40);
11158   keyFrames.Add(0.8f, 50);
11159   keyFrames.Add(1.0f, 60);
11160
11161   animation.AnimateBetween( Property(actor, index ), keyFrames );
11162
11163   // Start the animation
11164   animation.Play();
11165
11166   // Target value should change to the last key-frame's value straight away
11167   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11168
11169   END_TEST;
11170 }
11171
11172 int UtcDaliAnimationAnimateBetweenVector2P(void)
11173 {
11174   TestApplication application;
11175
11176   Vector2 startValue( 10.0f, 20.0f );
11177   Actor actor = Actor::New();
11178   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11179   Stage::GetCurrent().Add(actor);
11180
11181   application.Render();
11182   application.SendNotification();
11183
11184   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11185
11186   // Build the animation
11187   float durationSeconds(1.0f);
11188   Animation animation = Animation::New(durationSeconds);
11189
11190   KeyFrames keyFrames = KeyFrames::New();
11191   keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11192   keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11193   keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11194   keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11195   keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11196   keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11197
11198   animation.AnimateBetween( Property(actor, index ), keyFrames );
11199
11200   // Start the animation
11201   animation.Play();
11202
11203   // Target value should change to the last key-frame's value straight away
11204   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11205
11206   END_TEST;
11207 }