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