Harmonize Animation API parameter checking and add test cases for them
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <algorithm>
20
21 #include <stdlib.h>
22 #include <dali/public-api/dali-core.h>
23 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali-test-suite-utils.h>
25 #include <dali/devel-api/animation/animation-devel.h>
26
27 using std::max;
28 using namespace Dali;
29
30 void utc_dali_animation_startuP(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_animation_cleanuP(void)
36 {
37   test_return_value = TET_PASS;
38 }
39
40 namespace
41 {
42
43 static const float ROTATION_EPSILON = 0.0001f;
44 static const float VECTOR4_EPSILON = 0.0001f;
45
46 // Functor to test whether a Finish signal is emitted
47 struct AnimationFinishCheck
48 {
49   AnimationFinishCheck(bool& signalReceived)
50   : mSignalReceived(signalReceived)
51   {
52   }
53
54   void operator()(Animation& animation)
55   {
56     mSignalReceived = true;
57   }
58
59   void Reset()
60   {
61     mSignalReceived = false;
62   }
63
64   void CheckSignalReceived()
65   {
66     if (!mSignalReceived)
67     {
68       tet_printf("Expected Finish signal was not received\n");
69       tet_result(TET_FAIL);
70     }
71     else
72     {
73       tet_result(TET_PASS);
74     }
75   }
76
77   void CheckSignalNotReceived()
78   {
79     if (mSignalReceived)
80     {
81       tet_printf("Unexpected Finish signal was received\n");
82       tet_result(TET_FAIL);
83     }
84     else
85     {
86       tet_result(TET_PASS);
87     }
88   }
89
90   bool& mSignalReceived; // owned by individual tests
91 };
92
93 // Functor to test whether a Progress signal is emitted
94 struct AnimationProgressCheck
95 {
96   AnimationProgressCheck(bool& signalReceived, std::string name = " ")
97   : mSignalReceived(signalReceived),
98     mName( name )
99   {
100   }
101
102   void operator()(Animation& animation)
103   {
104     mSignalReceived = true;
105   }
106
107   void Reset()
108   {
109     mSignalReceived = false;
110   }
111
112   void CheckSignalReceived()
113   {
114     if (!mSignalReceived)
115     {
116       tet_printf("Expected Progress reached signal was not received %s \n", mName.c_str() );
117       tet_result(TET_FAIL);
118     }
119     else
120     {
121       tet_result(TET_PASS);
122     }
123   }
124
125   void CheckSignalNotReceived()
126   {
127     if (mSignalReceived)
128     {
129       tet_printf("Unexpected Progress reached signal was received %s \n", mName.c_str());
130       tet_result(TET_FAIL);
131     }
132     else
133     {
134       tet_result(TET_PASS);
135     }
136   }
137
138   bool& mSignalReceived; // owned by individual tests
139   std::string mName;
140 };
141
142 } // anon namespace
143
144 int UtcDaliAnimationConstructorP(void)
145 {
146   TestApplication application;
147
148   Animation animation;
149
150   DALI_TEST_CHECK( !animation );
151   END_TEST;
152 }
153
154 int UtcDaliAnimationNewP(void)
155 {
156   TestApplication application;
157
158   Animation animation = Animation::New( 1.0f );
159
160   DALI_TEST_CHECK(animation);
161   END_TEST;
162 }
163
164 int UtcDaliAnimationNewN(void)
165 {
166   TestApplication application;
167
168   Animation animation = Animation::New( -1.0f );
169
170   DALI_TEST_CHECK(animation);
171   DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
172   END_TEST;
173 }
174
175 int UtcDaliAnimationDownCastP(void)
176 {
177   TestApplication application;
178
179   tet_infoline("Testing Dali::Animation::DownCast()");
180
181   float durationSeconds(1.0f);
182   Animation animation = Animation::New(durationSeconds);
183
184   BaseHandle object(animation);
185
186   Animation animation2 = Animation::DownCast(object);
187   DALI_TEST_CHECK(animation2);
188
189   Animation animation3 = DownCast< Animation >(object);
190   DALI_TEST_CHECK(animation3);
191   END_TEST;
192 }
193
194 int UtcDaliAnimationDownCastN(void)
195 {
196   TestApplication application;
197
198   BaseHandle unInitializedObject;
199
200   Animation animation1 = Animation::DownCast( unInitializedObject );
201   DALI_TEST_CHECK( !animation1 );
202
203   Animation animation2 = DownCast< Animation >( unInitializedObject );
204   DALI_TEST_CHECK( !animation2 );
205   END_TEST;
206 }
207
208 int UtcDaliAnimationCopyConstructorP(void)
209 {
210   TestApplication application;
211
212   // Initialize an object, ref count == 1
213   Animation animation = Animation::New( 1.0f );
214
215   Animation copy( animation );
216   DALI_TEST_CHECK( copy );
217
218   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
219   END_TEST;
220 }
221
222 int UtcDaliAnimationAssignmentOperatorP(void)
223 {
224   TestApplication application;
225
226   Animation animation = Animation::New( 1.0f );
227
228   Animation copy = animation;
229   DALI_TEST_CHECK( copy );
230
231   DALI_TEST_CHECK( animation == copy );
232
233   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
234   END_TEST;
235 }
236
237 int UtcDaliAnimationSetDurationP(void)
238 {
239   TestApplication application;
240
241   Actor actor = Actor::New();
242   Stage::GetCurrent().Add(actor);
243
244   // Build the animation
245   float durationSeconds(1.0f);
246   Animation animation = Animation::New(durationSeconds);
247   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
248
249   // Start the animation
250   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
251   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
252   animation.Play();
253
254   bool signalReceived(false);
255   AnimationFinishCheck finishCheck(signalReceived);
256   animation.FinishedSignal().Connect(&application, finishCheck);
257
258   application.SendNotification();
259   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
260
261   // We didn't expect the animation to finish yet
262   application.SendNotification();
263   finishCheck.CheckSignalNotReceived();
264
265   application.Render(2u/*just beyond the animation duration*/);
266
267   // We did expect the animation to finish
268   application.SendNotification();
269   finishCheck.CheckSignalReceived();
270   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
271
272   // Restart the animation, with a different duration
273   finishCheck.Reset();
274   actor.SetPosition(Vector3::ZERO);
275   durationSeconds = 3.5f;
276   animation.SetDuration(durationSeconds);
277   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
278   animation.Play();
279
280   application.SendNotification();
281   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
282
283   // We didn't expect the animation to finish yet
284   application.SendNotification();
285   finishCheck.CheckSignalNotReceived();
286
287   application.Render(2u/*just beyond the animation duration*/);
288
289   // We did expect the animation to finish
290   application.SendNotification();
291   finishCheck.CheckSignalReceived();
292   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
293
294   // Check that nothing has changed after a couple of buffer swaps
295   application.Render(0);
296   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
297   application.Render(0);
298   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
299   END_TEST;
300 }
301
302 int UtcDaliAnimationSetDurationN(void)
303 {
304   TestApplication application;
305
306   Animation animation = Animation::New( 1.0f );
307   DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
308
309   animation.SetDuration( -1.0f );
310   DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
311   END_TEST;
312 }
313
314 int UtcDaliAnimationGetDurationP(void)
315 {
316   TestApplication application;
317
318   Animation animation = Animation::New(1.0f);
319   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
320
321   animation.SetDuration(2.0f);
322   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
323   END_TEST;
324 }
325
326 int UtcDaliAnimationSetLoopingP(void)
327 {
328   TestApplication application;
329
330   Actor actor = Actor::New();
331   Stage::GetCurrent().Add(actor);
332
333   // Build the animation
334   float durationSeconds(1.0f);
335   Animation animation = Animation::New(durationSeconds);
336   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
337   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
338
339   // Start the animation
340   animation.SetLooping(true);
341   DALI_TEST_CHECK(animation.IsLooping());
342   animation.Play();
343
344   bool signalReceived(false);
345   AnimationFinishCheck finishCheck(signalReceived);
346   animation.FinishedSignal().Connect(&application, finishCheck);
347
348   application.SendNotification();
349
350   // Loop 5 times
351   float intervalSeconds = 0.25f;
352   float progress = 0.0f;
353   for (int iterations = 0; iterations < 5;)
354   {
355     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
356
357     progress += intervalSeconds;
358     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
359
360     if (progress >= 1.0f)
361     {
362       progress = progress - 1.0f;
363       ++iterations;
364     }
365   }
366
367   // We didn't expect the animation to finish yet
368   application.SendNotification();
369   finishCheck.CheckSignalNotReceived();
370
371   animation.SetLooping(false);
372   DALI_TEST_CHECK(!animation.IsLooping());
373
374   application.SendNotification();
375   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
376
377   // We did expect the animation to finish
378   application.SendNotification();
379   finishCheck.CheckSignalReceived();
380   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
381
382   // Check that nothing has changed after a couple of buffer swaps
383   application.Render(0);
384   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
385   application.Render(0);
386   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
387   END_TEST;
388 }
389
390 int UtcDaliAnimationSetLoopCountP(void)
391 {
392   TestApplication application;
393
394   Actor actor = Actor::New();
395   Stage::GetCurrent().Add(actor);
396
397   // Build the animation
398   float durationSeconds(1.0f);
399   Animation animation = Animation::New(durationSeconds);
400   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
401   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
402
403   // Start the animation
404   animation.SetLoopCount(3);
405   DALI_TEST_CHECK(animation.IsLooping());
406   animation.Play();
407
408   bool signalReceived(false);
409   AnimationFinishCheck finishCheck(signalReceived);
410   animation.FinishedSignal().Connect(&application, finishCheck);
411
412   application.Render(0);
413   application.SendNotification();
414   application.Render(0);
415   application.SendNotification();
416   application.Render(0);
417   application.SendNotification();
418   application.Render(0);
419   application.SendNotification();
420
421   // Loop
422   float intervalSeconds = 3.0f;
423
424   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
425   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
426
427   application.Render(0);
428   application.SendNotification();
429   application.Render(0);
430   application.SendNotification();
431   application.Render(0);
432   application.SendNotification();
433   application.Render(0);
434   application.SendNotification();
435   finishCheck.CheckSignalNotReceived();
436
437   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
438
439   application.SendNotification();
440   finishCheck.CheckSignalReceived();
441   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
442
443   finishCheck.Reset();
444
445   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
446   application.SendNotification();
447   finishCheck.CheckSignalNotReceived();
448
449   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
450   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
451   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
452   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
453   application.SendNotification();
454   finishCheck.CheckSignalNotReceived();
455
456   END_TEST;
457 }
458
459 int UtcDaliAnimationSetLoopCountP2(void)
460 {
461   TestApplication application;
462
463   //
464   // switching between forever and loop count
465   //
466
467   Actor actor = Actor::New();
468   Stage::GetCurrent().Add(actor);
469
470   // Build the animation
471   float durationSeconds(1.0f);
472   Animation animation = Animation::New(durationSeconds);
473   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
474   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
475   animation.SetEndAction(Animation::Discard);
476
477   // Start the animation
478   animation.SetLoopCount(3);
479   DALI_TEST_CHECK(animation.IsLooping());
480   animation.Play();
481
482   bool signalReceived(false);
483   AnimationFinishCheck finishCheck(signalReceived);
484   animation.FinishedSignal().Connect(&application, finishCheck);
485
486   float intervalSeconds = 3.0f;
487
488   application.SendNotification();
489   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
490   application.SendNotification();
491   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
492   application.SendNotification();
493   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
494   application.SendNotification();
495
496   application.SendNotification();
497   finishCheck.CheckSignalReceived();
498
499   finishCheck.Reset();
500
501   // Loop forever
502   animation.SetLooping(true);
503   DALI_TEST_CHECK(animation.IsLooping());
504
505   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
506   application.SendNotification();
507   finishCheck.CheckSignalNotReceived();
508
509   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
510   application.SendNotification();
511   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
512   application.SendNotification();
513   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
514   application.SendNotification();
515   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
516   application.SendNotification();
517   application.SendNotification();
518   finishCheck.CheckSignalNotReceived();
519
520   finishCheck.Reset();
521
522   // Loop N again
523   animation.SetLoopCount(3);
524   DALI_TEST_CHECK(animation.IsLooping());
525   animation.Play();
526
527   application.SendNotification();
528   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
529   application.SendNotification();
530   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
531   application.SendNotification();
532   finishCheck.CheckSignalNotReceived();
533
534   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
535   application.SendNotification();
536   finishCheck.CheckSignalReceived();
537
538   finishCheck.Reset();
539
540   // loop forever
541   animation.SetLooping(true);
542   DALI_TEST_CHECK(animation.IsLooping());
543
544   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
545   application.SendNotification();
546   finishCheck.CheckSignalNotReceived();
547
548   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
549   application.SendNotification();
550   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
551   application.SendNotification();
552   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
553   application.SendNotification();
554   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
555   application.SendNotification();
556   finishCheck.CheckSignalNotReceived();
557
558   finishCheck.Reset();
559
560   // Loop N again
561   animation.SetLoopCount(3);
562   DALI_TEST_CHECK(animation.IsLooping());
563
564   application.SendNotification();
565   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
566   application.SendNotification();
567   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
568   application.SendNotification();
569   finishCheck.CheckSignalNotReceived();
570
571   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
572   application.SendNotification();
573   finishCheck.CheckSignalNotReceived(); // we never hit play
574
575   finishCheck.Reset();
576
577
578   END_TEST;
579 }
580
581 int UtcDaliAnimationSetLoopCountP3(void)
582 {
583   TestApplication application;
584
585   //
586   // switching between forever and loop count
587   //
588   Actor actor = Actor::New();
589   Stage::GetCurrent().Add(actor);
590
591   // Build the animation
592   float durationSeconds(1.0f);
593   Animation animation = Animation::New(durationSeconds);
594   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
595   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
596   animation.SetEndAction(Animation::Discard);
597
598   float intervalSeconds = 3.0f;
599
600   bool signalReceived(false);
601   AnimationFinishCheck finishCheck(signalReceived);
602   animation.FinishedSignal().Connect(&application, finishCheck);
603
604   // loop forever
605   animation.SetLooping(true);
606   DALI_TEST_CHECK(animation.IsLooping());
607
608   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
609   application.SendNotification();
610   finishCheck.CheckSignalNotReceived();
611
612   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
613   application.SendNotification();
614   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
615   application.SendNotification();
616   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
617   application.SendNotification();
618   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
619   application.SendNotification();
620   finishCheck.CheckSignalNotReceived();
621
622   finishCheck.Reset();
623
624   // Loop N again
625   animation.SetLoopCount(3);
626   DALI_TEST_CHECK(animation.IsLooping());
627
628   application.SendNotification();
629   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
630   application.SendNotification();
631   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
632   application.SendNotification();
633   finishCheck.CheckSignalNotReceived();
634
635   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
636   application.SendNotification();
637   finishCheck.CheckSignalNotReceived(); // we never hit play
638
639   finishCheck.Reset();
640
641
642   END_TEST;
643 }
644
645 int UtcDaliAnimationSetLoopCountP4(void)
646 {
647   TestApplication application;
648
649   //
650   // ..and play again
651   //
652   Actor actor = Actor::New();
653   Stage::GetCurrent().Add(actor);
654
655   // Build the animation
656   float durationSeconds(1.0f);
657   Animation animation = Animation::New(durationSeconds);
658   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
659   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
660   animation.SetEndAction(Animation::Bake);
661
662   float intervalSeconds = 3.0f;
663
664   bool signalReceived(false);
665   AnimationFinishCheck finishCheck(signalReceived);
666   animation.FinishedSignal().Connect(&application, finishCheck);
667
668   animation.SetLoopCount(1);
669   animation.Play();
670   DALI_TEST_CHECK(!animation.IsLooping());
671
672   application.SendNotification();
673   finishCheck.CheckSignalNotReceived();
674   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
675   application.SendNotification();
676   finishCheck.CheckSignalReceived();
677
678   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
679   actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
680
681   finishCheck.Reset();
682
683   animation.Play(); // again
684   DALI_TEST_CHECK(!animation.IsLooping());
685
686   application.SendNotification();
687   finishCheck.CheckSignalNotReceived();
688   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
689   application.SendNotification();
690   finishCheck.CheckSignalReceived();
691
692   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
693
694   END_TEST;
695 }
696
697 int UtcDaliAnimationGetLoopCountP(void)
698 {
699   TestApplication application;
700
701   Actor actor = Actor::New();
702   Stage::GetCurrent().Add(actor);
703
704   // Build the animation
705   float durationSeconds(1.0f);
706   Animation animation = Animation::New(durationSeconds);
707   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
708   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
709
710   DALI_TEST_CHECK(1 == animation.GetLoopCount());
711
712   // Start the animation
713   animation.SetLoopCount(3);
714   DALI_TEST_CHECK(animation.IsLooping());
715   DALI_TEST_CHECK(3 == animation.GetLoopCount());
716
717   animation.Play();
718
719   application.Render(0);
720   application.SendNotification();
721
722   // Loop
723   float intervalSeconds = 3.0f;
724
725   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
726   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
727
728   application.Render(0);
729   application.SendNotification();
730
731   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
732   application.SendNotification();
733
734   animation.SetLoopCount(0);
735   DALI_TEST_CHECK(animation.IsLooping());
736   DALI_TEST_CHECK(0 == animation.GetLoopCount());
737
738   animation.SetLoopCount(1);
739   DALI_TEST_CHECK(!animation.IsLooping());
740   DALI_TEST_CHECK(1 == animation.GetLoopCount());
741
742   END_TEST;
743 }
744
745
746 int UtcDaliAnimationGetCurrentLoopP(void)
747 {
748   TestApplication application;
749
750   Actor actor = Actor::New();
751   Stage::GetCurrent().Add(actor);
752
753   // Build the animation
754   float durationSeconds(1.0f);
755   Animation animation = Animation::New(durationSeconds);
756   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
757   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
758
759   // Start the animation
760   animation.SetLoopCount(3);
761   DALI_TEST_CHECK(animation.IsLooping());
762   DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
763   animation.Play();
764
765   bool signalReceived(false);
766   AnimationFinishCheck finishCheck(signalReceived);
767   animation.FinishedSignal().Connect(&application, finishCheck);
768
769   application.SendNotification();
770
771   // Loop
772   float intervalSeconds = 3.0f;
773
774   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
775   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
776
777   application.SendNotification();
778   finishCheck.CheckSignalNotReceived();
779   DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
780
781   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
782
783   application.SendNotification();
784   finishCheck.CheckSignalReceived();
785   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
786   DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
787
788   finishCheck.Reset();
789
790   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
791   application.SendNotification();
792   finishCheck.CheckSignalNotReceived();
793   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
794
795   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
796   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
797   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
798   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
799   application.SendNotification();
800   finishCheck.CheckSignalNotReceived();
801   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
802
803   END_TEST;
804 }
805
806 int UtcDaliAnimationIsLoopingP(void)
807 {
808   TestApplication application;
809
810   Animation animation = Animation::New(1.0f);
811   DALI_TEST_CHECK(!animation.IsLooping());
812
813   animation.SetLooping(true);
814   DALI_TEST_CHECK(animation.IsLooping());
815   END_TEST;
816 }
817
818 int UtcDaliAnimationSetEndActioN(void)
819 {
820   TestApplication application;
821
822   Actor actor = Actor::New();
823   Stage::GetCurrent().Add(actor);
824
825   // Build the animation
826   float durationSeconds(1.0f);
827   Animation animation = Animation::New(durationSeconds);
828   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
829
830   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
831   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
832
833   // Start the animation
834   animation.Play();
835
836   bool signalReceived(false);
837   AnimationFinishCheck finishCheck(signalReceived);
838   animation.FinishedSignal().Connect(&application, finishCheck);
839
840   application.SendNotification();
841   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
842
843   // We did expect the animation to finish
844   application.SendNotification();
845   finishCheck.CheckSignalReceived();
846   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
847
848   // Go back to the start
849   actor.SetPosition(Vector3::ZERO);
850   application.SendNotification();
851   application.Render(0);
852   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
853
854   // Test BakeFinal, animate again, for half the duration
855   finishCheck.Reset();
856   animation.SetEndAction(Animation::BakeFinal);
857   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
858   animation.Play();
859
860   application.SendNotification();
861   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
862
863   // Stop the animation early
864   animation.Stop();
865
866   // We did NOT expect the animation to finish
867   application.SendNotification();
868   finishCheck.CheckSignalNotReceived();
869   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
870
871   // The position should be same with target position in the next frame
872   application.Render(0);
873   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
874
875   // Go back to the start
876   actor.SetPosition(Vector3::ZERO);
877   application.SendNotification();
878   application.Render(0);
879   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
880
881   // Test EndAction::Discard, animate again, but don't bake this time
882   finishCheck.Reset();
883   animation.SetEndAction(Animation::Discard);
884   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
885   animation.Play();
886
887   application.SendNotification();
888   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
889
890   // We did expect the animation to finish
891   application.SendNotification();
892   finishCheck.CheckSignalReceived();
893   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
894
895   // The position should be discarded in the next frame
896   application.Render(0);
897   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
898
899   // Check that nothing has changed after a couple of buffer swaps
900   application.Render(0);
901   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
902   application.Render(0);
903   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
904   END_TEST;
905 }
906
907 int UtcDaliAnimationGetEndActionP(void)
908 {
909   TestApplication application;
910
911   Animation animation = Animation::New(1.0f);
912   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
913
914   animation.SetEndAction(Animation::Discard);
915   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
916
917   animation.SetEndAction(Animation::BakeFinal);
918   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
919
920   END_TEST;
921 }
922
923 int UtcDaliAnimationSetDisconnectActionP(void)
924 {
925   TestApplication application;
926   Stage stage( Stage::GetCurrent() );
927
928   // Default: BakeFinal
929   {
930     Actor actor = Actor::New();
931     stage.Add(actor);
932
933     // Build the animation
934     float durationSeconds(1.0f);
935     Animation animation = Animation::New(durationSeconds);
936     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
937
938     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
939     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
940
941     // Start the animation
942     animation.Play();
943
944     application.SendNotification();
945     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
946
947     actor.Unparent();
948
949     application.SendNotification();
950     application.Render();
951
952     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
953   }
954
955   // Bake
956   {
957     Actor actor = Actor::New();
958     stage.Add(actor);
959
960     // Build the animation
961     float durationSeconds(1.0f);
962     Animation animation = Animation::New(durationSeconds);
963     animation.SetDisconnectAction( Animation::Bake );
964
965     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
966     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
967
968     // Start the animation
969     animation.Play();
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(), targetPosition*0.5f, TEST_LOCATION );
980   }
981
982   // Discard
983   {
984     Actor actor = Actor::New();
985     stage.Add(actor);
986
987     // Build the animation
988     float durationSeconds(1.0f);
989     Animation animation = Animation::New(durationSeconds);
990     animation.SetDisconnectAction( Animation::Discard );
991
992     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
993     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
994
995     // Start the animation
996     animation.Play();
997
998     application.SendNotification();
999     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1000
1001     actor.Unparent();
1002
1003     application.SendNotification();
1004     application.Render();
1005
1006     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
1007   }
1008
1009   // Don't play the animation: disconnect action should not be applied
1010   {
1011     Actor actor = Actor::New();
1012     stage.Add(actor);
1013
1014     // Build the animation
1015     float durationSeconds(1.0f);
1016     Animation animation = Animation::New(durationSeconds);
1017
1018     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
1019     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1020
1021     application.SendNotification();
1022     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1023
1024     actor.Unparent();
1025
1026     application.SendNotification();
1027     application.Render();
1028
1029     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
1030   }
1031
1032   END_TEST;
1033 }
1034
1035 int UtcDaliAnimationGetDisconnectActionP(void)
1036 {
1037   TestApplication application;
1038   Animation animation = Animation::New(1.0f);
1039   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
1040
1041   animation.SetDisconnectAction(Animation::Discard);
1042   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
1043
1044   animation.SetDisconnectAction(Animation::Bake);
1045   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
1046
1047   END_TEST;
1048 }
1049
1050 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
1051 {
1052   TestApplication application;
1053
1054   Animation animation = Animation::New(1.0f);
1055   AlphaFunction func = animation.GetDefaultAlphaFunction();
1056   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1057
1058   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1059   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1060   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1061   END_TEST;
1062 }
1063
1064 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
1065 {
1066   TestApplication application;
1067
1068   Animation animation = Animation::New(1.0f);
1069   AlphaFunction func = animation.GetDefaultAlphaFunction();
1070
1071   // Test that the default is linear
1072   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1073
1074   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1075   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1076   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1077
1078   END_TEST;
1079 }
1080
1081 int UtcDaliAnimationSetCurrentProgressP(void)
1082 {
1083   TestApplication application;
1084
1085   Actor actor = Actor::New();
1086   Stage::GetCurrent().Add(actor);
1087
1088   // Build the animation
1089   Animation animation = Animation::New(0.0f);
1090
1091   //Set duration
1092   float durationSeconds(1.0f);
1093   animation.SetDuration(durationSeconds);
1094
1095   bool signalReceived(false);
1096   AnimationFinishCheck finishCheck(signalReceived);
1097   animation.FinishedSignal().Connect(&application, finishCheck);
1098   application.SendNotification();
1099
1100   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1101   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1102
1103   // Start the animation from 40% progress
1104   animation.SetCurrentProgress( 0.4f );
1105   animation.Play();
1106
1107   application.SendNotification();
1108   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1109
1110   // We didn't expect the animation to finish yet
1111   application.SendNotification();
1112   finishCheck.CheckSignalNotReceived();
1113   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1114   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1115
1116   animation.Play(); // Test that calling play has no effect, when animation is already playing
1117   application.SendNotification();
1118
1119   //Set the progress to 70%
1120   animation.SetCurrentProgress( 0.7f );
1121   application.SendNotification();
1122   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1123   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1124
1125   application.SendNotification();
1126   finishCheck.CheckSignalNotReceived();
1127   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1128   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1129
1130   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1131   // We did expect the animation to finish
1132   application.SendNotification();
1133   finishCheck.CheckSignalReceived();
1134   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1135
1136   // Check that nothing has changed after a couple of buffer swaps
1137   application.Render(0);
1138   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1139   application.Render(0);
1140   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1141   END_TEST;
1142 }
1143
1144 int UtcDaliAnimationSetCurrentProgressN(void)
1145 {
1146   TestApplication application;
1147
1148   Actor actor = Actor::New();
1149   Stage::GetCurrent().Add(actor);
1150
1151   // Build the animation
1152   Animation animation = Animation::New(0.0f);
1153
1154   //Set duration
1155   float durationSeconds(1.0f);
1156   animation.SetDuration(durationSeconds);
1157
1158   bool signalReceived(false);
1159   AnimationFinishCheck finishCheck(signalReceived);
1160   animation.FinishedSignal().Connect(&application, finishCheck);
1161   application.SendNotification();
1162
1163   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1164   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1165
1166   //Trying to set the current cursor outside the range [0..1] is ignored
1167   animation.SetCurrentProgress( -1.0f);
1168   application.SendNotification();
1169   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1170
1171   animation.SetCurrentProgress( 100.0f);
1172   application.SendNotification();
1173   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1174   END_TEST;
1175 }
1176
1177 int UtcDaliAnimationGetCurrentProgressP(void)
1178 {
1179   TestApplication application;
1180
1181   Actor actor = Actor::New();
1182   Stage::GetCurrent().Add(actor);
1183
1184   // Build the animation
1185   Animation animation = Animation::New(0.0f);
1186   animation.Play();
1187
1188   //Test GetCurrentProgress return 0.0 as the duration is 0.0
1189   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1190
1191   animation.SetCurrentProgress( 0.5f );
1192   application.SendNotification();
1193   application.Render(static_cast<unsigned int>(100.0f));
1194
1195   //Progress should still be 0.0
1196   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1197
1198   //Set duration
1199   float durationSeconds(1.0f);
1200   animation.SetDuration(durationSeconds);
1201   application.SendNotification();
1202
1203   bool signalReceived(false);
1204   AnimationFinishCheck finishCheck(signalReceived);
1205   animation.FinishedSignal().Connect(&application, finishCheck);
1206   application.SendNotification();
1207
1208   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1209   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1210
1211   // Start the animation from 40% progress
1212   animation.SetCurrentProgress( 0.4f );
1213   animation.Play();
1214
1215   application.SendNotification();
1216   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1217
1218   // We didn't expect the animation to finish yet
1219   application.SendNotification();
1220   finishCheck.CheckSignalNotReceived();
1221   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1222
1223   animation.Play(); // Test that calling play has no effect, when animation is already playing
1224   application.SendNotification();
1225
1226   //Set the progress to 70%
1227   animation.SetCurrentProgress( 0.7f );
1228   application.SendNotification();
1229   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1230   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1231
1232   application.SendNotification();
1233   finishCheck.CheckSignalNotReceived();
1234   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1235
1236   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1237   // We did expect the animation to finish
1238   application.SendNotification();
1239   finishCheck.CheckSignalReceived();
1240   END_TEST;
1241 }
1242
1243 int UtcDaliAnimationSetSpeedFactorP1(void)
1244 {
1245   TestApplication application;
1246
1247   tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1248
1249   Actor actor = Actor::New();
1250   Stage::GetCurrent().Add(actor);
1251
1252   // Build the animation
1253   float durationSeconds(1.0f);
1254   Animation animation = Animation::New(durationSeconds);
1255
1256   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1257   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1258
1259   KeyFrames keyframes = KeyFrames::New();
1260   keyframes.Add( 0.0f, initialPosition);
1261   keyframes.Add( 1.0f, targetPosition );
1262   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1263
1264   //Set speed to be x2
1265   animation.SetSpeedFactor(2.0f);
1266
1267   // Start the animation
1268   animation.Play();
1269
1270   bool signalReceived(false);
1271   AnimationFinishCheck finishCheck(signalReceived);
1272   animation.FinishedSignal().Connect(&application, finishCheck);
1273
1274   application.SendNotification();
1275   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1276
1277   // We didn't expect the animation to finish yet
1278   application.SendNotification();
1279   finishCheck.CheckSignalNotReceived();
1280   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1281
1282   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1283
1284   // We didn't expect the animation to finish yet
1285   application.SendNotification();
1286   finishCheck.CheckSignalNotReceived();
1287   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1288
1289   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1290
1291   // We did expect the animation to finish
1292   application.SendNotification();
1293   finishCheck.CheckSignalReceived();
1294   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1295
1296   // Check that nothing has changed after a couple of buffer swaps
1297   application.Render(0);
1298   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1299   application.Render(0);
1300   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1301
1302   END_TEST;
1303 }
1304
1305 int UtcDaliAnimationSetSpeedFactorP2(void)
1306 {
1307   TestApplication application;
1308
1309   Actor actor = Actor::New();
1310   Stage::GetCurrent().Add(actor);
1311
1312   // Build the animation
1313   float durationSeconds(1.0f);
1314   Animation animation = Animation::New(durationSeconds);
1315
1316   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1317   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1318
1319   KeyFrames keyframes = KeyFrames::New();
1320   keyframes.Add( 0.0f, initialPosition);
1321   keyframes.Add( 1.0f, targetPosition );
1322   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1323
1324   tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1325   animation.SetSpeedFactor( -1.0f );
1326
1327   // Start the animation
1328   animation.Play();
1329
1330   bool signalReceived(false);
1331   AnimationFinishCheck finishCheck(signalReceived);
1332   animation.FinishedSignal().Connect(&application, finishCheck);
1333
1334   application.SendNotification();
1335   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1336
1337   // We didn't expect the animation to finish yet
1338   application.SendNotification();
1339   finishCheck.CheckSignalNotReceived();
1340   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1341
1342   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1343
1344   // We didn't expect the animation to finish yet
1345   application.SendNotification();
1346   finishCheck.CheckSignalNotReceived();
1347   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1348
1349   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1350
1351   // We didn't expect the animation to finish yet
1352   application.SendNotification();
1353   finishCheck.CheckSignalNotReceived();
1354   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1355
1356   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1357
1358   // We didn't expect the animation to finish yet
1359   application.SendNotification();
1360   finishCheck.CheckSignalNotReceived();
1361   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1362
1363   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1364
1365   // We did expect the animation to finish
1366   application.SendNotification();
1367   finishCheck.CheckSignalReceived();
1368   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1369
1370   // Check that nothing has changed after a couple of buffer swaps
1371   application.Render(0);
1372   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1373   application.Render(0);
1374   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1375
1376   END_TEST;
1377 }
1378
1379 int UtcDaliAnimationSetSpeedFactorP3(void)
1380 {
1381   TestApplication application;
1382
1383   Actor actor = Actor::New();
1384   Stage::GetCurrent().Add(actor);
1385
1386   // Build the animation
1387   float durationSeconds(1.0f);
1388   Animation animation = Animation::New(durationSeconds);
1389
1390   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1391   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1392
1393   KeyFrames keyframes = KeyFrames::New();
1394   keyframes.Add( 0.0f, initialPosition);
1395   keyframes.Add( 1.0f, targetPosition );
1396   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1397
1398   bool signalReceived(false);
1399   AnimationFinishCheck finishCheck(signalReceived);
1400   animation.FinishedSignal().Connect(&application, finishCheck);
1401
1402   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1403
1404   //Set speed to be half of normal speed
1405   animation.SetSpeedFactor( 0.5f );
1406
1407   // Start the animation
1408   animation.Play();
1409
1410   application.SendNotification();
1411   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1412
1413   // We didn't expect the animation to finish yet
1414   application.SendNotification();
1415   finishCheck.CheckSignalNotReceived();
1416   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1417
1418   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1419
1420   // We didn't expect the animation to finish yet
1421   application.SendNotification();
1422   finishCheck.CheckSignalNotReceived();
1423   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1424
1425   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1426
1427   // We didn't expect the animation to finish yet
1428   application.SendNotification();
1429   finishCheck.CheckSignalNotReceived();
1430   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1431
1432   application.SendNotification();
1433   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1434
1435   // We didn't expect the animation to finish yet
1436   application.SendNotification();
1437   finishCheck.CheckSignalNotReceived();
1438   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1439
1440   application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1441
1442   // We did expect the animation to finish
1443   application.SendNotification();
1444   finishCheck.CheckSignalReceived();
1445   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1446
1447   // Check that nothing has changed after a couple of buffer swaps
1448   application.Render(0);
1449   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1450   application.Render(0);
1451   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1452   END_TEST;
1453 }
1454
1455
1456 int UtcDaliAnimationSetSpeedFactorP4(void)
1457 {
1458   TestApplication application;
1459
1460   Actor actor = Actor::New();
1461   Stage::GetCurrent().Add(actor);
1462
1463   // Build the animation
1464   float durationSeconds(1.0f);
1465   Animation animation = Animation::New(durationSeconds);
1466
1467   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1468   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1469
1470   KeyFrames keyframes = KeyFrames::New();
1471   keyframes.Add( 0.0f, initialPosition);
1472   keyframes.Add( 1.0f, targetPosition );
1473   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1474
1475   bool signalReceived(false);
1476   AnimationFinishCheck finishCheck(signalReceived);
1477   animation.FinishedSignal().Connect(&application, finishCheck);
1478
1479   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1480
1481   tet_printf("Set speed to be half of normal speed\n");
1482   tet_printf("SetSpeedFactor(0.5f)\n");
1483   animation.SetSpeedFactor( 0.5f );
1484
1485   // Start the animation
1486   animation.Play();
1487
1488   application.SendNotification();
1489   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1490
1491   // We didn't expect the animation to finish yet
1492   application.SendNotification();
1493   finishCheck.CheckSignalNotReceived();
1494   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1495
1496   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1497
1498   // We didn't expect the animation to finish yet
1499   application.SendNotification();
1500   finishCheck.CheckSignalNotReceived();
1501   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1502
1503   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1504
1505   // We didn't expect the animation to finish yet
1506   application.SendNotification();
1507   finishCheck.CheckSignalNotReceived();
1508   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1509
1510   tet_printf("Reverse direction of animation whilst playing\n");
1511   tet_printf("SetSpeedFactor(-0.5f)\n");
1512   animation.SetSpeedFactor(-0.5f);
1513
1514   application.SendNotification();
1515   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1516
1517   // We didn't expect the animation to finish yet
1518   application.SendNotification();
1519   finishCheck.CheckSignalNotReceived();
1520   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1521
1522   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1523
1524   // We didn't expect the animation to finish yet
1525   application.SendNotification();
1526   finishCheck.CheckSignalNotReceived();
1527   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1528
1529   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1530
1531   // We did expect the animation to finish
1532   application.SendNotification();
1533   finishCheck.CheckSignalReceived();
1534   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1535
1536   // Check that nothing has changed after a couple of buffer swaps
1537   application.Render(0);
1538   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1539   application.Render(0);
1540   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1541   END_TEST;
1542 }
1543
1544 int UtcDaliAnimationSetSpeedFactorAndRange(void)
1545 {
1546   TestApplication application;
1547
1548   const unsigned int NUM_FRAMES(15);
1549
1550   struct TestData
1551   {
1552     float startTime;
1553     float endTime;
1554     float startX;
1555     float endX;
1556     float expected[NUM_FRAMES];
1557   };
1558
1559   TestData testData[] = {
1560     // ACTOR 0
1561     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1562     /*                       |----------PlayRange---------------|                 */
1563     /*                                            | reverse                       */
1564     { 0.0f,                                                                  1.0f, // TimePeriod
1565       0.0f,                                                                100.0f, // POS
1566       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1567        /**/                 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1568        /**/                               50.0f,
1569        /**/                        40.0f,
1570        /**/                 30.0f,
1571        /**/                                             70.0f,
1572        /**/                                      60.0f,
1573        /**/                               50.0f,
1574        /**/
1575       }
1576     },
1577
1578     // ACTOR 1 - Across start of range
1579     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1580     /*                       |----------PlayRange---------------|                 */
1581     /*                                            | reverse                       */
1582     {                0.2f,                0.5f,                               // TimePeriod
1583                      20.0f,               50.0f,                // POS
1584       {/**/                 30.0f, 40.0f, 50.0f, 50.0f, 50.0f,  /* Loop */
1585        /**/                 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1586        /**/                               50.0f,
1587        /**/                        40.0f,
1588        /**/                 30.0f,
1589        /**/                                             50.0f,
1590        /**/                                      50.0f,
1591        /**/                               50.0f
1592       }
1593     },
1594
1595     // ACTOR 2 - Across end of range
1596     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1597     /*                       |----------PlayRange---------------|                 */
1598     /*                                            | reverse                       */
1599     {/**/                                  0.5f,                      0.9f,   // TimePeriod
1600      /**/                                 50.0f,                      90.0f,  // POS
1601      { /**/                 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1602        /**/                 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1603        /**/                               50.0f,
1604        /**/                        50.0f,
1605        /**/                 50.0f,                      70.0f,
1606        /**/                                      60.0f,
1607        /**/                               50.0f,
1608       }
1609     },
1610
1611     // ACTOR 3 - Before beginning of range
1612     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1613     /*                       |----------PlayRange---------------|                 */
1614     /*                                            | reverse                       */
1615     {/**/     0.1f,      0.25f, // TimePeriod
1616      /**/     10.0f,     25.0f, // POS
1617      { /**/
1618        /**/ 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
1619        /**/
1620       }
1621     },
1622
1623     // ACTOR 4 - After end of range
1624     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1625     /*                       |----------PlayRange---------------|                 */
1626     /*                                            | reverse                       */
1627     {/**/                                                           0.85f,   1.0f, // TimePeriod
1628      /**/                                                           85.0f,  100.0f, // POS
1629      { /**/
1630        /**/ 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
1631        /**/
1632      }
1633     },
1634     // Actor 5 - Middle of range
1635     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1636     /*                       |----------PlayRange---------------|                 */
1637     /*                                            | reverse                       */
1638     {/**/                          0.4f,            0.65f, // Time Period
1639      /**/                         40.0f,            65.0f, // Position
1640      { /**/                40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1641        /**/                40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1642        /**/                              50.0f,
1643        /**/                       40.0f,
1644        /**/                40.0f,
1645        /**/                                            65.0f,
1646        /**/                                      60.0f,
1647        /**/                              50.0f,
1648      }
1649     }
1650   };
1651
1652   const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1653
1654   // Build the animation
1655   float durationSeconds(1.0f);
1656   Animation animation = Animation::New(durationSeconds);
1657   bool signalReceived(false);
1658   AnimationFinishCheck finishCheck(signalReceived);
1659   animation.FinishedSignal().Connect(&application, finishCheck);
1660
1661   std::vector<Dali::Actor> actors;
1662
1663   for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1664   {
1665     Actor actor = Actor::New();
1666     actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1667     actors.push_back(actor);
1668     Stage::GetCurrent().Add(actor);
1669
1670     if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1671     {
1672       KeyFrames keyframes = KeyFrames::New();
1673       keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1674       keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1675       animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1676     }
1677     else
1678     {
1679       animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1680     }
1681   }
1682
1683   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1684   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1685   tet_printf("SetSpeedFactor(0.5f)\n");
1686   animation.SetSpeedFactor( 0.5f );
1687   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1688   animation.SetLooping(true);
1689
1690   // Start the animation
1691   animation.Play();
1692   application.SendNotification();
1693   application.Render(0);   // Frame 0 tests initial values
1694
1695   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1696   {
1697     unsigned int actorIndex = 0u;
1698     for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1699     {
1700       DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1701       if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) )
1702       {
1703         tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1704       }
1705     }
1706
1707     if( frame == 8 )
1708     {
1709       tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1710       tet_printf("SetSpeedFactor(-0.5f)\n");
1711       animation.SetSpeedFactor(-0.5f);
1712       application.SendNotification();
1713     }
1714     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1715
1716     // We didn't expect the animation to finish yet
1717     application.SendNotification();
1718     finishCheck.CheckSignalNotReceived();
1719   }
1720
1721   END_TEST;
1722 }
1723
1724 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void)
1725 {
1726   TestApplication application;
1727
1728   const unsigned int NUM_FRAMES(15);
1729
1730   struct TestData
1731   {
1732     float startTime;
1733     float endTime;
1734     float startX;
1735     float endX;
1736     float expected[NUM_FRAMES];
1737   };
1738
1739   TestData testData =
1740     // ACTOR 0
1741     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1742     /*                       |----------PlayRange---------------|                 */
1743     { 0.0f,                                                                  1.0f, // TimePeriod
1744       0.0f,                                                                100.0f, // POS
1745       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1746        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1747        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1748        /**/
1749       }
1750     };
1751
1752
1753   // Build the animation
1754   float durationSeconds(1.0f);
1755   Animation animation = Animation::New(durationSeconds);
1756   bool signalReceived(false);
1757   AnimationFinishCheck finishCheck(signalReceived);
1758   animation.FinishedSignal().Connect(&application, finishCheck);
1759
1760   std::vector<Dali::Actor> actors;
1761
1762   Actor actor = Actor::New();
1763   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1764   actors.push_back(actor);
1765   Stage::GetCurrent().Add(actor);
1766
1767   KeyFrames keyframes = KeyFrames::New();
1768   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1769   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1770   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1771
1772   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1773   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1774   tet_printf("SetSpeedFactor(0.5f)\n");
1775   tet_printf("SetLoopCount(3)\n");
1776   animation.SetSpeedFactor( 0.5f );
1777   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1778   animation.SetLoopCount(3);
1779
1780   // Start the animation
1781   animation.Play();
1782   application.SendNotification();
1783   application.Render(0);   // Frame 0 tests initial values
1784
1785   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1786   {
1787     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1788
1789     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1790
1791     if( frame < NUM_FRAMES-1 )
1792     {
1793       // We didn't expect the animation to finish yet
1794       application.SendNotification();
1795       finishCheck.CheckSignalNotReceived();
1796     }
1797   }
1798
1799   // We did expect the animation to finish
1800   application.SendNotification();
1801   finishCheck.CheckSignalReceived();
1802   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION );
1803
1804   END_TEST;
1805 }
1806
1807 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void)
1808 {
1809   TestApplication application;
1810
1811   const unsigned int NUM_FRAMES(15);
1812
1813   struct TestData
1814   {
1815     float startTime;
1816     float endTime;
1817     float startX;
1818     float endX;
1819     float expected[NUM_FRAMES];
1820   };
1821
1822   TestData testData =
1823     // ACTOR 0
1824     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1825     /*                       |----------PlayRange---------------|                 */
1826     { 0.0f,                                                                  1.0f, // TimePeriod
1827       0.0f,                                                                100.0f, // POS
1828       {/**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1829        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1830        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1831       }
1832     };
1833
1834
1835   // Build the animation
1836   float durationSeconds(1.0f);
1837   Animation animation = Animation::New(durationSeconds);
1838   bool signalReceived(false);
1839   AnimationFinishCheck finishCheck(signalReceived);
1840   animation.FinishedSignal().Connect(&application, finishCheck);
1841
1842   std::vector<Dali::Actor> actors;
1843
1844   Actor actor = Actor::New();
1845   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1846   actors.push_back(actor);
1847   Stage::GetCurrent().Add(actor);
1848
1849   KeyFrames keyframes = KeyFrames::New();
1850   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1851   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1852   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1853
1854   tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1855   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1856   tet_printf("SetSpeedFactor(-0.5f)\n");
1857   tet_printf("SetLoopCount(3)\n");
1858   animation.SetSpeedFactor( -0.5f );
1859   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1860   animation.SetLoopCount(3);
1861
1862   // Start the animation
1863   animation.Play();
1864   application.SendNotification();
1865   application.Render(0);   // Frame 0 tests initial values
1866
1867   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1868   {
1869     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1870
1871     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1872
1873     if( frame < NUM_FRAMES-1 )
1874     {
1875       // We didn't expect the animation to finish yet
1876       application.SendNotification();
1877       finishCheck.CheckSignalNotReceived();
1878     }
1879   }
1880
1881   // We did expect the animation to finish
1882   application.SendNotification();
1883   finishCheck.CheckSignalReceived();
1884   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION );
1885
1886   END_TEST;
1887 }
1888
1889
1890 int UtcDaliAnimationGetSpeedFactorP(void)
1891 {
1892   TestApplication application;
1893
1894   Animation animation = Animation::New(1.0f);
1895   animation.SetSpeedFactor(0.5f);
1896   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1897
1898   animation.SetSpeedFactor(-2.5f);
1899   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1900   END_TEST;
1901 }
1902
1903 int UtcDaliAnimationSetPlayRangeP(void)
1904 {
1905   TestApplication application;
1906
1907   Actor actor = Actor::New();
1908   Stage::GetCurrent().Add( actor );
1909
1910   // Build the animation
1911   float durationSeconds( 1.0f );
1912   Animation animation = Animation::New( durationSeconds );
1913
1914   bool signalReceived( false );
1915   AnimationFinishCheck finishCheck( signalReceived );
1916   animation.FinishedSignal().Connect( &application, finishCheck );
1917   application.SendNotification();
1918
1919   // Set range between 0.4 and 0.8
1920   animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1921   application.SendNotification();
1922   DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1923
1924   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1925   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1926
1927   // Start the animation from 40% progress
1928   animation.Play();
1929
1930   application.SendNotification();
1931   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1932
1933   // We didn't expect the animation to finish yet
1934   application.SendNotification();
1935   finishCheck.CheckSignalNotReceived();
1936   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
1937
1938   application.SendNotification();
1939   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1940
1941   application.SendNotification();
1942   finishCheck.CheckSignalNotReceived();
1943   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
1944
1945   application.SendNotification();
1946   application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1947
1948   // We did expect the animation to finish
1949   application.SendNotification();
1950   finishCheck.CheckSignalReceived();
1951   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1952   END_TEST;
1953 }
1954
1955 int UtcDaliAnimationSetPlayRangeN(void)
1956 {
1957   TestApplication application;
1958
1959   Actor actor = Actor::New();
1960   Stage::GetCurrent().Add(actor);
1961
1962   // Build the animation
1963   Animation animation = Animation::New(0);
1964   application.SendNotification();
1965
1966   //PlayRange out of bounds
1967   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1968   application.SendNotification();
1969   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1970   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1971   application.SendNotification();
1972   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1973
1974   //If playRange is not in the correct order it has to be ordered
1975   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1976   application.SendNotification();
1977   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1978
1979   END_TEST;
1980 }
1981
1982 int UtcDaliAnimationGetPlayRangeP(void)
1983 {
1984   TestApplication application;
1985
1986   Actor actor = Actor::New();
1987   Stage::GetCurrent().Add( actor );
1988
1989   // Build the animation
1990   Animation animation = Animation::New( 1.0f );
1991   application.SendNotification();
1992
1993   //If PlayRange not specified it should be 0.0-1.0 by default
1994   DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1995
1996   // Set range between 0.4 and 0.8
1997   animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1998   application.SendNotification();
1999   DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
2000
2001   END_TEST;
2002 }
2003
2004 int UtcDaliAnimationPlayP(void)
2005 {
2006   TestApplication application;
2007
2008   Actor actor = Actor::New();
2009   Stage::GetCurrent().Add(actor);
2010
2011   // Build the animation
2012   float durationSeconds(1.0f);
2013   Animation animation = Animation::New(durationSeconds);
2014   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2015   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2016
2017   // Start the animation
2018   animation.Play();
2019
2020   bool signalReceived(false);
2021   AnimationFinishCheck finishCheck(signalReceived);
2022   animation.FinishedSignal().Connect(&application, finishCheck);
2023
2024   application.SendNotification();
2025   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2026
2027   // We didn't expect the animation to finish yet
2028   application.SendNotification();
2029   finishCheck.CheckSignalNotReceived();
2030   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2031
2032   animation.Play(); // Test that calling play has no effect, when animation is already playing
2033   application.SendNotification();
2034   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2035
2036   // We didn't expect the animation to finish yet
2037   application.SendNotification();
2038   finishCheck.CheckSignalNotReceived();
2039   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2040
2041   animation.Play(); // Test that calling play has no effect, when animation is already playing
2042   application.SendNotification();
2043   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2044
2045   // We didn't expect the animation to finish yet
2046   application.SendNotification();
2047   finishCheck.CheckSignalNotReceived();
2048   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2049
2050   animation.Play(); // Test that calling play has no effect, when animation is already playing
2051   application.SendNotification();
2052   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2053
2054   // We didn't expect the animation to finish yet
2055   application.SendNotification();
2056   finishCheck.CheckSignalNotReceived();
2057   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2058
2059   animation.Play(); // Test that calling play has no effect, when animation is already playing
2060   application.SendNotification();
2061   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2062
2063   // We did expect the animation to finish
2064   application.SendNotification();
2065   finishCheck.CheckSignalReceived();
2066   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2067
2068   // Check that nothing has changed after a couple of buffer swaps
2069   application.Render(0);
2070   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2071   application.Render(0);
2072   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2073   END_TEST;
2074 }
2075
2076 int UtcDaliAnimationPlayOffStageP(void)
2077 {
2078   // Test that an animation can be played, when the actor is off-stage.
2079   // When the actor is added to the stage, it should appear at the current position
2080   // i.e. where it would have been anyway, if on-stage from the beginning.
2081
2082   TestApplication application;
2083
2084   Actor actor = Actor::New();
2085   Vector3 basePosition(Vector3::ZERO);
2086   DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
2087   // Not added to the stage!
2088
2089   // Build the animation
2090   float durationSeconds(1.0f);
2091   Animation animation = Animation::New(durationSeconds);
2092   animation.SetDisconnectAction( Animation::Discard );
2093   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2094   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2095
2096   // Start the animation
2097   animation.Play();
2098
2099   bool signalReceived(false);
2100   AnimationFinishCheck finishCheck(signalReceived);
2101   animation.FinishedSignal().Connect(&application, finishCheck);
2102
2103   application.SendNotification();
2104   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2105
2106   // We didn't expect the animation to finish yet
2107   application.SendNotification();
2108   finishCheck.CheckSignalNotReceived();
2109   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
2110
2111   // Add to the stage
2112   Stage::GetCurrent().Add(actor);
2113
2114   application.SendNotification();
2115   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2116
2117   // We didn't expect the animation to finish yet
2118   application.SendNotification();
2119   finishCheck.CheckSignalNotReceived();
2120   Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
2121   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
2122
2123   // Remove from the stage
2124   Stage::GetCurrent().Remove(actor);
2125
2126   application.SendNotification();
2127   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2128
2129   // We didn't expect the animation to finish yet
2130   application.SendNotification();
2131   finishCheck.CheckSignalNotReceived();
2132   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
2133
2134   // Add to the stage
2135   Stage::GetCurrent().Add(actor);
2136
2137   application.SendNotification();
2138   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2139
2140   // We didn't expect the animation to finish yet
2141   application.SendNotification();
2142   finishCheck.CheckSignalNotReceived();
2143   expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
2144   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
2145
2146   application.SendNotification();
2147   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2148
2149   // We did expect the animation to finish
2150   application.SendNotification();
2151   finishCheck.CheckSignalReceived();
2152   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2153
2154   // Check that nothing has changed after a couple of buffer swaps
2155   application.Render(0);
2156   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2157   application.Render(0);
2158   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2159   END_TEST;
2160 }
2161
2162 int UtcDaliAnimationPlayDiscardHandleP(void)
2163 {
2164   TestApplication application;
2165
2166   Actor actor = Actor::New();
2167   Stage::GetCurrent().Add(actor);
2168
2169   // Build the animation
2170   float durationSeconds(1.0f);
2171   Animation animation = Animation::New(durationSeconds);
2172   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2173   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2174
2175   bool signalReceived(false);
2176   AnimationFinishCheck finishCheck(signalReceived);
2177   animation.FinishedSignal().Connect(&application, finishCheck);
2178
2179   // Start the animation
2180   animation.Play();
2181
2182   // This is a test of the "Fire and Forget" behaviour
2183   // Discard the animation handle!
2184   animation.Reset();
2185   DALI_TEST_CHECK( !animation );
2186
2187   application.SendNotification();
2188   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2189
2190   // We didn't expect the animation to finish yet
2191   application.SendNotification();
2192   finishCheck.CheckSignalNotReceived();
2193   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2194
2195   application.SendNotification();
2196   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2197
2198   // We didn't expect the animation to finish yet
2199   application.SendNotification();
2200   finishCheck.CheckSignalNotReceived();
2201   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2202
2203   application.SendNotification();
2204   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2205
2206   // We didn't expect the animation to finish yet
2207   application.SendNotification();
2208   finishCheck.CheckSignalNotReceived();
2209   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2210
2211   application.SendNotification();
2212   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2213
2214   // We didn't expect the animation to finish yet
2215   application.SendNotification();
2216   finishCheck.CheckSignalNotReceived();
2217   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2218
2219   application.SendNotification();
2220   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2221
2222   // We did expect the animation to finish
2223   application.SendNotification();
2224   finishCheck.CheckSignalReceived();
2225   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2226
2227   // Check that nothing has changed after a couple of buffer swaps
2228   application.Render(0);
2229   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2230   application.Render(0);
2231   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2232   END_TEST;
2233 }
2234
2235 int UtcDaliAnimationPlayStopDiscardHandleP(void)
2236 {
2237   TestApplication application;
2238
2239   Actor actor = Actor::New();
2240   Stage::GetCurrent().Add(actor);
2241
2242   // Build the animation
2243   float durationSeconds(1.0f);
2244   Animation animation = Animation::New(durationSeconds);
2245   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2246   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2247
2248   // Start the animation
2249   animation.Play();
2250
2251   bool signalReceived(false);
2252   AnimationFinishCheck finishCheck(signalReceived);
2253   animation.FinishedSignal().Connect(&application, finishCheck);
2254
2255   application.SendNotification();
2256   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2257
2258   // We didn't expect the animation to finish yet
2259   application.SendNotification();
2260   finishCheck.CheckSignalNotReceived();
2261   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2262
2263   // This is a test of the "Fire and Forget" behaviour
2264   // Stop the animation, and Discard the animation handle!
2265   animation.Stop();
2266   animation.Reset();
2267   DALI_TEST_CHECK( !animation );
2268
2269   application.SendNotification();
2270   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2271
2272   // We expect the animation to finish at 20% progress
2273   application.SendNotification();
2274   finishCheck.CheckSignalReceived();
2275   finishCheck.Reset();
2276   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2277
2278   application.SendNotification();
2279   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2280
2281   // Check that nothing has changed
2282   application.SendNotification();
2283   finishCheck.CheckSignalNotReceived();
2284   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2285
2286   application.SendNotification();
2287   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2288
2289   // Check that nothing has changed
2290   application.SendNotification();
2291   finishCheck.CheckSignalNotReceived();
2292   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2293
2294   application.SendNotification();
2295   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2296
2297   // Check that nothing has changed
2298   application.SendNotification();
2299   finishCheck.CheckSignalNotReceived();
2300   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2301   END_TEST;
2302 }
2303
2304 int UtcDaliAnimationPlayRangeP(void)
2305 {
2306   TestApplication application;
2307
2308   Actor actor = Actor::New();
2309   Stage::GetCurrent().Add(actor);
2310
2311   // Build the animation
2312   float durationSeconds(1.0f);
2313   Animation animation = Animation::New(durationSeconds);
2314   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2315   KeyFrames keyframes = KeyFrames::New();
2316   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2317   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2318
2319   animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2320
2321   // Set range between 0.4 and 0.8
2322   animation.SetPlayRange( Vector2(0.4f,0.8f) );
2323   animation.Play();
2324
2325   bool signalReceived(false);
2326   AnimationFinishCheck finishCheck(signalReceived);
2327   animation.FinishedSignal().Connect(&application, finishCheck);
2328
2329   //Test that setting progress outside the range doesn't work
2330   animation.SetCurrentProgress( 0.9f );
2331   application.SendNotification();
2332   application.Render(0);
2333   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2334   animation.SetCurrentProgress( 0.2f );
2335   application.SendNotification();
2336   application.Render(0);
2337   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2338
2339   application.SendNotification();
2340   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2341
2342   // We didn't expect the animation to finish yet
2343   application.SendNotification();
2344   finishCheck.CheckSignalNotReceived();
2345   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2346
2347   animation.Play(); // Test that calling play has no effect, when animation is already playing
2348   application.SendNotification();
2349   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2350
2351   // We did expect the animation to finish
2352   application.SendNotification();
2353   finishCheck.CheckSignalReceived();
2354   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2355
2356   // Check that nothing has changed after a couple of buffer swaps
2357   application.Render(0);
2358   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2359   application.Render(0);
2360   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2361
2362
2363   //Loop inside the range
2364   finishCheck.Reset();
2365   animation.SetLooping( true );
2366   animation.Play();
2367   application.SendNotification();
2368   float intervalSeconds = 0.1f;
2369   float progress = 0.4f;
2370   for (int iterations = 0; iterations < 10; ++iterations )
2371   {
2372     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2373
2374     progress += intervalSeconds;
2375     if (progress > 0.8f)
2376     {
2377       progress = progress - 0.4f;
2378     }
2379
2380     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2381   }
2382
2383   // We didn't expect the animation to finish yet
2384   application.SendNotification();
2385   finishCheck.CheckSignalNotReceived();
2386
2387
2388   //Test change range on the fly
2389   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2390   application.SendNotification();
2391
2392   for (int iterations = 0; iterations < 10; ++iterations )
2393   {
2394     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2395
2396     progress += intervalSeconds;
2397     if (progress > 0.9f)
2398     {
2399       progress = progress - 0.7f;
2400     }
2401
2402     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2403   }
2404
2405   END_TEST;
2406 }
2407
2408 int UtcDaliAnimationPlayFromP(void)
2409 {
2410   TestApplication application;
2411
2412   Actor actor = Actor::New();
2413   Stage::GetCurrent().Add(actor);
2414
2415   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2416
2417   // Build the animation
2418   float durationSeconds(1.0f);
2419   Animation animation = Animation::New(durationSeconds);
2420   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2421   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2422
2423   // Start the animation from 40% progress
2424   animation.PlayFrom( 0.4f );
2425
2426   // Target value should be updated straight away
2427   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2428
2429   bool signalReceived(false);
2430   AnimationFinishCheck finishCheck(signalReceived);
2431   animation.FinishedSignal().Connect(&application, finishCheck);
2432
2433   application.SendNotification();
2434   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2435
2436   // We didn't expect the animation to finish yet
2437   application.SendNotification();
2438   finishCheck.CheckSignalNotReceived();
2439   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2440
2441   animation.Play(); // Test that calling play has no effect, when animation is already playing
2442   application.SendNotification();
2443   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2444
2445   // We didn't expect the animation to finish yet
2446   application.SendNotification();
2447   finishCheck.CheckSignalNotReceived();
2448   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2449
2450   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2451   // We did expect the animation to finish
2452   application.SendNotification();
2453   finishCheck.CheckSignalReceived();
2454   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2455
2456   // Check that nothing has changed after a couple of buffer swaps
2457   application.Render(0);
2458   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2459   application.Render(0);
2460   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2461   END_TEST;
2462 }
2463
2464 int UtcDaliAnimationPlayFromN(void)
2465 {
2466   TestApplication application;
2467
2468   Actor actor = Actor::New();
2469   Stage::GetCurrent().Add(actor);
2470
2471   // Build the animation
2472   float durationSeconds(1.0f);
2473   Animation animation = Animation::New(durationSeconds);
2474   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2475   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2476
2477   //PlayFrom with an argument outside the range [0..1] will be ignored
2478   animation.PlayFrom(-1.0f);
2479   application.SendNotification();
2480   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2481
2482   animation.PlayFrom(100.0f);
2483   application.SendNotification();
2484   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2485   END_TEST;
2486 }
2487
2488 int UtcDaliAnimationPauseP(void)
2489 {
2490   TestApplication application;
2491
2492   Actor actor = Actor::New();
2493   Stage::GetCurrent().Add(actor);
2494
2495   // Build the animation
2496   float durationSeconds(1.0f);
2497   Animation animation = Animation::New(durationSeconds);
2498   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2499   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2500
2501   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2502
2503   // Start the animation
2504   animation.Play();
2505
2506   bool signalReceived(false);
2507   AnimationFinishCheck finishCheck(signalReceived);
2508   animation.FinishedSignal().Connect(&application, finishCheck);
2509
2510   application.SendNotification();
2511   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2512
2513   // We didn't expect the animation to finish yet
2514   application.SendNotification();
2515   finishCheck.CheckSignalNotReceived();
2516   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2517
2518   // Pause the animation
2519   animation.Pause();
2520   application.SendNotification();
2521
2522   // Loop 5 times
2523   for (int i=0; i<5; ++i)
2524   {
2525     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2526
2527     // We didn't expect the animation to finish yet
2528     application.SendNotification();
2529     finishCheck.CheckSignalNotReceived();
2530     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2531   }
2532
2533   // Keep going
2534   animation.Play();
2535   application.SendNotification();
2536   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2537
2538   // We didn't expect the animation to finish yet
2539   application.SendNotification();
2540   finishCheck.CheckSignalNotReceived();
2541
2542   application.SendNotification();
2543   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2544
2545   // We did expect the animation to finish
2546   application.SendNotification();
2547   finishCheck.CheckSignalReceived();
2548   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2549
2550   // Check that nothing has changed after a couple of buffer swaps
2551   application.Render(0);
2552   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2553   application.Render(0);
2554   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2555   END_TEST;
2556 }
2557
2558
2559 int UtcDaliAnimationGetStateP(void)
2560 {
2561   TestApplication application;
2562
2563   Actor actor = Actor::New();
2564   Stage::GetCurrent().Add(actor);
2565
2566   // Build the animation
2567   float durationSeconds(1.0f);
2568   Animation animation = Animation::New(durationSeconds);
2569   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2570   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2571   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2572
2573   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2574
2575   // Start the animation
2576   animation.Play();
2577
2578   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2579
2580   bool signalReceived(false);
2581   AnimationFinishCheck finishCheck(signalReceived);
2582   animation.FinishedSignal().Connect(&application, finishCheck);
2583
2584   application.SendNotification();
2585   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2586
2587   // We didn't expect the animation to finish yet
2588   application.SendNotification();
2589   finishCheck.CheckSignalNotReceived();
2590   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2591   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2592
2593   // Pause the animation
2594   animation.Pause();
2595   DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2596   application.SendNotification();
2597   application.Render(0.f);
2598
2599   // Loop 5 times
2600   for (int i=0; i<5; ++i)
2601   {
2602     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2603
2604     // We didn't expect the animation to finish yet
2605     application.SendNotification();
2606     finishCheck.CheckSignalNotReceived();
2607     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2608     DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2609   }
2610
2611   // Keep going
2612   finishCheck.Reset();
2613   animation.Play();
2614   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2615   application.SendNotification();
2616   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2617   // We didn't expect the animation to finish yet
2618   application.SendNotification();
2619   finishCheck.CheckSignalNotReceived();
2620   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2621
2622   application.SendNotification();
2623   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2624
2625   // We did expect the animation to finish
2626   application.SendNotification();
2627   finishCheck.CheckSignalReceived();
2628   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2629   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2630
2631   // Check that nothing has changed after a couple of buffer swaps
2632   application.Render(0);
2633   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2634   application.Render(0);
2635   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2636   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2637
2638   // re-play
2639   finishCheck.Reset();
2640   animation.Play();
2641   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2642   application.SendNotification();
2643   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2644   application.SendNotification();
2645   finishCheck.CheckSignalNotReceived();
2646   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2647
2648
2649   END_TEST;
2650 }
2651
2652 int UtcDaliAnimationStopP(void)
2653 {
2654   TestApplication application;
2655
2656   Actor actor = Actor::New();
2657   Stage::GetCurrent().Add(actor);
2658
2659   // Build the animation
2660   float durationSeconds(1.0f);
2661   Animation animation = Animation::New(durationSeconds);
2662   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2663   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2664
2665   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2666
2667   // Start the animation
2668   animation.Play();
2669
2670   bool signalReceived(false);
2671   AnimationFinishCheck finishCheck(signalReceived);
2672   animation.FinishedSignal().Connect(&application, finishCheck);
2673
2674   application.SendNotification();
2675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2676
2677   // We didn't expect the animation to finish yet
2678   application.SendNotification();
2679   finishCheck.CheckSignalNotReceived();
2680   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2681
2682   // Stop the animation
2683   animation.Stop();
2684   application.SendNotification();
2685
2686   // Loop 5 times
2687   for (int i=0; i<5; ++i)
2688   {
2689     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2690
2691     // We did expect the animation to finish
2692     application.SendNotification();
2693     finishCheck.CheckSignalReceived();
2694     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2695   }
2696   END_TEST;
2697 }
2698
2699 int UtcDaliAnimationStopSetPositionP(void)
2700 {
2701   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2702   // i.e. to check that the animation does not interfere with the position set.
2703
2704   TestApplication application;
2705
2706   Actor actor = Actor::New();
2707   Stage::GetCurrent().Add(actor);
2708
2709   // Build the animation
2710   float durationSeconds(1.0f);
2711   Animation animation = Animation::New(durationSeconds);
2712   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2713   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2714
2715   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2716
2717   // Start the animation
2718   animation.Play();
2719
2720   bool signalReceived(false);
2721   AnimationFinishCheck finishCheck(signalReceived);
2722   animation.FinishedSignal().Connect(&application, finishCheck);
2723
2724   application.SendNotification();
2725   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2726
2727   // We didn't expect the animation to finish yet
2728   application.SendNotification();
2729   finishCheck.CheckSignalNotReceived();
2730   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2731
2732   // Stop the animation
2733   animation.Stop();
2734   Vector3 positionSet(2.0f, 3.0f, 4.0f);
2735   actor.SetPosition(positionSet);
2736   application.SendNotification();
2737
2738   // Loop 5 times
2739   for (int i=0; i<5; ++i)
2740   {
2741     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2742
2743     // We did expect the animation to finish
2744     application.SendNotification();
2745     finishCheck.CheckSignalReceived();
2746     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2747   }
2748   END_TEST;
2749 }
2750
2751 int UtcDaliAnimationClearP(void)
2752 {
2753   TestApplication application;
2754
2755   Actor actor = Actor::New();
2756   Stage::GetCurrent().Add(actor);
2757
2758   // Build the animation
2759   float durationSeconds(1.0f);
2760   Animation animation = Animation::New(durationSeconds);
2761   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2762   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2763
2764   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2765
2766   // Start the animation
2767   animation.Play();
2768
2769   bool signalReceived(false);
2770   AnimationFinishCheck finishCheck(signalReceived);
2771   animation.FinishedSignal().Connect(&application, finishCheck);
2772
2773   application.SendNotification();
2774   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2775
2776   // We didn't expect the animation to finish yet
2777   application.SendNotification();
2778   finishCheck.CheckSignalNotReceived();
2779   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2780
2781   // Clear the animation
2782   animation.Clear();
2783   application.SendNotification();
2784
2785   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2786
2787   // We don't expect the animation to finish now
2788   application.SendNotification();
2789   finishCheck.CheckSignalNotReceived();
2790   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2791
2792   // Restart as a scale animation; this should not move the actor's position
2793   finishCheck.Reset();
2794   actor.SetPosition(Vector3::ZERO);
2795   Vector3 targetScale(3.0f, 3.0f, 3.0f);
2796   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2797   animation.Play();
2798
2799   application.SendNotification();
2800   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2801
2802   // We didn't expect the animation to finish yet
2803   application.SendNotification();
2804   finishCheck.CheckSignalNotReceived();
2805   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2806   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2807
2808   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2809
2810   // We did expect the animation to finish
2811   application.SendNotification();
2812   finishCheck.CheckSignalReceived();
2813   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2814   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2815   END_TEST;
2816 }
2817
2818 int UtcDaliAnimationFinishedSignalP(void)
2819 {
2820   TestApplication application;
2821
2822   // Start the empty animation
2823   float durationSeconds(1.0f);
2824   Animation animation = Animation::New(durationSeconds);
2825   animation.Play();
2826
2827   bool signalReceived(false);
2828   AnimationFinishCheck finishCheck(signalReceived);
2829   animation.FinishedSignal().Connect(&application, finishCheck);
2830
2831   application.SendNotification();
2832   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2833
2834   // We did expect the animation to finish
2835   application.SendNotification();
2836   finishCheck.CheckSignalReceived();
2837   END_TEST;
2838 }
2839
2840 int UtcDaliAnimationAnimateByBooleanP(void)
2841 {
2842   TestApplication application;
2843
2844   Actor actor = Actor::New();
2845
2846   // Register a boolean property
2847   bool startValue(false);
2848   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2849   Stage::GetCurrent().Add(actor);
2850   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2851   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2852
2853   // Build the animation
2854   float durationSeconds(2.0f);
2855   Animation animation = Animation::New(durationSeconds);
2856   const bool relativeValue(true);
2857   const bool finalValue( false || relativeValue );
2858   animation.AnimateBy(Property(actor, index), relativeValue);
2859
2860   // Start the animation
2861   animation.Play();
2862
2863   // Target value should be retrievable straight away
2864   DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
2865
2866   bool signalReceived(false);
2867   AnimationFinishCheck finishCheck(signalReceived);
2868   animation.FinishedSignal().Connect(&application, finishCheck);
2869
2870   application.SendNotification();
2871   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2872
2873   // We didn't expect the animation to finish yet
2874   application.SendNotification();
2875   finishCheck.CheckSignalNotReceived();
2876   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2877
2878   application.SendNotification();
2879   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2880
2881   // We did expect the animation to finish
2882   application.SendNotification();
2883   finishCheck.CheckSignalReceived();
2884   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2885
2886   // Check that nothing has changed after a couple of buffer swaps
2887   application.Render(0);
2888   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2889   application.Render(0);
2890   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2891
2892   // Repeat with relative value "false" - this should be an NOOP
2893   animation = Animation::New(durationSeconds);
2894   bool noOpValue(false);
2895   animation.AnimateBy(Property(actor, index), noOpValue);
2896
2897   // Start the animation
2898   animation.Play();
2899
2900   finishCheck.Reset();
2901   animation.FinishedSignal().Connect(&application, finishCheck);
2902
2903   application.SendNotification();
2904   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2905
2906   // We didn't expect the animation to finish yet
2907   application.SendNotification();
2908   finishCheck.CheckSignalNotReceived();
2909   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2910
2911   application.SendNotification();
2912   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2913
2914   // We did expect the animation to finish
2915   application.SendNotification();
2916   finishCheck.CheckSignalReceived();
2917   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2918
2919   // Check that nothing has changed after a couple of buffer swaps
2920   application.Render(0);
2921   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2922   application.Render(0);
2923   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2924   END_TEST;
2925 }
2926
2927 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
2928 {
2929   TestApplication application;
2930
2931   Actor actor = Actor::New();
2932
2933   // Register a boolean property
2934   bool startValue(false);
2935   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2936   Stage::GetCurrent().Add(actor);
2937   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2938   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2939
2940   // Build the animation
2941   float durationSeconds(2.0f);
2942   Animation animation = Animation::New(durationSeconds);
2943   bool relativeValue(true);
2944   bool finalValue( false || relativeValue );
2945   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2946
2947   // Start the animation
2948   animation.Play();
2949
2950   bool signalReceived(false);
2951   AnimationFinishCheck finishCheck(signalReceived);
2952   animation.FinishedSignal().Connect(&application, finishCheck);
2953
2954   application.SendNotification();
2955   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2956
2957   // We didn't expect the animation to finish yet
2958   application.SendNotification();
2959   finishCheck.CheckSignalNotReceived();
2960   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2961
2962   application.SendNotification();
2963   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2964
2965   // We did expect the animation to finish
2966   application.SendNotification();
2967   finishCheck.CheckSignalReceived();
2968   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2969
2970   // Check that nothing has changed after a couple of buffer swaps
2971   application.Render(0);
2972   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2973   application.Render(0);
2974   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2975
2976   // Repeat with relative value "false" - this should be an NOOP
2977   animation = Animation::New(durationSeconds);
2978   bool noOpValue(false);
2979   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2980
2981   // Start the animation
2982   animation.Play();
2983
2984   finishCheck.Reset();
2985   animation.FinishedSignal().Connect(&application, finishCheck);
2986
2987   application.SendNotification();
2988   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2989
2990   // We didn't expect the animation to finish yet
2991   application.SendNotification();
2992   finishCheck.CheckSignalNotReceived();
2993   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2994
2995   application.SendNotification();
2996   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2997
2998   // We did expect the animation to finish
2999   application.SendNotification();
3000   finishCheck.CheckSignalReceived();
3001   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3002   END_TEST;
3003 }
3004
3005 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
3006 {
3007   TestApplication application;
3008
3009   Actor actor = Actor::New();
3010
3011   // Register a boolean property
3012   bool startValue(false);
3013   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3014   Stage::GetCurrent().Add(actor);
3015   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3016   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3017
3018   // Build the animation
3019   float durationSeconds(2.0f);
3020   Animation animation = Animation::New(durationSeconds);
3021   bool relativeValue(true);
3022   bool finalValue( false || relativeValue );
3023   float animatorDurationSeconds(durationSeconds * 0.5f);
3024   animation.AnimateBy( Property(actor, index),
3025                        relativeValue,
3026                        TimePeriod( animatorDurationSeconds ) );
3027
3028   // Start the animation
3029   animation.Play();
3030
3031   bool signalReceived(false);
3032   AnimationFinishCheck finishCheck(signalReceived);
3033   animation.FinishedSignal().Connect(&application, finishCheck);
3034
3035   application.SendNotification();
3036   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3037
3038   // We didn't expect the animation to finish yet
3039   application.SendNotification();
3040   finishCheck.CheckSignalNotReceived();
3041   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3042
3043   application.SendNotification();
3044   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3045
3046   // We didn't expect the animation to finish yet...
3047   application.SendNotification();
3048   finishCheck.CheckSignalNotReceived();
3049
3050   // ...however we should have reached the final value
3051   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3052
3053   application.SendNotification();
3054   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3055
3056   // We did expect the animation to finish
3057   application.SendNotification();
3058   finishCheck.CheckSignalReceived();
3059   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3060
3061   // Check that nothing has changed after a couple of buffer swaps
3062   application.Render(0);
3063   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3064   application.Render(0);
3065   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3066   END_TEST;
3067 }
3068
3069 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3070 {
3071   TestApplication application;
3072
3073   Actor actor = Actor::New();
3074
3075   // Register a boolean property
3076   bool startValue(false);
3077   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3078   Stage::GetCurrent().Add(actor);
3079   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3080   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3081
3082   // Build the animation
3083   float durationSeconds(2.0f);
3084   Animation animation = Animation::New(durationSeconds);
3085   bool relativeValue(true);
3086   bool finalValue( false || relativeValue );
3087   float animatorDurationSeconds(durationSeconds * 0.5f);
3088   animation.AnimateBy( Property(actor, index),
3089                        relativeValue,
3090                        AlphaFunction::EASE_IN_OUT,
3091                        TimePeriod( animatorDurationSeconds ) );
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>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3102
3103   // We didn't expect the animation to finish yet
3104   application.SendNotification();
3105   finishCheck.CheckSignalNotReceived();
3106   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3107
3108   application.SendNotification();
3109   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3110
3111   // We didn't expect the animation to finish yet...
3112   application.SendNotification();
3113   finishCheck.CheckSignalNotReceived();
3114
3115   // ...however we should have reached the final value
3116   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3117
3118   application.SendNotification();
3119   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3120
3121   // We did expect the animation to finish
3122   application.SendNotification();
3123   finishCheck.CheckSignalReceived();
3124   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3125
3126   // Check that nothing has changed after a couple of buffer swaps
3127   application.Render(0);
3128   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3129   application.Render(0);
3130   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3131   END_TEST;
3132 }
3133
3134 int UtcDaliAnimationAnimateByFloatP(void)
3135 {
3136   TestApplication application;
3137
3138   Actor actor = Actor::New();
3139
3140   // Register a float property
3141   float startValue(10.0f);
3142   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3143   Stage::GetCurrent().Add(actor);
3144   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3145   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3146
3147   // Build the animation
3148   float durationSeconds(2.0f);
3149   Animation animation = Animation::New(durationSeconds);
3150   float targetValue(50.0f);
3151   float relativeValue(targetValue - startValue);
3152   animation.AnimateBy(Property(actor, index), relativeValue);
3153
3154   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3155
3156   // Start the animation
3157   animation.Play();
3158
3159   // Target value should be retrievable straight away
3160   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
3161
3162   bool signalReceived(false);
3163   AnimationFinishCheck finishCheck(signalReceived);
3164   animation.FinishedSignal().Connect(&application, finishCheck);
3165
3166   application.SendNotification();
3167   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3168
3169   // We didn't expect the animation to finish yet
3170   application.SendNotification();
3171   finishCheck.CheckSignalNotReceived();
3172   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3173
3174   application.SendNotification();
3175   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3176
3177   // We did expect the animation to finish
3178   application.SendNotification();
3179   finishCheck.CheckSignalReceived();
3180   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3181
3182   // Check that nothing has changed after a couple of buffer swaps
3183   application.Render(0);
3184   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3185   application.Render(0);
3186   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3187   END_TEST;
3188 }
3189
3190 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3191 {
3192   TestApplication application;
3193
3194   Actor actor = Actor::New();
3195
3196   // Register a float property
3197   float startValue(10.0f);
3198   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3199   Stage::GetCurrent().Add(actor);
3200   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3201   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3202
3203   // Build the animation
3204   float durationSeconds(1.0f);
3205   Animation animation = Animation::New(durationSeconds);
3206   float targetValue(90.0f);
3207   float relativeValue(targetValue - startValue);
3208   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3209
3210   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3211
3212   // Start the animation
3213   animation.Play();
3214
3215   bool signalReceived(false);
3216   AnimationFinishCheck finishCheck(signalReceived);
3217   animation.FinishedSignal().Connect(&application, finishCheck);
3218
3219   application.SendNotification();
3220   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3221
3222   // We didn't expect the animation to finish yet
3223   application.SendNotification();
3224   finishCheck.CheckSignalNotReceived();
3225
3226   // The position should have moved more, than with a linear alpha function
3227   float current( actor.GetCurrentProperty< float >( index ) );
3228   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3229
3230   application.SendNotification();
3231   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3232
3233   // We did expect the animation to finish
3234   application.SendNotification();
3235   finishCheck.CheckSignalReceived();
3236   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3237
3238   // Check that nothing has changed after a couple of buffer swaps
3239   application.Render(0);
3240   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3241   application.Render(0);
3242   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3243   END_TEST;
3244 }
3245
3246 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3247 {
3248   TestApplication application;
3249
3250   Actor actor = Actor::New();
3251
3252   // Register a float property
3253   float startValue(10.0f);
3254   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3255   Stage::GetCurrent().Add(actor);
3256   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3257   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3258
3259   // Build the animation
3260   float durationSeconds(1.0f);
3261   Animation animation = Animation::New(durationSeconds);
3262   float targetValue(30.0f);
3263   float relativeValue(targetValue - startValue);
3264   float delay = 0.5f;
3265   animation.AnimateBy(Property(actor, index),
3266                       relativeValue,
3267                       TimePeriod(delay, durationSeconds - delay));
3268
3269   // Start the animation
3270   animation.Play();
3271
3272   bool signalReceived(false);
3273   AnimationFinishCheck finishCheck(signalReceived);
3274   animation.FinishedSignal().Connect(&application, finishCheck);
3275
3276   application.SendNotification();
3277   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3278
3279   // We didn't expect the animation to finish yet
3280   application.SendNotification();
3281   finishCheck.CheckSignalNotReceived();
3282   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3283
3284   application.SendNotification();
3285   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3286
3287   // We didn't expect the animation to finish yet
3288   application.SendNotification();
3289   finishCheck.CheckSignalNotReceived();
3290   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3291
3292   application.SendNotification();
3293   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3294
3295   // We did expect the animation to finish
3296   application.SendNotification();
3297   finishCheck.CheckSignalReceived();
3298   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3299
3300   // Check that nothing has changed after a couple of buffer swaps
3301   application.Render(0);
3302   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3303   application.Render(0);
3304   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3305   END_TEST;
3306 }
3307
3308 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3309 {
3310   TestApplication application;
3311
3312   Actor actor = Actor::New();
3313
3314   // Register a float property
3315   float startValue(10.0f);
3316   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3317   Stage::GetCurrent().Add(actor);
3318   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3319   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3320
3321   // Build the animation
3322   float durationSeconds(1.0f);
3323   Animation animation = Animation::New(durationSeconds);
3324   float targetValue(30.0f);
3325   float relativeValue(targetValue - startValue);
3326   float delay = 0.5f;
3327   animation.AnimateBy(Property(actor, index),
3328                       relativeValue,
3329                       AlphaFunction::LINEAR,
3330                       TimePeriod(delay, durationSeconds - delay));
3331
3332   // Start the animation
3333   animation.Play();
3334
3335   bool signalReceived(false);
3336   AnimationFinishCheck finishCheck(signalReceived);
3337   animation.FinishedSignal().Connect(&application, finishCheck);
3338
3339   application.SendNotification();
3340   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3341
3342   // We didn't expect the animation to finish yet
3343   application.SendNotification();
3344   finishCheck.CheckSignalNotReceived();
3345   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3346
3347   application.SendNotification();
3348   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3349
3350   // We didn't expect the animation to finish yet
3351   application.SendNotification();
3352   finishCheck.CheckSignalNotReceived();
3353   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3354
3355   application.SendNotification();
3356   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3357
3358   // We did expect the animation to finish
3359   application.SendNotification();
3360   finishCheck.CheckSignalReceived();
3361   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3362
3363   // Check that nothing has changed after a couple of buffer swaps
3364   application.Render(0);
3365   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3366   application.Render(0);
3367   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3368   END_TEST;
3369 }
3370
3371 int UtcDaliAnimationAnimateByIntegerP(void)
3372 {
3373   TestApplication application;
3374
3375   Actor actor = Actor::New();
3376
3377   // Register an integer property
3378   int startValue(1);
3379   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3380   Stage::GetCurrent().Add(actor);
3381   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3382   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3383
3384   // Build the animation
3385   float durationSeconds(2.0f);
3386   Animation animation = Animation::New(durationSeconds);
3387   int targetValue(50);
3388   int relativeValue(targetValue - startValue);
3389   animation.AnimateBy(Property(actor, index), relativeValue);
3390
3391   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3392
3393   // Start the animation
3394   animation.Play();
3395
3396   // Target value should be retrievable straight away
3397   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
3398
3399   bool signalReceived(false);
3400   AnimationFinishCheck finishCheck(signalReceived);
3401   animation.FinishedSignal().Connect(&application, finishCheck);
3402
3403   application.SendNotification();
3404   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3405
3406   // We didn't expect the animation to finish yet
3407   application.SendNotification();
3408   finishCheck.CheckSignalNotReceived();
3409   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3410
3411   application.SendNotification();
3412   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3413
3414   // We did expect the animation to finish
3415   application.SendNotification();
3416   finishCheck.CheckSignalReceived();
3417   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3418
3419   // Check that nothing has changed after a couple of buffer swaps
3420   application.Render(0);
3421   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3422   application.Render(0);
3423   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3424   END_TEST;
3425 }
3426
3427 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3428 {
3429   TestApplication application;
3430
3431   Actor actor = Actor::New();
3432
3433   // Register an integer property
3434   int startValue(1);
3435   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3436   Stage::GetCurrent().Add(actor);
3437   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3438   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3439
3440   // Build the animation
3441   float durationSeconds(1.0f);
3442   Animation animation = Animation::New(durationSeconds);
3443   int targetValue(90);
3444   int relativeValue(targetValue - startValue);
3445   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3446
3447   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3448
3449   // Start the animation
3450   animation.Play();
3451
3452   bool signalReceived(false);
3453   AnimationFinishCheck finishCheck(signalReceived);
3454   animation.FinishedSignal().Connect(&application, finishCheck);
3455
3456   application.SendNotification();
3457   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3458
3459   // We didn't expect the animation to finish yet
3460   application.SendNotification();
3461   finishCheck.CheckSignalNotReceived();
3462
3463   // The position should have moved more, than with a linear alpha function
3464   int current( actor.GetCurrentProperty< int >( index ) );
3465   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3466
3467   application.SendNotification();
3468   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3469
3470   // We did expect the animation to finish
3471   application.SendNotification();
3472   finishCheck.CheckSignalReceived();
3473   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3474
3475   // Check that nothing has changed after a couple of buffer swaps
3476   application.Render(0);
3477   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3478   application.Render(0);
3479   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3480   END_TEST;
3481 }
3482
3483 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3484 {
3485   TestApplication application;
3486
3487   Actor actor = Actor::New();
3488
3489   // Register an integer property
3490   int startValue(10);
3491   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3492   Stage::GetCurrent().Add(actor);
3493   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3494   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3495
3496   // Build the animation
3497   float durationSeconds(1.0f);
3498   Animation animation = Animation::New(durationSeconds);
3499   int targetValue(30);
3500   int relativeValue(targetValue - startValue);
3501   float delay = 0.5f;
3502   animation.AnimateBy(Property(actor, index),
3503                       relativeValue,
3504                       TimePeriod(delay, durationSeconds - delay));
3505
3506   // Start the animation
3507   animation.Play();
3508
3509   bool signalReceived(false);
3510   AnimationFinishCheck finishCheck(signalReceived);
3511   animation.FinishedSignal().Connect(&application, finishCheck);
3512
3513   application.SendNotification();
3514   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3515
3516   // We didn't expect the animation to finish yet
3517   application.SendNotification();
3518   finishCheck.CheckSignalNotReceived();
3519   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3520
3521   application.SendNotification();
3522   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3523
3524   // We didn't expect the animation to finish yet
3525   application.SendNotification();
3526   finishCheck.CheckSignalNotReceived();
3527   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3528
3529   application.SendNotification();
3530   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3531
3532   // We did expect the animation to finish
3533   application.SendNotification();
3534   finishCheck.CheckSignalReceived();
3535   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3536
3537   // Check that nothing has changed after a couple of buffer swaps
3538   application.Render(0);
3539   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3540   application.Render(0);
3541   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3542   END_TEST;
3543 }
3544
3545 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3546 {
3547   TestApplication application;
3548
3549   Actor actor = Actor::New();
3550
3551   // Register an integer property
3552   int startValue(10);
3553   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3554   Stage::GetCurrent().Add(actor);
3555   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3556   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3557
3558   // Build the animation
3559   float durationSeconds(1.0f);
3560   Animation animation = Animation::New(durationSeconds);
3561   int targetValue(30);
3562   int relativeValue(targetValue - startValue);
3563   float delay = 0.5f;
3564   animation.AnimateBy(Property(actor, index),
3565                       relativeValue,
3566                       AlphaFunction::LINEAR,
3567                       TimePeriod(delay, durationSeconds - delay));
3568
3569   // Start the animation
3570   animation.Play();
3571
3572   bool signalReceived(false);
3573   AnimationFinishCheck finishCheck(signalReceived);
3574   animation.FinishedSignal().Connect(&application, finishCheck);
3575
3576   application.SendNotification();
3577   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3578
3579   // We didn't expect the animation to finish yet
3580   application.SendNotification();
3581   finishCheck.CheckSignalNotReceived();
3582   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3583
3584   application.SendNotification();
3585   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3586
3587   // We didn't expect the animation to finish yet
3588   application.SendNotification();
3589   finishCheck.CheckSignalNotReceived();
3590   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3591
3592   application.SendNotification();
3593   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3594
3595   // We did expect the animation to finish
3596   application.SendNotification();
3597   finishCheck.CheckSignalReceived();
3598   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3599
3600   // Check that nothing has changed after a couple of buffer swaps
3601   application.Render(0);
3602   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3603   application.Render(0);
3604   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3605   END_TEST;
3606 }
3607
3608 int UtcDaliAnimationAnimateByQuaternionP(void)
3609 {
3610   TestApplication application;
3611
3612   Actor actor = Actor::New();
3613
3614   // Register a quaternion property
3615   const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
3616   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3617   Stage::GetCurrent().Add(actor);
3618   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3619   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3620
3621   // Build the animation
3622   float durationSeconds(2.0f);
3623   Animation animation = Animation::New(durationSeconds);
3624   const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
3625   const Quaternion finalValue( startValue * relativeValue );
3626   animation.AnimateBy(Property(actor, index), relativeValue);
3627
3628   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3629   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3630
3631   // Start the animation
3632   animation.Play();
3633
3634   // Target value should be retrievable straight away
3635   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3636
3637   application.SendNotification();
3638   application.Render( 2000 ); // animation complete
3639
3640   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3641   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
3642
3643   END_TEST;
3644 }
3645
3646 int UtcDaliAnimationAnimateByVector2P(void)
3647 {
3648   TestApplication application;
3649
3650   Actor actor = Actor::New();
3651
3652   // Register a Vector2 property
3653   Vector2 startValue(10.0f, 10.0f);
3654   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3655   Stage::GetCurrent().Add(actor);
3656   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3657   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3658
3659   // Build the animation
3660   float durationSeconds(2.0f);
3661   Animation animation = Animation::New(durationSeconds);
3662   Vector2 targetValue(60.0f, 60.0f);
3663   Vector2 relativeValue(targetValue - startValue);
3664   animation.AnimateBy(Property(actor, index), relativeValue);
3665
3666   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3667
3668   // Start the animation
3669   animation.Play();
3670
3671   // Target value should be retrievable straight away
3672   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3673
3674   bool signalReceived(false);
3675   AnimationFinishCheck finishCheck(signalReceived);
3676   animation.FinishedSignal().Connect(&application, finishCheck);
3677
3678   application.SendNotification();
3679   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3680
3681   // We didn't expect the animation to finish yet
3682   application.SendNotification();
3683   finishCheck.CheckSignalNotReceived();
3684   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3685
3686   application.SendNotification();
3687   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3688
3689   // We did expect the animation to finish
3690   application.SendNotification();
3691   finishCheck.CheckSignalReceived();
3692   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3693
3694   // Check that nothing has changed after a couple of buffer swaps
3695   application.Render(0);
3696   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3697   application.Render(0);
3698   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3699   END_TEST;
3700 }
3701
3702 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3703 {
3704   TestApplication application;
3705
3706   Actor actor = Actor::New();
3707
3708   // Register a Vector2 property
3709   Vector2 startValue(100.0f, 100.0f);
3710   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3711   Stage::GetCurrent().Add(actor);
3712   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3713   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3714
3715   // Build the animation
3716   float durationSeconds(1.0f);
3717   Animation animation = Animation::New(durationSeconds);
3718   Vector2 targetValue(20.0f, 20.0f);
3719   Vector2 relativeValue(targetValue - startValue);
3720   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3721
3722   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
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*950.0f)/* 95% progress */);
3733
3734   // We didn't expect the animation to finish yet
3735   application.SendNotification();
3736   finishCheck.CheckSignalNotReceived();
3737
3738   // The position should have moved more, than with a linear alpha function
3739   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3740   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3741   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3742
3743   application.SendNotification();
3744   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3745
3746   // We did expect the animation to finish
3747   application.SendNotification();
3748   finishCheck.CheckSignalReceived();
3749   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3750
3751   // Check that nothing has changed after a couple of buffer swaps
3752   application.Render(0);
3753   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3754   application.Render(0);
3755   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3756   END_TEST;
3757 }
3758
3759 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3760 {
3761   TestApplication application;
3762
3763   Actor actor = Actor::New();
3764
3765   // Register a Vector2 property
3766   Vector2 startValue(10.0f, 10.0f);
3767   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3768   Stage::GetCurrent().Add(actor);
3769   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3770   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3771
3772   // Build the animation
3773   float durationSeconds(1.0f);
3774   Animation animation = Animation::New(durationSeconds);
3775   Vector2 targetValue(30.0f, 30.0f);
3776   Vector2 relativeValue(targetValue - startValue);
3777   float delay = 0.5f;
3778   animation.AnimateBy(Property(actor, index),
3779                       relativeValue,
3780                       TimePeriod(delay, durationSeconds - delay));
3781
3782   // Start the animation
3783   animation.Play();
3784
3785   bool signalReceived(false);
3786   AnimationFinishCheck finishCheck(signalReceived);
3787   animation.FinishedSignal().Connect(&application, finishCheck);
3788
3789   application.SendNotification();
3790   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3791
3792   // We didn't expect the animation to finish yet
3793   application.SendNotification();
3794   finishCheck.CheckSignalNotReceived();
3795   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3796
3797   application.SendNotification();
3798   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3799
3800   // We didn't expect the animation to finish yet
3801   application.SendNotification();
3802   finishCheck.CheckSignalNotReceived();
3803   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3804
3805   application.SendNotification();
3806   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3807
3808   // We did expect the animation to finish
3809   application.SendNotification();
3810   finishCheck.CheckSignalReceived();
3811   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3812
3813   // Check that nothing has changed after a couple of buffer swaps
3814   application.Render(0);
3815   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3816   application.Render(0);
3817   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3818   END_TEST;
3819 }
3820
3821 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
3822 {
3823   TestApplication application;
3824
3825   Actor actor = Actor::New();
3826
3827   // Register a Vector2 property
3828   Vector2 startValue(5.0f, 5.0f);
3829   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3830   Stage::GetCurrent().Add(actor);
3831   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3832   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3833
3834   // Build the animation
3835   float durationSeconds(1.0f);
3836   Animation animation = Animation::New(durationSeconds);
3837   Vector2 targetValue(10.0f, 10.0f);
3838   Vector2 relativeValue(targetValue - startValue);
3839   float delay = 0.5f;
3840   animation.AnimateBy(Property(actor, index),
3841                       relativeValue,
3842                       AlphaFunction::LINEAR,
3843                       TimePeriod(delay, durationSeconds - delay));
3844
3845   // Start the animation
3846   animation.Play();
3847
3848   bool signalReceived(false);
3849   AnimationFinishCheck finishCheck(signalReceived);
3850   animation.FinishedSignal().Connect(&application, finishCheck);
3851
3852   application.SendNotification();
3853   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3854
3855   // We didn't expect the animation to finish yet
3856   application.SendNotification();
3857   finishCheck.CheckSignalNotReceived();
3858   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3859
3860   application.SendNotification();
3861   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3862
3863   // We didn't expect the animation to finish yet
3864   application.SendNotification();
3865   finishCheck.CheckSignalNotReceived();
3866   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3867
3868   application.SendNotification();
3869   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3870
3871   // We did expect the animation to finish
3872   application.SendNotification();
3873   finishCheck.CheckSignalReceived();
3874   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3875
3876   // Check that nothing has changed after a couple of buffer swaps
3877   application.Render(0);
3878   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3879   application.Render(0);
3880   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3881   END_TEST;
3882 }
3883
3884 int UtcDaliAnimationAnimateByVector3P(void)
3885 {
3886   TestApplication application;
3887
3888   Actor actor = Actor::New();
3889
3890   // Register a Vector3 property
3891   Vector3 startValue(10.0f, 10.0f, 10.0f);
3892   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3893   Stage::GetCurrent().Add(actor);
3894   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3895   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3896
3897   // Build the animation
3898   float durationSeconds(2.0f);
3899   Animation animation = Animation::New(durationSeconds);
3900   Vector3 targetValue(60.0f, 60.0f, 60.0f);
3901   Vector3 relativeValue(targetValue - startValue);
3902   animation.AnimateBy(Property(actor, index), relativeValue);
3903
3904   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3905
3906   // Start the animation
3907   animation.Play();
3908
3909   // Target value should be retrievable straight away
3910   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3911
3912   bool signalReceived(false);
3913   AnimationFinishCheck finishCheck(signalReceived);
3914   animation.FinishedSignal().Connect(&application, finishCheck);
3915
3916   application.SendNotification();
3917   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3918
3919   // We didn't expect the animation to finish yet
3920   application.SendNotification();
3921   finishCheck.CheckSignalNotReceived();
3922   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3923
3924   application.SendNotification();
3925   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3926
3927   // We did expect the animation to finish
3928   application.SendNotification();
3929   finishCheck.CheckSignalReceived();
3930   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3931
3932   // Check that nothing has changed after a couple of buffer swaps
3933   application.Render(0);
3934   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3935   application.Render(0);
3936   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3937   END_TEST;
3938 }
3939
3940 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
3941 {
3942   TestApplication application;
3943
3944   Actor actor = Actor::New();
3945
3946   // Register a Vector3 property
3947   Vector3 startValue(100.0f, 100.0f, 100.0f);
3948   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3949   Stage::GetCurrent().Add(actor);
3950   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3951   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3952
3953   // Build the animation
3954   float durationSeconds(1.0f);
3955   Animation animation = Animation::New(durationSeconds);
3956   Vector3 targetValue(20.0f, 20.0f, 20.0f);
3957   Vector3 relativeValue(targetValue - startValue);
3958   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3959
3960   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3961
3962   // Start the animation
3963   animation.Play();
3964
3965   bool signalReceived(false);
3966   AnimationFinishCheck finishCheck(signalReceived);
3967   animation.FinishedSignal().Connect(&application, finishCheck);
3968
3969   application.SendNotification();
3970   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3971
3972   // We didn't expect the animation to finish yet
3973   application.SendNotification();
3974   finishCheck.CheckSignalNotReceived();
3975
3976   // The position should have moved more, than with a linear alpha function
3977   Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
3978   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3979   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3980   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3981
3982   application.SendNotification();
3983   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3984
3985   // We did expect the animation to finish
3986   application.SendNotification();
3987   finishCheck.CheckSignalReceived();
3988   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3989
3990   // Check that nothing has changed after a couple of buffer swaps
3991   application.Render(0);
3992   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3993   application.Render(0);
3994   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3995   END_TEST;
3996 }
3997
3998 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
3999 {
4000   TestApplication application;
4001
4002   Actor actor = Actor::New();
4003
4004   // Register a Vector3 property
4005   Vector3 startValue(10.0f, 10.0f, 10.0f);
4006   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4007   Stage::GetCurrent().Add(actor);
4008   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4009   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4010
4011   // Build the animation
4012   float durationSeconds(1.0f);
4013   Animation animation = Animation::New(durationSeconds);
4014   Vector3 targetValue(30.0f, 30.0f, 30.0f);
4015   Vector3 relativeValue(targetValue - startValue);
4016   float delay = 0.5f;
4017   animation.AnimateBy(Property(actor, index),
4018                       relativeValue,
4019                       TimePeriod(delay, durationSeconds - delay));
4020
4021   // Start the animation
4022   animation.Play();
4023
4024   bool signalReceived(false);
4025   AnimationFinishCheck finishCheck(signalReceived);
4026   animation.FinishedSignal().Connect(&application, finishCheck);
4027
4028   application.SendNotification();
4029   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4030
4031   // We didn't expect the animation to finish yet
4032   application.SendNotification();
4033   finishCheck.CheckSignalNotReceived();
4034   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4035
4036   application.SendNotification();
4037   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4038
4039   // We didn't expect the animation to finish yet
4040   application.SendNotification();
4041   finishCheck.CheckSignalNotReceived();
4042   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4043
4044   application.SendNotification();
4045   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4046
4047   // We did expect the animation to finish
4048   application.SendNotification();
4049   finishCheck.CheckSignalReceived();
4050   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4051
4052   // Check that nothing has changed after a couple of buffer swaps
4053   application.Render(0);
4054   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4055   application.Render(0);
4056   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4057   END_TEST;
4058 }
4059
4060 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
4061 {
4062   TestApplication application;
4063
4064   Actor actor = Actor::New();
4065
4066   // Register a Vector3 property
4067   Vector3 startValue(5.0f, 5.0f, 5.0f);
4068   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4069   Stage::GetCurrent().Add(actor);
4070   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4071   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4072
4073   // Build the animation
4074   float durationSeconds(1.0f);
4075   Animation animation = Animation::New(durationSeconds);
4076   Vector3 targetValue(10.0f, 10.0f, 10.0f);
4077   Vector3 relativeValue(targetValue - startValue);
4078   float delay = 0.5f;
4079   animation.AnimateBy(Property(actor, index),
4080                       relativeValue,
4081                       AlphaFunction::LINEAR,
4082                       TimePeriod(delay, durationSeconds - delay));
4083
4084   // Start the animation
4085   animation.Play();
4086
4087   bool signalReceived(false);
4088   AnimationFinishCheck finishCheck(signalReceived);
4089   animation.FinishedSignal().Connect(&application, finishCheck);
4090
4091   application.SendNotification();
4092   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4093
4094   // We didn't expect the animation to finish yet
4095   application.SendNotification();
4096   finishCheck.CheckSignalNotReceived();
4097   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4098
4099   application.SendNotification();
4100   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4101
4102   // We didn't expect the animation to finish yet
4103   application.SendNotification();
4104   finishCheck.CheckSignalNotReceived();
4105   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4106
4107   application.SendNotification();
4108   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4109
4110   // We did expect the animation to finish
4111   application.SendNotification();
4112   finishCheck.CheckSignalReceived();
4113   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4114
4115   // Check that nothing has changed after a couple of buffer swaps
4116   application.Render(0);
4117   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4118   application.Render(0);
4119   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4120   END_TEST;
4121 }
4122
4123 int UtcDaliAnimationAnimateByVector4P(void)
4124 {
4125   TestApplication application;
4126
4127   Actor actor = Actor::New();
4128
4129   // Register a Vector4 property
4130   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4131   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4132   Stage::GetCurrent().Add(actor);
4133   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4134   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4135
4136   // Build the animation
4137   float durationSeconds(2.0f);
4138   Animation animation = Animation::New(durationSeconds);
4139   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4140   Vector4 relativeValue(targetValue - startValue);
4141   animation.AnimateBy(Property(actor, index), relativeValue);
4142
4143   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4144
4145   // Start the animation
4146   animation.Play();
4147
4148   // Target value should be retrievable straight away
4149   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4150
4151   bool signalReceived(false);
4152   AnimationFinishCheck finishCheck(signalReceived);
4153   animation.FinishedSignal().Connect(&application, finishCheck);
4154
4155   application.SendNotification();
4156   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4157
4158   // We didn't expect the animation to finish yet
4159   application.SendNotification();
4160   finishCheck.CheckSignalNotReceived();
4161   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4162
4163   application.SendNotification();
4164   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4165
4166   // We did expect the animation to finish
4167   application.SendNotification();
4168   finishCheck.CheckSignalReceived();
4169   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4170
4171   // Check that nothing has changed after a couple of buffer swaps
4172   application.Render(0);
4173   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4174   application.Render(0);
4175   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4176   END_TEST;
4177 }
4178
4179 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4180 {
4181   TestApplication application;
4182
4183   Actor actor = Actor::New();
4184
4185   // Register a Vector4 property
4186   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4187   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4188   Stage::GetCurrent().Add(actor);
4189   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4190   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4191
4192   // Build the animation
4193   float durationSeconds(1.0f);
4194   Animation animation = Animation::New(durationSeconds);
4195   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4196   Vector4 relativeValue(targetValue - startValue);
4197   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4198
4199   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4200
4201   // Start the animation
4202   animation.Play();
4203
4204   bool signalReceived(false);
4205   AnimationFinishCheck finishCheck(signalReceived);
4206   animation.FinishedSignal().Connect(&application, finishCheck);
4207
4208   application.SendNotification();
4209   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4210
4211   // We didn't expect the animation to finish yet
4212   application.SendNotification();
4213   finishCheck.CheckSignalNotReceived();
4214
4215   // The position should have moved more, than with a linear alpha function
4216   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4217   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4218   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4219   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4220   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4221
4222   application.SendNotification();
4223   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4224
4225   // We did expect the animation to finish
4226   application.SendNotification();
4227   finishCheck.CheckSignalReceived();
4228   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4229
4230   // Check that nothing has changed after a couple of buffer swaps
4231   application.Render(0);
4232   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4233   application.Render(0);
4234   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4235   END_TEST;
4236 }
4237
4238 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4239 {
4240   TestApplication application;
4241
4242   Actor actor = Actor::New();
4243
4244   // Register a Vector4 property
4245   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4246   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4247   Stage::GetCurrent().Add(actor);
4248   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4249   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4250
4251   // Build the animation
4252   float durationSeconds(1.0f);
4253   Animation animation = Animation::New(durationSeconds);
4254   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4255   Vector4 relativeValue(targetValue - startValue);
4256   float delay = 0.5f;
4257   animation.AnimateBy(Property(actor, index),
4258                       relativeValue,
4259                       TimePeriod(delay, durationSeconds - delay));
4260
4261   // Start the animation
4262   animation.Play();
4263
4264   bool signalReceived(false);
4265   AnimationFinishCheck finishCheck(signalReceived);
4266   animation.FinishedSignal().Connect(&application, finishCheck);
4267
4268   application.SendNotification();
4269   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4270
4271   // We didn't expect the animation to finish yet
4272   application.SendNotification();
4273   finishCheck.CheckSignalNotReceived();
4274   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4275
4276   application.SendNotification();
4277   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4278
4279   // We didn't expect the animation to finish yet
4280   application.SendNotification();
4281   finishCheck.CheckSignalNotReceived();
4282   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4283
4284   application.SendNotification();
4285   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4286
4287   // We did expect the animation to finish
4288   application.SendNotification();
4289   finishCheck.CheckSignalReceived();
4290   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4291
4292   // Check that nothing has changed after a couple of buffer swaps
4293   application.Render(0);
4294   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4295   application.Render(0);
4296   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4297   END_TEST;
4298 }
4299
4300 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4301 {
4302   TestApplication application;
4303
4304   Actor actor = Actor::New();
4305
4306   // Register a Vector4 property
4307   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4308   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4309   Stage::GetCurrent().Add(actor);
4310   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4311   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4312
4313   // Build the animation
4314   float durationSeconds(1.0f);
4315   Animation animation = Animation::New(durationSeconds);
4316   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4317   Vector4 relativeValue(targetValue - startValue);
4318   float delay = 0.5f;
4319   animation.AnimateBy(Property(actor, index),
4320                       relativeValue,
4321                       AlphaFunction::LINEAR,
4322                       TimePeriod(delay, durationSeconds - delay));
4323
4324   // Start the animation
4325   animation.Play();
4326
4327   bool signalReceived(false);
4328   AnimationFinishCheck finishCheck(signalReceived);
4329   animation.FinishedSignal().Connect(&application, finishCheck);
4330
4331   application.SendNotification();
4332   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4333
4334   // We didn't expect the animation to finish yet
4335   application.SendNotification();
4336   finishCheck.CheckSignalNotReceived();
4337   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4338
4339   application.SendNotification();
4340   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4341
4342   // We didn't expect the animation to finish yet
4343   application.SendNotification();
4344   finishCheck.CheckSignalNotReceived();
4345   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4346
4347   application.SendNotification();
4348   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4349
4350   // We did expect the animation to finish
4351   application.SendNotification();
4352   finishCheck.CheckSignalReceived();
4353   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4354
4355   // Check that nothing has changed after a couple of buffer swaps
4356   application.Render(0);
4357   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4358   application.Render(0);
4359   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4360   END_TEST;
4361 }
4362
4363 int UtcDaliAnimationAnimateByActorPositionP(void)
4364 {
4365   TestApplication application;
4366
4367   Actor actor = Actor::New();
4368   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4369   actor.SetPosition(startPosition);
4370   Stage::GetCurrent().Add(actor);
4371   application.SendNotification();
4372   application.Render(0);
4373   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4374
4375   // Build the animation
4376   float durationSeconds(1.0f);
4377   Animation animation = Animation::New(durationSeconds);
4378   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4379   Vector3 relativePosition(targetPosition - startPosition);
4380   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4381
4382   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4383
4384   // Start the animation
4385   animation.Play();
4386
4387   // Target value should be retrievable straight away
4388   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4389
4390   bool signalReceived(false);
4391   AnimationFinishCheck finishCheck(signalReceived);
4392   animation.FinishedSignal().Connect(&application, finishCheck);
4393
4394   application.SendNotification();
4395   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4396
4397   // We didn't expect the animation to finish yet
4398   application.SendNotification();
4399   finishCheck.CheckSignalNotReceived();
4400   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4401
4402   application.SendNotification();
4403   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4404
4405   // We did expect the animation to finish
4406   application.SendNotification();
4407   finishCheck.CheckSignalReceived();
4408   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4409
4410   // Check that nothing has changed after a couple of buffer swaps
4411   application.Render(0);
4412   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4413   application.Render(0);
4414   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4415   END_TEST;
4416 }
4417
4418 int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
4419 {
4420   TestApplication application;
4421
4422   Actor actor = Actor::New();
4423   Stage::GetCurrent().Add(actor);
4424   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4425
4426   // Build the animation
4427   float durationSeconds(1.0f);
4428   Animation animation = Animation::New(durationSeconds);
4429   Vector3 targetPosition(200.0f, 300.0f, 400.0f);
4430   Vector3 relativePosition(targetPosition - Vector3::ZERO);
4431   animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
4432   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
4433   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
4434
4435   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
4436   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4437
4438   // Start the animation
4439   animation.Play();
4440
4441   // Target value should be retrievable straight away
4442   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4443   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
4444   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
4445   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
4446
4447   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
4448
4449   application.SendNotification();
4450   application.Render( 1000 ); // 1 second progress
4451
4452   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4453
4454   END_TEST;
4455 }
4456
4457 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4458 {
4459   TestApplication application;
4460
4461   Actor actor = Actor::New();
4462   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4463   actor.SetPosition(startPosition);
4464   Stage::GetCurrent().Add(actor);
4465   application.SendNotification();
4466   application.Render(0);
4467   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4468
4469   // Build the animation
4470   float durationSeconds(1.0f);
4471   Animation animation = Animation::New(durationSeconds);
4472   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4473   Vector3 relativePosition(targetPosition - startPosition);
4474   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4475
4476   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4477
4478   // Start the animation
4479   animation.Play();
4480
4481   bool signalReceived(false);
4482   AnimationFinishCheck finishCheck(signalReceived);
4483   animation.FinishedSignal().Connect(&application, finishCheck);
4484
4485   application.SendNotification();
4486   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4487
4488   // We didn't expect the animation to finish yet
4489   application.SendNotification();
4490   finishCheck.CheckSignalNotReceived();
4491
4492   // The position should have moved more, than with a linear alpha function
4493   Vector3 current(actor.GetCurrentPosition());
4494   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4495   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4496   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4497
4498   application.SendNotification();
4499   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4500
4501   // We did expect the animation to finish
4502   application.SendNotification();
4503   finishCheck.CheckSignalReceived();
4504   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4505
4506   // Check that nothing has changed after a couple of buffer swaps
4507   application.Render(0);
4508   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4509   application.Render(0);
4510   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4511   END_TEST;
4512 }
4513
4514 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4515 {
4516   TestApplication application;
4517
4518   Actor actor = Actor::New();
4519   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4520   actor.SetPosition(startPosition);
4521   Stage::GetCurrent().Add(actor);
4522   application.SendNotification();
4523   application.Render(0);
4524   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4525
4526   // Build the animation
4527   float durationSeconds(1.0f);
4528   Animation animation = Animation::New(durationSeconds);
4529   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4530   Vector3 relativePosition(targetPosition - startPosition);
4531   float delay = 0.5f;
4532   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4533                       relativePosition,
4534                       TimePeriod(delay, durationSeconds - delay));
4535
4536   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4537
4538   // Start the animation
4539   animation.Play();
4540
4541   bool signalReceived(false);
4542   AnimationFinishCheck finishCheck(signalReceived);
4543   animation.FinishedSignal().Connect(&application, finishCheck);
4544
4545   application.SendNotification();
4546   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4547
4548   // We didn't expect the animation to finish yet
4549   application.SendNotification();
4550   finishCheck.CheckSignalNotReceived();
4551   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4552
4553   application.SendNotification();
4554   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4555
4556   // We did expect the animation to finish
4557   application.SendNotification();
4558   finishCheck.CheckSignalReceived();
4559   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4560
4561   // Check that nothing has changed after a couple of buffer swaps
4562   application.Render(0);
4563   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4564   application.Render(0);
4565   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4566   END_TEST;
4567 }
4568
4569 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4570 {
4571   TestApplication application;
4572
4573   Actor actor = Actor::New();
4574   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4575   actor.SetPosition(startPosition);
4576   Stage::GetCurrent().Add(actor);
4577   application.SendNotification();
4578   application.Render(0);
4579   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4580
4581   // Build the animation
4582   float durationSeconds(1.0f);
4583   Animation animation = Animation::New(durationSeconds);
4584   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4585   Vector3 relativePosition(targetPosition - startPosition);
4586   float delay = 0.5f;
4587   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4588                       relativePosition,
4589                       AlphaFunction::LINEAR,
4590                       TimePeriod(delay, durationSeconds - delay));
4591
4592   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4593
4594   // Start the animation
4595   animation.Play();
4596
4597   bool signalReceived(false);
4598   AnimationFinishCheck finishCheck(signalReceived);
4599   animation.FinishedSignal().Connect(&application, finishCheck);
4600
4601   application.SendNotification();
4602   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4603
4604   // We didn't expect the animation to finish yet
4605   application.SendNotification();
4606   finishCheck.CheckSignalNotReceived();
4607   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4608
4609   application.SendNotification();
4610   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4611
4612   // We did expect the animation to finish
4613   application.SendNotification();
4614   finishCheck.CheckSignalReceived();
4615   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4616
4617   // Check that nothing has changed after a couple of buffer swaps
4618   application.Render(0);
4619   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4620   application.Render(0);
4621   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4622   END_TEST;
4623 }
4624
4625 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4626 {
4627   TestApplication application;
4628
4629   Actor actor = Actor::New();
4630   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4631   Stage::GetCurrent().Add(actor);
4632   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4633
4634   // Build the animation
4635   float durationSeconds(1.0f);
4636   Animation animation = Animation::New(durationSeconds);
4637   Degree relativeRotationDegrees(360.0f);
4638   Radian relativeRotationRadians(relativeRotationDegrees);
4639   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4640
4641   // Start the animation
4642   animation.Play();
4643
4644   // Target value should be retrievable straight away
4645   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
4646
4647   bool signalReceived(false);
4648   AnimationFinishCheck finishCheck(signalReceived);
4649   animation.FinishedSignal().Connect(&application, finishCheck);
4650
4651   application.SendNotification();
4652   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4653
4654   // We didn't expect the animation to finish yet
4655   application.SendNotification();
4656   finishCheck.CheckSignalNotReceived();
4657   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4658
4659   application.SendNotification();
4660   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4661
4662   // We didn't expect the animation to finish yet
4663   application.SendNotification();
4664   finishCheck.CheckSignalNotReceived();
4665   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4666
4667   application.SendNotification();
4668   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4669
4670   // We didn't expect the animation to finish yet
4671   application.SendNotification();
4672   finishCheck.CheckSignalNotReceived();
4673   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4674
4675   application.SendNotification();
4676   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4677
4678   // We did expect the animation to finish
4679   application.SendNotification();
4680   finishCheck.CheckSignalReceived();
4681   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4682   END_TEST;
4683 }
4684
4685 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4686 {
4687   TestApplication application;
4688
4689   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4690
4691   Actor actor = Actor::New();
4692   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4693   Stage::GetCurrent().Add(actor);
4694   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4695
4696   // Build the animation
4697   float durationSeconds(1.0f);
4698   Animation animation = Animation::New(durationSeconds);
4699   Degree relativeRotationDegrees(710.0f);
4700   Radian relativeRotationRadians(relativeRotationDegrees);
4701
4702   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4703
4704   // Start the animation
4705   animation.Play();
4706
4707   bool signalReceived(false);
4708   AnimationFinishCheck finishCheck(signalReceived);
4709   animation.FinishedSignal().Connect(&application, finishCheck);
4710
4711   application.SendNotification();
4712   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4713
4714   // We didn't expect the animation to finish yet
4715   application.SendNotification();
4716   finishCheck.CheckSignalNotReceived();
4717   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4718
4719   application.SendNotification();
4720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4721
4722   // We didn't expect the animation to finish yet
4723   application.SendNotification();
4724   finishCheck.CheckSignalNotReceived();
4725   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4726
4727   application.SendNotification();
4728   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4729
4730   // We didn't expect the animation to finish yet
4731   application.SendNotification();
4732   finishCheck.CheckSignalNotReceived();
4733   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4734
4735   application.SendNotification();
4736   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4737
4738   // We did expect the animation to finish
4739   application.SendNotification();
4740   finishCheck.CheckSignalReceived();
4741   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4742   END_TEST;
4743 }
4744
4745
4746 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4747 {
4748   TestApplication application;
4749
4750   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4751
4752   Actor actor = Actor::New();
4753   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4754   Stage::GetCurrent().Add(actor);
4755   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4756
4757   // Build the animation
4758   float durationSeconds(1.0f);
4759   Animation animation = Animation::New(durationSeconds);
4760   Degree relativeRotationDegrees(730.0f);
4761   Radian relativeRotationRadians(relativeRotationDegrees);
4762
4763   Radian actualRotationRadians( Degree(10.0f) );
4764
4765   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4766
4767   // Start the animation
4768   animation.Play();
4769
4770   bool signalReceived(false);
4771   AnimationFinishCheck finishCheck(signalReceived);
4772   animation.FinishedSignal().Connect(&application, finishCheck);
4773
4774   application.SendNotification();
4775   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4776
4777   // We didn't expect the animation to finish yet
4778   application.SendNotification();
4779   finishCheck.CheckSignalNotReceived();
4780   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4781
4782   application.SendNotification();
4783   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4784
4785   // We didn't expect the animation to finish yet
4786   application.SendNotification();
4787   finishCheck.CheckSignalNotReceived();
4788   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4789
4790   application.SendNotification();
4791   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4792
4793   // We didn't expect the animation to finish yet
4794   application.SendNotification();
4795   finishCheck.CheckSignalNotReceived();
4796   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4797
4798   application.SendNotification();
4799   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4800
4801   // We did expect the animation to finish
4802   application.SendNotification();
4803   finishCheck.CheckSignalReceived();
4804   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4805   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4806   END_TEST;
4807 }
4808
4809
4810 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4811 {
4812   TestApplication application;
4813
4814   Actor actor = Actor::New();
4815   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4816   Stage::GetCurrent().Add(actor);
4817   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4818
4819   // Build the animation
4820   float durationSeconds(1.0f);
4821   Animation animation = Animation::New(durationSeconds);
4822   Degree relativeRotationDegrees(360.0f);
4823   Radian relativeRotationRadians(relativeRotationDegrees);
4824   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4825
4826   // Start the animation
4827   animation.Play();
4828
4829   bool signalReceived(false);
4830   AnimationFinishCheck finishCheck(signalReceived);
4831   animation.FinishedSignal().Connect(&application, finishCheck);
4832
4833   application.SendNotification();
4834   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4835
4836   // We didn't expect the animation to finish yet
4837   application.SendNotification();
4838   finishCheck.CheckSignalNotReceived();
4839   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4840
4841   application.SendNotification();
4842   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4843
4844   // We didn't expect the animation to finish yet
4845   application.SendNotification();
4846   finishCheck.CheckSignalNotReceived();
4847   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4848
4849   application.SendNotification();
4850   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4851
4852   // We didn't expect the animation to finish yet
4853   application.SendNotification();
4854   finishCheck.CheckSignalNotReceived();
4855   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4856
4857   application.SendNotification();
4858   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4859
4860   // We did expect the animation to finish
4861   application.SendNotification();
4862   finishCheck.CheckSignalReceived();
4863   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4864   END_TEST;
4865 }
4866
4867 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4868 {
4869   TestApplication application;
4870
4871   Actor actor = Actor::New();
4872   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4873   Stage::GetCurrent().Add(actor);
4874   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4875
4876   // Build the animation
4877   float durationSeconds(1.0f);
4878   Animation animation = Animation::New(durationSeconds);
4879   Degree relativeRotationDegrees(360.0f);
4880   Radian relativeRotationRadians(relativeRotationDegrees);
4881   float delay = 0.3f;
4882   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4883                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4884
4885   // Start the animation
4886   animation.Play();
4887
4888   bool signalReceived(false);
4889   AnimationFinishCheck finishCheck(signalReceived);
4890   animation.FinishedSignal().Connect(&application, finishCheck);
4891
4892   application.SendNotification();
4893   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4894
4895   // We didn't expect the animation to finish yet
4896   application.SendNotification();
4897   finishCheck.CheckSignalNotReceived();
4898   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4899   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4900
4901   application.SendNotification();
4902   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4903
4904   // We didn't expect the animation to finish yet
4905   application.SendNotification();
4906   finishCheck.CheckSignalNotReceived();
4907   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4908   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4909
4910   application.SendNotification();
4911   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4912
4913   // We didn't expect the animation to finish yet
4914   application.SendNotification();
4915   finishCheck.CheckSignalNotReceived();
4916   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4917   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4918
4919   application.SendNotification();
4920   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4921
4922   // We did expect the animation to finish
4923   application.SendNotification();
4924   finishCheck.CheckSignalReceived();
4925   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4926   END_TEST;
4927 }
4928
4929 int UtcDaliAnimationAnimateByActorScaleP(void)
4930 {
4931   TestApplication application;
4932
4933   Actor actor = Actor::New();
4934   Stage::GetCurrent().Add(actor);
4935   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4936
4937   // Build the animation
4938   float durationSeconds(1.0f);
4939   Animation animation = Animation::New(durationSeconds);
4940   Vector3 targetScale(2.0f, 2.0f, 2.0f);
4941   Vector3 relativeScale(targetScale - Vector3::ONE);
4942   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4943
4944   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4945
4946   // Start the animation
4947   animation.Play();
4948
4949   // Target value should be retrievable straight away
4950   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
4951
4952   bool signalReceived(false);
4953   AnimationFinishCheck finishCheck(signalReceived);
4954   animation.FinishedSignal().Connect(&application, finishCheck);
4955
4956   application.SendNotification();
4957   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4958
4959   // We didn't expect the animation to finish yet
4960   application.SendNotification();
4961   finishCheck.CheckSignalNotReceived();
4962   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4963
4964   application.SendNotification();
4965   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4966
4967   // We did expect the animation to finish
4968   application.SendNotification();
4969   finishCheck.CheckSignalReceived();
4970   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4971
4972   // Reset everything
4973   finishCheck.Reset();
4974   actor.SetScale(Vector3::ONE);
4975   application.SendNotification();
4976   application.Render(0);
4977   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4978
4979   // Repeat with a different (ease-in) alpha function
4980   animation = Animation::New(durationSeconds);
4981   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4982   animation.FinishedSignal().Connect(&application, finishCheck);
4983   animation.Play();
4984
4985   application.SendNotification();
4986   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4987
4988   // We didn't expect the animation to finish yet
4989   application.SendNotification();
4990   finishCheck.CheckSignalNotReceived();
4991
4992   // The scale should have grown less, than with a linear alpha function
4993   Vector3 current(actor.GetCurrentScale());
4994   DALI_TEST_CHECK( current.x > 1.0f );
4995   DALI_TEST_CHECK( current.y > 1.0f );
4996   DALI_TEST_CHECK( current.z > 1.0f );
4997   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4998   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4999   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5000
5001   application.SendNotification();
5002   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5003
5004   // We did expect the animation to finish
5005   application.SendNotification();
5006   finishCheck.CheckSignalReceived();
5007   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5008
5009   // Reset everything
5010   finishCheck.Reset();
5011   actor.SetScale(Vector3::ONE);
5012   application.SendNotification();
5013   application.Render(0);
5014   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5015
5016   // Repeat with a delay
5017   float delay = 0.5f;
5018   animation = Animation::New(durationSeconds);
5019   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
5020   animation.FinishedSignal().Connect(&application, finishCheck);
5021   animation.Play();
5022
5023   application.SendNotification();
5024   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5025
5026   // We didn't expect the animation to finish yet
5027   application.SendNotification();
5028   finishCheck.CheckSignalNotReceived();
5029   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5030
5031   application.SendNotification();
5032   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5033
5034   // We did expect the animation to finish
5035   application.SendNotification();
5036   finishCheck.CheckSignalReceived();
5037   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5038   END_TEST;
5039 }
5040
5041 int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
5042 {
5043   TestApplication application;
5044
5045   Actor actor = Actor::New();
5046   Stage::GetCurrent().Add(actor);
5047   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5048
5049   // Build the animation
5050   float durationSeconds(1.0f);
5051   Animation animation = Animation::New(durationSeconds);
5052   Vector3 targetScale(2.0f, 3.0f, 4.0f);
5053   Vector3 relativeScale(targetScale - Vector3::ONE);
5054   animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
5055   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
5056   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
5057
5058   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
5059   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5060
5061   // Start the animation
5062   animation.Play();
5063
5064   // Target value should be retrievable straight away
5065   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5066   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
5067   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
5068   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
5069
5070   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); // Not changed yet
5071
5072   application.SendNotification();
5073   application.Render( 1000 ); // 1 second progress
5074
5075   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
5076
5077   END_TEST;
5078 }
5079
5080 int UtcDaliAnimationAnimateByActorColorP(void)
5081 {
5082   TestApplication application;
5083
5084   Actor actor = Actor::New();
5085   Stage::GetCurrent().Add(actor);
5086   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5087
5088   // Build the animation
5089   float durationSeconds(1.0f);
5090   Animation animation = Animation::New(durationSeconds);
5091   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5092   Vector4 relativeColor( targetColor - Color::WHITE );
5093   animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
5094
5095   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5096   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5097
5098   // Start the animation
5099   animation.Play();
5100
5101   // Target value should be retrievable straight away
5102   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5103   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5104   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5105   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5106   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5107
5108   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5109
5110   application.SendNotification();
5111   application.Render( 1000 ); // 1 second progress
5112
5113   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5114
5115   END_TEST;
5116 }
5117
5118 int UtcDaliAnimationAnimateByActorColorComponentsP(void)
5119 {
5120   TestApplication application;
5121
5122   Actor actor = Actor::New();
5123   Stage::GetCurrent().Add(actor);
5124   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5125
5126   // Build the animation
5127   float durationSeconds(1.0f);
5128   Animation animation = Animation::New(durationSeconds);
5129   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5130   Vector4 relativeColor( targetColor - Color::WHITE );
5131   animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
5132   animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
5133   animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
5134   animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
5135
5136   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
5137   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5138
5139   // Start the animation
5140   animation.Play();
5141
5142   // Target value should be retrievable straight away
5143   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5144   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5145   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5146   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5147   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5148
5149   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); // Not changed yet
5150
5151   application.SendNotification();
5152   application.Render( 1000 ); // 1 second progress
5153
5154   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
5155
5156   END_TEST;
5157 }
5158
5159 int UtcDaliAnimationAnimateByActorSizeP(void)
5160 {
5161   TestApplication application;
5162
5163   Actor actor = Actor::New();
5164   Stage::GetCurrent().Add(actor);
5165   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5166
5167   // Build the animation
5168   float durationSeconds(1.0f);
5169   Animation animation = Animation::New(durationSeconds);
5170   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5171   Vector3 relativeSize( targetSize - Vector3::ZERO );
5172   animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
5173
5174   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5175   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5176
5177   // Start the animation
5178   animation.Play();
5179
5180   // Target value should be retrievable straight away
5181   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5182   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5183   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5184   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5185
5186   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5187
5188   application.SendNotification();
5189   application.Render( 1000 ); // 1 second progress
5190
5191   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5192
5193   END_TEST;
5194 }
5195
5196 int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
5197 {
5198   TestApplication application;
5199
5200   Actor actor = Actor::New();
5201   Stage::GetCurrent().Add(actor);
5202   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5203
5204   // Build the animation
5205   float durationSeconds(1.0f);
5206   Animation animation = Animation::New(durationSeconds);
5207   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5208   Vector3 relativeSize( targetSize - Vector3::ZERO );
5209   animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
5210   animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
5211   animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
5212
5213   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5214   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5215
5216   // Start the animation
5217   animation.Play();
5218
5219   // Target value should be retrievable straight away
5220   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5221   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5222   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5223   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5224
5225   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5226
5227   application.SendNotification();
5228   application.Render( 1000 ); // 1 second progress
5229
5230   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5231
5232   END_TEST;
5233 }
5234
5235 int UtcDaliAnimationAnimateByActorVisibilityP(void)
5236 {
5237   TestApplication application;
5238
5239   Actor actor = Actor::New();
5240   Stage::GetCurrent().Add(actor);
5241   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5242
5243   actor.SetVisible( false );
5244
5245   application.SendNotification();
5246   application.Render();
5247
5248   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
5249
5250   // Build the animation
5251   float durationSeconds(1.0f);
5252   Animation animation = Animation::New(durationSeconds);
5253   bool targetVisibility( true );
5254   bool relativeVisibility( targetVisibility );
5255   animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
5256
5257   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5258
5259   // Start the animation
5260   animation.Play();
5261
5262   // Target value should be retrievable straight away
5263   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
5264   DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); // Not changed yet
5265
5266   application.SendNotification();
5267   application.Render( 1000 ); // 1 second progress
5268
5269   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
5270
5271   END_TEST;
5272 }
5273
5274 int UtcDaliAnimationAnimateToBooleanP(void)
5275 {
5276   TestApplication application;
5277
5278   Actor actor = Actor::New();
5279
5280   // Register a boolean property
5281   const bool startValue(false);
5282   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5283   Stage::GetCurrent().Add(actor);
5284   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5285   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5286
5287   // Build the animation
5288   float durationSeconds(2.0f);
5289   Animation animation = Animation::New(durationSeconds);
5290   const bool targetValue( !startValue );
5291   animation.AnimateTo(Property(actor, index), targetValue);
5292
5293   // Start the animation
5294   animation.Play();
5295
5296   bool signalReceived(false);
5297   AnimationFinishCheck finishCheck(signalReceived);
5298   animation.FinishedSignal().Connect(&application, finishCheck);
5299
5300   application.SendNotification();
5301   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5302
5303   // We didn't expect the animation to finish yet
5304   application.SendNotification();
5305   finishCheck.CheckSignalNotReceived();
5306   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5307
5308   application.SendNotification();
5309   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5310
5311   // We did expect the animation to finish
5312   application.SendNotification();
5313   finishCheck.CheckSignalReceived();
5314   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5315
5316   // Check that nothing has changed after a couple of buffer swaps
5317   application.Render(0);
5318   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5319   application.Render(0);
5320   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5321
5322   // Repeat with target value "false"
5323   animation = Animation::New(durationSeconds);
5324   const bool finalValue( !targetValue );
5325   animation.AnimateTo(Property(actor, index), finalValue);
5326
5327   // Start the animation
5328   animation.Play();
5329
5330   finishCheck.Reset();
5331   animation.FinishedSignal().Connect(&application, finishCheck);
5332
5333   application.SendNotification();
5334   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5335
5336   // We didn't expect the animation to finish yet
5337   application.SendNotification();
5338   finishCheck.CheckSignalNotReceived();
5339   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5340
5341   application.SendNotification();
5342   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5343
5344   // We did expect the animation to finish
5345   application.SendNotification();
5346   finishCheck.CheckSignalReceived();
5347   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5348
5349   // Check that nothing has changed after a couple of buffer swaps
5350   application.Render(0);
5351   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5352   application.Render(0);
5353   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5354   END_TEST;
5355 }
5356
5357 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
5358 {
5359   TestApplication application;
5360
5361   Actor actor = Actor::New();
5362
5363   // Register a boolean property
5364   const bool startValue(false);
5365   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5366   Stage::GetCurrent().Add(actor);
5367   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5368   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5369
5370   // Build the animation
5371   float durationSeconds(2.0f);
5372   Animation animation = Animation::New(durationSeconds);
5373   const bool targetValue( !startValue );
5374   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5375
5376   // Start the animation
5377   animation.Play();
5378
5379   bool signalReceived(false);
5380   AnimationFinishCheck finishCheck(signalReceived);
5381   animation.FinishedSignal().Connect(&application, finishCheck);
5382
5383   application.SendNotification();
5384   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5385
5386   // We didn't expect the animation to finish yet
5387   application.SendNotification();
5388   finishCheck.CheckSignalNotReceived();
5389   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5390
5391   application.SendNotification();
5392   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5393
5394   // We did expect the animation to finish
5395   application.SendNotification();
5396   finishCheck.CheckSignalReceived();
5397   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5398
5399   // Check that nothing has changed after a couple of buffer swaps
5400   application.Render(0);
5401   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5402   application.Render(0);
5403   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5404
5405   // Repeat with target value "false"
5406   animation = Animation::New(durationSeconds);
5407   const bool finalValue( !targetValue );
5408   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5409
5410   // Start the animation
5411   animation.Play();
5412
5413   finishCheck.Reset();
5414   animation.FinishedSignal().Connect(&application, finishCheck);
5415
5416   application.SendNotification();
5417   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5418
5419   // We didn't expect the animation to finish yet
5420   application.SendNotification();
5421   finishCheck.CheckSignalNotReceived();
5422   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5423
5424   application.SendNotification();
5425   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5426
5427   // We did expect the animation to finish
5428   application.SendNotification();
5429   finishCheck.CheckSignalReceived();
5430   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5431
5432   // Check that nothing has changed after a couple of buffer swaps
5433   application.Render(0);
5434   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5435   application.Render(0);
5436   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5437   END_TEST;
5438 }
5439
5440 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5441 {
5442   TestApplication application;
5443
5444   Actor actor = Actor::New();
5445
5446   // Register a boolean property
5447   bool startValue(false);
5448   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5449   Stage::GetCurrent().Add(actor);
5450   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5451   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5452
5453   // Build the animation
5454   float durationSeconds(2.0f);
5455   Animation animation = Animation::New(durationSeconds);
5456   bool finalValue( !startValue );
5457   float animatorDurationSeconds(durationSeconds * 0.5f);
5458   animation.AnimateTo( Property(actor, index),
5459                        finalValue,
5460                        TimePeriod( animatorDurationSeconds ) );
5461
5462   // Start the animation
5463   animation.Play();
5464
5465   bool signalReceived(false);
5466   AnimationFinishCheck finishCheck(signalReceived);
5467   animation.FinishedSignal().Connect(&application, finishCheck);
5468
5469   application.SendNotification();
5470   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5471
5472   // We didn't expect the animation to finish yet
5473   application.SendNotification();
5474   finishCheck.CheckSignalNotReceived();
5475   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5476
5477   application.SendNotification();
5478   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5479
5480   // We didn't expect the animation to finish yet...
5481   application.SendNotification();
5482   finishCheck.CheckSignalNotReceived();
5483
5484   // ...however we should have reached the final value
5485   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5486
5487   application.SendNotification();
5488   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5489
5490   // We did expect the animation to finish
5491   application.SendNotification();
5492   finishCheck.CheckSignalReceived();
5493   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5494
5495   // Check that nothing has changed after a couple of buffer swaps
5496   application.Render(0);
5497   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5498   application.Render(0);
5499   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5500   END_TEST;
5501 }
5502
5503 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5504 {
5505   TestApplication application;
5506
5507   Actor actor = Actor::New();
5508
5509   // Register a boolean property
5510   bool startValue(false);
5511   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5512   Stage::GetCurrent().Add(actor);
5513   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5514   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5515
5516   // Build the animation
5517   float durationSeconds(2.0f);
5518   Animation animation = Animation::New(durationSeconds);
5519   bool finalValue( !startValue );
5520   float animatorDurationSeconds(durationSeconds * 0.5f);
5521   animation.AnimateTo( Property(actor, index),
5522                        finalValue,
5523                        AlphaFunction::LINEAR,
5524                        TimePeriod( animatorDurationSeconds ) );
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>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5535
5536   // We didn't expect the animation to finish yet
5537   application.SendNotification();
5538   finishCheck.CheckSignalNotReceived();
5539   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5540
5541   application.SendNotification();
5542   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5543
5544   // We didn't expect the animation to finish yet...
5545   application.SendNotification();
5546   finishCheck.CheckSignalNotReceived();
5547
5548   // ...however we should have reached the final value
5549   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5550
5551   application.SendNotification();
5552   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5553
5554   // We did expect the animation to finish
5555   application.SendNotification();
5556   finishCheck.CheckSignalReceived();
5557   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5558
5559   // Check that nothing has changed after a couple of buffer swaps
5560   application.Render(0);
5561   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5562   application.Render(0);
5563   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5564   END_TEST;
5565 }
5566
5567 int UtcDaliAnimationAnimateToFloatP(void)
5568 {
5569   TestApplication application;
5570
5571   Actor actor = Actor::New();
5572
5573   // Register a float property
5574   float startValue(10.0f);
5575   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5576   Stage::GetCurrent().Add(actor);
5577   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5579
5580   // Build the animation
5581   float durationSeconds(2.0f);
5582   Animation animation = Animation::New(durationSeconds);
5583   float targetValue(50.0f);
5584   float relativeValue(targetValue - startValue);
5585   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5586
5587   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5588
5589   // Start the animation
5590   animation.Play();
5591
5592   bool signalReceived(false);
5593   AnimationFinishCheck finishCheck(signalReceived);
5594   animation.FinishedSignal().Connect(&application, finishCheck);
5595
5596   application.SendNotification();
5597   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5598
5599   // We didn't expect the animation to finish yet
5600   application.SendNotification();
5601   finishCheck.CheckSignalNotReceived();
5602   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5603
5604   application.SendNotification();
5605   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5606
5607   // We did expect the animation to finish
5608   application.SendNotification();
5609   finishCheck.CheckSignalReceived();
5610   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5611   END_TEST;
5612 }
5613
5614 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5615 {
5616   TestApplication application;
5617
5618   Actor actor = Actor::New();
5619
5620   // Register a float property
5621   float startValue(10.0f);
5622   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5623   Stage::GetCurrent().Add(actor);
5624   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5625   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5626
5627   // Build the animation
5628   float durationSeconds(1.0f);
5629   Animation animation = Animation::New(durationSeconds);
5630   float targetValue(90.0f);
5631   float relativeValue(targetValue - startValue);
5632   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5633
5634   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5635
5636   // Start the animation
5637   animation.Play();
5638
5639   bool signalReceived(false);
5640   AnimationFinishCheck finishCheck(signalReceived);
5641   animation.FinishedSignal().Connect(&application, finishCheck);
5642
5643   application.SendNotification();
5644   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5645
5646   // We didn't expect the animation to finish yet
5647   application.SendNotification();
5648   finishCheck.CheckSignalNotReceived();
5649
5650   // The position should have moved more, than with a linear alpha function
5651   float current( actor.GetCurrentProperty< float >( index ) );
5652   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5653
5654   application.SendNotification();
5655   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5656
5657   // We did expect the animation to finish
5658   application.SendNotification();
5659   finishCheck.CheckSignalReceived();
5660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5661   END_TEST;
5662 }
5663
5664 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5665 {
5666   TestApplication application;
5667
5668   Actor actor = Actor::New();
5669
5670   // Register a float property
5671   float startValue(10.0f);
5672   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5673   Stage::GetCurrent().Add(actor);
5674   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5675   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5676
5677   // Build the animation
5678   float durationSeconds(1.0f);
5679   Animation animation = Animation::New(durationSeconds);
5680   float targetValue(30.0f);
5681   float relativeValue(targetValue - startValue);
5682   float delay = 0.5f;
5683   animation.AnimateTo(Property(actor, index),
5684                       targetValue,
5685                       TimePeriod(delay, durationSeconds - delay));
5686
5687   // Start the animation
5688   animation.Play();
5689
5690   bool signalReceived(false);
5691   AnimationFinishCheck finishCheck(signalReceived);
5692   animation.FinishedSignal().Connect(&application, finishCheck);
5693
5694   application.SendNotification();
5695   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5696
5697   // We didn't expect the animation to finish yet
5698   application.SendNotification();
5699   finishCheck.CheckSignalNotReceived();
5700   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5701
5702   application.SendNotification();
5703   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5704
5705   // We didn't expect the animation to finish yet
5706   application.SendNotification();
5707   finishCheck.CheckSignalNotReceived();
5708   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5709
5710   application.SendNotification();
5711   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5712
5713   // We did expect the animation to finish
5714   application.SendNotification();
5715   finishCheck.CheckSignalReceived();
5716   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5717   END_TEST;
5718 }
5719
5720 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5721 {
5722   TestApplication application;
5723
5724   Actor actor = Actor::New();
5725
5726   // Register a float property
5727   float startValue(10.0f);
5728   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5729   Stage::GetCurrent().Add(actor);
5730   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5731   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5732
5733   // Build the animation
5734   float durationSeconds(1.0f);
5735   Animation animation = Animation::New(durationSeconds);
5736   float targetValue(30.0f);
5737   float relativeValue(targetValue - startValue);
5738   float delay = 0.5f;
5739   animation.AnimateTo(Property(actor, index),
5740                       targetValue,
5741                       AlphaFunction::LINEAR,
5742                       TimePeriod(delay, durationSeconds - delay));
5743
5744   // Start the animation
5745   animation.Play();
5746
5747   bool signalReceived(false);
5748   AnimationFinishCheck finishCheck(signalReceived);
5749   animation.FinishedSignal().Connect(&application, finishCheck);
5750
5751   application.SendNotification();
5752   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5753
5754   // We didn't expect the animation to finish yet
5755   application.SendNotification();
5756   finishCheck.CheckSignalNotReceived();
5757   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5758
5759   application.SendNotification();
5760   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5761
5762   // We didn't expect the animation to finish yet
5763   application.SendNotification();
5764   finishCheck.CheckSignalNotReceived();
5765   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5766
5767   application.SendNotification();
5768   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5769
5770   // We did expect the animation to finish
5771   application.SendNotification();
5772   finishCheck.CheckSignalReceived();
5773   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5774   END_TEST;
5775 }
5776
5777 int UtcDaliAnimationAnimateToIntegerP(void)
5778 {
5779   TestApplication application;
5780
5781   Actor actor = Actor::New();
5782
5783   // Register an integer property
5784   int startValue(10);
5785   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5786   Stage::GetCurrent().Add(actor);
5787   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5788   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5789
5790   // Build the animation
5791   float durationSeconds(2.0f);
5792   Animation animation = Animation::New(durationSeconds);
5793   int targetValue(50);
5794   int relativeValue(targetValue - startValue);
5795   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5796
5797   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5798
5799   // Start the animation
5800   animation.Play();
5801
5802   bool signalReceived(false);
5803   AnimationFinishCheck finishCheck(signalReceived);
5804   animation.FinishedSignal().Connect(&application, finishCheck);
5805
5806   application.SendNotification();
5807   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5808
5809   // We didn't expect the animation to finish yet
5810   application.SendNotification();
5811   finishCheck.CheckSignalNotReceived();
5812   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5813
5814   application.SendNotification();
5815   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5816
5817   // We did expect the animation to finish
5818   application.SendNotification();
5819   finishCheck.CheckSignalReceived();
5820   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5821   END_TEST;
5822 }
5823
5824 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5825 {
5826   TestApplication application;
5827
5828   Actor actor = Actor::New();
5829
5830   // Register an integer property
5831   int startValue(10);
5832   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5833   Stage::GetCurrent().Add(actor);
5834   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5835   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5836
5837   // Build the animation
5838   float durationSeconds(1.0f);
5839   Animation animation = Animation::New(durationSeconds);
5840   int targetValue(90);
5841   int relativeValue(targetValue - startValue);
5842   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5843
5844   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5845
5846   // Start the animation
5847   animation.Play();
5848
5849   bool signalReceived(false);
5850   AnimationFinishCheck finishCheck(signalReceived);
5851   animation.FinishedSignal().Connect(&application, finishCheck);
5852
5853   application.SendNotification();
5854   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5855
5856   // We didn't expect the animation to finish yet
5857   application.SendNotification();
5858   finishCheck.CheckSignalNotReceived();
5859
5860   // The position should have moved more, than with a linear alpha function
5861   int current( actor.GetCurrentProperty< int >( index ) );
5862   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5863
5864   application.SendNotification();
5865   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5866
5867   // We did expect the animation to finish
5868   application.SendNotification();
5869   finishCheck.CheckSignalReceived();
5870   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5871   END_TEST;
5872 }
5873
5874 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5875 {
5876   TestApplication application;
5877
5878   Actor actor = Actor::New();
5879
5880   // Register an integer property
5881   int startValue(10);
5882   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5883   Stage::GetCurrent().Add(actor);
5884   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5885   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5886
5887   // Build the animation
5888   float durationSeconds(1.0f);
5889   Animation animation = Animation::New(durationSeconds);
5890   int targetValue(30);
5891   int relativeValue(targetValue - startValue);
5892   float delay = 0.5f;
5893   animation.AnimateTo(Property(actor, index),
5894                       targetValue,
5895                       TimePeriod(delay, durationSeconds - delay));
5896
5897   // Start the animation
5898   animation.Play();
5899
5900   bool signalReceived(false);
5901   AnimationFinishCheck finishCheck(signalReceived);
5902   animation.FinishedSignal().Connect(&application, finishCheck);
5903
5904   application.SendNotification();
5905   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5906
5907   // We didn't expect the animation to finish yet
5908   application.SendNotification();
5909   finishCheck.CheckSignalNotReceived();
5910   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5911
5912   application.SendNotification();
5913   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5914
5915   // We didn't expect the animation to finish yet
5916   application.SendNotification();
5917   finishCheck.CheckSignalNotReceived();
5918   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5919
5920   application.SendNotification();
5921   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5922
5923   // We did expect the animation to finish
5924   application.SendNotification();
5925   finishCheck.CheckSignalReceived();
5926   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5927   END_TEST;
5928 }
5929
5930 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5931 {
5932   TestApplication application;
5933
5934   Actor actor = Actor::New();
5935
5936   // Register an integer property
5937   int startValue(10);
5938   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5939   Stage::GetCurrent().Add(actor);
5940   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5941   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5942
5943   // Build the animation
5944   float durationSeconds(1.0f);
5945   Animation animation = Animation::New(durationSeconds);
5946   int targetValue(30);
5947   int relativeValue(targetValue - startValue);
5948   float delay = 0.5f;
5949   animation.AnimateTo(Property(actor, index),
5950                       targetValue,
5951                       AlphaFunction::LINEAR,
5952                       TimePeriod(delay, durationSeconds - delay));
5953
5954   // Start the animation
5955   animation.Play();
5956
5957   bool signalReceived(false);
5958   AnimationFinishCheck finishCheck(signalReceived);
5959   animation.FinishedSignal().Connect(&application, finishCheck);
5960
5961   application.SendNotification();
5962   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5963
5964   // We didn't expect the animation to finish yet
5965   application.SendNotification();
5966   finishCheck.CheckSignalNotReceived();
5967   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5968
5969   application.SendNotification();
5970   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5971
5972   // We didn't expect the animation to finish yet
5973   application.SendNotification();
5974   finishCheck.CheckSignalNotReceived();
5975   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5976
5977   application.SendNotification();
5978   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5979
5980   // We did expect the animation to finish
5981   application.SendNotification();
5982   finishCheck.CheckSignalReceived();
5983   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5984   END_TEST;
5985 }
5986
5987 int UtcDaliAnimationAnimateToVector2P(void)
5988 {
5989   TestApplication application;
5990
5991   Actor actor = Actor::New();
5992
5993   // Register a Vector2 property
5994   Vector2 startValue(-50.0f, -50.0f);
5995   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5996   Stage::GetCurrent().Add(actor);
5997   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5998   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5999
6000   // Build the animation
6001   float durationSeconds(2.0f);
6002   Animation animation = Animation::New(durationSeconds);
6003   Vector2 targetValue(50.0f, 50.0f);
6004   Vector2 relativeValue(targetValue - startValue);
6005   animation.AnimateTo(Property(actor, index), targetValue);
6006
6007   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6008
6009   // Start the animation
6010   animation.Play();
6011
6012   bool signalReceived(false);
6013   AnimationFinishCheck finishCheck(signalReceived);
6014   animation.FinishedSignal().Connect(&application, finishCheck);
6015
6016   application.SendNotification();
6017   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6018
6019   // We didn't expect the animation to finish yet
6020   application.SendNotification();
6021   finishCheck.CheckSignalNotReceived();
6022   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6023
6024   application.SendNotification();
6025   application.Render(static_cast<unsigned int>(durationSeconds*50.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.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6031   END_TEST;
6032 }
6033
6034 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
6035 {
6036   TestApplication application;
6037
6038   Actor actor = Actor::New();
6039
6040   // Register a Vector2 property
6041   Vector2 startValue(1000.0f, 1000.0f);
6042   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6043   Stage::GetCurrent().Add(actor);
6044   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6045   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6046
6047   // Build the animation
6048   float durationSeconds(1.0f);
6049   Animation animation = Animation::New(durationSeconds);
6050   Vector2 targetValue(9000.0f, 9000.0f);
6051   Vector2 relativeValue(targetValue - startValue);
6052   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
6053
6054   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6055
6056   // Start the animation
6057   animation.Play();
6058
6059   bool signalReceived(false);
6060   AnimationFinishCheck finishCheck(signalReceived);
6061   animation.FinishedSignal().Connect(&application, finishCheck);
6062
6063   application.SendNotification();
6064   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6065
6066   // We didn't expect the animation to finish yet
6067   application.SendNotification();
6068   finishCheck.CheckSignalNotReceived();
6069
6070   // The position should have moved more, than with a linear alpha function
6071   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
6072   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6073   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6074
6075   application.SendNotification();
6076   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6077
6078   // We did expect the animation to finish
6079   application.SendNotification();
6080   finishCheck.CheckSignalReceived();
6081   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6082   END_TEST;
6083 }
6084
6085 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
6086 {
6087   TestApplication application;
6088
6089   Actor actor = Actor::New();
6090
6091   // Register a Vector2 property
6092   Vector2 startValue(10.0f, 10.0f);
6093   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6094   Stage::GetCurrent().Add(actor);
6095   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6096   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6097
6098   // Build the animation
6099   float durationSeconds(1.0f);
6100   Animation animation = Animation::New(durationSeconds);
6101   Vector2 targetValue(-10.0f, 20.0f);
6102   Vector2 relativeValue(targetValue - startValue);
6103   float delay = 0.5f;
6104   animation.AnimateTo(Property(actor, index),
6105                       targetValue,
6106                       TimePeriod(delay, durationSeconds - delay));
6107
6108   // Start the animation
6109   animation.Play();
6110
6111   bool signalReceived(false);
6112   AnimationFinishCheck finishCheck(signalReceived);
6113   animation.FinishedSignal().Connect(&application, finishCheck);
6114
6115   application.SendNotification();
6116   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6117
6118   // We didn't expect the animation to finish yet
6119   application.SendNotification();
6120   finishCheck.CheckSignalNotReceived();
6121   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6122
6123   application.SendNotification();
6124   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6125
6126   // We didn't expect the animation to finish yet
6127   application.SendNotification();
6128   finishCheck.CheckSignalNotReceived();
6129   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6130
6131   application.SendNotification();
6132   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6133
6134   // We did expect the animation to finish
6135   application.SendNotification();
6136   finishCheck.CheckSignalReceived();
6137   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6138   END_TEST;
6139 }
6140
6141 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
6142 {
6143   TestApplication application;
6144
6145   Actor actor = Actor::New();
6146
6147   // Register a Vector2 property
6148   Vector2 startValue(10.0f, 10.0f);
6149   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6150   Stage::GetCurrent().Add(actor);
6151   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6152   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6153
6154   // Build the animation
6155   float durationSeconds(1.0f);
6156   Animation animation = Animation::New(durationSeconds);
6157   Vector2 targetValue(30.0f, 30.0f);
6158   Vector2 relativeValue(targetValue - startValue);
6159   float delay = 0.5f;
6160   animation.AnimateTo(Property(actor, index),
6161                       targetValue,
6162                       AlphaFunction::LINEAR,
6163                       TimePeriod(delay, durationSeconds - delay));
6164
6165   // Start the animation
6166   animation.Play();
6167
6168   bool signalReceived(false);
6169   AnimationFinishCheck finishCheck(signalReceived);
6170   animation.FinishedSignal().Connect(&application, finishCheck);
6171
6172   application.SendNotification();
6173   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6174
6175   // We didn't expect the animation to finish yet, but cached value should be the final one
6176   application.SendNotification();
6177   finishCheck.CheckSignalNotReceived();
6178   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6179   DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
6180
6181   application.SendNotification();
6182   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6183
6184   // We didn't expect the animation to finish yet
6185   application.SendNotification();
6186   finishCheck.CheckSignalNotReceived();
6187   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6188
6189   application.SendNotification();
6190   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6191
6192   // We did expect the animation to finish
6193   application.SendNotification();
6194   finishCheck.CheckSignalReceived();
6195   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6196   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6197   END_TEST;
6198 }
6199
6200 int UtcDaliAnimationAnimateToVector3P(void)
6201 {
6202   TestApplication application;
6203
6204   Actor actor = Actor::New();
6205
6206   // Register a Vector3 property
6207   Vector3 startValue(-50.0f, -50.0f, -50.0f);
6208   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6209   Stage::GetCurrent().Add(actor);
6210   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
6211   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6212
6213   // Build the animation
6214   float durationSeconds(2.0f);
6215   Animation animation = Animation::New(durationSeconds);
6216   Vector3 targetValue(50.0f, 50.0f, 50.0f);
6217   Vector3 relativeValue(targetValue - startValue);
6218   animation.AnimateTo(Property(actor, index), targetValue);
6219
6220   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6221
6222   // Start the animation
6223   animation.Play();
6224
6225   bool signalReceived(false);
6226   AnimationFinishCheck finishCheck(signalReceived);
6227   animation.FinishedSignal().Connect(&application, finishCheck);
6228
6229   application.SendNotification();
6230   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6231
6232   // We didn't expect the animation to finish yet
6233   application.SendNotification();
6234   finishCheck.CheckSignalNotReceived();
6235   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6236
6237   application.SendNotification();
6238   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6239
6240   // We did expect the animation to finish
6241   application.SendNotification();
6242   finishCheck.CheckSignalReceived();
6243   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6244   END_TEST;
6245 }
6246
6247 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
6248 {
6249   TestApplication application;
6250
6251   Actor actor = Actor::New();
6252
6253   // Register a Vector3 property
6254   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
6255   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6256   Stage::GetCurrent().Add(actor);
6257   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6258   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6259
6260   // Build the animation
6261   float durationSeconds(1.0f);
6262   Animation animation = Animation::New(durationSeconds);
6263   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
6264   Vector3 relativeValue(targetValue - startValue);
6265   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6266
6267   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6268
6269   // Start the animation
6270   animation.Play();
6271
6272   bool signalReceived(false);
6273   AnimationFinishCheck finishCheck(signalReceived);
6274   animation.FinishedSignal().Connect(&application, finishCheck);
6275
6276   application.SendNotification();
6277   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6278
6279   // We didn't expect the animation to finish yet
6280   application.SendNotification();
6281   finishCheck.CheckSignalNotReceived();
6282
6283   // The position should have moved more, than with a linear alpha function
6284   Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
6285   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6286   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6287   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6288
6289   application.SendNotification();
6290   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6291
6292   // We did expect the animation to finish
6293   application.SendNotification();
6294   finishCheck.CheckSignalReceived();
6295   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6296   END_TEST;
6297 }
6298
6299 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
6300 {
6301   TestApplication application;
6302
6303   Actor actor = Actor::New();
6304
6305   // Register a Vector3 property
6306   Vector3 startValue(10.0f, 10.0f, 10.0f);
6307   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6308   Stage::GetCurrent().Add(actor);
6309   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6310   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6311
6312   // Build the animation
6313   float durationSeconds(1.0f);
6314   Animation animation = Animation::New(durationSeconds);
6315   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
6316   Vector3 relativeValue(targetValue - startValue);
6317   float delay = 0.5f;
6318   animation.AnimateTo(Property(actor, index),
6319                       targetValue,
6320                       TimePeriod(delay, durationSeconds - delay));
6321
6322   // Start the animation
6323   animation.Play();
6324
6325   bool signalReceived(false);
6326   AnimationFinishCheck finishCheck(signalReceived);
6327   animation.FinishedSignal().Connect(&application, finishCheck);
6328
6329   application.SendNotification();
6330   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6331
6332   // We didn't expect the animation to finish yet
6333   application.SendNotification();
6334   finishCheck.CheckSignalNotReceived();
6335   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6336
6337   application.SendNotification();
6338   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6339
6340   // We didn't expect the animation to finish yet
6341   application.SendNotification();
6342   finishCheck.CheckSignalNotReceived();
6343   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6344
6345   application.SendNotification();
6346   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6347
6348   // We did expect the animation to finish
6349   application.SendNotification();
6350   finishCheck.CheckSignalReceived();
6351   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6352   END_TEST;
6353 }
6354
6355 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
6356 {
6357   TestApplication application;
6358
6359   Actor actor = Actor::New();
6360
6361   // Register a Vector3 property
6362   Vector3 startValue(10.0f, 10.0f, 10.0f);
6363   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6364   Stage::GetCurrent().Add(actor);
6365   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6366   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6367
6368   // Build the animation
6369   float durationSeconds(1.0f);
6370   Animation animation = Animation::New(durationSeconds);
6371   Vector3 targetValue(30.0f, 30.0f, 30.0f);
6372   Vector3 relativeValue(targetValue - startValue);
6373   float delay = 0.5f;
6374   animation.AnimateTo(Property(actor, "testProperty"),
6375                       targetValue,
6376                       AlphaFunction::LINEAR,
6377                       TimePeriod(delay, durationSeconds - delay));
6378
6379   // Start the animation
6380   animation.Play();
6381
6382   bool signalReceived(false);
6383   AnimationFinishCheck finishCheck(signalReceived);
6384   animation.FinishedSignal().Connect(&application, finishCheck);
6385
6386   application.SendNotification();
6387   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6388
6389   // We didn't expect the animation to finish yet
6390   application.SendNotification();
6391   finishCheck.CheckSignalNotReceived();
6392   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6393
6394   application.SendNotification();
6395   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6396
6397   // We didn't expect the animation to finish yet
6398   application.SendNotification();
6399   finishCheck.CheckSignalNotReceived();
6400   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6401
6402   application.SendNotification();
6403   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6404
6405   // We did expect the animation to finish
6406   application.SendNotification();
6407   finishCheck.CheckSignalReceived();
6408   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6409   END_TEST;
6410 }
6411
6412 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6413 {
6414   TestApplication application;
6415
6416   Actor actor = Actor::New();
6417
6418   // Register a Vector3 property
6419   Vector3 startValue(10.0f, 10.0f, 10.0f);
6420   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6421   Stage::GetCurrent().Add(actor);
6422   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6423   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6424
6425   // Build the animation
6426   float durationSeconds(1.0f);
6427   Animation animation = Animation::New(durationSeconds);
6428   Vector3 targetValue(30.0f, 30.0f, 10.0f);
6429   Vector3 relativeValue(targetValue - startValue);
6430   float delay = 0.5f;
6431   animation.AnimateTo(Property(actor, "testProperty",  0),
6432                       30.0f,
6433                       AlphaFunction::LINEAR,
6434                       TimePeriod(delay, durationSeconds - delay));
6435   animation.AnimateTo(Property(actor, index, 1),
6436                       30.0f,
6437                       AlphaFunction::LINEAR,
6438                       TimePeriod(delay, durationSeconds - delay));
6439
6440   // Start the animation
6441   animation.Play();
6442
6443   bool signalReceived(false);
6444   AnimationFinishCheck finishCheck(signalReceived);
6445   animation.FinishedSignal().Connect(&application, finishCheck);
6446
6447   application.SendNotification();
6448   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6449
6450   // We didn't expect the animation to finish yet
6451   application.SendNotification();
6452   finishCheck.CheckSignalNotReceived();
6453   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6454
6455   application.SendNotification();
6456   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6457
6458   // We didn't expect the animation to finish yet
6459   application.SendNotification();
6460   finishCheck.CheckSignalNotReceived();
6461   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6462
6463   application.SendNotification();
6464   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6465
6466   // We did expect the animation to finish
6467   application.SendNotification();
6468   finishCheck.CheckSignalReceived();
6469   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6470   END_TEST;
6471 }
6472
6473 int UtcDaliAnimationAnimateToVector4P(void)
6474 {
6475   TestApplication application;
6476
6477   Actor actor = Actor::New();
6478
6479   // Register a Vector4 property
6480   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6481   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6482   Stage::GetCurrent().Add(actor);
6483   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6484   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6485
6486   // Build the animation
6487   float durationSeconds(2.0f);
6488   Animation animation = Animation::New(durationSeconds);
6489   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6490   Vector4 relativeValue(targetValue - startValue);
6491   animation.AnimateTo(Property(actor, index), targetValue);
6492
6493   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6494
6495   // Start the animation
6496   animation.Play();
6497
6498   bool signalReceived(false);
6499   AnimationFinishCheck finishCheck(signalReceived);
6500   animation.FinishedSignal().Connect(&application, finishCheck);
6501
6502   application.SendNotification();
6503   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6504
6505   // We didn't expect the animation to finish yet
6506   application.SendNotification();
6507   finishCheck.CheckSignalNotReceived();
6508   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6509
6510   application.SendNotification();
6511   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6512
6513   // We did expect the animation to finish
6514   application.SendNotification();
6515   finishCheck.CheckSignalReceived();
6516   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6517   END_TEST;
6518 }
6519
6520 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6521 {
6522   TestApplication application;
6523
6524   Actor actor = Actor::New();
6525
6526   // Register a Vector4 property
6527   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6528   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6529   Stage::GetCurrent().Add(actor);
6530   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6531   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6532
6533   // Build the animation
6534   float durationSeconds(1.0f);
6535   Animation animation = Animation::New(durationSeconds);
6536   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6537   Vector4 relativeValue(targetValue - startValue);
6538   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6539
6540   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6541
6542   // Start the animation
6543   animation.Play();
6544
6545   bool signalReceived(false);
6546   AnimationFinishCheck finishCheck(signalReceived);
6547   animation.FinishedSignal().Connect(&application, finishCheck);
6548
6549   application.SendNotification();
6550   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6551
6552   // We didn't expect the animation to finish yet
6553   application.SendNotification();
6554   finishCheck.CheckSignalNotReceived();
6555
6556   // The position should have moved more, than with a linear alpha function
6557   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6558   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6559   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6560   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6561   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6562
6563   application.SendNotification();
6564   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6565
6566   // We did expect the animation to finish
6567   application.SendNotification();
6568   finishCheck.CheckSignalReceived();
6569   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6570   END_TEST;
6571 }
6572
6573 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6574 {
6575   TestApplication application;
6576
6577   Actor actor = Actor::New();
6578
6579   // Register a Vector4 property
6580   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6581   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6582   Stage::GetCurrent().Add(actor);
6583   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6584   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6585
6586   // Build the animation
6587   float durationSeconds(1.0f);
6588   Animation animation = Animation::New(durationSeconds);
6589   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6590   Vector4 relativeValue(targetValue - startValue);
6591   float delay = 0.5f;
6592   animation.AnimateTo(Property(actor, index),
6593                       targetValue,
6594                       TimePeriod(delay, durationSeconds - delay));
6595
6596   // Start the animation
6597   animation.Play();
6598
6599   bool signalReceived(false);
6600   AnimationFinishCheck finishCheck(signalReceived);
6601   animation.FinishedSignal().Connect(&application, finishCheck);
6602
6603   application.SendNotification();
6604   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6605
6606   // We didn't expect the animation to finish yet
6607   application.SendNotification();
6608   finishCheck.CheckSignalNotReceived();
6609   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6610
6611   application.SendNotification();
6612   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6613
6614   // We didn't expect the animation to finish yet
6615   application.SendNotification();
6616   finishCheck.CheckSignalNotReceived();
6617   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6618
6619   application.SendNotification();
6620   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6621
6622   // We did expect the animation to finish
6623   application.SendNotification();
6624   finishCheck.CheckSignalReceived();
6625   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6626   END_TEST;
6627 }
6628
6629 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6630 {
6631   TestApplication application;
6632
6633   Actor actor = Actor::New();
6634
6635   // Register a Vector4 property
6636   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6637   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6638   Stage::GetCurrent().Add(actor);
6639   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6640   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6641
6642   // Build the animation
6643   float durationSeconds(1.0f);
6644   Animation animation = Animation::New(durationSeconds);
6645   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6646   Vector4 relativeValue(targetValue - startValue);
6647   float delay = 0.5f;
6648   animation.AnimateTo(Property(actor, index),
6649                       targetValue,
6650                       AlphaFunction::LINEAR,
6651                       TimePeriod(delay, durationSeconds - delay));
6652
6653   // Start the animation
6654   animation.Play();
6655
6656   bool signalReceived(false);
6657   AnimationFinishCheck finishCheck(signalReceived);
6658   animation.FinishedSignal().Connect(&application, finishCheck);
6659
6660   application.SendNotification();
6661   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6662
6663   // We didn't expect the animation to finish yet
6664   application.SendNotification();
6665   finishCheck.CheckSignalNotReceived();
6666   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6667
6668   application.SendNotification();
6669   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6670
6671   // We didn't expect the animation to finish yet
6672   application.SendNotification();
6673   finishCheck.CheckSignalNotReceived();
6674   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6675
6676   application.SendNotification();
6677   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6678
6679   // We did expect the animation to finish
6680   application.SendNotification();
6681   finishCheck.CheckSignalReceived();
6682   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6683   END_TEST;
6684 }
6685
6686 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6687 {
6688   TestApplication application;
6689
6690   Actor actor = Actor::New();
6691   Stage::GetCurrent().Add(actor);
6692   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6693
6694   // Build the animation
6695   float durationSeconds(1.0f);
6696   Animation animation = Animation::New(durationSeconds);
6697   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6698
6699   DALI_TEST_ASSERTION(
6700   {
6701     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6702   }, "IsPropertyAnimatable( index )" );
6703
6704   END_TEST;
6705 }
6706
6707 int UtcDaliAnimationAnimateToActorParentOriginXN(void)
6708 {
6709   TestApplication application;
6710
6711   Actor actor = Actor::New();
6712   Stage::GetCurrent().Add(actor);
6713   float startValue(0.0f);
6714   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6715   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6716
6717   // Build the animation
6718   float durationSeconds(1.0f);
6719   Animation animation = Animation::New(durationSeconds);
6720   float targetX(1.0f);
6721
6722   DALI_TEST_ASSERTION(
6723   {
6724     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6725   }, "IsPropertyAnimatable( index )" );
6726
6727   END_TEST;
6728 }
6729
6730 int UtcDaliAnimationAnimateToActorParentOriginYN(void)
6731 {
6732   TestApplication application;
6733
6734   Actor actor = Actor::New();
6735   Stage::GetCurrent().Add(actor);
6736   float startValue(0.0f);
6737   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6738   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6739
6740   // Build the animation
6741   float durationSeconds(1.0f);
6742   Animation animation = Animation::New(durationSeconds);
6743   float targetY(1.0f);
6744
6745   DALI_TEST_ASSERTION(
6746   {
6747     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6748   }, "IsPropertyAnimatable( index )" );
6749
6750   END_TEST;
6751 }
6752
6753 int UtcDaliAnimationAnimateToActorParentOriginZN(void)
6754 {
6755   TestApplication application;
6756
6757   Actor actor = Actor::New();
6758   Stage::GetCurrent().Add(actor);
6759   float startValue(0.5f);
6760   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6761   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6762
6763   // Build the animation
6764   float durationSeconds(1.0f);
6765   Animation animation = Animation::New(durationSeconds);
6766   float targetZ(1.0f);
6767
6768   DALI_TEST_ASSERTION(
6769   {
6770     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6771   }, "IsPropertyAnimatable( index )" );
6772
6773   END_TEST;
6774 }
6775
6776 int UtcDaliAnimationAnimateToActorAnchorPointN(void)
6777 {
6778   TestApplication application;
6779
6780   Actor actor = Actor::New();
6781   Stage::GetCurrent().Add(actor);
6782   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6783
6784   // Build the animation
6785   float durationSeconds(1.0f);
6786   Animation animation = Animation::New(durationSeconds);
6787   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6788
6789   DALI_TEST_ASSERTION(
6790   {
6791     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6792   }, "IsPropertyAnimatable( index )" );
6793
6794   END_TEST;
6795 }
6796
6797 int UtcDaliAnimationAnimateToActorAnchorPointXN(void)
6798 {
6799   TestApplication application;
6800
6801   Actor actor = Actor::New();
6802   Stage::GetCurrent().Add(actor);
6803   float startValue(0.5f);
6804   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6805   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6806
6807   // Build the animation
6808   float durationSeconds(1.0f);
6809   Animation animation = Animation::New(durationSeconds);
6810   float targetX(1.0f);
6811
6812   DALI_TEST_ASSERTION(
6813   {
6814     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6815   }, "IsPropertyAnimatable( index )" );
6816
6817   END_TEST;
6818 }
6819
6820 int UtcDaliAnimationAnimateToActorAnchorPointYN(void)
6821 {
6822   TestApplication application;
6823
6824   Actor actor = Actor::New();
6825   Stage::GetCurrent().Add(actor);
6826   float startValue(0.5f);
6827   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6828   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6829
6830   // Build the animation
6831   float durationSeconds(1.0f);
6832   Animation animation = Animation::New(durationSeconds);
6833   float targetY(0.0f);
6834
6835   DALI_TEST_ASSERTION(
6836   {
6837     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6838   }, "IsPropertyAnimatable( index )" );
6839
6840   END_TEST;
6841 }
6842
6843 int UtcDaliAnimationAnimateToActorAnchorPointZN(void)
6844 {
6845   TestApplication application;
6846
6847   Actor actor = Actor::New();
6848   Stage::GetCurrent().Add(actor);
6849   float startValue(0.5f);
6850   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6851   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6852
6853   // Build the animation
6854   float durationSeconds(1.0f);
6855   Animation animation = Animation::New(durationSeconds);
6856   float targetZ(100.0f);
6857
6858   DALI_TEST_ASSERTION(
6859   {
6860     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6861   }, "IsPropertyAnimatable( index )" );
6862
6863   END_TEST;
6864 }
6865
6866 int UtcDaliAnimationAnimateToActorSizeP(void)
6867 {
6868   TestApplication application;
6869
6870   Actor actor = Actor::New();
6871   Stage::GetCurrent().Add(actor);
6872   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6873
6874   // Build the animation
6875   float durationSeconds(1.0f);
6876   Animation animation = Animation::New(durationSeconds);
6877   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6878   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6879
6880   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6881
6882   // Should return the initial properties before play
6883   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6884   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6885   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6886   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6887
6888   // Start the animation
6889   animation.Play();
6890
6891   // Should return the target property after play
6892   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6893   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6894   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6895   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6896
6897   bool signalReceived(false);
6898   AnimationFinishCheck finishCheck(signalReceived);
6899   animation.FinishedSignal().Connect(&application, finishCheck);
6900
6901   application.SendNotification();
6902   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6903
6904   // We didn't expect the animation to finish yet
6905   application.SendNotification();
6906   finishCheck.CheckSignalNotReceived();
6907   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6908
6909   application.SendNotification();
6910   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6911
6912   // We did expect the animation to finish
6913   application.SendNotification();
6914   finishCheck.CheckSignalReceived();
6915   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6916
6917   // Reset everything
6918   finishCheck.Reset();
6919   actor.SetSize(Vector3::ZERO);
6920   application.SendNotification();
6921   application.Render(0);
6922   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6923
6924   // Repeat with a different (ease-in) alpha function
6925   animation = Animation::New(durationSeconds);
6926   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6927   animation.FinishedSignal().Connect(&application, finishCheck);
6928   animation.Play();
6929
6930   application.SendNotification();
6931   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6932
6933   // We didn't expect the animation to finish yet
6934   application.SendNotification();
6935   finishCheck.CheckSignalNotReceived();
6936
6937   // The size should have travelled less, than with a linear alpha function
6938   Vector3 current(actor.GetCurrentSize());
6939   DALI_TEST_CHECK( current.x > 0.0f );
6940   DALI_TEST_CHECK( current.y > 0.0f );
6941   DALI_TEST_CHECK( current.z > 0.0f );
6942   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6943   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6944   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6945
6946   application.SendNotification();
6947   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6948
6949   // We did expect the animation to finish
6950   application.SendNotification();
6951   finishCheck.CheckSignalReceived();
6952   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6953
6954   // Reset everything
6955   finishCheck.Reset();
6956   actor.SetSize(Vector3::ZERO);
6957   application.SendNotification();
6958   application.Render(0);
6959   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6960
6961   // Repeat with a delay
6962   float delay = 0.5f;
6963   animation = Animation::New(durationSeconds);
6964   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6965   animation.FinishedSignal().Connect(&application, finishCheck);
6966   animation.Play();
6967
6968   application.SendNotification();
6969   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6970
6971   // We didn't expect the animation to finish yet
6972   application.SendNotification();
6973   finishCheck.CheckSignalNotReceived();
6974   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6975
6976   application.SendNotification();
6977   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6978
6979   // We did expect the animation to finish
6980   application.SendNotification();
6981   finishCheck.CheckSignalReceived();
6982   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6983   END_TEST;
6984 }
6985
6986 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6987 {
6988   TestApplication application;
6989
6990   Actor actor = Actor::New();
6991   Stage::GetCurrent().Add(actor);
6992   float startValue(0.0f);
6993   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6994   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6995
6996   // Build the animation
6997   float durationSeconds(1.0f);
6998   Animation animation = Animation::New(durationSeconds);
6999   float targetWidth(10.0f);
7000   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
7001
7002   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
7003
7004   // Should return the initial properties before play
7005   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7006   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
7007
7008   // Start the animation
7009   animation.Play();
7010
7011   // Should return the target property after play
7012   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
7013   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
7014
7015   bool signalReceived(false);
7016   AnimationFinishCheck finishCheck(signalReceived);
7017   animation.FinishedSignal().Connect(&application, finishCheck);
7018
7019   application.SendNotification();
7020   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7021
7022   // We didn't expect the animation to finish yet
7023   application.SendNotification();
7024   finishCheck.CheckSignalNotReceived();
7025   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
7026
7027   application.SendNotification();
7028   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7029
7030   // We did expect the animation to finish
7031   application.SendNotification();
7032   finishCheck.CheckSignalReceived();
7033   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
7034   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7035   END_TEST;
7036 }
7037
7038 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7039 {
7040   TestApplication application;
7041
7042   Actor actor = Actor::New();
7043   Stage::GetCurrent().Add(actor);
7044   float startValue(0.0f);
7045   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
7046   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7047
7048   // Build the animation
7049   float durationSeconds(1.0f);
7050   Animation animation = Animation::New(durationSeconds);
7051   float targetHeight(-10.0f);
7052   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7053
7054   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7055
7056   // Should return the initial properties before play
7057   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7058   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7059
7060   // Start the animation
7061   animation.Play();
7062
7063   // Should return the target property after play
7064   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7065   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7066
7067   bool signalReceived(false);
7068   AnimationFinishCheck finishCheck(signalReceived);
7069   animation.FinishedSignal().Connect(&application, finishCheck);
7070
7071   application.SendNotification();
7072   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7073
7074   // We didn't expect the animation to finish yet
7075   application.SendNotification();
7076   finishCheck.CheckSignalNotReceived();
7077   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
7078
7079   application.SendNotification();
7080   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7081
7082   // We did expect the animation to finish
7083   application.SendNotification();
7084   finishCheck.CheckSignalReceived();
7085   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
7086   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7087   END_TEST;
7088 }
7089
7090 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7091 {
7092   TestApplication application;
7093
7094   Actor actor = Actor::New();
7095   Stage::GetCurrent().Add(actor);
7096   float startValue(0.0f);
7097   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
7098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7099
7100   // Build the animation
7101   float durationSeconds(1.0f);
7102   Animation animation = Animation::New(durationSeconds);
7103   float targetDepth(-10.0f);
7104   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7105
7106   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7107
7108   // Should return the initial properties before play
7109   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7110   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7111
7112   // Start the animation
7113   animation.Play();
7114
7115   // Should return the target property after play
7116   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7117   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7118
7119   bool signalReceived(false);
7120   AnimationFinishCheck finishCheck(signalReceived);
7121   animation.FinishedSignal().Connect(&application, finishCheck);
7122
7123   application.SendNotification();
7124   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7125
7126   // We didn't expect the animation to finish yet
7127   application.SendNotification();
7128   finishCheck.CheckSignalNotReceived();
7129   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
7130
7131   application.SendNotification();
7132   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7133
7134   // We did expect the animation to finish
7135   application.SendNotification();
7136   finishCheck.CheckSignalReceived();
7137   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
7138   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7139   END_TEST;
7140 }
7141
7142 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7143 {
7144   TestApplication application;
7145
7146   Actor actor = Actor::New();
7147   Stage::GetCurrent().Add(actor);
7148   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7149
7150   // Build the animation
7151   float durationSeconds(1.0f);
7152   Animation animation = Animation::New(durationSeconds);
7153   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7154   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7155
7156   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7157
7158   // Start the animation
7159   animation.Play();
7160
7161   bool signalReceived(false);
7162   AnimationFinishCheck finishCheck(signalReceived);
7163   animation.FinishedSignal().Connect(&application, finishCheck);
7164
7165   application.SendNotification();
7166   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7167
7168   // We didn't expect the animation to finish yet
7169   application.SendNotification();
7170   finishCheck.CheckSignalNotReceived();
7171   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
7172
7173   application.SendNotification();
7174   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7175
7176   // We did expect the animation to finish
7177   application.SendNotification();
7178   finishCheck.CheckSignalReceived();
7179   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7180
7181   // Reset everything
7182   finishCheck.Reset();
7183   actor.SetSize(Vector3::ZERO);
7184   application.SendNotification();
7185   application.Render(0);
7186   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7187
7188   // Repeat with a different (ease-in) alpha function
7189   animation = Animation::New(durationSeconds);
7190   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7191   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7192   animation.FinishedSignal().Connect(&application, finishCheck);
7193   animation.Play();
7194
7195   application.SendNotification();
7196   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7197
7198   // We didn't expect the animation to finish yet
7199   application.SendNotification();
7200   finishCheck.CheckSignalNotReceived();
7201
7202   // The size should have travelled less, than with a linear alpha function
7203   Vector3 current(actor.GetCurrentSize());
7204   DALI_TEST_CHECK( current.x > 0.0f );
7205   DALI_TEST_CHECK( current.y > 0.0f );
7206   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7207   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7208
7209   application.SendNotification();
7210   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7211
7212   // We did expect the animation to finish
7213   application.SendNotification();
7214   finishCheck.CheckSignalReceived();
7215   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7216   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7217
7218   // Reset everything
7219   finishCheck.Reset();
7220   actor.SetSize(Vector3::ZERO);
7221   application.SendNotification();
7222   application.Render(0);
7223   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7224
7225   // Repeat with a delay
7226   float delay = 0.5f;
7227   animation = Animation::New(durationSeconds);
7228   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7229   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7230   animation.FinishedSignal().Connect(&application, finishCheck);
7231   animation.Play();
7232
7233   application.SendNotification();
7234   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7235
7236   // We didn't expect the animation to finish yet
7237   application.SendNotification();
7238   finishCheck.CheckSignalNotReceived();
7239   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7240
7241   application.SendNotification();
7242   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7243
7244   // We did expect the animation to finish
7245   application.SendNotification();
7246   finishCheck.CheckSignalReceived();
7247   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7248   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7249   END_TEST;
7250 }
7251
7252 int UtcDaliAnimationAnimateToActorPositionP(void)
7253 {
7254   TestApplication application;
7255
7256   Actor actor = Actor::New();
7257   Stage::GetCurrent().Add(actor);
7258   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7259
7260   // Build the animation
7261   float durationSeconds(1.0f);
7262   Animation animation = Animation::New(durationSeconds);
7263   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7264   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7265
7266   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7267
7268   // Should return the initial properties before play
7269   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7270   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7271   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7272   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7273
7274   // Start the animation
7275   animation.Play();
7276
7277   // Should return the target property after play
7278   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7279   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7280   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7281   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
7282
7283   bool signalReceived(false);
7284   AnimationFinishCheck finishCheck(signalReceived);
7285   animation.FinishedSignal().Connect(&application, finishCheck);
7286
7287   application.SendNotification();
7288   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7289
7290   // We didn't expect the animation to finish yet
7291   application.SendNotification();
7292   finishCheck.CheckSignalNotReceived();
7293   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7294
7295   application.SendNotification();
7296   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7297
7298   // We did expect the animation to finish
7299   application.SendNotification();
7300   finishCheck.CheckSignalReceived();
7301   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7302   END_TEST;
7303 }
7304
7305 int UtcDaliAnimationAnimateToActorPositionXP(void)
7306 {
7307   TestApplication application;
7308
7309   Actor actor = Actor::New();
7310   Stage::GetCurrent().Add(actor);
7311   float startValue(0.0f);
7312   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
7313   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7314   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7315   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7316
7317   // Build the animation
7318   float durationSeconds(1.0f);
7319   Animation animation = Animation::New(durationSeconds);
7320   float targetX(1.0f);
7321   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7322
7323   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7324
7325   // Should return the initial properties before play
7326   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7327   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7328
7329   // Start the animation
7330   animation.Play();
7331
7332   // Should return the target property after play
7333   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7334   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
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*500.0f)/* 50% progress */);
7342
7343   // We didn't expect the animation to finish yet
7344   application.SendNotification();
7345   finishCheck.CheckSignalNotReceived();
7346   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
7347
7348   application.SendNotification();
7349   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7350
7351   // We did expect the animation to finish
7352   application.SendNotification();
7353   finishCheck.CheckSignalReceived();
7354   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
7355   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7356   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7357   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7358   END_TEST;
7359 }
7360
7361 int UtcDaliAnimationAnimateToActorPositionYP(void)
7362 {
7363   TestApplication application;
7364
7365   Actor actor = Actor::New();
7366   Stage::GetCurrent().Add(actor);
7367   float startValue(0.0f);
7368   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7369   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7370   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7371   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7372
7373   // Build the animation
7374   float durationSeconds(1.0f);
7375   Animation animation = Animation::New(durationSeconds);
7376   float targetY(10.0f);
7377   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7378
7379   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7380
7381   // Should return the initial properties before play
7382   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7383   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7384
7385   // Start the animation
7386   animation.Play();
7387
7388   // Should return the target property after play
7389   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7390   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7391
7392   bool signalReceived(false);
7393   AnimationFinishCheck finishCheck(signalReceived);
7394   animation.FinishedSignal().Connect(&application, finishCheck);
7395
7396   application.SendNotification();
7397   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7398
7399   // We didn't expect the animation to finish yet
7400   application.SendNotification();
7401   finishCheck.CheckSignalNotReceived();
7402   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7403
7404   application.SendNotification();
7405   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7406
7407   // We did expect the animation to finish
7408   application.SendNotification();
7409   finishCheck.CheckSignalReceived();
7410   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7411   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7412   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7413   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7414   END_TEST;
7415 }
7416
7417 int UtcDaliAnimationAnimateToActorPositionZP(void)
7418 {
7419   TestApplication application;
7420
7421   Actor actor = Actor::New();
7422   Stage::GetCurrent().Add(actor);
7423   float startValue(0.0f);
7424   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7425   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7426   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7427   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7428
7429   // Build the animation
7430   float durationSeconds(1.0f);
7431   Animation animation = Animation::New(durationSeconds);
7432   float targetZ(-5.0f);
7433   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7434
7435   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7436
7437   // Should return the initial properties before play
7438   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7439   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7440
7441   // Start the animation
7442   animation.Play();
7443
7444   // Should return the target property after play
7445   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7446   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7447
7448   bool signalReceived(false);
7449   AnimationFinishCheck finishCheck(signalReceived);
7450   animation.FinishedSignal().Connect(&application, finishCheck);
7451
7452   application.SendNotification();
7453   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7454
7455   // We didn't expect the animation to finish yet
7456   application.SendNotification();
7457   finishCheck.CheckSignalNotReceived();
7458   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7459
7460   application.SendNotification();
7461   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7462
7463   // We did expect the animation to finish
7464   application.SendNotification();
7465   finishCheck.CheckSignalReceived();
7466   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7467   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7468   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7469   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7470   END_TEST;
7471 }
7472
7473 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7474 {
7475   TestApplication application;
7476
7477   Actor actor = Actor::New();
7478   Stage::GetCurrent().Add(actor);
7479   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7480
7481   // Build the animation
7482   float durationSeconds(1.0f);
7483   Animation animation = Animation::New(durationSeconds);
7484   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7485   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7486
7487   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7488
7489   // Start the animation
7490   animation.Play();
7491
7492   bool signalReceived(false);
7493   AnimationFinishCheck finishCheck(signalReceived);
7494   animation.FinishedSignal().Connect(&application, finishCheck);
7495
7496   application.SendNotification();
7497   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7498
7499   // We didn't expect the animation to finish yet
7500   application.SendNotification();
7501   finishCheck.CheckSignalNotReceived();
7502
7503   // The position should have moved less, than with a linear alpha function
7504   Vector3 current(actor.GetCurrentPosition());
7505   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7506   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7507   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7508   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7509   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7510   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7511
7512   application.SendNotification();
7513   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7514
7515   // We did expect the animation to finish
7516   application.SendNotification();
7517   finishCheck.CheckSignalReceived();
7518   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7519   END_TEST;
7520 }
7521
7522 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7523 {
7524   TestApplication application;
7525
7526   Actor actor = Actor::New();
7527   Stage::GetCurrent().Add(actor);
7528   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7529
7530   // Build the animation
7531   float durationSeconds(1.0f);
7532   Animation animation = Animation::New(durationSeconds);
7533   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7534   float delay = 0.5f;
7535   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7536                        targetPosition,
7537                        TimePeriod( delay, durationSeconds - delay ) );
7538
7539   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7540
7541   // Start the animation
7542   animation.Play();
7543
7544   bool signalReceived(false);
7545   AnimationFinishCheck finishCheck(signalReceived);
7546   animation.FinishedSignal().Connect(&application, finishCheck);
7547
7548   application.SendNotification();
7549   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7550
7551   // We didn't expect the animation to finish yet
7552   application.SendNotification();
7553   finishCheck.CheckSignalNotReceived();
7554   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7555
7556   application.SendNotification();
7557   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7558
7559   // We didn't expect the animation to finish yet
7560   application.SendNotification();
7561   finishCheck.CheckSignalNotReceived();
7562   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7563
7564   application.SendNotification();
7565   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7566
7567   // We did expect the animation to finish
7568   application.SendNotification();
7569   finishCheck.CheckSignalReceived();
7570   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7571   END_TEST;
7572 }
7573
7574 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7575 {
7576   TestApplication application;
7577
7578   Actor actor = Actor::New();
7579   Stage::GetCurrent().Add(actor);
7580   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7581
7582   // Build the animation
7583   float durationSeconds(1.0f);
7584   Animation animation = Animation::New(durationSeconds);
7585   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7586   float delay = 0.5f;
7587   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7588                        targetPosition,
7589                        AlphaFunction::LINEAR,
7590                        TimePeriod( delay, durationSeconds - delay ) );
7591
7592   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7593
7594   // Start the animation
7595   animation.Play();
7596
7597   bool signalReceived(false);
7598   AnimationFinishCheck finishCheck(signalReceived);
7599   animation.FinishedSignal().Connect(&application, finishCheck);
7600
7601   application.SendNotification();
7602   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7603
7604   // We didn't expect the animation to finish yet
7605   application.SendNotification();
7606   finishCheck.CheckSignalNotReceived();
7607   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7608
7609   application.SendNotification();
7610   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7611
7612   // We didn't expect the animation to finish yet
7613   application.SendNotification();
7614   finishCheck.CheckSignalNotReceived();
7615   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7616
7617   application.SendNotification();
7618   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7619
7620   // We did expect the animation to finish
7621   application.SendNotification();
7622   finishCheck.CheckSignalReceived();
7623   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7624   END_TEST;
7625 }
7626
7627 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7628 {
7629   TestApplication application;
7630
7631   Actor actor = Actor::New();
7632   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7633   Stage::GetCurrent().Add(actor);
7634   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7635
7636   // Build the animation
7637   float durationSeconds(1.0f);
7638   Animation animation = Animation::New(durationSeconds);
7639   Degree targetRotationDegrees(90.0f);
7640   Radian targetRotationRadians(targetRotationDegrees);
7641   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7642
7643   // Start the animation
7644   animation.Play();
7645
7646   // Target value should be retrievable straight away
7647   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7648
7649   bool signalReceived(false);
7650   AnimationFinishCheck finishCheck(signalReceived);
7651   animation.FinishedSignal().Connect(&application, finishCheck);
7652
7653   application.SendNotification();
7654   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7655
7656   // We didn't expect the animation to finish yet
7657   application.SendNotification();
7658   finishCheck.CheckSignalNotReceived();
7659   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7660
7661   application.SendNotification();
7662   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7663
7664   // We didn't expect the animation to finish yet
7665   application.SendNotification();
7666   finishCheck.CheckSignalNotReceived();
7667   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7668
7669   application.SendNotification();
7670   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7671
7672   // We didn't expect the animation to finish yet
7673   application.SendNotification();
7674   finishCheck.CheckSignalNotReceived();
7675   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7676
7677   application.SendNotification();
7678   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7679
7680   // We did expect the animation to finish
7681   application.SendNotification();
7682   finishCheck.CheckSignalReceived();
7683   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7684   END_TEST;
7685 }
7686
7687 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7688 {
7689   TestApplication application;
7690
7691   Actor actor = Actor::New();
7692   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7693   Stage::GetCurrent().Add(actor);
7694   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7695
7696   // Build the animation
7697   float durationSeconds(1.0f);
7698   Animation animation = Animation::New(durationSeconds);
7699   Degree targetRotationDegrees(90.0f);
7700   Radian targetRotationRadians(targetRotationDegrees);
7701   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7702   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7703
7704   // Start the animation
7705   animation.Play();
7706
7707   bool signalReceived(false);
7708   AnimationFinishCheck finishCheck(signalReceived);
7709   animation.FinishedSignal().Connect(&application, finishCheck);
7710
7711   application.SendNotification();
7712   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7713
7714   // We didn't expect the animation to finish yet
7715   application.SendNotification();
7716   finishCheck.CheckSignalNotReceived();
7717   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7718
7719   application.SendNotification();
7720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7721
7722   // We didn't expect the animation to finish yet
7723   application.SendNotification();
7724   finishCheck.CheckSignalNotReceived();
7725   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7726
7727   application.SendNotification();
7728   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7729
7730   // We didn't expect the animation to finish yet
7731   application.SendNotification();
7732   finishCheck.CheckSignalNotReceived();
7733   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7734
7735   application.SendNotification();
7736   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7737
7738   // We did expect the animation to finish
7739   application.SendNotification();
7740   finishCheck.CheckSignalReceived();
7741   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7742   END_TEST;
7743 }
7744
7745 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7746 {
7747   TestApplication application;
7748
7749   Actor actor = Actor::New();
7750   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7751   Stage::GetCurrent().Add(actor);
7752   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7753
7754   // Build the animation
7755   float durationSeconds(1.0f);
7756   Animation animation = Animation::New(durationSeconds);
7757   Degree targetRotationDegrees(90.0f);
7758   Radian targetRotationRadians(targetRotationDegrees);
7759   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7760
7761   // Start the animation
7762   animation.Play();
7763
7764   bool signalReceived(false);
7765   AnimationFinishCheck finishCheck(signalReceived);
7766   animation.FinishedSignal().Connect(&application, finishCheck);
7767
7768   application.SendNotification();
7769   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7770
7771   // We didn't expect the animation to finish yet
7772   application.SendNotification();
7773   finishCheck.CheckSignalNotReceived();
7774   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7775
7776   application.SendNotification();
7777   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7778
7779   // We didn't expect the animation to finish yet
7780   application.SendNotification();
7781   finishCheck.CheckSignalNotReceived();
7782   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7783
7784   application.SendNotification();
7785   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7786
7787   // We didn't expect the animation to finish yet
7788   application.SendNotification();
7789   finishCheck.CheckSignalNotReceived();
7790   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7791
7792   application.SendNotification();
7793   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7794
7795   // We did expect the animation to finish
7796   application.SendNotification();
7797   finishCheck.CheckSignalReceived();
7798   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7799   END_TEST;
7800 }
7801
7802 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7803 {
7804   TestApplication application;
7805
7806   Actor actor = Actor::New();
7807   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7808   Stage::GetCurrent().Add(actor);
7809   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7810
7811   // Build the animation
7812   float durationSeconds(1.0f);
7813   Animation animation = Animation::New(durationSeconds);
7814   Degree targetRotationDegrees(90.0f);
7815   Radian targetRotationRadians(targetRotationDegrees);
7816   float delay(0.1f);
7817   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7818
7819   // Start the animation
7820   animation.Play();
7821
7822   bool signalReceived(false);
7823   AnimationFinishCheck finishCheck(signalReceived);
7824   animation.FinishedSignal().Connect(&application, finishCheck);
7825
7826   application.SendNotification();
7827   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7828
7829   // We didn't expect the animation to finish yet
7830   application.SendNotification();
7831   finishCheck.CheckSignalNotReceived();
7832   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7833   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7834
7835   application.SendNotification();
7836   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7837
7838   // We didn't expect the animation to finish yet
7839   application.SendNotification();
7840   finishCheck.CheckSignalNotReceived();
7841   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7842   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7843
7844   application.SendNotification();
7845   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7846
7847   // We didn't expect the animation to finish yet
7848   application.SendNotification();
7849   finishCheck.CheckSignalNotReceived();
7850   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7851   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7852
7853   application.SendNotification();
7854   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7855
7856   // We did expect the animation to finish
7857   application.SendNotification();
7858   finishCheck.CheckSignalReceived();
7859   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7860   END_TEST;
7861 }
7862
7863 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7864 {
7865   TestApplication application;
7866
7867   Actor actor = Actor::New();
7868   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7869   Stage::GetCurrent().Add(actor);
7870   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7871
7872   // Build the animation
7873   float durationSeconds(1.0f);
7874   Animation animation = Animation::New(durationSeconds);
7875   Degree targetRotationDegrees(90.0f);
7876   Radian targetRotationRadians(targetRotationDegrees);
7877   float delay(0.1f);
7878   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7879
7880   // Start the animation
7881   animation.Play();
7882
7883   bool signalReceived(false);
7884   AnimationFinishCheck finishCheck(signalReceived);
7885   animation.FinishedSignal().Connect(&application, finishCheck);
7886
7887   application.SendNotification();
7888   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7889
7890   // We didn't expect the animation to finish yet
7891   application.SendNotification();
7892   finishCheck.CheckSignalNotReceived();
7893   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7894   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7895
7896   application.SendNotification();
7897   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7898
7899   // We didn't expect the animation to finish yet
7900   application.SendNotification();
7901   finishCheck.CheckSignalNotReceived();
7902   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7903   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7904
7905   application.SendNotification();
7906   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7907
7908   // We didn't expect the animation to finish yet
7909   application.SendNotification();
7910   finishCheck.CheckSignalNotReceived();
7911   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7912   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7913
7914   application.SendNotification();
7915   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7916
7917   // We did expect the animation to finish
7918   application.SendNotification();
7919   finishCheck.CheckSignalReceived();
7920   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7921   END_TEST;
7922 }
7923
7924 int UtcDaliAnimationAnimateToActorScaleP(void)
7925 {
7926   TestApplication application;
7927
7928   Actor actor = Actor::New();
7929   Stage::GetCurrent().Add(actor);
7930   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7931
7932   // Build the animation
7933   float durationSeconds(1.0f);
7934   Animation animation = Animation::New(durationSeconds);
7935   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7936   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7937
7938   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7939
7940   // Start the animation
7941   animation.Play();
7942
7943   // Target value should be retrievable straight away
7944   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7945   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7946   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7947   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
7948
7949   bool signalReceived(false);
7950   AnimationFinishCheck finishCheck(signalReceived);
7951   animation.FinishedSignal().Connect(&application, finishCheck);
7952
7953   application.SendNotification();
7954   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7955
7956   // We didn't expect the animation to finish yet
7957   application.SendNotification();
7958   finishCheck.CheckSignalNotReceived();
7959   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7960
7961   application.SendNotification();
7962   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7963
7964   // We did expect the animation to finish
7965   application.SendNotification();
7966   finishCheck.CheckSignalReceived();
7967   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7968
7969   // Reset everything
7970   finishCheck.Reset();
7971   actor.SetScale(Vector3::ONE);
7972   application.SendNotification();
7973   application.Render(0);
7974   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7975
7976   // Repeat with a different (ease-in) alpha function
7977   animation = Animation::New(durationSeconds);
7978   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7979   animation.FinishedSignal().Connect(&application, finishCheck);
7980   animation.Play();
7981
7982   application.SendNotification();
7983   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7984
7985   // We didn't expect the animation to finish yet
7986   application.SendNotification();
7987   finishCheck.CheckSignalNotReceived();
7988
7989   // The scale should have grown less, than with a linear alpha function
7990   Vector3 current(actor.GetCurrentScale());
7991   DALI_TEST_CHECK( current.x > 1.0f );
7992   DALI_TEST_CHECK( current.y > 1.0f );
7993   DALI_TEST_CHECK( current.z > 1.0f );
7994   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7995   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7996   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7997
7998   application.SendNotification();
7999   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8000
8001   // We did expect the animation to finish
8002   application.SendNotification();
8003   finishCheck.CheckSignalReceived();
8004   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8005
8006   // Reset everything
8007   finishCheck.Reset();
8008   actor.SetScale(Vector3::ONE);
8009   application.SendNotification();
8010   application.Render(0);
8011   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8012
8013   // Repeat with a delay
8014   float delay = 0.5f;
8015   animation = Animation::New(durationSeconds);
8016   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
8017   animation.FinishedSignal().Connect(&application, finishCheck);
8018   animation.Play();
8019
8020   application.SendNotification();
8021   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8022
8023   // We didn't expect the animation to finish yet
8024   application.SendNotification();
8025   finishCheck.CheckSignalNotReceived();
8026   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8027
8028   application.SendNotification();
8029   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8030
8031   // We did expect the animation to finish
8032   application.SendNotification();
8033   finishCheck.CheckSignalReceived();
8034   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8035   END_TEST;
8036 }
8037
8038 int UtcDaliAnimationAnimateToActorScaleXP(void)
8039 {
8040   TestApplication application;
8041
8042   Actor actor = Actor::New();
8043   Stage::GetCurrent().Add(actor);
8044   float startValue(1.0f);
8045   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
8046   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8047   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8048   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8049   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8050   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8051   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8052
8053   // Build the animation
8054   float durationSeconds(1.0f);
8055   Animation animation = Animation::New(durationSeconds);
8056   float targetX(10.0f);
8057   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8058
8059   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8060
8061   // Start the animation
8062   animation.Play();
8063
8064   // Target value should be retrievable straight away
8065   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8066   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8067
8068   bool signalReceived(false);
8069   AnimationFinishCheck finishCheck(signalReceived);
8070   animation.FinishedSignal().Connect(&application, finishCheck);
8071
8072   application.SendNotification();
8073   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8074
8075   // We didn't expect the animation to finish yet
8076   application.SendNotification();
8077   finishCheck.CheckSignalNotReceived();
8078   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
8079   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8080   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8081   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8082
8083   application.SendNotification();
8084   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8085
8086   // We did expect the animation to finish
8087   application.SendNotification();
8088   finishCheck.CheckSignalReceived();
8089   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
8090   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8091   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8092   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8093   END_TEST;
8094 }
8095
8096 int UtcDaliAnimationAnimateToActorScaleYP(void)
8097 {
8098   TestApplication application;
8099
8100   Actor actor = Actor::New();
8101   Stage::GetCurrent().Add(actor);
8102   float startValue(1.0f);
8103   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
8104   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8105   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8106   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8107   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8108   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8109   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8110
8111   // Build the animation
8112   float durationSeconds(1.0f);
8113   Animation animation = Animation::New(durationSeconds);
8114   float targetY(1000.0f);
8115   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8116
8117   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8118
8119   // Start the animation
8120   animation.Play();
8121
8122   // Target value should be retrievable straight away
8123   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8124   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8125
8126   bool signalReceived(false);
8127   AnimationFinishCheck finishCheck(signalReceived);
8128   animation.FinishedSignal().Connect(&application, finishCheck);
8129
8130   application.SendNotification();
8131   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8132
8133   // We didn't expect the animation to finish yet
8134   application.SendNotification();
8135   finishCheck.CheckSignalNotReceived();
8136   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
8137   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8138   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8139   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8140
8141   application.SendNotification();
8142   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8143
8144   // We did expect the animation to finish
8145   application.SendNotification();
8146   finishCheck.CheckSignalReceived();
8147   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
8148   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8149   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8150   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8151   END_TEST;
8152 }
8153
8154 int UtcDaliAnimationAnimateToActorScaleZP(void)
8155 {
8156   TestApplication application;
8157
8158   Actor actor = Actor::New();
8159   Stage::GetCurrent().Add(actor);
8160   float startValue(1.0f);
8161   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
8162   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8163   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8164   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8165   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8166   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8167   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8168
8169   // Build the animation
8170   float durationSeconds(1.0f);
8171   Animation animation = Animation::New(durationSeconds);
8172   float targetZ(-1000.0f);
8173   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8174
8175   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8176
8177   // Start the animation
8178   animation.Play();
8179
8180   // Target value should be retrievable straight away
8181   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8182   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8183
8184   bool signalReceived(false);
8185   AnimationFinishCheck finishCheck(signalReceived);
8186   animation.FinishedSignal().Connect(&application, finishCheck);
8187
8188   application.SendNotification();
8189   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8190
8191   // We didn't expect the animation to finish yet
8192   application.SendNotification();
8193   finishCheck.CheckSignalNotReceived();
8194   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
8195   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8196   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8197   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8198
8199   application.SendNotification();
8200   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8201
8202   // We did expect the animation to finish
8203   application.SendNotification();
8204   finishCheck.CheckSignalReceived();
8205   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
8206   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8207   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8208   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8209   END_TEST;
8210 }
8211
8212 int UtcDaliAnimationAnimateToActorColorP(void)
8213 {
8214   TestApplication application;
8215
8216   Actor actor = Actor::New();
8217   Stage::GetCurrent().Add(actor);
8218   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8219
8220   // Build the animation
8221   float durationSeconds(1.0f);
8222   Animation animation = Animation::New(durationSeconds);
8223   Vector4 targetColor(Color::RED);
8224   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8225
8226   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8227   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8228
8229   // Start the animation
8230   animation.Play();
8231
8232   // Target value should be retrievable straight away
8233   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8234   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8235   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8236   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8237   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8238   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8239
8240   bool signalReceived(false);
8241   AnimationFinishCheck finishCheck(signalReceived);
8242   animation.FinishedSignal().Connect(&application, finishCheck);
8243
8244   application.SendNotification();
8245   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8246
8247   // We didn't expect the animation to finish yet
8248   application.SendNotification();
8249   finishCheck.CheckSignalNotReceived();
8250   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8251
8252   application.SendNotification();
8253   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8254
8255   // We did expect the animation to finish
8256   application.SendNotification();
8257   finishCheck.CheckSignalReceived();
8258   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8259
8260   // Reset everything
8261   finishCheck.Reset();
8262   actor.SetColor(Color::WHITE);
8263   application.SendNotification();
8264   application.Render(0);
8265   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8266
8267   // Repeat with a different (ease-in) alpha function
8268   animation = Animation::New(durationSeconds);
8269   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8270   animation.FinishedSignal().Connect(&application, finishCheck);
8271   animation.Play();
8272
8273   application.SendNotification();
8274   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8275
8276   // We didn't expect the animation to finish yet
8277   application.SendNotification();
8278   finishCheck.CheckSignalNotReceived();
8279
8280   // The color should have changed less, than with a linear alpha function
8281   Vector4 current(actor.GetCurrentColor());
8282   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8283   DALI_TEST_CHECK( current.y < 1.0f );
8284   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8285   DALI_TEST_CHECK( current.z  < 1.0f );
8286   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8287   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8288
8289   application.SendNotification();
8290   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8291
8292   // We did expect the animation to finish
8293   application.SendNotification();
8294   finishCheck.CheckSignalReceived();
8295   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8296
8297   // Reset everything
8298   finishCheck.Reset();
8299   actor.SetColor(Color::WHITE);
8300   application.SendNotification();
8301   application.Render(0);
8302   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8303
8304   // Repeat with a shorter animator duration
8305   float animatorDuration = 0.5f;
8306   animation = Animation::New(durationSeconds);
8307   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8308   animation.FinishedSignal().Connect(&application, finishCheck);
8309   animation.Play();
8310
8311   application.SendNotification();
8312   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8313
8314   // We didn't expect the animation to finish yet
8315   application.SendNotification();
8316   finishCheck.CheckSignalNotReceived();
8317   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8318
8319   application.SendNotification();
8320   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8321
8322   // We didn't expect the animation to finish yet
8323   application.SendNotification();
8324   finishCheck.CheckSignalNotReceived();
8325   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8326
8327   application.SendNotification();
8328   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8329
8330   // We did expect the animation to finish
8331   application.SendNotification();
8332   finishCheck.CheckSignalReceived();
8333   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8334   END_TEST;
8335 }
8336
8337 int UtcDaliAnimationAnimateToActorColorRedP(void)
8338 {
8339   TestApplication application;
8340
8341   Actor actor = Actor::New();
8342   Stage::GetCurrent().Add(actor);
8343   float startValue(1.0f);
8344   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
8345   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8346   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8349   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8350   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8351   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8352   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8353
8354   // Build the animation
8355   float durationSeconds(1.0f);
8356   Animation animation = Animation::New(durationSeconds);
8357   float targetRed(0.5f);
8358   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8359
8360   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8361
8362   // Start the animation
8363   animation.Play();
8364
8365   // Target value should be retrievable straight away
8366   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8367   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8368
8369   bool signalReceived(false);
8370   AnimationFinishCheck finishCheck(signalReceived);
8371   animation.FinishedSignal().Connect(&application, finishCheck);
8372
8373   application.SendNotification();
8374   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8375
8376   // We didn't expect the animation to finish yet
8377   application.SendNotification();
8378   finishCheck.CheckSignalNotReceived();
8379   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8380   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8381   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8382   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8383   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8384
8385   application.SendNotification();
8386   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8387
8388   // We did expect the animation to finish
8389   application.SendNotification();
8390   finishCheck.CheckSignalReceived();
8391   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8392   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8393   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8394   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8395   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8396   END_TEST;
8397 }
8398
8399 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8400 {
8401   TestApplication application;
8402
8403   Actor actor = Actor::New();
8404   Stage::GetCurrent().Add(actor);
8405   float startValue(1.0f);
8406   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8407   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8408   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8409   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8410   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8411   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8412   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8413   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8414   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8415
8416   // Build the animation
8417   float durationSeconds(1.0f);
8418   Animation animation = Animation::New(durationSeconds);
8419   float targetGreen(0.5f);
8420   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8421
8422   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8423
8424   // Start the animation
8425   animation.Play();
8426
8427   // Target value should be retrievable straight away
8428   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8429   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8430
8431   bool signalReceived(false);
8432   AnimationFinishCheck finishCheck(signalReceived);
8433   animation.FinishedSignal().Connect(&application, finishCheck);
8434
8435   application.SendNotification();
8436   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8437
8438   // We didn't expect the animation to finish yet
8439   application.SendNotification();
8440   finishCheck.CheckSignalNotReceived();
8441   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8442   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8443   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8444   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8445   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8446
8447   application.SendNotification();
8448   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8449
8450   // We did expect the animation to finish
8451   application.SendNotification();
8452   finishCheck.CheckSignalReceived();
8453   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8454   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8455   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8456   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8457   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8458   END_TEST;
8459 }
8460
8461 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8462 {
8463   TestApplication application;
8464
8465   Actor actor = Actor::New();
8466   Stage::GetCurrent().Add(actor);
8467   float startValue(1.0f);
8468   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8469   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8470   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8471   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8472   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8473   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8474   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8475   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8476   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8477
8478   // Build the animation
8479   float durationSeconds(1.0f);
8480   Animation animation = Animation::New(durationSeconds);
8481   float targetBlue(0.5f);
8482   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8483
8484   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8485
8486   // Start the animation
8487   animation.Play();
8488
8489   // Target value should be retrievable straight away
8490   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8491   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8492
8493   bool signalReceived(false);
8494   AnimationFinishCheck finishCheck(signalReceived);
8495   animation.FinishedSignal().Connect(&application, finishCheck);
8496
8497   application.SendNotification();
8498   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8499
8500   // We didn't expect the animation to finish yet
8501   application.SendNotification();
8502   finishCheck.CheckSignalNotReceived();
8503   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8504   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8505   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8506   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8507   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8508
8509   application.SendNotification();
8510   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8511
8512   // We did expect the animation to finish
8513   application.SendNotification();
8514   finishCheck.CheckSignalReceived();
8515   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8516   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8517   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8518   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8519   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8520   END_TEST;
8521 }
8522
8523 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8524 {
8525   TestApplication application;
8526
8527   Actor actor = Actor::New();
8528   Stage::GetCurrent().Add(actor);
8529   float startValue(1.0f);
8530   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8531   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8532   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8533   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8534   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8535   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8536   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8537   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8538   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8539
8540   // Build the animation
8541   float durationSeconds(1.0f);
8542   Animation animation = Animation::New(durationSeconds);
8543   float targetAlpha(0.5f);
8544   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8545
8546   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8547
8548   // Start the animation
8549   animation.Play();
8550
8551   // Target value should be retrievable straight away
8552   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8553   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8554   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8555
8556   bool signalReceived(false);
8557   AnimationFinishCheck finishCheck(signalReceived);
8558   animation.FinishedSignal().Connect(&application, finishCheck);
8559
8560   application.SendNotification();
8561   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8562
8563   // We didn't expect the animation to finish yet
8564   application.SendNotification();
8565   finishCheck.CheckSignalNotReceived();
8566   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8567   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8568   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8569   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8570   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8571
8572   application.SendNotification();
8573   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8574
8575   // We did expect the animation to finish
8576   application.SendNotification();
8577   finishCheck.CheckSignalReceived();
8578   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8579   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8581   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8582   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8583   END_TEST;
8584 }
8585
8586 int UtcDaliAnimationKeyFrames01P(void)
8587 {
8588   TestApplication application;
8589
8590   KeyFrames keyFrames = KeyFrames::New();
8591   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8592
8593   keyFrames.Add(0.0f, 0.1f);
8594
8595   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8596
8597   KeyFrames keyFrames2( keyFrames);
8598   DALI_TEST_CHECK( keyFrames2 );
8599   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8600
8601   KeyFrames keyFrames3 = KeyFrames::New();
8602   keyFrames3.Add(0.6f, true);
8603   DALI_TEST_CHECK( keyFrames3 );
8604   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8605
8606   keyFrames3 = keyFrames;
8607   DALI_TEST_CHECK( keyFrames3 );
8608   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8609
8610   END_TEST;
8611 }
8612
8613 int UtcDaliAnimationKeyFrames02N(void)
8614 {
8615   TestApplication application;
8616
8617   KeyFrames keyFrames = KeyFrames::New();
8618   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8619
8620   keyFrames.Add(0.0f, 0.1f);
8621   keyFrames.Add(0.2f, 0.5f);
8622   keyFrames.Add(0.4f, 0.0f);
8623   keyFrames.Add(0.6f, 1.0f);
8624   keyFrames.Add(0.8f, 0.7f);
8625   keyFrames.Add(1.0f, 0.9f);
8626
8627   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8628
8629   DALI_TEST_ASSERTION(
8630   {
8631     keyFrames.Add(1.9f, false);
8632   }, "mType == value.GetType()" );
8633
8634   END_TEST;
8635 }
8636
8637 int UtcDaliAnimationKeyFrames03N(void)
8638 {
8639   TestApplication application;
8640
8641   KeyFrames keyFrames = KeyFrames::New();
8642   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8643
8644   keyFrames.Add(0.0f, true);
8645   keyFrames.Add(0.2f, false);
8646   keyFrames.Add(0.4f, false);
8647   keyFrames.Add(0.6f, true);
8648   keyFrames.Add(0.8f, true);
8649   keyFrames.Add(1.0f, false);
8650
8651   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8652
8653   DALI_TEST_ASSERTION(
8654   {
8655     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8656   }, "mType == value.GetType()" );
8657
8658   END_TEST;
8659 }
8660
8661 int UtcDaliAnimationKeyFrames04N(void)
8662 {
8663   TestApplication application;
8664
8665   KeyFrames keyFrames = KeyFrames::New();
8666   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8667
8668   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8669   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8670   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8671   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8672   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8673   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8674
8675   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8676
8677   DALI_TEST_ASSERTION(
8678   {
8679     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8680   }, "mType == value.GetType()" );
8681
8682   END_TEST;
8683 }
8684
8685 int UtcDaliAnimationKeyFrames05N(void)
8686 {
8687   TestApplication application;
8688
8689   KeyFrames keyFrames = KeyFrames::New();
8690   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8691
8692   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8693   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8694   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8695   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8696   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8697   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8698
8699   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8700
8701   DALI_TEST_ASSERTION(
8702   {
8703     keyFrames.Add(0.7f, 1.0f);
8704   }, "mType == value.GetType()" );
8705
8706   END_TEST;
8707 }
8708
8709 int UtcDaliAnimationKeyFrames06N(void)
8710 {
8711   TestApplication application;
8712
8713   KeyFrames keyFrames = KeyFrames::New();
8714   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8715
8716   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8717   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8718   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8719   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8720   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8721   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8722
8723   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8724
8725   DALI_TEST_ASSERTION(
8726   {
8727     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8728   }, "mType == value.GetType()" );
8729
8730   END_TEST;
8731 }
8732
8733 int UtcDaliAnimationKeyFrames07N(void)
8734 {
8735   TestApplication application;
8736
8737   KeyFrames keyFrames = KeyFrames::New();
8738   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8739
8740   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8741   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8742   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8743   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8744   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8745   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8746
8747   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8748
8749   DALI_TEST_ASSERTION(
8750   {
8751     keyFrames.Add(0.7f, 1.1f);
8752   }, "mType == value.GetType()" );
8753
8754   END_TEST;
8755 }
8756
8757 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8758 {
8759   TestApplication application;
8760
8761   float startValue(1.0f);
8762   Actor actor = Actor::New();
8763   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8764   Stage::GetCurrent().Add(actor);
8765
8766   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8767   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8771   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8772   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8773   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8774   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8775
8776   // Build the animation
8777   float durationSeconds(1.0f);
8778   Animation animation = Animation::New(durationSeconds);
8779
8780   KeyFrames keyFrames = KeyFrames::New();
8781   keyFrames.Add(0.0f, 0.1f);
8782   keyFrames.Add(0.2f, 0.5f);
8783   keyFrames.Add(0.4f, 0.0f);
8784   keyFrames.Add(0.6f, 1.0f);
8785   keyFrames.Add(0.8f, 0.7f);
8786   keyFrames.Add(1.0f, 0.9f);
8787
8788   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8789
8790   // Start the animation
8791   animation.Play();
8792
8793   // Final key frame value should be retrievable straight away
8794   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8795
8796   bool signalReceived(false);
8797   AnimationFinishCheck finishCheck(signalReceived);
8798   animation.FinishedSignal().Connect(&application, finishCheck);
8799   application.SendNotification();
8800   application.Render(0);
8801   application.SendNotification();
8802   finishCheck.CheckSignalNotReceived();
8803   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8804
8805   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8806   application.SendNotification();
8807   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8808   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8809   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8810   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8811   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8812
8813   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8814   application.SendNotification();
8815   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8817   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8818   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8819   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8820
8821   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8822   application.SendNotification();
8823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8825   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8826   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8827   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8828
8829   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8830   application.SendNotification();
8831   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8832   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8833   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8834   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8835   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8836
8837   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8838   application.SendNotification();
8839   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8840   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8841   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8842   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8843   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8844
8845   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8846   application.SendNotification();
8847   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8850   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8851   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8852
8853   // We did expect the animation to finish
8854
8855   finishCheck.CheckSignalReceived();
8856   END_TEST;
8857 }
8858
8859 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8860 {
8861   TestApplication application;
8862
8863   float startValue(1.0f);
8864   Actor actor = Actor::New();
8865   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8866   Stage::GetCurrent().Add(actor);
8867
8868   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8869   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8870   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8871   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8872   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8873   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8874   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8875   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8876   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8877
8878   // Build the animation
8879   float durationSeconds(1.0f);
8880   Animation animation = Animation::New(durationSeconds);
8881
8882   KeyFrames keyFrames = KeyFrames::New();
8883   keyFrames.Add(0.0f, 0.1f);
8884   keyFrames.Add(0.2f, 0.5f);
8885   keyFrames.Add(0.4f, 0.0f);
8886   keyFrames.Add(0.6f, 1.0f);
8887   keyFrames.Add(0.8f, 0.7f);
8888   keyFrames.Add(1.0f, 0.9f);
8889
8890   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8891
8892   // Start the animation
8893   animation.Play();
8894
8895   bool signalReceived(false);
8896   AnimationFinishCheck finishCheck(signalReceived);
8897   animation.FinishedSignal().Connect(&application, finishCheck);
8898   application.SendNotification();
8899   application.Render(0);
8900   application.SendNotification();
8901   finishCheck.CheckSignalNotReceived();
8902   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8903
8904   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8905   application.SendNotification();
8906   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8907   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8908   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8909   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8910   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8911
8912   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8913   application.SendNotification();
8914   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8915   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8916   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8917   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8918   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8919
8920   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8921   application.SendNotification();
8922   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8923   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8924   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8925   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8926   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8927
8928   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8929   application.SendNotification();
8930   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8932   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8933   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8934   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8935
8936   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8937   application.SendNotification();
8938   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8939   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8940   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8941   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8942   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8943
8944   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8945   application.SendNotification();
8946   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8947   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8948   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8949   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
8950   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8951
8952   // We did expect the animation to finish
8953
8954   finishCheck.CheckSignalReceived();
8955   END_TEST;
8956 }
8957
8958 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8959 {
8960   TestApplication application;
8961
8962   float startValue(1.0f);
8963   Actor actor = Actor::New();
8964   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8965   Stage::GetCurrent().Add(actor);
8966
8967   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8968   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8969   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8970   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8971   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8972   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8973   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8974   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8975   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8976
8977   // Build the animation
8978   float durationSeconds(1.0f);
8979   Animation animation = Animation::New(durationSeconds);
8980
8981   KeyFrames keyFrames = KeyFrames::New();
8982   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8983   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8984   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8985
8986   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8987
8988   // Start the animation
8989   animation.Play();
8990
8991   bool signalReceived(false);
8992   AnimationFinishCheck finishCheck(signalReceived);
8993   animation.FinishedSignal().Connect(&application, finishCheck);
8994   application.SendNotification();
8995   application.Render(0);
8996   application.SendNotification();
8997   finishCheck.CheckSignalNotReceived();
8998   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
8999   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9000   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9001   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9002
9003   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9004   application.SendNotification();
9005   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9006   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9007   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9008   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9009
9010   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9011   application.SendNotification();
9012   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9013   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9014   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9015   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9016
9017   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9018   application.SendNotification();
9019   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9022   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9023
9024   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9025   application.SendNotification();
9026   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9027   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9028   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9029   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9030
9031   // We did expect the animation to finish
9032
9033   finishCheck.CheckSignalReceived();
9034   END_TEST;
9035 }
9036
9037 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9038 {
9039   TestApplication application;
9040
9041   float startValue(1.0f);
9042   Actor actor = Actor::New();
9043   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9044   Stage::GetCurrent().Add(actor);
9045
9046   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9047   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9048   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9049   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9050   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9051   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9052   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9053   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9054   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9055
9056   // Build the animation
9057   float durationSeconds(1.0f);
9058   Animation animation = Animation::New(durationSeconds);
9059
9060   KeyFrames keyFrames = KeyFrames::New();
9061   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9062   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9063   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9064
9065   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9066
9067   // Start the animation
9068   animation.Play();
9069
9070   bool signalReceived(false);
9071   AnimationFinishCheck finishCheck(signalReceived);
9072   animation.FinishedSignal().Connect(&application, finishCheck);
9073   application.SendNotification();
9074   application.Render(0);
9075   application.SendNotification();
9076   finishCheck.CheckSignalNotReceived();
9077   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9078   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9079   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9080   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9081
9082   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9083   application.SendNotification();
9084   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9086   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9087   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9088
9089   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9090   application.SendNotification();
9091   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9092   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9093   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9094   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9095
9096   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9097   application.SendNotification();
9098   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9099   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9100   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9101   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9102
9103   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9104   application.SendNotification();
9105   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9106   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9107   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9108   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9109
9110   // We did expect the animation to finish
9111
9112   finishCheck.CheckSignalReceived();
9113   END_TEST;
9114 }
9115
9116 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9117 {
9118   TestApplication application;
9119
9120   Actor actor = Actor::New();
9121   AngleAxis aa(Degree(90), Vector3::XAXIS);
9122   actor.SetOrientation(aa.angle, aa.axis);
9123   Stage::GetCurrent().Add(actor);
9124
9125   application.SendNotification();
9126   application.Render(0);
9127
9128   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9129
9130   // Build the animation
9131   float durationSeconds(1.0f);
9132   Animation animation = Animation::New(durationSeconds);
9133
9134   KeyFrames keyFrames = KeyFrames::New();
9135   keyFrames.Add(0.0f, false);
9136   keyFrames.Add(0.2f, true);
9137   keyFrames.Add(0.4f, true);
9138   keyFrames.Add(0.8f, false);
9139   keyFrames.Add(1.0f, true);
9140
9141   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9142
9143   // Start the animation
9144   animation.Play();
9145
9146   // Final key frame value should be retrievable straight away
9147   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9148
9149   bool signalReceived(false);
9150   AnimationFinishCheck finishCheck(signalReceived);
9151   animation.FinishedSignal().Connect(&application, finishCheck);
9152   application.SendNotification();
9153   application.SendNotification();
9154   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9155   application.SendNotification();
9156   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9157   application.SendNotification();
9158
9159   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9160   finishCheck.CheckSignalReceived();
9161   END_TEST;
9162 }
9163
9164 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9165 {
9166   TestApplication application;
9167
9168   Actor actor = Actor::New();
9169   AngleAxis aa(Degree(90), Vector3::XAXIS);
9170   actor.SetOrientation(aa.angle, aa.axis);
9171   Stage::GetCurrent().Add(actor);
9172
9173   application.SendNotification();
9174   application.Render(0);
9175
9176   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9177
9178   // Build the animation
9179   float durationSeconds(1.0f);
9180   Animation animation = Animation::New(durationSeconds);
9181
9182   KeyFrames keyFrames = KeyFrames::New();
9183   keyFrames.Add(0.0f, false);
9184   keyFrames.Add(0.2f, true);
9185   keyFrames.Add(0.4f, true);
9186   keyFrames.Add(0.8f, false);
9187   keyFrames.Add(1.0f, true);
9188
9189   //Cubic interpolation for boolean values should be ignored
9190   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9191
9192   // Start the animation
9193   animation.Play();
9194
9195   bool signalReceived(false);
9196   AnimationFinishCheck finishCheck(signalReceived);
9197   animation.FinishedSignal().Connect(&application, finishCheck);
9198   application.SendNotification();
9199   application.SendNotification();
9200   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9201   application.SendNotification();
9202   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9203   application.SendNotification();
9204
9205   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9206   finishCheck.CheckSignalReceived();
9207   END_TEST;
9208 }
9209
9210 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9211 {
9212   TestApplication application;
9213
9214   Actor actor = Actor::New();
9215   AngleAxis aa(Degree(90), Vector3::XAXIS);
9216   actor.SetOrientation(aa.angle, aa.axis);
9217   Stage::GetCurrent().Add(actor);
9218
9219   application.SendNotification();
9220   application.Render(0);
9221   Quaternion start(Radian(aa.angle), aa.axis);
9222   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9223
9224   // Build the animation
9225   float durationSeconds(1.0f);
9226   Animation animation = Animation::New(durationSeconds);
9227
9228   KeyFrames keyFrames = KeyFrames::New();
9229   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9230
9231   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9232
9233   // Start the animation
9234   animation.Play();
9235
9236   // Final key frame value should be retrievable straight away
9237   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9238
9239   bool signalReceived(false);
9240   AnimationFinishCheck finishCheck(signalReceived);
9241   animation.FinishedSignal().Connect(&application, finishCheck);
9242   application.SendNotification();
9243   application.SendNotification();
9244   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9245   application.SendNotification();
9246   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9247   application.SendNotification();
9248
9249   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9250
9251   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9252   finishCheck.CheckSignalReceived();
9253   END_TEST;
9254 }
9255
9256 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9257 {
9258   TestApplication application;
9259
9260   Actor actor = Actor::New();
9261   AngleAxis aa(Degree(90), Vector3::XAXIS);
9262   actor.SetOrientation(aa.angle, aa.axis);
9263   application.SendNotification();
9264   application.Render(0);
9265   Stage::GetCurrent().Add(actor);
9266
9267   Quaternion start(Radian(aa.angle), aa.axis);
9268   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9269
9270   // Build the animation
9271   float durationSeconds(1.0f);
9272   Animation animation = Animation::New(durationSeconds);
9273
9274   KeyFrames keyFrames = KeyFrames::New();
9275   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9276   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9277   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9278
9279   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9280
9281   // Start the animation
9282   animation.Play();
9283
9284   bool signalReceived(false);
9285   AnimationFinishCheck finishCheck(signalReceived);
9286   animation.FinishedSignal().Connect(&application, finishCheck);
9287   application.SendNotification();
9288   application.Render(0);
9289   application.SendNotification();
9290   finishCheck.CheckSignalNotReceived();
9291
9292   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9293   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9294
9295   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9296   application.SendNotification();
9297   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9298   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9299
9300   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9301   application.SendNotification();
9302   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9303   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9304
9305   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9306   application.SendNotification();
9307   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9308   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9309
9310   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9311   application.SendNotification();
9312   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9313   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9314
9315   // We did expect the animation to finish
9316
9317   finishCheck.CheckSignalReceived();
9318   END_TEST;
9319 }
9320
9321 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9322 {
9323   TestApplication application;
9324
9325   Actor actor = Actor::New();
9326   AngleAxis aa(Degree(90), Vector3::XAXIS);
9327   actor.SetOrientation(aa.angle, aa.axis);
9328   Stage::GetCurrent().Add(actor);
9329
9330   application.SendNotification();
9331   application.Render(0);
9332   Quaternion start(Radian(aa.angle), aa.axis);
9333   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9334
9335   // Build the animation
9336   float durationSeconds(1.0f);
9337   Animation animation = Animation::New(durationSeconds);
9338
9339   KeyFrames keyFrames = KeyFrames::New();
9340   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9341
9342   //Cubic interpolation should be ignored for quaternions
9343   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9344
9345   // Start the animation
9346   animation.Play();
9347
9348   bool signalReceived(false);
9349   AnimationFinishCheck finishCheck(signalReceived);
9350   animation.FinishedSignal().Connect(&application, finishCheck);
9351   application.SendNotification();
9352   application.SendNotification();
9353   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9354   application.SendNotification();
9355   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9356   application.SendNotification();
9357
9358   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9359
9360   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9361   finishCheck.CheckSignalReceived();
9362   END_TEST;
9363 }
9364
9365 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9366 {
9367   TestApplication application;
9368
9369   Actor actor = Actor::New();
9370   AngleAxis aa(Degree(90), Vector3::XAXIS);
9371   actor.SetOrientation(aa.angle, aa.axis);
9372   application.SendNotification();
9373   application.Render(0);
9374   Stage::GetCurrent().Add(actor);
9375
9376   Quaternion start(Radian(aa.angle), aa.axis);
9377   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9378
9379   // Build the animation
9380   float durationSeconds(1.0f);
9381   Animation animation = Animation::New(durationSeconds);
9382
9383   KeyFrames keyFrames = KeyFrames::New();
9384   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9385   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9386   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9387
9388   //Cubic interpolation should be ignored for quaternions
9389   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9390
9391   // Start the animation
9392   animation.Play();
9393
9394   bool signalReceived(false);
9395   AnimationFinishCheck finishCheck(signalReceived);
9396   animation.FinishedSignal().Connect(&application, finishCheck);
9397   application.SendNotification();
9398   application.Render(0);
9399   application.SendNotification();
9400   finishCheck.CheckSignalNotReceived();
9401
9402   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9403   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9404
9405   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9406   application.SendNotification();
9407   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9408   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9409
9410   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9411   application.SendNotification();
9412   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9413   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9414
9415   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9416   application.SendNotification();
9417   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9418   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9419
9420   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9421   application.SendNotification();
9422   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9423   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9424
9425   // We did expect the animation to finish
9426
9427   finishCheck.CheckSignalReceived();
9428   END_TEST;
9429 }
9430
9431 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9432 {
9433   TestApplication application;
9434
9435   float startValue(1.0f);
9436   Actor actor = Actor::New();
9437   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9438   Stage::GetCurrent().Add(actor);
9439
9440   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9441   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9442   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9443   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9444   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9445   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9446   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9447   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9448   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9449
9450   // Build the animation
9451   float durationSeconds(1.0f);
9452   Animation animation = Animation::New(durationSeconds);
9453
9454   KeyFrames keyFrames = KeyFrames::New();
9455   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9456   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9457   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9458
9459   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9460
9461   // Start the animation
9462   animation.Play();
9463
9464   bool signalReceived(false);
9465   AnimationFinishCheck finishCheck(signalReceived);
9466   animation.FinishedSignal().Connect(&application, finishCheck);
9467   application.SendNotification();
9468   application.Render(0);
9469   application.SendNotification();
9470   finishCheck.CheckSignalNotReceived();
9471   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9472   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9473   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9474   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9475
9476   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9477   application.SendNotification();
9478   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9480   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9481   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9482
9483   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9484   application.SendNotification();
9485   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9488   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9489
9490   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9491   application.SendNotification();
9492   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9493   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9494   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9495   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9496
9497   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9498   application.SendNotification();
9499   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9500   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9502   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9503
9504   // We did expect the animation to finish
9505
9506   finishCheck.CheckSignalReceived();
9507   END_TEST;
9508 }
9509
9510 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9511 {
9512   TestApplication application;
9513
9514   float startValue(1.0f);
9515   Actor actor = Actor::New();
9516   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9517   Stage::GetCurrent().Add(actor);
9518
9519   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9520   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9521   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9522   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9523   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9524   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9525   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9526   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9527   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9528
9529   // Build the animation
9530   float durationSeconds(1.0f);
9531   Animation animation = Animation::New(durationSeconds);
9532
9533   KeyFrames keyFrames = KeyFrames::New();
9534   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9535   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9536   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9537
9538   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9539
9540   // Start the animation
9541   animation.Play();
9542
9543   bool signalReceived(false);
9544   AnimationFinishCheck finishCheck(signalReceived);
9545   animation.FinishedSignal().Connect(&application, finishCheck);
9546   application.SendNotification();
9547   application.Render(0);
9548   application.SendNotification();
9549   finishCheck.CheckSignalNotReceived();
9550   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9552   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9553   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9554
9555   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9556   application.SendNotification();
9557   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9559   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9560   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9561
9562   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9563   application.SendNotification();
9564   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9565   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9566   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9567   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9568
9569   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9570   application.SendNotification();
9571   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9572   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9573   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9574   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9575
9576   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9577   application.SendNotification();
9578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9579   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9581   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9582
9583   // We did expect the animation to finish
9584
9585   finishCheck.CheckSignalReceived();
9586   END_TEST;
9587 }
9588
9589 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9590 {
9591   TestApplication application;
9592
9593   float startValue(1.0f);
9594   Actor actor = Actor::New();
9595   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9596   Stage::GetCurrent().Add(actor);
9597
9598   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9599   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9600   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9601   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9602   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9603   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9604   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9605   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9606   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9607
9608   // Build the animation
9609   float durationSeconds(1.0f);
9610   float delay = 0.5f;
9611   Animation animation = Animation::New(durationSeconds);
9612
9613   KeyFrames keyFrames = KeyFrames::New();
9614   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9615   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9616   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9617
9618   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9619
9620   // Start the animation
9621   animation.Play();
9622
9623   bool signalReceived(false);
9624   AnimationFinishCheck finishCheck(signalReceived);
9625   animation.FinishedSignal().Connect(&application, finishCheck);
9626   application.SendNotification();
9627
9628   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9629   application.SendNotification();
9630   finishCheck.CheckSignalNotReceived();
9631   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9632   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9633   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9634   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9635
9636   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9637   application.SendNotification();
9638   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9639   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9640   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9641   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9642
9643   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9644   application.SendNotification();
9645   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9646   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9647   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9648   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9649
9650   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9651   application.SendNotification();
9652   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9653   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9654   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9655   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9656
9657   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9658   application.SendNotification();
9659   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9662   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9663
9664   // We did expect the animation to finish
9665
9666   finishCheck.CheckSignalReceived();
9667   END_TEST;
9668 }
9669
9670 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9671 {
9672   TestApplication application;
9673
9674   float startValue(1.0f);
9675   Actor actor = Actor::New();
9676   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9677   Stage::GetCurrent().Add(actor);
9678
9679   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9680   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9681   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9682   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9683   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9684   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9685   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9686   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9687   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9688
9689   // Build the animation
9690   float durationSeconds(1.0f);
9691   float delay = 0.5f;
9692   Animation animation = Animation::New(durationSeconds);
9693
9694   KeyFrames keyFrames = KeyFrames::New();
9695   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9696   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9697   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9698
9699   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9700
9701   // Start the animation
9702   animation.Play();
9703
9704   bool signalReceived(false);
9705   AnimationFinishCheck finishCheck(signalReceived);
9706   animation.FinishedSignal().Connect(&application, finishCheck);
9707   application.SendNotification();
9708
9709   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9710   application.SendNotification();
9711   finishCheck.CheckSignalNotReceived();
9712   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9713   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9714   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9716
9717   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9718   application.SendNotification();
9719   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9720   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9722   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9723
9724   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9725   application.SendNotification();
9726   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9727   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9728   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9729   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9730
9731   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9732   application.SendNotification();
9733   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9734   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9735   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9736   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9737
9738   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9739   application.SendNotification();
9740   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9741   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9742   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9743   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9744
9745   // We did expect the animation to finish
9746
9747   finishCheck.CheckSignalReceived();
9748   END_TEST;
9749 }
9750
9751 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9752 {
9753   TestApplication application;
9754
9755   float startValue(1.0f);
9756   float delay = 0.5f;
9757   Actor actor = Actor::New();
9758   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9759   Stage::GetCurrent().Add(actor);
9760
9761   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9762   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9763   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9764   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9765   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9766   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9767   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9768   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9770
9771   // Build the animation
9772   float durationSeconds(1.0f);
9773   Animation animation = Animation::New(durationSeconds);
9774
9775   KeyFrames keyFrames = KeyFrames::New();
9776   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9777   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9778   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9779
9780   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9781
9782   // Start the animation
9783   animation.Play();
9784
9785   bool signalReceived(false);
9786   AnimationFinishCheck finishCheck(signalReceived);
9787   animation.FinishedSignal().Connect(&application, finishCheck);
9788   application.SendNotification();
9789
9790   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9791   application.SendNotification();
9792   finishCheck.CheckSignalNotReceived();
9793   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9794   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9795   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9796   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9797
9798   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9799   application.SendNotification();
9800   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9801   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9802   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9803   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9804
9805   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9806   application.SendNotification();
9807   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9808   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9809   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9810   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9811
9812   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9813   application.SendNotification();
9814   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9815   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9816   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9817   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9818
9819   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9820   application.SendNotification();
9821   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9825
9826   // We did expect the animation to finish
9827
9828   finishCheck.CheckSignalReceived();
9829   END_TEST;
9830 }
9831
9832 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9833 {
9834   TestApplication application;
9835
9836   float startValue(1.0f);
9837   Actor actor = Actor::New();
9838   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9839   Stage::GetCurrent().Add(actor);
9840
9841   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9842   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9843   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9844   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9845   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9846   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9847   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9850
9851
9852   // Build the animation
9853   float durationSeconds(1.0f);
9854   float delay = 0.5f;
9855   Animation animation = Animation::New(durationSeconds);
9856
9857   KeyFrames keyFrames = KeyFrames::New();
9858   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9859   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9860   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9861
9862   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9863
9864   // Start the animation
9865   animation.Play();
9866
9867   bool signalReceived(false);
9868   AnimationFinishCheck finishCheck(signalReceived);
9869   animation.FinishedSignal().Connect(&application, finishCheck);
9870   application.SendNotification();
9871
9872   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9873   application.SendNotification();
9874   finishCheck.CheckSignalNotReceived();
9875   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9876   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9877   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9878   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9879
9880   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9881   application.SendNotification();
9882   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9883   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9884   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9885   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9886
9887   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9888   application.SendNotification();
9889   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9890   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9891   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9892   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9893
9894   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9895   application.SendNotification();
9896   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9897   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9898   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9899   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9900
9901   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9902   application.SendNotification();
9903   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9904   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9906   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9907
9908   // We did expect the animation to finish
9909
9910   finishCheck.CheckSignalReceived();
9911   END_TEST;
9912 }
9913
9914 int UtcDaliAnimationAnimateP(void)
9915 {
9916   TestApplication application;
9917
9918   Actor actor = Actor::New();
9919   Stage::GetCurrent().Add(actor);
9920
9921   //Build the path
9922   Vector3 position0( 30.0,  80.0,  0.0);
9923   Vector3 position1( 70.0,  120.0, 0.0);
9924   Vector3 position2( 100.0, 100.0, 0.0);
9925
9926   Dali::Path path = Dali::Path::New();
9927   path.AddPoint(position0);
9928   path.AddPoint(position1);
9929   path.AddPoint(position2);
9930
9931   //Control points for first segment
9932   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9933   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9934
9935   //Control points for second segment
9936   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9937   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9938
9939   // Build the animation
9940   float durationSeconds( 1.0f );
9941   Animation animation = Animation::New(durationSeconds);
9942   animation.Animate(actor, path, Vector3::XAXIS);
9943
9944   // Start the animation
9945   animation.Play();
9946
9947   bool signalReceived(false);
9948   AnimationFinishCheck finishCheck(signalReceived);
9949   animation.FinishedSignal().Connect(&application, finishCheck);
9950   application.SendNotification();
9951   application.Render(0);
9952   application.SendNotification();
9953   finishCheck.CheckSignalNotReceived();
9954   Vector3 position, tangent;
9955   Quaternion rotation;
9956   path.Sample( 0.0f, position, tangent );
9957   rotation = Quaternion( Vector3::XAXIS, tangent );
9958   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9959   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9960
9961   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9962   application.SendNotification();
9963   path.Sample( 0.25f, position, tangent );
9964   rotation = Quaternion( Vector3::XAXIS, tangent );
9965   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9966   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9967
9968   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9969   application.SendNotification();
9970   path.Sample( 0.5f, position, tangent );
9971   rotation = Quaternion( Vector3::XAXIS, tangent );
9972   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9973   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9974
9975   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9976   application.SendNotification();
9977   path.Sample( 0.75f, position, tangent );
9978   rotation = Quaternion( Vector3::XAXIS, tangent );
9979   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9980   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9981
9982   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9983   application.SendNotification();
9984   path.Sample( 1.0f, position, tangent );
9985   rotation = Quaternion( Vector3::XAXIS, tangent );
9986   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9987   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9988
9989   finishCheck.CheckSignalReceived();
9990   END_TEST;
9991 }
9992
9993 int UtcDaliAnimationAnimateAlphaFunctionP(void)
9994 {
9995   TestApplication application;
9996
9997   Actor actor = Actor::New();
9998   Stage::GetCurrent().Add(actor);
9999
10000   //Build the path
10001   Vector3 position0( 30.0,  80.0,  0.0);
10002   Vector3 position1( 70.0,  120.0, 0.0);
10003   Vector3 position2( 100.0, 100.0, 0.0);
10004
10005   Dali::Path path = Dali::Path::New();
10006   path.AddPoint(position0);
10007   path.AddPoint(position1);
10008   path.AddPoint(position2);
10009
10010   //Control points for first segment
10011   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10012   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10013
10014   //Control points for second segment
10015   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10016   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10017
10018   // Build the animation
10019   float durationSeconds( 1.0f );
10020   Animation animation = Animation::New(durationSeconds);
10021   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10022
10023   // Start the animation
10024   animation.Play();
10025
10026   bool signalReceived(false);
10027   AnimationFinishCheck finishCheck(signalReceived);
10028   animation.FinishedSignal().Connect(&application, finishCheck);
10029   application.SendNotification();
10030   application.Render(0);
10031   application.SendNotification();
10032   finishCheck.CheckSignalNotReceived();
10033   Vector3 position, tangent;
10034   Quaternion rotation;
10035   path.Sample( 0.0f, position, tangent );
10036   rotation = Quaternion( Vector3::XAXIS, tangent );
10037   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10038   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10039
10040   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10041   application.SendNotification();
10042   path.Sample( 0.25f, position, tangent );
10043   rotation = Quaternion( Vector3::XAXIS, tangent );
10044   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10045   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10046
10047   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10048   application.SendNotification();
10049   path.Sample( 0.5f, position, tangent );
10050   rotation = Quaternion( Vector3::XAXIS, tangent );
10051   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10052   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10053
10054   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10055   application.SendNotification();
10056   path.Sample( 0.75f, position, tangent );
10057   rotation = Quaternion( Vector3::XAXIS, tangent );
10058   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10059   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10060
10061   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10062   application.SendNotification();
10063   path.Sample( 1.0f, position, tangent );
10064   rotation = Quaternion( Vector3::XAXIS, tangent );
10065   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10066   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10067
10068   finishCheck.CheckSignalReceived();
10069   END_TEST;
10070 }
10071
10072 int UtcDaliAnimationAnimateTimePeriodP(void)
10073 {
10074   TestApplication application;
10075
10076   Actor actor = Actor::New();
10077   Stage::GetCurrent().Add(actor);
10078
10079   //Build the path
10080   Vector3 position0( 30.0,  80.0,  0.0);
10081   Vector3 position1( 70.0,  120.0, 0.0);
10082   Vector3 position2( 100.0, 100.0, 0.0);
10083
10084   Dali::Path path = Dali::Path::New();
10085   path.AddPoint(position0);
10086   path.AddPoint(position1);
10087   path.AddPoint(position2);
10088
10089   //Control points for first segment
10090   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10091   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10092
10093   //Control points for second segment
10094   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10095   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10096
10097   // Build the animation
10098   float durationSeconds( 1.0f );
10099   Animation animation = Animation::New(durationSeconds);
10100   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10101
10102   // Start the animation
10103   animation.Play();
10104
10105   bool signalReceived(false);
10106   AnimationFinishCheck finishCheck(signalReceived);
10107   animation.FinishedSignal().Connect(&application, finishCheck);
10108   application.SendNotification();
10109   application.Render(0);
10110   application.SendNotification();
10111   finishCheck.CheckSignalNotReceived();
10112   Vector3 position, tangent;
10113   Quaternion rotation;
10114   path.Sample( 0.0f, position, tangent );
10115   rotation = Quaternion( Vector3::XAXIS, tangent );
10116   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10117   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10118
10119   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10120   application.SendNotification();
10121   path.Sample( 0.25f, position, tangent );
10122   rotation = Quaternion( Vector3::XAXIS, tangent );
10123   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10124   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10125
10126   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10127   application.SendNotification();
10128   path.Sample( 0.5f, position, tangent );
10129   rotation = Quaternion( Vector3::XAXIS, tangent );
10130   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10131   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10132
10133   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10134   application.SendNotification();
10135   path.Sample( 0.75f, position, tangent );
10136   rotation = Quaternion( Vector3::XAXIS, tangent );
10137   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10138   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10139
10140   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10141   application.SendNotification();
10142   path.Sample( 1.0f, position, tangent );
10143   rotation = Quaternion( Vector3::XAXIS, tangent );
10144   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10145   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10146
10147   finishCheck.CheckSignalReceived();
10148   END_TEST;
10149 }
10150
10151 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10152 {
10153   TestApplication application;
10154
10155   Actor actor = Actor::New();
10156   Stage::GetCurrent().Add(actor);
10157
10158   //Build the path
10159   Vector3 position0( 30.0,  80.0,  0.0);
10160   Vector3 position1( 70.0,  120.0, 0.0);
10161   Vector3 position2( 100.0, 100.0, 0.0);
10162
10163   Dali::Path path = Dali::Path::New();
10164   path.AddPoint(position0);
10165   path.AddPoint(position1);
10166   path.AddPoint(position2);
10167
10168   //Control points for first segment
10169   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10170   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10171
10172   //Control points for second segment
10173   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10174   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10175
10176   // Build the animation
10177   float durationSeconds( 1.0f );
10178   Animation animation = Animation::New(durationSeconds);
10179   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10180
10181   // Start the animation
10182   animation.Play();
10183
10184   bool signalReceived(false);
10185   AnimationFinishCheck finishCheck(signalReceived);
10186   animation.FinishedSignal().Connect(&application, finishCheck);
10187   application.SendNotification();
10188   application.Render(0);
10189   application.SendNotification();
10190   finishCheck.CheckSignalNotReceived();
10191   Vector3 position, tangent;
10192   Quaternion rotation;
10193   path.Sample( 0.0f, position, tangent );
10194   rotation = Quaternion( Vector3::XAXIS, tangent );
10195   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10196   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10197
10198   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10199   application.SendNotification();
10200   path.Sample( 0.25f, position, tangent );
10201   rotation = Quaternion( Vector3::XAXIS, tangent );
10202   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10203   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10204
10205   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10206   application.SendNotification();
10207   path.Sample( 0.5f, position, tangent );
10208   rotation = Quaternion( Vector3::XAXIS, tangent );
10209   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10210   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10211
10212   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10213   application.SendNotification();
10214   path.Sample( 0.75f, position, tangent );
10215   rotation = Quaternion( Vector3::XAXIS, tangent );
10216   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10217   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10218
10219   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10220   application.SendNotification();
10221   path.Sample( 1.0f, position, tangent );
10222   rotation = Quaternion( Vector3::XAXIS, tangent );
10223   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10224   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10225
10226   finishCheck.CheckSignalReceived();
10227   END_TEST;
10228 }
10229
10230 int UtcDaliAnimationShowP(void)
10231 {
10232   TestApplication application;
10233
10234   Actor actor = Actor::New();
10235   actor.SetVisible(false);
10236   application.SendNotification();
10237   application.Render(0);
10238   DALI_TEST_CHECK( !actor.IsVisible() );
10239   Stage::GetCurrent().Add(actor);
10240
10241   // Start the animation
10242   float durationSeconds(10.0f);
10243   Animation animation = Animation::New(durationSeconds);
10244   animation.Show(actor, durationSeconds*0.5f);
10245   animation.Play();
10246
10247   bool signalReceived(false);
10248   AnimationFinishCheck finishCheck(signalReceived);
10249   animation.FinishedSignal().Connect(&application, finishCheck);
10250
10251   application.SendNotification();
10252   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10253
10254   // We didn't expect the animation to finish yet
10255   application.SendNotification();
10256   finishCheck.CheckSignalNotReceived();
10257   DALI_TEST_CHECK( !actor.IsVisible() );
10258
10259   application.SendNotification();
10260   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10261
10262   // We didn't expect the animation to finish yet
10263   application.SendNotification();
10264   finishCheck.CheckSignalNotReceived();
10265   DALI_TEST_CHECK( actor.IsVisible() );
10266
10267   application.SendNotification();
10268   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10269
10270   // We did expect the animation to finish
10271   application.SendNotification();
10272   finishCheck.CheckSignalReceived();
10273   DALI_TEST_CHECK( actor.IsVisible() );
10274   END_TEST;
10275 }
10276
10277 int UtcDaliAnimationHideP(void)
10278 {
10279   TestApplication application;
10280
10281   Actor actor = Actor::New();
10282   DALI_TEST_CHECK( actor.IsVisible() );
10283   Stage::GetCurrent().Add(actor);
10284
10285   // Start the animation
10286   float durationSeconds(10.0f);
10287   Animation animation = Animation::New(durationSeconds);
10288   animation.Hide(actor, durationSeconds*0.5f);
10289   animation.Play();
10290
10291   bool signalReceived(false);
10292   AnimationFinishCheck finishCheck(signalReceived);
10293   animation.FinishedSignal().Connect(&application, finishCheck);
10294
10295   application.SendNotification();
10296   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10297
10298   // We didn't expect the animation to finish yet
10299   application.SendNotification();
10300   finishCheck.CheckSignalNotReceived();
10301   DALI_TEST_CHECK( actor.IsVisible() );
10302
10303   application.SendNotification();
10304   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10305
10306   // We didn't expect the animation to finish yet
10307   application.SendNotification();
10308   finishCheck.CheckSignalNotReceived();
10309   DALI_TEST_CHECK( !actor.IsVisible() );
10310
10311   application.SendNotification();
10312   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10313
10314   // We did expect the animation to finish
10315   application.SendNotification();
10316   finishCheck.CheckSignalReceived();
10317   DALI_TEST_CHECK( !actor.IsVisible() );
10318   END_TEST;
10319 }
10320
10321 int UtcDaliAnimationShowHideAtEndP(void)
10322 {
10323   // Test that show/hide delay can be the same as animation duration
10324   // i.e. to show/hide at the end of the animation
10325
10326   TestApplication application;
10327
10328   Actor actor = Actor::New();
10329   DALI_TEST_CHECK( actor.IsVisible() );
10330   Stage::GetCurrent().Add(actor);
10331
10332   // Start Hide animation
10333   float durationSeconds(10.0f);
10334   Animation animation = Animation::New(durationSeconds);
10335   animation.Hide(actor, durationSeconds/*Hide at end*/);
10336   animation.Play();
10337
10338   bool signalReceived(false);
10339   AnimationFinishCheck finishCheck(signalReceived);
10340   animation.FinishedSignal().Connect(&application, finishCheck);
10341
10342   application.SendNotification();
10343   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10344
10345   // We did expect the animation to finish
10346   application.SendNotification();
10347   finishCheck.CheckSignalReceived();
10348   DALI_TEST_CHECK( !actor.IsVisible() );
10349
10350   // Start Show animation
10351   animation = Animation::New(durationSeconds);
10352   animation.Show(actor, durationSeconds/*Show at end*/);
10353   animation.FinishedSignal().Connect(&application, finishCheck);
10354   animation.Play();
10355
10356   application.SendNotification();
10357   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10358
10359   // We did expect the animation to finish
10360   application.SendNotification();
10361   finishCheck.CheckSignalReceived();
10362   DALI_TEST_CHECK( actor.IsVisible() );
10363   END_TEST;
10364 }
10365
10366 int UtcDaliKeyFramesCreateDestroyP(void)
10367 {
10368   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10369
10370   KeyFrames* keyFrames = new KeyFrames;
10371   delete keyFrames;
10372   DALI_TEST_CHECK( true );
10373   END_TEST;
10374 }
10375
10376 int UtcDaliKeyFramesDownCastP(void)
10377 {
10378   TestApplication application;
10379   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10380
10381   KeyFrames keyFrames = KeyFrames::New();
10382   BaseHandle object(keyFrames);
10383
10384   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10385   DALI_TEST_CHECK(keyFrames2);
10386
10387   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10388   DALI_TEST_CHECK(keyFrames3);
10389
10390   BaseHandle unInitializedObject;
10391   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10392   DALI_TEST_CHECK(!keyFrames4);
10393
10394   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10395   DALI_TEST_CHECK(!keyFrames5);
10396   END_TEST;
10397 }
10398
10399 int UtcDaliAnimationCreateDestroyP(void)
10400 {
10401   TestApplication application;
10402   Animation* animation = new Animation;
10403   DALI_TEST_CHECK( animation );
10404   delete animation;
10405   END_TEST;
10406 }
10407
10408 struct UpdateManagerTestConstraint
10409 {
10410   UpdateManagerTestConstraint(TestApplication& application)
10411   : mApplication(application)
10412   {
10413   }
10414
10415   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10416   {
10417     mApplication.SendNotification();  // Process events
10418   }
10419
10420   TestApplication& mApplication;
10421 };
10422
10423 int UtcDaliAnimationUpdateManagerP(void)
10424 {
10425   TestApplication application;
10426
10427   Actor actor = Actor::New();
10428   Stage::GetCurrent().Add( actor );
10429
10430   // Build the animation
10431   Animation animation = Animation::New( 0.0f );
10432
10433   bool signalReceived = false;
10434   AnimationFinishCheck finishCheck( signalReceived );
10435   animation.FinishedSignal().Connect( &application, finishCheck );
10436
10437   Vector3 startValue(1.0f, 1.0f, 1.0f);
10438   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10439   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10440   constraint.Apply();
10441
10442   // Apply animation to actor
10443   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10444   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10445
10446   animation.Play();
10447
10448   application.SendNotification();
10449   application.UpdateOnly( 16 );
10450
10451   finishCheck.CheckSignalNotReceived();
10452
10453   application.SendNotification();   // Process events
10454
10455   finishCheck.CheckSignalReceived();
10456
10457   END_TEST;
10458 }
10459
10460 int UtcDaliAnimationSignalOrderP(void)
10461 {
10462   TestApplication application;
10463
10464   Actor actor = Actor::New();
10465   Stage::GetCurrent().Add( actor );
10466
10467   // Build the animations
10468   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10469   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10470
10471   bool signal1Received = false;
10472   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10473
10474   bool signal2Received = false;
10475   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10476
10477   // Apply animations to actor
10478   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10479   animation1.Play();
10480   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10481   animation2.Play();
10482
10483   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10484   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10485
10486   application.SendNotification();
10487   application.UpdateOnly( 10 ); // 10ms progress
10488
10489   // no notifications yet
10490   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10491   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10492
10493   application.SendNotification();
10494
10495   // first completed
10496   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10497   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10498   signal1Received = false;
10499
10500   // 1st animation is complete now, do another update with no ProcessEvents in between
10501   application.UpdateOnly( 20 ); // 20ms progress
10502
10503   // ProcessEvents
10504   application.SendNotification();
10505
10506   // 2nd should complete now
10507   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10508   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10509
10510   END_TEST;
10511 }
10512
10513 int UtcDaliAnimationExtendDurationP(void)
10514 {
10515   TestApplication application;
10516
10517   Actor actor = Actor::New();
10518
10519   // Register a float property
10520   float startValue(10.0f);
10521   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10522   Stage::GetCurrent().Add(actor);
10523   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10524   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10525
10526   // Build the animation
10527   float initialDurationSeconds(1.0f);
10528   float animatorDelay = 5.0f;
10529   float animatorDurationSeconds(5.0f);
10530   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10531   Animation animation = Animation::New(initialDurationSeconds);
10532   float targetValue(30.0f);
10533   float relativeValue(targetValue - startValue);
10534
10535   animation.AnimateTo(Property(actor, index),
10536                       targetValue,
10537                       TimePeriod(animatorDelay, animatorDurationSeconds));
10538
10539   // The duration should have been extended
10540   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10541
10542   // Start the animation
10543   animation.Play();
10544
10545   bool signalReceived(false);
10546   AnimationFinishCheck finishCheck(signalReceived);
10547   animation.FinishedSignal().Connect(&application, finishCheck);
10548
10549   application.SendNotification();
10550   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10551
10552   // We didn't expect the animation to finish yet, but cached value should be the final one
10553   application.SendNotification();
10554   finishCheck.CheckSignalNotReceived();
10555   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10556   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10557
10558   application.SendNotification();
10559   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10560
10561   // We didn't expect the animation to finish yet
10562   application.SendNotification();
10563   finishCheck.CheckSignalNotReceived();
10564   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10565
10566   application.SendNotification();
10567   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10568
10569   // We did expect the animation to finish
10570   application.SendNotification();
10571   finishCheck.CheckSignalReceived();
10572   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10573   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10574   END_TEST;
10575 }
10576
10577 int UtcDaliAnimationCustomIntProperty(void)
10578 {
10579   TestApplication application;
10580
10581   Actor actor = Actor::New();
10582   Stage::GetCurrent().Add(actor);
10583   int startValue(0u);
10584
10585   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10586   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10587   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10588
10589   // Build the animation
10590   float durationSeconds(1.0f);
10591   Animation animation = Animation::New(durationSeconds);
10592   animation.AnimateTo( Property(actor, index), 20 );
10593
10594   // Start the animation
10595   animation.Play();
10596
10597   // Target value should be retrievable straight away
10598   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10599
10600   bool signalReceived(false);
10601   AnimationFinishCheck finishCheck(signalReceived);
10602   animation.FinishedSignal().Connect(&application, finishCheck);
10603
10604   application.SendNotification();
10605   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10606
10607   // We didn't expect the animation to finish yet
10608   application.SendNotification();
10609   finishCheck.CheckSignalNotReceived();
10610   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10611
10612   application.SendNotification();
10613   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10614
10615   // We did expect the animation to finish
10616   application.SendNotification();
10617   finishCheck.CheckSignalReceived();
10618   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10619   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10620   END_TEST;
10621 }
10622
10623 int UtcDaliAnimationDuration(void)
10624 {
10625   TestApplication application;
10626
10627   Actor actor = Actor::New();
10628   Stage::GetCurrent().Add(actor);
10629
10630   Animation animation = Animation::New( 0.0f );
10631   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10632
10633   // The animation duration should automatically increase depending on the animator time period
10634
10635   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10636   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10637
10638   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10639   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10640
10641   END_TEST;
10642 }
10643
10644 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10645 {
10646   TestApplication application;
10647
10648   Actor actor = Actor::New();
10649
10650   // Register an integer property
10651   int startValue(1);
10652   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10653   Stage::GetCurrent().Add(actor);
10654   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10655
10656   DALI_TEST_ASSERTION(
10657   {
10658     // Build the animation
10659     Animation animation = Animation::New( 2.0f );
10660     std::string relativeValue = "relative string";
10661     animation.AnimateBy( Property(actor, index), relativeValue );
10662     tet_result(TET_FAIL);
10663   }, "Target value is not animatable" );
10664
10665   END_TEST;
10666 }
10667
10668
10669 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10670 {
10671   TestApplication application;
10672
10673   Actor actor = Actor::New();
10674
10675   // Register an integer property
10676   int startValue(1);
10677   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10678   Stage::GetCurrent().Add(actor);
10679   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10680
10681   DALI_TEST_ASSERTION(
10682   {
10683     // Build the animation
10684     Animation animation = Animation::New( 2.0f );
10685     std::string relativeValue = "relative string";
10686     animation.AnimateTo( Property(actor, index), relativeValue );
10687   }, "Target value is not animatable" );
10688
10689   END_TEST;
10690 }
10691
10692 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10693 {
10694   TestApplication application;
10695
10696   Actor actor = Actor::New();
10697
10698   // Register an integer property
10699   int startValue(1);
10700   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10701   Stage::GetCurrent().Add(actor);
10702   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10703
10704   DALI_TEST_ASSERTION(
10705   {
10706     // Build the animation
10707     KeyFrames keyFrames = KeyFrames::New();
10708     keyFrames.Add( 0.0f, std::string("relative string1") );
10709     keyFrames.Add( 1.0f, std::string("relative string2") );
10710     // no need to really create the animation as keyframes do the check
10711   }, "Property type is not animatable" );
10712
10713   END_TEST;
10714 }
10715
10716 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10717 {
10718   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10719
10720   TestApplication application;
10721
10722   tet_infoline("Set initial position and set up animation to re-position actor");
10723
10724   Actor actor = Actor::New();
10725   Stage::GetCurrent().Add(actor);
10726   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10727   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10728
10729   // Build the animation
10730   Animation animation = Animation::New(2.0f);
10731
10732   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10733   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10734   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10735
10736   tet_infoline("Set target position in animation without intiating play");
10737
10738   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10739   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10740
10741   application.SendNotification();
10742   application.Render();
10743
10744   tet_infoline("Ensure position of actor is still at intial value");
10745
10746   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10747   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10748   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10749
10750   tet_infoline("Play animation and ensure actor position is now target");
10751
10752   animation.Play();
10753   application.SendNotification();
10754   application.Render(1000u);
10755
10756   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10757
10758   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10759   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10760   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10761
10762   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10763
10764   application.Render(2000u);
10765
10766   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10767
10768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10771
10772   END_TEST;
10773 }
10774
10775 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10776 {
10777   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10778
10779   TestApplication application;
10780
10781   std::vector<Vector3> targetPositions;
10782
10783   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10784   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10785   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10786
10787   tet_infoline("Set initial position and set up animation to re-position actor");
10788
10789   Actor actor = Actor::New();
10790   Stage::GetCurrent().Add(actor);
10791   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10792   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10793
10794   // Build the animation
10795   Animation animation = Animation::New(2.0f);
10796
10797   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10798   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10799   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10800
10801   tet_infoline("Set target position in animation without intiating play");
10802
10803   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10804   {
10805     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10806   }
10807
10808   application.SendNotification();
10809   application.Render();
10810
10811   tet_infoline("Ensure position of actor is still at intial value");
10812
10813   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10814   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10816
10817   tet_infoline("Play animation and ensure actor position is now target");
10818
10819   animation.Play();
10820   application.SendNotification();
10821   application.Render(1000u);
10822
10823   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10824
10825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10827   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10828
10829   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10830
10831   application.Render(2000u);
10832
10833   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10834
10835   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10836   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10837   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10838
10839   END_TEST;
10840 }
10841
10842 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10843 {
10844   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");
10845
10846   TestApplication application;
10847
10848   std::vector<Vector3> targetSizes;
10849   std::vector<Vector3> targetPositions;
10850
10851   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10852   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10853
10854   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10855
10856   tet_infoline("Set initial position and set up animation to re-position actor");
10857
10858   Actor actor = Actor::New();
10859   Stage::GetCurrent().Add(actor);
10860   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10861   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10862
10863   actor.SetProperty( Actor::Property::SIZE, initialSize );
10864   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10865
10866   // Build the animation
10867   Animation animation = Animation::New(2.0f);
10868
10869   tet_infoline("Set target size in animation without intiating play");
10870   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10871   tet_infoline("Set target position in animation without intiating play");
10872   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10873   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10874
10875   application.SendNotification();
10876   application.Render();
10877
10878   tet_infoline("Ensure position of actor is still at intial size and position");
10879
10880   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10881   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10882   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10883
10884   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10885   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10886   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10887
10888   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10889
10890   animation.Play();
10891   application.SendNotification();
10892   application.Render(2000u);
10893
10894   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10895
10896   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10897   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10899
10900   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10901   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10902   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10903
10904   END_TEST;
10905 }
10906
10907 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10908 {
10909   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10910
10911   TestApplication application;
10912
10913   std::vector<Vector3> targetSizes;
10914   std::vector<float> targetColors;
10915
10916   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10917   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10918
10919   targetColors.push_back( 1.0f );
10920
10921   tet_infoline("Set initial position and set up animation to re-position actor");
10922
10923   Actor actor = Actor::New();
10924   Stage::GetCurrent().Add(actor);
10925   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10926
10927   actor.SetProperty( Actor::Property::SIZE, initialSize );
10928
10929   // Build the animation
10930   Animation animation = Animation::New(2.0f);
10931
10932   tet_infoline("Set target size in animation without initiating play");
10933   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10934   tet_infoline("Set target position in animation without intiating play");
10935   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
10936   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10937
10938   application.SendNotification();
10939   application.Render();
10940
10941   tet_infoline("Ensure position of actor is still at initial size and position");
10942
10943   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10944   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10945   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10946
10947   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10948
10949   animation.Play();
10950   application.SendNotification();
10951   application.Render(2000u);
10952
10953   tet_infoline("Ensure position and size of actor is at target value when animation playing");
10954
10955   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10956   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10957   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10958
10959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
10960
10961   END_TEST;
10962 }
10963
10964 int UtcDaliAnimationTimePeriodOrder(void)
10965 {
10966   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
10967
10968   TestApplication application;
10969
10970   Actor actor = Actor::New();
10971   Stage::GetCurrent().Add( actor );
10972
10973   application.SendNotification();
10974   application.Render();
10975
10976   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10977   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10978   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10979   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10980   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10981
10982   //////////////////////////////////////////////////////////////////////////////////
10983
10984   tet_infoline( "With two AnimateTo calls" );
10985
10986   Animation animation = Animation::New( 0.0f );
10987   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
10988   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
10989   animation.Play();
10990
10991   tet_infoline( "The target position should change instantly" );
10992   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10993   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10994
10995   application.SendNotification();
10996   application.Render(5000); // After the animation is complete
10997
10998   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10999   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11000   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11001
11002   //////////////////////////////////////////////////////////////////////////////////
11003
11004   tet_infoline( "Same animation again but in a different order - should yield the same result" );
11005
11006   actor.SetX( 0.0f );
11007   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11008   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11009
11010   application.SendNotification();
11011   application.Render();
11012
11013   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11014   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11015   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11016
11017   animation = Animation::New( 0.0f );
11018   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11019   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11020   animation.Play();
11021
11022   tet_infoline( "The target position should change instantly" );
11023   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11024   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11025
11026   application.SendNotification();
11027   application.Render(5000); // After the animation is complete
11028
11029   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11030   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11031   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11032
11033   END_TEST;
11034 }
11035
11036 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11037 {
11038   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place with several AnimateTo calls" );
11039
11040   TestApplication application;
11041
11042   Actor actor = Actor::New();
11043   Stage::GetCurrent().Add( actor );
11044
11045   application.SendNotification();
11046   application.Render();
11047
11048   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11049   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11050   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11051   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11052   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11053
11054   //////////////////////////////////////////////////////////////////////////////////
11055
11056   tet_infoline( "" );
11057
11058   Animation animation = Animation::New( 0.0f );
11059   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11060   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11061   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11062   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11063   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11064   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11065   animation.Play();
11066
11067   tet_infoline( "The target position should change instantly" );
11068   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11069   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11070
11071   application.SendNotification();
11072   application.Render(14000); // After the animation is complete
11073
11074   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11075   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11076   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11077
11078   //////////////////////////////////////////////////////////////////////////////////
11079
11080   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11081
11082   actor.SetX( 0.0f );
11083
11084   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11085   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11086
11087   application.SendNotification();
11088   application.Render();
11089
11090   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11091   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11092   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11093
11094   animation = Animation::New( 0.0f );
11095   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11096   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11097   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11098   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11099   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11100   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11101   animation.Play();
11102
11103   tet_infoline( "The target position should change instantly" );
11104   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11105   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11106
11107   application.SendNotification();
11108   application.Render(14000); // After the animation is complete
11109
11110   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11111   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11112   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11113
11114   END_TEST;
11115 }
11116
11117 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11118 {
11119   TestApplication application;
11120
11121   int startValue(1);
11122   Actor actor = Actor::New();
11123   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11124   Stage::GetCurrent().Add(actor);
11125
11126   application.Render();
11127   application.SendNotification();
11128
11129   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11130
11131   // Build the animation
11132   float durationSeconds(1.0f);
11133   Animation animation = Animation::New(durationSeconds);
11134
11135   KeyFrames keyFrames = KeyFrames::New();
11136   keyFrames.Add(0.0f, 10);
11137   keyFrames.Add(0.2f, 20);
11138   keyFrames.Add(0.4f, 30);
11139   keyFrames.Add(0.6f, 40);
11140   keyFrames.Add(0.8f, 50);
11141   keyFrames.Add(1.0f, 60);
11142
11143   animation.AnimateBetween( Property(actor, index ), keyFrames );
11144
11145   // Start the animation
11146   animation.Play();
11147
11148   // Target value should change to the last key-frame's value straight away
11149   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11150
11151   END_TEST;
11152 }
11153
11154 int UtcDaliAnimationAnimateBetweenVector2P(void)
11155 {
11156   TestApplication application;
11157
11158   Vector2 startValue( 10.0f, 20.0f );
11159   Actor actor = Actor::New();
11160   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11161   Stage::GetCurrent().Add(actor);
11162
11163   application.Render();
11164   application.SendNotification();
11165
11166   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11167
11168   // Build the animation
11169   float durationSeconds(1.0f);
11170   Animation animation = Animation::New(durationSeconds);
11171
11172   KeyFrames keyFrames = KeyFrames::New();
11173   keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11174   keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11175   keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11176   keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11177   keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11178   keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11179
11180   animation.AnimateBetween( Property(actor, index ), keyFrames );
11181
11182   // Start the animation
11183   animation.Play();
11184
11185   // Target value should change to the last key-frame's value straight away
11186   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11187
11188   END_TEST;
11189 }
11190
11191 int UtcDaliAnimationProgressCallbackP(void)
11192 {
11193   TestApplication application;
11194
11195   Actor actor = Actor::New();
11196   Stage::GetCurrent().Add(actor);
11197
11198   // Build the animation
11199   Animation animation = Animation::New(0.0f);
11200
11201   //Set duration
11202   float durationSeconds(1.0f);
11203   animation.SetDuration(durationSeconds);
11204
11205   bool finishedSignalReceived(false);
11206   bool progressSignalReceived(false);
11207
11208   AnimationFinishCheck finishCheck(finishedSignalReceived);
11209   animation.FinishedSignal().Connect(&application, finishCheck);
11210
11211   AnimationProgressCheck progressCheck(progressSignalReceived);
11212   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
11213   application.SendNotification();
11214
11215   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11216   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
11217
11218   tet_infoline( "Animation Progress notification set to 30%" );
11219   DevelAnimation::SetProgressNotification( animation, 0.3f );
11220
11221   application.SendNotification();
11222   application.Render( );
11223
11224   DALI_TEST_EQUALS( 0.3f, DevelAnimation::GetProgressNotification( animation ), TEST_LOCATION );
11225
11226   progressCheck.CheckSignalNotReceived();
11227
11228   // Start the animation from 10% progress
11229   animation.SetCurrentProgress( 0.1f );
11230   animation.Play();
11231
11232   tet_infoline( "Animation Playing from 10%" );
11233
11234   application.SendNotification();
11235   application.Render(0); // start animation
11236   application.Render(durationSeconds*100.0f ); // 20% progress
11237
11238   tet_infoline( "Animation at 20%" );
11239
11240   progressCheck.CheckSignalNotReceived();
11241
11242   application.SendNotification();
11243   application.Render(durationSeconds*200.0f ); // 40% progress
11244   application.SendNotification();
11245   tet_infoline( "Animation at 40%" );
11246   DALI_TEST_EQUALS( 0.4f, animation.GetCurrentProgress(), TEST_LOCATION );
11247
11248   progressCheck.CheckSignalReceived();
11249
11250   tet_infoline( "Progress check reset" );
11251   progressCheck.Reset();
11252
11253   application.Render(durationSeconds*100.0f ); // 50% progress
11254   tet_infoline( "Animation at 50%" );
11255   application.SendNotification();
11256
11257   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
11258
11259   progressCheck.CheckSignalNotReceived();
11260
11261   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
11262   application.SendNotification();
11263
11264   tet_infoline( "Animation at 60%" );
11265
11266   finishCheck.CheckSignalNotReceived();
11267
11268   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
11269   application.SendNotification();
11270   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
11271   tet_infoline( "Animation at 80%" );
11272
11273   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
11274   // We did expect the animation to finish
11275   application.SendNotification();
11276   finishCheck.CheckSignalReceived();
11277   tet_infoline( "Animation finished" );
11278   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11279
11280   END_TEST;
11281 }
11282
11283 int UtcDaliAnimationPlayAfterP(void)
11284 {
11285   TestApplication application;
11286
11287   tet_printf("Testing that playing after 2 seconds\n");
11288
11289   {
11290     Actor actor = Actor::New();
11291     Stage::GetCurrent().Add(actor);
11292
11293     // Build the animation
11294     float durationSeconds(1.0f);
11295     Animation animation = Animation::New(durationSeconds);
11296
11297     bool signalReceived( false );
11298     AnimationFinishCheck finishCheck( signalReceived );
11299     animation.FinishedSignal().Connect( &application, finishCheck );
11300     application.SendNotification();
11301
11302     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11303     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11304
11305     // Play animation after the initial delay time
11306     animation.PlayAfter( 0.2f );
11307     application.SendNotification();
11308     application.Render(0); // start animation
11309
11310     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11311     application.SendNotification();
11312     finishCheck.CheckSignalNotReceived();
11313     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11314
11315     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11316
11317     // We didn't expect the animation to finish yet
11318     application.SendNotification();
11319     finishCheck.CheckSignalNotReceived();
11320     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11321
11322     application.SendNotification();
11323     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11324
11325     application.SendNotification();
11326     finishCheck.CheckSignalNotReceived();
11327     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11328
11329     application.SendNotification();
11330     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11331
11332     // We did expect the animation to finish
11333     application.SendNotification();
11334     finishCheck.CheckSignalReceived();
11335     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11336
11337     // Check that nothing has changed after a couple of buffer swaps
11338     application.Render(0);
11339     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11340   }
11341
11342   tet_printf("Testing that playing after 2 seconds with negative speedfactor\n");
11343   // SpeedFactor < 0
11344   {
11345     Actor actor = Actor::New();
11346     Stage::GetCurrent().Add(actor);
11347
11348     // Build the animation
11349     float durationSeconds(1.0f);
11350     Animation animation = Animation::New(durationSeconds);
11351     animation.SetSpeedFactor( -1.0f ); // Set SpeedFactor as < 0
11352
11353     bool signalReceived( false );
11354     AnimationFinishCheck finishCheck( signalReceived );
11355     animation.FinishedSignal().Connect( &application, finishCheck );
11356     application.SendNotification();
11357
11358     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11359     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11360
11361     // Play animation after the initial delay time
11362     animation.PlayAfter( 0.2f );
11363     application.SendNotification();
11364     application.Render(0); // start animation
11365
11366     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11367     application.SendNotification();
11368     finishCheck.CheckSignalNotReceived();
11369     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11370
11371     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11372
11373     // We didn't expect the animation to finish yet
11374     application.SendNotification();
11375     finishCheck.CheckSignalNotReceived();
11376     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11377
11378     application.SendNotification();
11379     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11380
11381     application.SendNotification();
11382     finishCheck.CheckSignalNotReceived();
11383     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11384
11385     application.SendNotification();
11386     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) + 1u/*just beyond the animation duration*/ );
11387
11388     // We did expect the animation to finish
11389     application.SendNotification();
11390     finishCheck.CheckSignalReceived();
11391     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of Timeperiod in seconds
11392
11393     // Check that nothing has changed after a couple of buffer swaps
11394     application.Render(0);
11395     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11396   }
11397
11398   END_TEST;
11399 }
11400
11401 int UtcDaliAnimationPlayAfterP2(void)
11402 {
11403   TestApplication application;
11404
11405   tet_printf("Testing that playing after 2 seconds before looping\n");
11406
11407   {
11408     Actor actor = Actor::New();
11409     Stage::GetCurrent().Add(actor);
11410
11411     // Build the animation
11412     float durationSeconds(1.0f);
11413     Animation animation = Animation::New(durationSeconds);
11414     animation.SetLooping( true );
11415
11416     bool signalReceived( false );
11417     AnimationFinishCheck finishCheck( signalReceived );
11418     animation.FinishedSignal().Connect( &application, finishCheck );
11419     application.SendNotification();
11420
11421     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11422     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11423
11424     // Play animation after the initial delay time
11425     animation.PlayAfter( 0.2f );
11426     application.SendNotification();
11427     application.Render(0); // start animation
11428
11429     for( int iterations = 0; iterations < 3; ++iterations )
11430     {
11431       // The initial delay time of PlayAfter() applies only once in looping mode.
11432       if( iterations == 0 )
11433       {
11434         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11435         application.SendNotification();
11436         finishCheck.CheckSignalNotReceived();
11437         DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11438       }
11439
11440       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11441
11442       // We didn't expect the animation to finish yet
11443       application.SendNotification();
11444       finishCheck.CheckSignalNotReceived();
11445       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11446
11447       application.SendNotification();
11448       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11449
11450       application.SendNotification();
11451       finishCheck.CheckSignalNotReceived();
11452       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11453
11454       application.SendNotification();
11455       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) /* 100% progress */ );
11456
11457       // We did expect the animation to finish
11458       application.SendNotification();
11459       finishCheck.CheckSignalNotReceived();
11460       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11461     }
11462
11463     animation.SetLooping(false);
11464     application.SendNotification();
11465     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11466
11467     application.SendNotification();
11468     finishCheck.CheckSignalReceived();
11469     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11470   }
11471
11472   tet_printf("Testing that playing after 2 seconds before looping with negative speedfactor\n");
11473   // SpeedFactor < 0
11474   {
11475     Actor actor = Actor::New();
11476     Stage::GetCurrent().Add(actor);
11477
11478     // Build the animation
11479     float durationSeconds(1.0f);
11480     Animation animation = Animation::New(durationSeconds);
11481     animation.SetLooping( true );
11482     animation.SetSpeedFactor( -1.0f ); //Set SpeedFactor as < 0
11483
11484     bool signalReceived( false );
11485     AnimationFinishCheck finishCheck( signalReceived );
11486     animation.FinishedSignal().Connect( &application, finishCheck );
11487     application.SendNotification();
11488
11489     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11490     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11491
11492     // Play animation after the initial delay time
11493     animation.PlayAfter( 0.2f );
11494     application.SendNotification();
11495     application.Render(0); // start animation
11496
11497     for( int iterations = 0; iterations < 3; ++iterations )
11498     {
11499       // The initial delay time of PlayAfter() applies only once in looping mode.
11500       if( iterations == 0 )
11501       {
11502         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11503         application.SendNotification();
11504         finishCheck.CheckSignalNotReceived();
11505         DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11506       }
11507
11508       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11509
11510       // We didn't expect the animation to finish yet
11511       application.SendNotification();
11512       finishCheck.CheckSignalNotReceived();
11513       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11514
11515       application.SendNotification();
11516       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11517
11518       application.SendNotification();
11519       finishCheck.CheckSignalNotReceived();
11520       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11521
11522       application.SendNotification();
11523       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) /* 100% progress */ );
11524
11525       // We did expect the animation to finish
11526       application.SendNotification();
11527       finishCheck.CheckSignalNotReceived();
11528       DALI_TEST_EQUALS( actor.GetCurrentPosition(),  ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in second
11529     }
11530
11531     animation.SetLooping(false);
11532     application.SendNotification();
11533     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11534
11535     application.SendNotification();
11536     finishCheck.CheckSignalReceived();
11537     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11538   }
11539
11540   END_TEST;
11541 }
11542
11543 int UtcDaliAnimationPlayAfterP3(void)
11544 {
11545   TestApplication application;
11546
11547   tet_printf("Testing that PlayAfter with the negative delay seconds\n");
11548
11549   Actor actor = Actor::New();
11550   Stage::GetCurrent().Add(actor);
11551
11552   // Build the animation
11553   float durationSeconds(1.0f);
11554   Animation animation = Animation::New(durationSeconds);
11555
11556   bool signalReceived( false );
11557   AnimationFinishCheck finishCheck( signalReceived );
11558   animation.FinishedSignal().Connect( &application, finishCheck );
11559   application.SendNotification();
11560
11561   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11562   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11563
11564   // When the delay time is negative value, it would treat as play immediately.
11565   animation.PlayAfter( -2.0f );
11566   application.SendNotification();
11567   application.Render(0); // start animation
11568
11569   application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11570
11571   // We didn't expect the animation to finish yet
11572   application.SendNotification();
11573   finishCheck.CheckSignalNotReceived();
11574   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11575
11576   application.SendNotification();
11577   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11578
11579   application.SendNotification();
11580   finishCheck.CheckSignalNotReceived();
11581   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11582
11583   application.SendNotification();
11584   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11585
11586   // We did expect the animation to finish
11587   application.SendNotification();
11588   finishCheck.CheckSignalReceived();
11589   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11590
11591   // Check that nothing has changed after a couple of buffer swaps
11592   application.Render(0);
11593   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11594   END_TEST;
11595 }
11596
11597 int UtcDaliAnimationPlayAfterP4(void)
11598 {
11599   TestApplication application;
11600
11601   tet_printf("Testing that PlayAfter with progress value\n");
11602
11603   Actor actor = Actor::New();
11604   Stage::GetCurrent().Add(actor);
11605
11606   // Build the animation
11607   float durationSeconds(1.0f);
11608   Animation animation = Animation::New(durationSeconds);
11609
11610   bool signalReceived( false );
11611   AnimationFinishCheck finishCheck( signalReceived );
11612   animation.FinishedSignal().Connect( &application, finishCheck );
11613   application.SendNotification();
11614
11615   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11616   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11617
11618   // Delay time is 0.3s. So after duration times, progress must be 70%. animation will finished at 1.3s.
11619   animation.PlayAfter( durationSeconds * 0.3f );
11620   application.SendNotification();
11621   application.Render(0); // start animation
11622
11623   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 5/6 delay progress, 0% animation progress, 0% animator progress */ );
11624
11625   // We didn't expect the animation to finish yet
11626   application.SendNotification();
11627   finishCheck.CheckSignalNotReceived();
11628   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of PlayAfter
11629
11630   application.SendNotification();
11631   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 20% animation progress, 0% animator progress */ );
11632
11633   application.SendNotification();
11634   finishCheck.CheckSignalNotReceived();
11635   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11636
11637   application.SendNotification();
11638   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 45% animation progress, 0% animator progress */ );
11639
11640   application.SendNotification();
11641   finishCheck.CheckSignalNotReceived();
11642   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11643
11644   application.SendNotification();
11645   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 70% animation progress, 40% animator progress */ );
11646
11647   application.SendNotification();
11648   finishCheck.CheckSignalNotReceived();
11649   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.4f ), TEST_LOCATION ); // 40% of animator progress
11650
11651   application.SendNotification();
11652   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 95% animation progress, 90% animator progress */ );
11653
11654   application.SendNotification();
11655   finishCheck.CheckSignalNotReceived();
11656   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION ); // 90% of animator progress
11657
11658   application.SendNotification();
11659   application.Render( static_cast< unsigned int >( durationSeconds * 50.0f ) + 1u/*just beyond the animation duration*/ );
11660
11661   // We did expect the animation to finish
11662   application.SendNotification();
11663   finishCheck.CheckSignalReceived();
11664   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11665
11666   // Check that nothing has changed after a couple of buffer swaps
11667   application.Render(0);
11668   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11669   END_TEST;
11670 }
11671
11672 int UtcDaliAnimationSetLoopingModeP(void)
11673 {
11674   // Test Loop forever and Loop mode being set
11675   TestApplication application;
11676   Stage stage( Stage::GetCurrent() );
11677
11678   // Default: LoopingMode::RESTART
11679   {
11680     Actor actor = Actor::New();
11681     stage.Add( actor );
11682
11683     float durationSeconds( 1.0f );
11684     Animation animation = Animation::New( durationSeconds );
11685     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
11686
11687     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
11688     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11689
11690     // Start the animation
11691     animation.Play();
11692     application.SendNotification();
11693     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
11694
11695     actor.Unparent();
11696
11697     application.SendNotification();
11698     application.Render();
11699     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11700   }
11701
11702   // LoopingMode::AUTO_REVERSE
11703   {
11704     Actor actor = Actor::New();
11705     stage.Add( actor );
11706
11707     float durationSeconds( 1.0f );
11708     Animation animation = Animation::New( durationSeconds );
11709     animation.SetLooping( true );
11710
11711     bool signalReceived( false );
11712     AnimationFinishCheck finishCheck( signalReceived );
11713     animation.FinishedSignal().Connect( &application, finishCheck );
11714     application.SendNotification();
11715
11716     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11717     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11718
11719     animation.SetLoopingMode( Animation::LoopingMode::AUTO_REVERSE );
11720     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11721
11722     // Start the animation
11723     animation.Play();
11724     application.SendNotification();
11725     application.Render(0);
11726
11727     for( int iterations = 0; iterations < 3; ++iterations )
11728     {
11729       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11730       application.SendNotification();
11731       finishCheck.CheckSignalNotReceived();
11732
11733       // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11734       // and arrives at the beginning.
11735       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11736
11737       application.SendNotification();
11738       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11739
11740       // We did expect the animation to finish
11741       application.SendNotification();
11742       finishCheck.CheckSignalNotReceived();
11743       DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11744     }
11745
11746     animation.SetLooping( false );
11747     application.SendNotification();
11748     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11749
11750     application.SendNotification();
11751     finishCheck.CheckSignalReceived();
11752
11753     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11754   }
11755
11756   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11757   {
11758     Actor actor = Actor::New();
11759     stage.Add( actor );
11760
11761     float durationSeconds( 1.0f );
11762     Animation animation = Animation::New( durationSeconds );
11763     animation.SetLooping( true );
11764
11765     bool signalReceived( false );
11766     AnimationFinishCheck finishCheck( signalReceived );
11767     animation.FinishedSignal().Connect( &application, finishCheck );
11768     application.SendNotification();
11769
11770     // Specify a negative multiplier to play the animation in reverse
11771     animation.SetSpeedFactor( -1.0f );
11772
11773     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11774     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11775
11776     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11777     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11778
11779     // Start the animation
11780     animation.Play();
11781     application.SendNotification();
11782     application.Render(0);
11783
11784     for( int iterations = 0; iterations < 3; ++iterations )
11785     {
11786       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11787       application.SendNotification();
11788       finishCheck.CheckSignalNotReceived();
11789
11790       // Setting a negative speed factor is to play the animation in reverse.
11791       // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11792       // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11793       DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11794
11795       application.SendNotification();
11796       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11797
11798       // We did expect the animation to finish
11799       application.SendNotification();
11800       finishCheck.CheckSignalNotReceived();
11801       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11802     }
11803
11804     animation.SetLooping( false );
11805     application.SendNotification();
11806     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11807
11808     application.SendNotification();
11809     finishCheck.CheckSignalReceived();
11810
11811     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11812   }
11813
11814   END_TEST;
11815 }
11816
11817 int UtcDaliAnimationSetLoopingModeP2(void)
11818 {
11819   // Test Loop Count and Loop mode being set
11820   TestApplication application;
11821   Stage stage( Stage::GetCurrent() );
11822
11823   // LoopingMode::AUTO_REVERSE
11824   {
11825     Actor actor = Actor::New();
11826     stage.Add( actor );
11827
11828     float durationSeconds( 1.0f );
11829     Animation animation = Animation::New( durationSeconds );
11830     animation.SetLoopCount(3);
11831     DALI_TEST_CHECK(animation.IsLooping());
11832
11833     bool signalReceived( false );
11834     AnimationFinishCheck finishCheck( signalReceived );
11835     animation.FinishedSignal().Connect( &application, finishCheck );
11836     application.SendNotification();
11837
11838     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11839     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11840
11841     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11842     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11843
11844     // Start the animation
11845     animation.Play();
11846
11847     application.Render(0);
11848     application.SendNotification();
11849     application.Render(0);
11850     application.SendNotification();
11851     application.Render(0);
11852     application.SendNotification();
11853     application.Render(0);
11854     application.SendNotification();
11855
11856     // Loop
11857     float intervalSeconds = 3.0f;
11858
11859     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11860     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11861     // and arrives at the beginning.
11862     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11863
11864     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11865
11866     application.Render(0);
11867     application.SendNotification();
11868     application.Render(0);
11869     application.SendNotification();
11870     application.Render(0);
11871     application.SendNotification();
11872     application.Render(0);
11873     application.SendNotification();
11874     finishCheck.CheckSignalNotReceived();
11875
11876     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11877
11878     application.SendNotification();
11879     finishCheck.CheckSignalReceived();
11880     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11881
11882     finishCheck.Reset();
11883   }
11884
11885   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11886   {
11887     Actor actor = Actor::New();
11888     stage.Add( actor );
11889
11890     float durationSeconds( 1.0f );
11891     Animation animation = Animation::New( durationSeconds );
11892     animation.SetLoopCount(3);
11893     DALI_TEST_CHECK(animation.IsLooping());
11894
11895     bool signalReceived( false );
11896     AnimationFinishCheck finishCheck( signalReceived );
11897     animation.FinishedSignal().Connect( &application, finishCheck );
11898     application.SendNotification();
11899
11900     // Specify a negative multiplier to play the animation in reverse
11901     animation.SetSpeedFactor( -1.0f );
11902
11903     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11904     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11905
11906     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11907     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11908
11909     // Start the animation
11910     animation.Play();
11911
11912     application.Render(0);
11913     application.SendNotification();
11914     application.Render(0);
11915     application.SendNotification();
11916     application.Render(0);
11917     application.SendNotification();
11918     application.Render(0);
11919     application.SendNotification();
11920
11921     // Loop
11922     float intervalSeconds = 3.0f;
11923
11924     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11925     // Setting a negative speed factor is to play the animation in reverse.
11926     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11927     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11928     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11929
11930     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11931
11932     application.Render(0);
11933     application.SendNotification();
11934     application.Render(0);
11935     application.SendNotification();
11936     application.Render(0);
11937     application.SendNotification();
11938     application.Render(0);
11939     application.SendNotification();
11940     finishCheck.CheckSignalNotReceived();
11941
11942     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11943
11944     application.SendNotification();
11945     finishCheck.CheckSignalReceived();
11946     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11947
11948     finishCheck.Reset();
11949   }
11950
11951   END_TEST;
11952 }
11953
11954 int UtcDaliAnimationSetLoopingModeP3(void)
11955 {
11956   // Test Loop Count is 1 (== default) and Loop mode being set
11957   TestApplication application;
11958   Stage stage( Stage::GetCurrent() );
11959
11960   // LoopingMode::AUTO_REVERSE
11961   {
11962     Actor actor = Actor::New();
11963     stage.Add( actor );
11964
11965     float durationSeconds( 1.0f );
11966     Animation animation = Animation::New( durationSeconds );
11967     DALI_TEST_CHECK(1 == animation.GetLoopCount());
11968
11969     bool signalReceived( false );
11970     AnimationFinishCheck finishCheck( signalReceived );
11971     animation.FinishedSignal().Connect( &application, finishCheck );
11972     application.SendNotification();
11973
11974     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11975     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11976
11977     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11978     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11979
11980     // Start the animation
11981     animation.Play();
11982     application.Render(0);
11983     application.SendNotification();
11984
11985     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
11986     application.SendNotification();
11987     finishCheck.CheckSignalNotReceived();
11988
11989     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11990     // and arrives at the beginning.
11991     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11992
11993     application.SendNotification();
11994     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
11995
11996     application.SendNotification();
11997     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11998
11999     application.SendNotification();
12000     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12001
12002     application.SendNotification();
12003     application.Render(0);
12004     application.SendNotification();
12005     finishCheck.CheckSignalReceived();
12006
12007     // After all animation finished, arrives at the beginning.
12008     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12009
12010     finishCheck.Reset();
12011   }
12012
12013   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
12014   {
12015     Actor actor = Actor::New();
12016     stage.Add( actor );
12017
12018     float durationSeconds( 1.0f );
12019     Animation animation = Animation::New( durationSeconds );
12020     DALI_TEST_CHECK(1 == animation.GetLoopCount());
12021
12022     bool signalReceived( false );
12023     AnimationFinishCheck finishCheck( signalReceived );
12024     animation.FinishedSignal().Connect( &application, finishCheck );
12025     application.SendNotification();
12026
12027     // Specify a negative multiplier to play the animation in reverse
12028     animation.SetSpeedFactor( -1.0f );
12029
12030     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12031     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12032
12033     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12034     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12035
12036     // Start the animation
12037     animation.Play();
12038     application.Render(0);
12039     application.SendNotification();
12040
12041     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12042     application.SendNotification();
12043     finishCheck.CheckSignalNotReceived();
12044
12045     // Setting a negative speed factor is to play the animation in reverse.
12046     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12047     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12048     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12049
12050     application.SendNotification();
12051     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12052
12053     application.SendNotification();
12054     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12055
12056     application.SendNotification();
12057     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12058
12059     application.SendNotification();
12060     application.Render(0);
12061     application.SendNotification();
12062     finishCheck.CheckSignalReceived();
12063
12064     // After all animation finished, arrives at the target.
12065     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12066
12067     finishCheck.Reset();
12068   }
12069
12070   END_TEST;
12071 }
12072
12073 int UtcDaliAnimationGetLoopingModeP(void)
12074 {
12075   TestApplication application;
12076
12077   Animation animation = Animation::New(1.0f);
12078
12079   // default mode
12080   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
12081
12082   animation.SetLoopingMode( Animation::AUTO_REVERSE );
12083   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12084
12085   END_TEST;
12086 }
12087
12088 int UtcDaliAnimationProgressSignalConnectionWithoutProgressMarkerP(void)
12089 {
12090   TestApplication application;
12091
12092   tet_infoline( "Connect to ProgressReachedSignal but do not set a required Progress marker" );
12093
12094   Actor actor = Actor::New();
12095   Stage::GetCurrent().Add(actor);
12096
12097   // Build the animation
12098   Animation animation = Animation::New(0.0f);
12099
12100   //Set duration
12101   float durationSeconds(1.0f);
12102   animation.SetDuration(durationSeconds);
12103
12104   bool finishedSignalReceived(false);
12105   bool progressSignalReceived(false);
12106
12107   AnimationFinishCheck finishCheck(finishedSignalReceived);
12108   animation.FinishedSignal().Connect(&application, finishCheck);
12109
12110   AnimationProgressCheck progressCheck( progressSignalReceived );
12111   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12112   application.SendNotification();
12113
12114   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12115   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12116
12117   progressCheck.CheckSignalNotReceived();
12118
12119   animation.Play();
12120
12121   application.SendNotification();
12122   application.Render(0); // start animation
12123   application.Render(durationSeconds*100.0f ); // 10% progress
12124   application.SendNotification();
12125
12126   tet_infoline( "Ensure after animation has started playing that ProgressReachedSignal not emitted" );
12127   progressCheck.CheckSignalNotReceived();
12128
12129   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
12130
12131   application.SendNotification();
12132   finishCheck.CheckSignalReceived();
12133   tet_infoline( "Animation finished" );
12134   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12135
12136   END_TEST;
12137 }
12138
12139 int UtcDaliAnimationMultipleProgressSignalsP(void)
12140 {
12141   tet_infoline( "Multiple animations with different progress markers" );
12142
12143   TestApplication application;
12144
12145   Actor actor = Actor::New();
12146   Stage::GetCurrent().Add(actor);
12147
12148   // Build the animation
12149   Animation animationAlpha = Animation::New(0.0f);
12150   Animation animationBeta = Animation::New(0.0f);
12151
12152   //Set duration
12153   float durationSeconds(1.0f);
12154   animationAlpha.SetDuration(durationSeconds);
12155   animationBeta.SetDuration(durationSeconds);
12156
12157   bool progressSignalReceivedAlpha(false);
12158   bool progressSignalReceivedBeta(false);
12159
12160   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12161   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12162
12163   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12164   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12165   application.SendNotification();
12166
12167   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12168   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12169   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12170
12171   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12172   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12173
12174   tet_infoline( "AnimationBeta Progress notification set to 50%" );
12175   DevelAnimation::SetProgressNotification( animationBeta, 0.5f );
12176
12177   application.SendNotification();
12178   application.Render( );
12179
12180   progressCheckAlpha.CheckSignalNotReceived();
12181   progressCheckBeta.CheckSignalNotReceived();
12182
12183   // Start the animations from 10% progress
12184   animationAlpha.SetCurrentProgress( 0.1f );
12185   animationBeta.SetCurrentProgress( 0.1f );
12186   animationAlpha.Play();
12187   animationBeta.Play();
12188
12189   tet_infoline( "Animation Playing from 10%" );
12190
12191   application.SendNotification();
12192   application.Render(0); // start animation
12193   application.Render(durationSeconds*100.0f ); // 20% progress
12194
12195   tet_infoline( "Animation at 20% - No signals to be received" );
12196
12197   progressCheckAlpha.CheckSignalNotReceived();
12198   progressCheckBeta.CheckSignalNotReceived();
12199
12200   application.SendNotification();
12201   application.Render(durationSeconds*200.0f ); // 40% progress
12202   application.SendNotification();
12203   tet_infoline( "Animation at 40% - Alpha signal should be received" );
12204   DALI_TEST_EQUALS( 0.4f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12205
12206   progressCheckAlpha.CheckSignalReceived();
12207   progressCheckBeta.CheckSignalNotReceived();
12208
12209   tet_infoline( "Progress check reset" );
12210   progressCheckAlpha.Reset();
12211   progressCheckBeta.Reset();
12212
12213   application.Render(durationSeconds*100.0f ); // 50% progress
12214   tet_infoline( "Animation at 50% - Beta should receive signal, Alpha should not" );
12215   application.SendNotification();
12216
12217   DALI_TEST_EQUALS( 0.5f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12218
12219   progressCheckAlpha.CheckSignalNotReceived();
12220   progressCheckBeta.CheckSignalReceived();
12221   tet_infoline( "Progress check reset" );
12222   progressCheckAlpha.Reset();
12223   progressCheckBeta.Reset();
12224
12225   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
12226   application.SendNotification();
12227
12228   tet_infoline( "Animation at 60%" );
12229
12230   progressCheckAlpha.CheckSignalNotReceived();
12231   progressCheckBeta.CheckSignalNotReceived();
12232
12233   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12234   application.SendNotification();
12235   tet_infoline( "Animation at 80%" );
12236
12237   progressCheckAlpha.CheckSignalNotReceived();
12238   progressCheckBeta.CheckSignalNotReceived();
12239
12240   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12241   // We did expect the animation to finish
12242   tet_infoline( "Animation finished" );
12243
12244   END_TEST;
12245 }
12246
12247 int UtcDaliAnimationMultipleProgressSignalsP2(void)
12248 {
12249   tet_infoline( "Multiple animations with different progress markers and big step time" );
12250
12251   TestApplication application;
12252
12253   Actor actor = Actor::New();
12254   Stage::GetCurrent().Add(actor);
12255
12256   // Build the animation
12257   Animation animationAlpha = Animation::New(0.0f);
12258   Animation animationBeta = Animation::New(0.0f);
12259
12260   //Set duration
12261   const float durationSeconds(1.0f);
12262   animationAlpha.SetDuration(durationSeconds);
12263   animationBeta.SetDuration(durationSeconds);
12264
12265   bool progressSignalReceivedAlpha(false);
12266   bool progressSignalReceivedBeta(false);
12267
12268   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12269   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12270
12271   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12272   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12273   application.SendNotification();
12274
12275   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12276   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12277   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12278
12279   tet_infoline( "AnimationAlpha Progress notification set to 1%" );
12280   DevelAnimation::SetProgressNotification( animationAlpha, 0.01f );
12281
12282   tet_infoline( "AnimationBeta Progress notification set to 99%" );
12283   DevelAnimation::SetProgressNotification( animationBeta, 0.99f );
12284
12285   application.SendNotification();
12286   application.Render( );
12287
12288   progressCheckAlpha.CheckSignalNotReceived();
12289   progressCheckBeta.CheckSignalNotReceived();
12290
12291   // Start the animations unlimited looping
12292   animationAlpha.SetLooping( true );
12293   animationBeta.SetLooping( true );
12294   animationAlpha.Play();
12295   animationBeta.Play();
12296
12297   application.SendNotification();
12298   application.Render(0); // start animation
12299   application.Render(durationSeconds*20.0f ); // 2% progress
12300   application.SendNotification();
12301   DALI_TEST_EQUALS( 0.02f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12302
12303   tet_infoline( "Animation at 2% - Alpha signals should be received, Beta should not." );
12304
12305   progressCheckAlpha.CheckSignalReceived();
12306   progressCheckBeta.CheckSignalNotReceived();
12307
12308   tet_infoline( "Progress check reset" );
12309   progressCheckAlpha.Reset();
12310   progressCheckBeta.Reset();
12311
12312   application.SendNotification();
12313   application.Render(durationSeconds*960.0f ); // 98% progress
12314   application.SendNotification();
12315   tet_infoline( "Animation at 98% - No signal received" );
12316   DALI_TEST_EQUALS( 0.98f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12317
12318   progressCheckAlpha.CheckSignalNotReceived();
12319   progressCheckBeta.CheckSignalNotReceived();
12320
12321   application.SendNotification();
12322   application.Render(durationSeconds*40.0f ); // 2% progress
12323   application.SendNotification();
12324   tet_infoline( "Animation loop once and now 2% - Alpha and Beta should receive signal" );
12325   application.SendNotification();
12326
12327   DALI_TEST_EQUALS( 0.02f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12328
12329   progressCheckAlpha.CheckSignalReceived();
12330   progressCheckBeta.CheckSignalReceived();
12331
12332   tet_infoline( "Progress check reset" );
12333   progressCheckAlpha.Reset();
12334   progressCheckBeta.Reset();
12335
12336   application.SendNotification();
12337   application.Render(durationSeconds*980.0f ); // 100% progress
12338   application.SendNotification();
12339   tet_infoline( "Animation loop one more time. and now 100% - Beta should receive signal, Alhpa sholud not" );
12340   application.SendNotification();
12341
12342   progressCheckAlpha.CheckSignalNotReceived();
12343   progressCheckBeta.CheckSignalReceived();
12344
12345   tet_infoline( "Progress check reset" );
12346   progressCheckAlpha.Reset();
12347   progressCheckBeta.Reset();
12348
12349   animationAlpha.SetLooping( false );
12350   animationBeta.SetLooping( false );
12351
12352   application.SendNotification();
12353   application.Render(static_cast<unsigned int>(durationSeconds*2000.0f) + 1u/*just beyond the animation duration*/);
12354   application.SendNotification();
12355
12356   // We did expect the animation to finish
12357   tet_infoline( "Animation finished" );
12358
12359   END_TEST;
12360 }
12361
12362 int UtcDaliAnimationProgressSignalWithPlayAfterP(void)
12363 {
12364   tet_infoline( "Multiple animations with different progress markers" );
12365
12366   TestApplication application;
12367
12368   Actor actor = Actor::New();
12369   Stage::GetCurrent().Add(actor);
12370
12371   // Build the animation
12372   Animation animationAlpha = Animation::New(0.0f);
12373   Animation animationBeta = Animation::New(0.0f);
12374
12375   //Set duration
12376   float durationSeconds(1.0f);
12377   float delaySeconds(0.5f);
12378   animationAlpha.SetDuration(durationSeconds);
12379   animationBeta.SetDuration(durationSeconds);
12380
12381   bool progressSignalReceivedAlpha(false);
12382   bool progressSignalReceivedBeta(false);
12383
12384   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12385   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12386
12387   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12388   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12389   application.SendNotification();
12390
12391   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12392   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12393   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12394
12395   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12396   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12397
12398   tet_infoline( "AnimationBeta Progress notification set to ~0% (==Notify when delay is done)" );
12399   DevelAnimation::SetProgressNotification( animationBeta, Math::MACHINE_EPSILON_1 );
12400
12401   application.SendNotification();
12402   application.Render( );
12403
12404   progressCheckAlpha.CheckSignalNotReceived();
12405   progressCheckBeta.CheckSignalNotReceived();
12406
12407   // Start the animations from 10% progress
12408   animationAlpha.PlayAfter(delaySeconds);
12409   animationBeta.PlayAfter(delaySeconds);
12410
12411   application.SendNotification();
12412   application.Render(0); // start animation
12413   application.Render(delaySeconds * 500.0f ); // 50% wait progress
12414
12415   tet_infoline( "Delay at 50% - No signals to be received" );
12416
12417   progressCheckAlpha.CheckSignalNotReceived();
12418   progressCheckBeta.CheckSignalNotReceived();
12419
12420   application.SendNotification();
12421   application.Render(delaySeconds * 500.0f + durationSeconds * 50.0f ); // 100% wait, 5% progress
12422   application.SendNotification();
12423   tet_infoline( "Delay at 100%, Animation at 5% - Beta signal should be received" );
12424   DALI_TEST_EQUALS( 0.05f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12425
12426   progressCheckBeta.CheckSignalReceived();
12427   progressCheckAlpha.CheckSignalNotReceived();
12428
12429   tet_infoline( "Progress check reset" );
12430   progressCheckAlpha.Reset();
12431   progressCheckBeta.Reset();
12432
12433   application.Render(durationSeconds * 200.0f ); // 25% progress
12434   tet_infoline( "Animation at 25% - No signals to be received" );
12435   application.SendNotification();
12436
12437   progressCheckAlpha.CheckSignalNotReceived();
12438   progressCheckBeta.CheckSignalNotReceived();
12439
12440   application.Render(durationSeconds * 200.0f ); // 45% progress
12441   tet_infoline( "Animation at 45% - Alpha should receive signal, Beta should not" );
12442   application.SendNotification();
12443
12444   DALI_TEST_EQUALS( 0.45f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12445
12446   progressCheckAlpha.CheckSignalReceived();
12447   progressCheckBeta.CheckSignalNotReceived();
12448
12449   tet_infoline( "Progress check reset" );
12450   progressCheckAlpha.Reset();
12451   progressCheckBeta.Reset();
12452
12453   application.Render(static_cast<unsigned int>(durationSeconds*150.0f)/* 60% progress */);
12454   application.SendNotification();
12455
12456   tet_infoline( "Animation at 60%" );
12457
12458   progressCheckAlpha.CheckSignalNotReceived();
12459   progressCheckBeta.CheckSignalNotReceived();
12460
12461   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12462   application.SendNotification();
12463   tet_infoline( "Animation at 80%" );
12464
12465   progressCheckAlpha.CheckSignalNotReceived();
12466   progressCheckBeta.CheckSignalNotReceived();
12467
12468   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12469   // We did expect the animation to finish
12470   tet_infoline( "Animation finished" );
12471
12472   END_TEST;
12473 }
12474
12475 int UtcDaliAnimationProgressCallbackWithLoopingP(void)
12476 {
12477   TestApplication application;
12478
12479   Actor actor = Actor::New();
12480   Stage::GetCurrent().Add(actor);
12481
12482   // Build the animation
12483   Animation animation = Animation::New(0.0f);
12484
12485   //Set duration
12486   const float durationSeconds(1.0f);
12487   animation.SetDuration(durationSeconds);
12488
12489   // Set Looping Count
12490   const int loopCount( 4 );
12491   animation.SetLoopCount( loopCount );
12492
12493   bool finishedSignalReceived(false);
12494   bool progressSignalReceived(false);
12495
12496   AnimationFinishCheck finishCheck(finishedSignalReceived);
12497   animation.FinishedSignal().Connect(&application, finishCheck);
12498
12499   AnimationProgressCheck progressCheck(progressSignalReceived);
12500   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12501   application.SendNotification();
12502
12503   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12504   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12505
12506   tet_infoline( "Animation Progress notification set to 50% with looping count 4" );
12507   DevelAnimation::SetProgressNotification( animation, 0.5f );
12508
12509   application.SendNotification();
12510   application.Render( );
12511
12512   progressCheck.CheckSignalNotReceived();
12513
12514   animation.Play();
12515
12516   for(int count = 0; count < loopCount; count++)
12517   {
12518     application.SendNotification();
12519     application.Render(0); // start animation
12520     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12521     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12522
12523     tet_infoline( "Animation at 25%" );
12524
12525     progressCheck.CheckSignalNotReceived();
12526
12527     application.SendNotification();
12528     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12529     application.SendNotification();
12530     tet_infoline( "Animation at 50%" );
12531     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12532
12533     progressCheck.CheckSignalReceived();
12534
12535     tet_infoline( "Progress check reset" );
12536     progressCheck.Reset();
12537
12538     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12539     tet_infoline( "Animation at 75%" );
12540     application.SendNotification();
12541
12542     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12543
12544     progressCheck.CheckSignalNotReceived();
12545
12546     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12547     tet_infoline( "Animation at 100%" );
12548     application.SendNotification();
12549
12550     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12551     application.SendNotification();
12552   }
12553   application.Render(10u);
12554   application.SendNotification();
12555   application.Render(0u);
12556   application.SendNotification();
12557
12558   finishCheck.CheckSignalReceived();
12559
12560   END_TEST;
12561 }
12562
12563 int UtcDaliAnimationProgressCallbackWithLoopingP2(void)
12564 {
12565   TestApplication application;
12566
12567   Actor actor = Actor::New();
12568   Stage::GetCurrent().Add(actor);
12569
12570   // Build the animation
12571   Animation animation = Animation::New(0.0f);
12572
12573   //Set duration
12574   const float durationSeconds(1.0f);
12575   animation.SetDuration(durationSeconds);
12576
12577   // Set Looping Unlmited
12578   animation.SetLooping( true );
12579
12580   bool finishedSignalReceived(false);
12581   bool progressSignalReceived(false);
12582
12583   AnimationFinishCheck finishCheck(finishedSignalReceived);
12584   animation.FinishedSignal().Connect(&application, finishCheck);
12585
12586   AnimationProgressCheck progressCheck(progressSignalReceived);
12587   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12588   application.SendNotification();
12589
12590   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12591   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12592
12593   tet_infoline( "Animation Progress notification set to 50% with unlimited looping" );
12594   DevelAnimation::SetProgressNotification( animation, 0.5f );
12595
12596   application.SendNotification();
12597   application.Render( );
12598
12599   progressCheck.CheckSignalNotReceived();
12600
12601   animation.Play();
12602
12603   for(int count = 0; count < 4; count++)
12604   {
12605     application.SendNotification();
12606     application.Render(0); // start animation
12607     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12608     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12609
12610     tet_infoline( "Animation at 25%" );
12611
12612     progressCheck.CheckSignalNotReceived();
12613
12614     application.SendNotification();
12615     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12616     application.SendNotification();
12617     tet_infoline( "Animation at 50%" );
12618     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12619
12620     progressCheck.CheckSignalReceived();
12621
12622     tet_infoline( "Progress check reset" );
12623     progressCheck.Reset();
12624
12625     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12626     tet_infoline( "Animation at 75%" );
12627     application.SendNotification();
12628
12629     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12630
12631     progressCheck.CheckSignalNotReceived();
12632
12633     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12634     tet_infoline( "Animation at 100%" );
12635     application.SendNotification();
12636
12637     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12638     finishCheck.CheckSignalNotReceived();
12639     application.SendNotification();
12640   }
12641   finishCheck.CheckSignalNotReceived();
12642
12643   animation.SetLooping( false );
12644   application.Render(0u);
12645   application.SendNotification();
12646   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 10u);
12647   application.SendNotification();
12648   application.Render(0u);
12649   application.SendNotification();
12650
12651   finishCheck.CheckSignalReceived();
12652
12653   END_TEST;
12654 }
12655
12656 int UtcDaliAnimationProgressCallbackNegativeSpeed(void)
12657 {
12658   TestApplication application;
12659
12660   Actor actor = Actor::New();
12661   Stage::GetCurrent().Add(actor);
12662
12663   // Build the animation
12664   Animation animation = Animation::New(0.0f);
12665
12666   //Set duration
12667   const float durationSeconds(1.0f);
12668   animation.SetDuration(durationSeconds);
12669
12670   //Set speed negative
12671   animation.SetSpeedFactor( -1.0f );
12672
12673   // Set Looping Unlmited
12674   animation.SetLooping( true );
12675
12676   bool finishedSignalReceived(false);
12677   bool progressSignalReceived(false);
12678
12679   AnimationFinishCheck finishCheck(finishedSignalReceived);
12680   animation.FinishedSignal().Connect(&application, finishCheck);
12681
12682   AnimationProgressCheck progressCheck(progressSignalReceived);
12683   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12684   application.SendNotification();
12685
12686   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12687   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12688
12689   tet_infoline( "Animation Progress notification set to 50%" );
12690   DevelAnimation::SetProgressNotification( animation, 0.5f );
12691
12692   application.SendNotification();
12693   application.Render( );
12694
12695   progressCheck.CheckSignalNotReceived();
12696
12697   animation.Play();
12698
12699   for(int count = 0; count < 4; count++)
12700   {
12701     application.SendNotification();
12702     application.Render(0); // start animation
12703     progressCheck.CheckSignalNotReceived();
12704
12705     application.SendNotification();
12706     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12707     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12708
12709     tet_infoline( "Animation at 25%" );
12710
12711     progressCheck.CheckSignalNotReceived();
12712
12713     application.SendNotification();
12714     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12715     application.SendNotification();
12716     tet_infoline( "Animation at 50%" );
12717     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12718
12719     progressCheck.CheckSignalReceived();
12720
12721     tet_infoline( "Progress check reset" );
12722     progressCheck.Reset();
12723
12724     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12725     tet_infoline( "Animation at 75%" );
12726     application.SendNotification();
12727
12728     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12729
12730     progressCheck.CheckSignalNotReceived();
12731
12732     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12733     tet_infoline( "Animation at 100%" );
12734     application.SendNotification();
12735
12736     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12737     finishCheck.CheckSignalNotReceived();
12738     application.SendNotification();
12739   }
12740   finishCheck.CheckSignalNotReceived();
12741
12742   animation.Stop();
12743   animation.SetLooping( false );
12744   animation.SetLoopCount( 4 );
12745   animation.Play();
12746   application.Render(0u);
12747   application.SendNotification();
12748
12749   for(int count = 0; count < 4; count++)
12750   {
12751     application.SendNotification();
12752     application.Render(0); // start animation
12753     progressCheck.CheckSignalNotReceived();
12754
12755     application.SendNotification();
12756     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12757     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12758
12759     tet_infoline( "Animation at 25%" );
12760
12761     progressCheck.CheckSignalNotReceived();
12762
12763     application.SendNotification();
12764     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12765     application.SendNotification();
12766     tet_infoline( "Animation at 50%" );
12767     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12768
12769     progressCheck.CheckSignalReceived();
12770
12771     tet_infoline( "Progress check reset" );
12772     progressCheck.Reset();
12773
12774     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12775     tet_infoline( "Animation at 75%" );
12776     application.SendNotification();
12777
12778     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12779
12780     progressCheck.CheckSignalNotReceived();
12781
12782     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12783     tet_infoline( "Animation at 100%" );
12784     application.SendNotification();
12785
12786     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12787     application.SendNotification();
12788   }
12789   application.Render(10u);
12790   application.SendNotification();
12791   application.Render(0u);
12792   application.SendNotification();
12793
12794   finishCheck.CheckSignalReceived();
12795
12796   END_TEST;
12797 }
12798
12799 int UtcDaliAnimationProgressCallbackInvalidSignalN(void)
12800 {
12801   TestApplication application;
12802
12803   Actor actor = Actor::New();
12804   Stage::GetCurrent().Add(actor);
12805
12806   // Build the animation
12807   Animation animation = Animation::New(0.0f);
12808
12809   //Set duration
12810   const float durationSeconds(1.0f);
12811   animation.SetDuration(durationSeconds);
12812
12813   bool finishedSignalReceived(false);
12814   bool progressSignalReceived(false);
12815
12816   AnimationFinishCheck finishCheck(finishedSignalReceived);
12817   animation.FinishedSignal().Connect(&application, finishCheck);
12818
12819   AnimationProgressCheck progressCheck(progressSignalReceived);
12820   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12821   application.SendNotification();
12822
12823   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12824   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12825
12826   tet_infoline( "Animation Progress PlayRange as 10% ~ 90%" );
12827   animation.SetPlayRange( Vector2( 0.1f, 0.9f ) );
12828
12829   tet_infoline( "Animation Progress notification set to >90% that never can notificated" );
12830   DevelAnimation::SetProgressNotification( animation, 0.9f + Math::MACHINE_EPSILON_1 );
12831
12832   application.SendNotification();
12833   application.Render( );
12834
12835   progressCheck.CheckSignalNotReceived();
12836
12837   animation.Play();
12838
12839   application.SendNotification();
12840   application.Render(0); // start animation
12841   application.Render(durationSeconds*0.25*1000.0f ); // 35% progress
12842   DALI_TEST_EQUALS( 0.35f, animation.GetCurrentProgress(), TEST_LOCATION );
12843
12844   tet_infoline( "Animation at 35%" );
12845
12846   progressCheck.CheckSignalNotReceived();
12847
12848   application.SendNotification();
12849   application.Render(durationSeconds*0.25*1000.0f ); // 60% progress
12850   application.SendNotification();
12851   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
12852
12853   tet_infoline( "Animation at 60%" );
12854
12855   progressCheck.CheckSignalNotReceived();
12856
12857   application.Render(durationSeconds*0.25*1000.0f ); // 85% progress
12858   tet_infoline( "Animation at 85%" );
12859   application.SendNotification();
12860   DALI_TEST_EQUALS( 0.85f, animation.GetCurrentProgress(), TEST_LOCATION );
12861
12862   progressCheck.CheckSignalNotReceived();
12863
12864   application.Render(durationSeconds*0.25*1000.0f ); // 90% progress
12865   tet_infoline( "Animation over 90%" );
12866   application.SendNotification();
12867
12868   // progress never signaled because playrange is 90%
12869   progressCheck.CheckSignalNotReceived();
12870
12871   END_TEST;
12872 }
12873
12874 int UtcDaliAnimationProgressCallbackLongDurationP(void)
12875 {
12876   TestApplication application;
12877
12878   Actor actor = Actor::New();
12879   Stage::GetCurrent().Add(actor);
12880
12881   // Build the animation
12882   Animation animation = Animation::New(0.0f);
12883
12884   //Set duration
12885   float durationSeconds(5.0f);
12886   animation.SetDuration(durationSeconds);
12887
12888   bool finishedSignalReceived(false);
12889   bool progressSignalReceived(false);
12890
12891   AnimationFinishCheck finishCheck(finishedSignalReceived);
12892   animation.FinishedSignal().Connect(&application, finishCheck);
12893
12894   AnimationProgressCheck progressCheck(progressSignalReceived);
12895   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12896   application.SendNotification();
12897
12898   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12899   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12900
12901   tet_infoline( "Animation Progress notification set to 50%" );
12902   DevelAnimation::SetProgressNotification( animation, 0.5f );
12903
12904   application.SendNotification();
12905   application.Render( );
12906
12907   progressCheck.CheckSignalNotReceived();
12908
12909   animation.Play();
12910
12911   application.SendNotification();
12912   application.Render(0); // start animation
12913   application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12914   DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12915
12916   tet_infoline( "Animation at 25%" );
12917
12918   progressCheck.CheckSignalNotReceived();
12919
12920   application.SendNotification();
12921   application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12922   application.SendNotification();
12923   tet_infoline( "Animation at 50%" );
12924   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12925
12926   progressCheck.CheckSignalReceived();
12927
12928   tet_infoline( "Progress check reset" );
12929   progressCheck.Reset();
12930
12931   application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12932   tet_infoline( "Animation at 75%" );
12933   application.SendNotification();
12934
12935   DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12936
12937   progressCheck.CheckSignalNotReceived();
12938
12939   END_TEST;
12940 }
12941
12942 int UtcDaliAnimationAnimateByInvalidParameters(void)
12943 {
12944   TestApplication application;
12945
12946   Actor actor = Actor::New();
12947   Stage::GetCurrent().Add(actor);
12948
12949   // Create the animation
12950   Animation animation = Animation::New(1.0f);
12951
12952   DALI_TEST_ASSERTION(
12953   {
12954     // non animateable property (STRING)
12955     animation.AnimateBy( Property( actor, Actor::Property::LAYOUT_DIRECTION ), Property::Value( "new direction" ) );
12956   }, "Property type is not animatable" );
12957
12958   DALI_TEST_ASSERTION(
12959   {
12960     // non animateable property (MATRIX)
12961     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Dali::Matrix() ), Property::ANIMATABLE );
12962     animation.AnimateBy( Property( actor, index ), Property::Value( Property::MATRIX ) );
12963   }, "Property type is not animatable" );
12964
12965   // AnimateBy
12966   DALI_TEST_ASSERTION(
12967   {
12968     // non animateable target (NONE)
12969     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value() );
12970   }, "Target value is not animatable" );
12971
12972   DALI_TEST_ASSERTION(
12973   {
12974     // non animateable target (STRING)
12975     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value("foo") );
12976   }, "Target value is not animatable" );
12977
12978   DALI_TEST_ASSERTION(
12979   {
12980     // not mathing properties (VECTOR3, FLOAT)
12981     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( 10.f ) );
12982   }, "Property and target types don't match" );
12983
12984   DALI_TEST_ASSERTION(
12985   {
12986     // not mathing properties (VECTOR3.A, VECTOR2)
12987     animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), Property::Value( Property::VECTOR2 ) );
12988   }, "Property and target types don't match" );
12989
12990   DALI_TEST_ASSERTION(
12991   {
12992     // negative duration
12993     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
12994   }, "Duration must be >=0" );
12995
12996   END_TEST;
12997 }
12998
12999 int UtcDaliAnimationAnimateToInvalidParameters(void)
13000 {
13001   TestApplication application;
13002
13003   Actor actor = Actor::New();
13004   Stage::GetCurrent().Add(actor);
13005
13006   // Create the animation
13007   Animation animation = Animation::New(1.0f);
13008
13009   // AnimateTo
13010   DALI_TEST_ASSERTION(
13011   {
13012     // non animateable property (MAP)
13013     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::MAP ), Property::ANIMATABLE );
13014     animation.AnimateTo( Property( actor, index ), Property::Value( Property::MAP ) );
13015   }, "Property type is not animatable" );
13016
13017   DALI_TEST_ASSERTION(
13018   {
13019     // non animateable target (NONE)
13020     animation.AnimateTo( Property( actor, Actor::Property::CLIPPING_MODE ), Property::Value() );
13021   }, "Property type is not animatable" );
13022
13023   DALI_TEST_ASSERTION(
13024   {
13025     // non animateable target (ARRAY)
13026     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Property::ARRAY ) );
13027   }, "Target value is not animatable" );
13028
13029   DALI_TEST_ASSERTION(
13030   {
13031     // non animateable target (RECTANGLE)
13032     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Rect<int32_t>() ) );
13033   }, "Target value is not animatable" );
13034
13035   DALI_TEST_ASSERTION(
13036   {
13037     // not mathing properties (FLOAT, INT)
13038     animation.AnimateTo( Property( actor, Actor::Property::SCALE_Y ), Property::Value(10) );
13039   }, "Property and target types don't match" );
13040
13041   DALI_TEST_ASSERTION(
13042   {
13043     // not mathing properties (VECTOR3, VECTOR2)
13044     animation.AnimateTo( Property( actor, Actor::Property::COLOR ), Property::Value( Property::VECTOR2 ) );
13045   }, "Property and target types don't match" );
13046
13047   DALI_TEST_ASSERTION(
13048   {
13049     // negative duration
13050     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
13051   }, "Duration must be >=0" );
13052
13053   END_TEST;
13054 }
13055
13056 int UtcDaliAnimationAnimateBetweenInvalidParameters(void)
13057 {
13058   TestApplication application;
13059
13060   Actor actor = Actor::New();
13061   Stage::GetCurrent().Add(actor);
13062
13063   // Create the animation
13064   Animation animation = Animation::New(1.0f);
13065
13066   // AnimateBetween
13067   DALI_TEST_ASSERTION(
13068   {
13069     // non animateable property (ARRAY)
13070     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::ARRAY ), Property::ANIMATABLE );
13071     KeyFrames keyframes = KeyFrames::New();
13072     keyframes.Add( 0.5f, Property::Value( Property::ARRAY ) );
13073     animation.AnimateBetween( Property( actor, index ), keyframes );
13074   }, "Property type is not animatable" );
13075
13076   DALI_TEST_ASSERTION(
13077   {
13078     // non animateable target (NONE)
13079     KeyFrames keyframes = KeyFrames::New();
13080     keyframes.Add( 0.5f, Property::Value() );
13081     animation.AnimateBetween( Property( actor, Actor::Property::CLIPPING_MODE ), keyframes );
13082   }, "Property type is not animatable" );
13083
13084   DALI_TEST_ASSERTION(
13085   {
13086     // non animateable target (EXTENTS)
13087     KeyFrames keyframes = KeyFrames::New();
13088     keyframes.Add( 0.5f, Property::Value( Property::EXTENTS ) ); // throws
13089     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13090   }, "Property type is not animatable" );
13091
13092   DALI_TEST_ASSERTION(
13093   {
13094     // non animateable target (RECTANGLE)
13095     KeyFrames keyframes = KeyFrames::New();
13096     keyframes.Add( 0.5f, Property::Value( Property::MAP ) ); // throws
13097     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13098   }, "Property type is not animatable" );
13099
13100   DALI_TEST_ASSERTION(
13101   {
13102     // not mathing properties (VECTOR2, VECTOR4)
13103     KeyFrames keyframes = KeyFrames::New();
13104     keyframes.Add( 0.5f, Property::Value( Vector4( 1, 2, 3, 4 ) ) );
13105     animation.AnimateBetween( Property( actor, Actor::Property::MAXIMUM_SIZE ), keyframes );
13106   }, "Property and target types don't match" );
13107
13108   DALI_TEST_ASSERTION(
13109   {
13110     // negative duration
13111     KeyFrames keyframes = KeyFrames::New();
13112     keyframes.Add( 0.5f, Property::Value(Vector3( 1, 2, 3 ) ) );
13113     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes, TimePeriod(-1) );
13114   }, "Duration must be >=0" );
13115
13116   END_TEST;
13117 }