66dba1b3a98bbf4b52c1a695fae394cd97a6d763
[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   try
6700   {
6701     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6702   }
6703   catch (Dali::DaliException& e)
6704   {
6705     DALI_TEST_PRINT_ASSERT( e );
6706     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6707   }
6708   END_TEST;
6709 }
6710
6711 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
6712 {
6713   TestApplication application;
6714
6715   Actor actor = Actor::New();
6716   Stage::GetCurrent().Add(actor);
6717   float startValue(0.0f);
6718   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6719   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6720
6721   // Build the animation
6722   float durationSeconds(1.0f);
6723   Animation animation = Animation::New(durationSeconds);
6724   float targetX(1.0f);
6725
6726   try
6727   {
6728     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6729   }
6730   catch (Dali::DaliException& e)
6731   {
6732     DALI_TEST_PRINT_ASSERT( e );
6733     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6734   }
6735   END_TEST;
6736 }
6737
6738 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
6739 {
6740   TestApplication application;
6741
6742   Actor actor = Actor::New();
6743   Stage::GetCurrent().Add(actor);
6744   float startValue(0.0f);
6745   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6746   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6747
6748   // Build the animation
6749   float durationSeconds(1.0f);
6750   Animation animation = Animation::New(durationSeconds);
6751   float targetY(1.0f);
6752
6753   try
6754   {
6755     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6756   }
6757   catch (Dali::DaliException& e)
6758   {
6759     DALI_TEST_PRINT_ASSERT( e );
6760     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6761   }
6762   END_TEST;
6763 }
6764
6765 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
6766 {
6767   TestApplication application;
6768
6769   Actor actor = Actor::New();
6770   Stage::GetCurrent().Add(actor);
6771   float startValue(0.5f);
6772   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6773   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6774
6775   // Build the animation
6776   float durationSeconds(1.0f);
6777   Animation animation = Animation::New(durationSeconds);
6778   float targetZ(1.0f);
6779
6780   try
6781   {
6782     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6783   }
6784   catch (Dali::DaliException& e)
6785   {
6786     DALI_TEST_PRINT_ASSERT( e );
6787     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6788   }
6789   END_TEST;
6790 }
6791
6792 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
6793 {
6794   TestApplication application;
6795
6796   Actor actor = Actor::New();
6797   Stage::GetCurrent().Add(actor);
6798   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6799
6800   // Build the animation
6801   float durationSeconds(1.0f);
6802   Animation animation = Animation::New(durationSeconds);
6803   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6804
6805   try
6806   {
6807     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6808   }
6809   catch (Dali::DaliException& e)
6810   {
6811     DALI_TEST_PRINT_ASSERT( e );
6812     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6813   }
6814   END_TEST;
6815 }
6816
6817 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
6818 {
6819   TestApplication application;
6820
6821   Actor actor = Actor::New();
6822   Stage::GetCurrent().Add(actor);
6823   float startValue(0.5f);
6824   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6826
6827   // Build the animation
6828   float durationSeconds(1.0f);
6829   Animation animation = Animation::New(durationSeconds);
6830   float targetX(1.0f);
6831
6832   try
6833   {
6834     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6835   }
6836   catch (Dali::DaliException& e)
6837   {
6838     DALI_TEST_PRINT_ASSERT( e );
6839     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6840   }
6841   END_TEST;
6842 }
6843
6844 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
6845 {
6846   TestApplication application;
6847
6848   Actor actor = Actor::New();
6849   Stage::GetCurrent().Add(actor);
6850   float startValue(0.5f);
6851   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6852   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6853
6854   // Build the animation
6855   float durationSeconds(1.0f);
6856   Animation animation = Animation::New(durationSeconds);
6857   float targetY(0.0f);
6858
6859   try
6860   {
6861     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6862   }
6863   catch (Dali::DaliException& e)
6864   {
6865     DALI_TEST_PRINT_ASSERT( e );
6866     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6867   }
6868   END_TEST;
6869 }
6870
6871 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
6872 {
6873   TestApplication application;
6874
6875   Actor actor = Actor::New();
6876   Stage::GetCurrent().Add(actor);
6877   float startValue(0.5f);
6878   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6879   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6880
6881   // Build the animation
6882   float durationSeconds(1.0f);
6883   Animation animation = Animation::New(durationSeconds);
6884   float targetZ(100.0f);
6885
6886   try
6887   {
6888     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6889   }
6890   catch (Dali::DaliException& e)
6891   {
6892     DALI_TEST_PRINT_ASSERT( e );
6893     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6894   }
6895   END_TEST;
6896 }
6897
6898 int UtcDaliAnimationAnimateToActorSizeP(void)
6899 {
6900   TestApplication application;
6901
6902   Actor actor = Actor::New();
6903   Stage::GetCurrent().Add(actor);
6904   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6905
6906   // Build the animation
6907   float durationSeconds(1.0f);
6908   Animation animation = Animation::New(durationSeconds);
6909   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6910   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6911
6912   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6913
6914   // Should return the initial properties before play
6915   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6916   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6917   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6918   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6919
6920   // Start the animation
6921   animation.Play();
6922
6923   // Should return the target property after play
6924   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6925   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6926   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6927   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6928
6929   bool signalReceived(false);
6930   AnimationFinishCheck finishCheck(signalReceived);
6931   animation.FinishedSignal().Connect(&application, finishCheck);
6932
6933   application.SendNotification();
6934   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6935
6936   // We didn't expect the animation to finish yet
6937   application.SendNotification();
6938   finishCheck.CheckSignalNotReceived();
6939   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6940
6941   application.SendNotification();
6942   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6943
6944   // We did expect the animation to finish
6945   application.SendNotification();
6946   finishCheck.CheckSignalReceived();
6947   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6948
6949   // Reset everything
6950   finishCheck.Reset();
6951   actor.SetSize(Vector3::ZERO);
6952   application.SendNotification();
6953   application.Render(0);
6954   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6955
6956   // Repeat with a different (ease-in) alpha function
6957   animation = Animation::New(durationSeconds);
6958   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6959   animation.FinishedSignal().Connect(&application, finishCheck);
6960   animation.Play();
6961
6962   application.SendNotification();
6963   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6964
6965   // We didn't expect the animation to finish yet
6966   application.SendNotification();
6967   finishCheck.CheckSignalNotReceived();
6968
6969   // The size should have travelled less, than with a linear alpha function
6970   Vector3 current(actor.GetCurrentSize());
6971   DALI_TEST_CHECK( current.x > 0.0f );
6972   DALI_TEST_CHECK( current.y > 0.0f );
6973   DALI_TEST_CHECK( current.z > 0.0f );
6974   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6975   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6976   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6977
6978   application.SendNotification();
6979   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6980
6981   // We did expect the animation to finish
6982   application.SendNotification();
6983   finishCheck.CheckSignalReceived();
6984   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6985
6986   // Reset everything
6987   finishCheck.Reset();
6988   actor.SetSize(Vector3::ZERO);
6989   application.SendNotification();
6990   application.Render(0);
6991   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6992
6993   // Repeat with a delay
6994   float delay = 0.5f;
6995   animation = Animation::New(durationSeconds);
6996   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6997   animation.FinishedSignal().Connect(&application, finishCheck);
6998   animation.Play();
6999
7000   application.SendNotification();
7001   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7002
7003   // We didn't expect the animation to finish yet
7004   application.SendNotification();
7005   finishCheck.CheckSignalNotReceived();
7006   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7007
7008   application.SendNotification();
7009   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7010
7011   // We did expect the animation to finish
7012   application.SendNotification();
7013   finishCheck.CheckSignalReceived();
7014   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7015   END_TEST;
7016 }
7017
7018 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
7019 {
7020   TestApplication application;
7021
7022   Actor actor = Actor::New();
7023   Stage::GetCurrent().Add(actor);
7024   float startValue(0.0f);
7025   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
7026   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
7027
7028   // Build the animation
7029   float durationSeconds(1.0f);
7030   Animation animation = Animation::New(durationSeconds);
7031   float targetWidth(10.0f);
7032   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
7033
7034   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
7035
7036   // Should return the initial properties before play
7037   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7038   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
7039
7040   // Start the animation
7041   animation.Play();
7042
7043   // Should return the target property after play
7044   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
7045   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
7046
7047   bool signalReceived(false);
7048   AnimationFinishCheck finishCheck(signalReceived);
7049   animation.FinishedSignal().Connect(&application, finishCheck);
7050
7051   application.SendNotification();
7052   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7053
7054   // We didn't expect the animation to finish yet
7055   application.SendNotification();
7056   finishCheck.CheckSignalNotReceived();
7057   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
7058
7059   application.SendNotification();
7060   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7061
7062   // We did expect the animation to finish
7063   application.SendNotification();
7064   finishCheck.CheckSignalReceived();
7065   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
7066   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7067   END_TEST;
7068 }
7069
7070 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7071 {
7072   TestApplication application;
7073
7074   Actor actor = Actor::New();
7075   Stage::GetCurrent().Add(actor);
7076   float startValue(0.0f);
7077   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
7078   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7079
7080   // Build the animation
7081   float durationSeconds(1.0f);
7082   Animation animation = Animation::New(durationSeconds);
7083   float targetHeight(-10.0f);
7084   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7085
7086   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7087
7088   // Should return the initial properties before play
7089   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7090   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7091
7092   // Start the animation
7093   animation.Play();
7094
7095   // Should return the target property after play
7096   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7097   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7098
7099   bool signalReceived(false);
7100   AnimationFinishCheck finishCheck(signalReceived);
7101   animation.FinishedSignal().Connect(&application, finishCheck);
7102
7103   application.SendNotification();
7104   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7105
7106   // We didn't expect the animation to finish yet
7107   application.SendNotification();
7108   finishCheck.CheckSignalNotReceived();
7109   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
7110
7111   application.SendNotification();
7112   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7113
7114   // We did expect the animation to finish
7115   application.SendNotification();
7116   finishCheck.CheckSignalReceived();
7117   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
7118   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7119   END_TEST;
7120 }
7121
7122 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7123 {
7124   TestApplication application;
7125
7126   Actor actor = Actor::New();
7127   Stage::GetCurrent().Add(actor);
7128   float startValue(0.0f);
7129   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
7130   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7131
7132   // Build the animation
7133   float durationSeconds(1.0f);
7134   Animation animation = Animation::New(durationSeconds);
7135   float targetDepth(-10.0f);
7136   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7137
7138   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7139
7140   // Should return the initial properties before play
7141   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7142   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7143
7144   // Start the animation
7145   animation.Play();
7146
7147   // Should return the target property after play
7148   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7149   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7150
7151   bool signalReceived(false);
7152   AnimationFinishCheck finishCheck(signalReceived);
7153   animation.FinishedSignal().Connect(&application, finishCheck);
7154
7155   application.SendNotification();
7156   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7157
7158   // We didn't expect the animation to finish yet
7159   application.SendNotification();
7160   finishCheck.CheckSignalNotReceived();
7161   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
7162
7163   application.SendNotification();
7164   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7165
7166   // We did expect the animation to finish
7167   application.SendNotification();
7168   finishCheck.CheckSignalReceived();
7169   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
7170   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7171   END_TEST;
7172 }
7173
7174 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7175 {
7176   TestApplication application;
7177
7178   Actor actor = Actor::New();
7179   Stage::GetCurrent().Add(actor);
7180   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7181
7182   // Build the animation
7183   float durationSeconds(1.0f);
7184   Animation animation = Animation::New(durationSeconds);
7185   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7186   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7187
7188   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7189
7190   // Start the animation
7191   animation.Play();
7192
7193   bool signalReceived(false);
7194   AnimationFinishCheck finishCheck(signalReceived);
7195   animation.FinishedSignal().Connect(&application, finishCheck);
7196
7197   application.SendNotification();
7198   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7199
7200   // We didn't expect the animation to finish yet
7201   application.SendNotification();
7202   finishCheck.CheckSignalNotReceived();
7203   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
7204
7205   application.SendNotification();
7206   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7207
7208   // We did expect the animation to finish
7209   application.SendNotification();
7210   finishCheck.CheckSignalReceived();
7211   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
7212
7213   // Reset everything
7214   finishCheck.Reset();
7215   actor.SetSize(Vector3::ZERO);
7216   application.SendNotification();
7217   application.Render(0);
7218   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7219
7220   // Repeat with a different (ease-in) alpha function
7221   animation = Animation::New(durationSeconds);
7222   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7223   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7224   animation.FinishedSignal().Connect(&application, finishCheck);
7225   animation.Play();
7226
7227   application.SendNotification();
7228   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7229
7230   // We didn't expect the animation to finish yet
7231   application.SendNotification();
7232   finishCheck.CheckSignalNotReceived();
7233
7234   // The size should have travelled less, than with a linear alpha function
7235   Vector3 current(actor.GetCurrentSize());
7236   DALI_TEST_CHECK( current.x > 0.0f );
7237   DALI_TEST_CHECK( current.y > 0.0f );
7238   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7239   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7240
7241   application.SendNotification();
7242   application.Render(static_cast<unsigned int>(durationSeconds*10.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
7250   // Reset everything
7251   finishCheck.Reset();
7252   actor.SetSize(Vector3::ZERO);
7253   application.SendNotification();
7254   application.Render(0);
7255   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7256
7257   // Repeat with a delay
7258   float delay = 0.5f;
7259   animation = Animation::New(durationSeconds);
7260   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7261   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7262   animation.FinishedSignal().Connect(&application, finishCheck);
7263   animation.Play();
7264
7265   application.SendNotification();
7266   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7267
7268   // We didn't expect the animation to finish yet
7269   application.SendNotification();
7270   finishCheck.CheckSignalNotReceived();
7271   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
7272
7273   application.SendNotification();
7274   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7275
7276   // We did expect the animation to finish
7277   application.SendNotification();
7278   finishCheck.CheckSignalReceived();
7279   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
7280   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
7281   END_TEST;
7282 }
7283
7284 int UtcDaliAnimationAnimateToActorPositionP(void)
7285 {
7286   TestApplication application;
7287
7288   Actor actor = Actor::New();
7289   Stage::GetCurrent().Add(actor);
7290   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7291
7292   // Build the animation
7293   float durationSeconds(1.0f);
7294   Animation animation = Animation::New(durationSeconds);
7295   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7296   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7297
7298   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7299
7300   // Should return the initial properties before play
7301   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7302   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7303   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7304   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7305
7306   // Start the animation
7307   animation.Play();
7308
7309   // Should return the target property after play
7310   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7311   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7312   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7313   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
7314
7315   bool signalReceived(false);
7316   AnimationFinishCheck finishCheck(signalReceived);
7317   animation.FinishedSignal().Connect(&application, finishCheck);
7318
7319   application.SendNotification();
7320   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7321
7322   // We didn't expect the animation to finish yet
7323   application.SendNotification();
7324   finishCheck.CheckSignalNotReceived();
7325   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7326
7327   application.SendNotification();
7328   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7329
7330   // We did expect the animation to finish
7331   application.SendNotification();
7332   finishCheck.CheckSignalReceived();
7333   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7334   END_TEST;
7335 }
7336
7337 int UtcDaliAnimationAnimateToActorPositionXP(void)
7338 {
7339   TestApplication application;
7340
7341   Actor actor = Actor::New();
7342   Stage::GetCurrent().Add(actor);
7343   float startValue(0.0f);
7344   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
7345   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7346   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7348
7349   // Build the animation
7350   float durationSeconds(1.0f);
7351   Animation animation = Animation::New(durationSeconds);
7352   float targetX(1.0f);
7353   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7354
7355   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7356
7357   // Should return the initial properties before play
7358   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7359   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7360
7361   // Start the animation
7362   animation.Play();
7363
7364   // Should return the target property after play
7365   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7366   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
7367
7368   bool signalReceived(false);
7369   AnimationFinishCheck finishCheck(signalReceived);
7370   animation.FinishedSignal().Connect(&application, finishCheck);
7371
7372   application.SendNotification();
7373   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7374
7375   // We didn't expect the animation to finish yet
7376   application.SendNotification();
7377   finishCheck.CheckSignalNotReceived();
7378   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
7379
7380   application.SendNotification();
7381   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7382
7383   // We did expect the animation to finish
7384   application.SendNotification();
7385   finishCheck.CheckSignalReceived();
7386   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
7387   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7388   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7389   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7390   END_TEST;
7391 }
7392
7393 int UtcDaliAnimationAnimateToActorPositionYP(void)
7394 {
7395   TestApplication application;
7396
7397   Actor actor = Actor::New();
7398   Stage::GetCurrent().Add(actor);
7399   float startValue(0.0f);
7400   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7401   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7402   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7403   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7404
7405   // Build the animation
7406   float durationSeconds(1.0f);
7407   Animation animation = Animation::New(durationSeconds);
7408   float targetY(10.0f);
7409   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7410
7411   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7412
7413   // Should return the initial properties before play
7414   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7415   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7416
7417   // Start the animation
7418   animation.Play();
7419
7420   // Should return the target property after play
7421   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7422   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7423
7424   bool signalReceived(false);
7425   AnimationFinishCheck finishCheck(signalReceived);
7426   animation.FinishedSignal().Connect(&application, finishCheck);
7427
7428   application.SendNotification();
7429   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7430
7431   // We didn't expect the animation to finish yet
7432   application.SendNotification();
7433   finishCheck.CheckSignalNotReceived();
7434   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7435
7436   application.SendNotification();
7437   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7438
7439   // We did expect the animation to finish
7440   application.SendNotification();
7441   finishCheck.CheckSignalReceived();
7442   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7443   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7444   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7445   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7446   END_TEST;
7447 }
7448
7449 int UtcDaliAnimationAnimateToActorPositionZP(void)
7450 {
7451   TestApplication application;
7452
7453   Actor actor = Actor::New();
7454   Stage::GetCurrent().Add(actor);
7455   float startValue(0.0f);
7456   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7457   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7458   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7459   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7460
7461   // Build the animation
7462   float durationSeconds(1.0f);
7463   Animation animation = Animation::New(durationSeconds);
7464   float targetZ(-5.0f);
7465   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7466
7467   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7468
7469   // Should return the initial properties before play
7470   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7471   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7472
7473   // Start the animation
7474   animation.Play();
7475
7476   // Should return the target property after play
7477   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7478   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7479
7480   bool signalReceived(false);
7481   AnimationFinishCheck finishCheck(signalReceived);
7482   animation.FinishedSignal().Connect(&application, finishCheck);
7483
7484   application.SendNotification();
7485   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7486
7487   // We didn't expect the animation to finish yet
7488   application.SendNotification();
7489   finishCheck.CheckSignalNotReceived();
7490   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7491
7492   application.SendNotification();
7493   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7494
7495   // We did expect the animation to finish
7496   application.SendNotification();
7497   finishCheck.CheckSignalReceived();
7498   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7499   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7500   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7501   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7502   END_TEST;
7503 }
7504
7505 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7506 {
7507   TestApplication application;
7508
7509   Actor actor = Actor::New();
7510   Stage::GetCurrent().Add(actor);
7511   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7512
7513   // Build the animation
7514   float durationSeconds(1.0f);
7515   Animation animation = Animation::New(durationSeconds);
7516   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7517   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7518
7519   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7520
7521   // Start the animation
7522   animation.Play();
7523
7524   bool signalReceived(false);
7525   AnimationFinishCheck finishCheck(signalReceived);
7526   animation.FinishedSignal().Connect(&application, finishCheck);
7527
7528   application.SendNotification();
7529   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7530
7531   // We didn't expect the animation to finish yet
7532   application.SendNotification();
7533   finishCheck.CheckSignalNotReceived();
7534
7535   // The position should have moved less, than with a linear alpha function
7536   Vector3 current(actor.GetCurrentPosition());
7537   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7538   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7539   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7540   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7541   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7542   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7543
7544   application.SendNotification();
7545   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7546
7547   // We did expect the animation to finish
7548   application.SendNotification();
7549   finishCheck.CheckSignalReceived();
7550   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7551   END_TEST;
7552 }
7553
7554 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7555 {
7556   TestApplication application;
7557
7558   Actor actor = Actor::New();
7559   Stage::GetCurrent().Add(actor);
7560   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7561
7562   // Build the animation
7563   float durationSeconds(1.0f);
7564   Animation animation = Animation::New(durationSeconds);
7565   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7566   float delay = 0.5f;
7567   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7568                        targetPosition,
7569                        TimePeriod( delay, durationSeconds - delay ) );
7570
7571   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7572
7573   // Start the animation
7574   animation.Play();
7575
7576   bool signalReceived(false);
7577   AnimationFinishCheck finishCheck(signalReceived);
7578   animation.FinishedSignal().Connect(&application, finishCheck);
7579
7580   application.SendNotification();
7581   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7582
7583   // We didn't expect the animation to finish yet
7584   application.SendNotification();
7585   finishCheck.CheckSignalNotReceived();
7586   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7587
7588   application.SendNotification();
7589   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7590
7591   // We didn't expect the animation to finish yet
7592   application.SendNotification();
7593   finishCheck.CheckSignalNotReceived();
7594   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7595
7596   application.SendNotification();
7597   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7598
7599   // We did expect the animation to finish
7600   application.SendNotification();
7601   finishCheck.CheckSignalReceived();
7602   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7603   END_TEST;
7604 }
7605
7606 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7607 {
7608   TestApplication application;
7609
7610   Actor actor = Actor::New();
7611   Stage::GetCurrent().Add(actor);
7612   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7613
7614   // Build the animation
7615   float durationSeconds(1.0f);
7616   Animation animation = Animation::New(durationSeconds);
7617   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7618   float delay = 0.5f;
7619   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7620                        targetPosition,
7621                        AlphaFunction::LINEAR,
7622                        TimePeriod( delay, durationSeconds - delay ) );
7623
7624   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7625
7626   // Start the animation
7627   animation.Play();
7628
7629   bool signalReceived(false);
7630   AnimationFinishCheck finishCheck(signalReceived);
7631   animation.FinishedSignal().Connect(&application, finishCheck);
7632
7633   application.SendNotification();
7634   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7635
7636   // We didn't expect the animation to finish yet
7637   application.SendNotification();
7638   finishCheck.CheckSignalNotReceived();
7639   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7640
7641   application.SendNotification();
7642   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7643
7644   // We didn't expect the animation to finish yet
7645   application.SendNotification();
7646   finishCheck.CheckSignalNotReceived();
7647   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7648
7649   application.SendNotification();
7650   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7651
7652   // We did expect the animation to finish
7653   application.SendNotification();
7654   finishCheck.CheckSignalReceived();
7655   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7656   END_TEST;
7657 }
7658
7659 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7660 {
7661   TestApplication application;
7662
7663   Actor actor = Actor::New();
7664   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7665   Stage::GetCurrent().Add(actor);
7666   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7667
7668   // Build the animation
7669   float durationSeconds(1.0f);
7670   Animation animation = Animation::New(durationSeconds);
7671   Degree targetRotationDegrees(90.0f);
7672   Radian targetRotationRadians(targetRotationDegrees);
7673   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7674
7675   // Start the animation
7676   animation.Play();
7677
7678   // Target value should be retrievable straight away
7679   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7680
7681   bool signalReceived(false);
7682   AnimationFinishCheck finishCheck(signalReceived);
7683   animation.FinishedSignal().Connect(&application, finishCheck);
7684
7685   application.SendNotification();
7686   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7687
7688   // We didn't expect the animation to finish yet
7689   application.SendNotification();
7690   finishCheck.CheckSignalNotReceived();
7691   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7692
7693   application.SendNotification();
7694   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7695
7696   // We didn't expect the animation to finish yet
7697   application.SendNotification();
7698   finishCheck.CheckSignalNotReceived();
7699   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7700
7701   application.SendNotification();
7702   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7703
7704   // We didn't expect the animation to finish yet
7705   application.SendNotification();
7706   finishCheck.CheckSignalNotReceived();
7707   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7708
7709   application.SendNotification();
7710   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7711
7712   // We did expect the animation to finish
7713   application.SendNotification();
7714   finishCheck.CheckSignalReceived();
7715   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7716   END_TEST;
7717 }
7718
7719 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7720 {
7721   TestApplication application;
7722
7723   Actor actor = Actor::New();
7724   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7725   Stage::GetCurrent().Add(actor);
7726   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7727
7728   // Build the animation
7729   float durationSeconds(1.0f);
7730   Animation animation = Animation::New(durationSeconds);
7731   Degree targetRotationDegrees(90.0f);
7732   Radian targetRotationRadians(targetRotationDegrees);
7733   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7734   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7735
7736   // Start the animation
7737   animation.Play();
7738
7739   bool signalReceived(false);
7740   AnimationFinishCheck finishCheck(signalReceived);
7741   animation.FinishedSignal().Connect(&application, finishCheck);
7742
7743   application.SendNotification();
7744   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7745
7746   // We didn't expect the animation to finish yet
7747   application.SendNotification();
7748   finishCheck.CheckSignalNotReceived();
7749   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7750
7751   application.SendNotification();
7752   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7753
7754   // We didn't expect the animation to finish yet
7755   application.SendNotification();
7756   finishCheck.CheckSignalNotReceived();
7757   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7758
7759   application.SendNotification();
7760   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7761
7762   // We didn't expect the animation to finish yet
7763   application.SendNotification();
7764   finishCheck.CheckSignalNotReceived();
7765   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7766
7767   application.SendNotification();
7768   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7769
7770   // We did expect the animation to finish
7771   application.SendNotification();
7772   finishCheck.CheckSignalReceived();
7773   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7774   END_TEST;
7775 }
7776
7777 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7778 {
7779   TestApplication application;
7780
7781   Actor actor = Actor::New();
7782   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7783   Stage::GetCurrent().Add(actor);
7784   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7785
7786   // Build the animation
7787   float durationSeconds(1.0f);
7788   Animation animation = Animation::New(durationSeconds);
7789   Degree targetRotationDegrees(90.0f);
7790   Radian targetRotationRadians(targetRotationDegrees);
7791   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7792
7793   // Start the animation
7794   animation.Play();
7795
7796   bool signalReceived(false);
7797   AnimationFinishCheck finishCheck(signalReceived);
7798   animation.FinishedSignal().Connect(&application, finishCheck);
7799
7800   application.SendNotification();
7801   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7802
7803   // We didn't expect the animation to finish yet
7804   application.SendNotification();
7805   finishCheck.CheckSignalNotReceived();
7806   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7807
7808   application.SendNotification();
7809   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7810
7811   // We didn't expect the animation to finish yet
7812   application.SendNotification();
7813   finishCheck.CheckSignalNotReceived();
7814   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7815
7816   application.SendNotification();
7817   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7818
7819   // We didn't expect the animation to finish yet
7820   application.SendNotification();
7821   finishCheck.CheckSignalNotReceived();
7822   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7823
7824   application.SendNotification();
7825   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7826
7827   // We did expect the animation to finish
7828   application.SendNotification();
7829   finishCheck.CheckSignalReceived();
7830   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7831   END_TEST;
7832 }
7833
7834 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7835 {
7836   TestApplication application;
7837
7838   Actor actor = Actor::New();
7839   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7840   Stage::GetCurrent().Add(actor);
7841   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7842
7843   // Build the animation
7844   float durationSeconds(1.0f);
7845   Animation animation = Animation::New(durationSeconds);
7846   Degree targetRotationDegrees(90.0f);
7847   Radian targetRotationRadians(targetRotationDegrees);
7848   float delay(0.1f);
7849   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7850
7851   // Start the animation
7852   animation.Play();
7853
7854   bool signalReceived(false);
7855   AnimationFinishCheck finishCheck(signalReceived);
7856   animation.FinishedSignal().Connect(&application, finishCheck);
7857
7858   application.SendNotification();
7859   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7860
7861   // We didn't expect the animation to finish yet
7862   application.SendNotification();
7863   finishCheck.CheckSignalNotReceived();
7864   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7865   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7866
7867   application.SendNotification();
7868   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7869
7870   // We didn't expect the animation to finish yet
7871   application.SendNotification();
7872   finishCheck.CheckSignalNotReceived();
7873   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7874   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7875
7876   application.SendNotification();
7877   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7878
7879   // We didn't expect the animation to finish yet
7880   application.SendNotification();
7881   finishCheck.CheckSignalNotReceived();
7882   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7883   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7884
7885   application.SendNotification();
7886   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7887
7888   // We did expect the animation to finish
7889   application.SendNotification();
7890   finishCheck.CheckSignalReceived();
7891   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7892   END_TEST;
7893 }
7894
7895 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7896 {
7897   TestApplication application;
7898
7899   Actor actor = Actor::New();
7900   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7901   Stage::GetCurrent().Add(actor);
7902   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7903
7904   // Build the animation
7905   float durationSeconds(1.0f);
7906   Animation animation = Animation::New(durationSeconds);
7907   Degree targetRotationDegrees(90.0f);
7908   Radian targetRotationRadians(targetRotationDegrees);
7909   float delay(0.1f);
7910   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7911
7912   // Start the animation
7913   animation.Play();
7914
7915   bool signalReceived(false);
7916   AnimationFinishCheck finishCheck(signalReceived);
7917   animation.FinishedSignal().Connect(&application, finishCheck);
7918
7919   application.SendNotification();
7920   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7921
7922   // We didn't expect the animation to finish yet
7923   application.SendNotification();
7924   finishCheck.CheckSignalNotReceived();
7925   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7926   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7927
7928   application.SendNotification();
7929   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7930
7931   // We didn't expect the animation to finish yet
7932   application.SendNotification();
7933   finishCheck.CheckSignalNotReceived();
7934   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7935   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7936
7937   application.SendNotification();
7938   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7939
7940   // We didn't expect the animation to finish yet
7941   application.SendNotification();
7942   finishCheck.CheckSignalNotReceived();
7943   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7944   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7945
7946   application.SendNotification();
7947   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7948
7949   // We did expect the animation to finish
7950   application.SendNotification();
7951   finishCheck.CheckSignalReceived();
7952   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7953   END_TEST;
7954 }
7955
7956 int UtcDaliAnimationAnimateToActorScaleP(void)
7957 {
7958   TestApplication application;
7959
7960   Actor actor = Actor::New();
7961   Stage::GetCurrent().Add(actor);
7962   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7963
7964   // Build the animation
7965   float durationSeconds(1.0f);
7966   Animation animation = Animation::New(durationSeconds);
7967   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7968   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7969
7970   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7971
7972   // Start the animation
7973   animation.Play();
7974
7975   // Target value should be retrievable straight away
7976   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7977   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7978   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7979   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
7980
7981   bool signalReceived(false);
7982   AnimationFinishCheck finishCheck(signalReceived);
7983   animation.FinishedSignal().Connect(&application, finishCheck);
7984
7985   application.SendNotification();
7986   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7987
7988   // We didn't expect the animation to finish yet
7989   application.SendNotification();
7990   finishCheck.CheckSignalNotReceived();
7991   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7992
7993   application.SendNotification();
7994   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7995
7996   // We did expect the animation to finish
7997   application.SendNotification();
7998   finishCheck.CheckSignalReceived();
7999   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8000
8001   // Reset everything
8002   finishCheck.Reset();
8003   actor.SetScale(Vector3::ONE);
8004   application.SendNotification();
8005   application.Render(0);
8006   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8007
8008   // Repeat with a different (ease-in) alpha function
8009   animation = Animation::New(durationSeconds);
8010   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
8011   animation.FinishedSignal().Connect(&application, finishCheck);
8012   animation.Play();
8013
8014   application.SendNotification();
8015   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8016
8017   // We didn't expect the animation to finish yet
8018   application.SendNotification();
8019   finishCheck.CheckSignalNotReceived();
8020
8021   // The scale should have grown less, than with a linear alpha function
8022   Vector3 current(actor.GetCurrentScale());
8023   DALI_TEST_CHECK( current.x > 1.0f );
8024   DALI_TEST_CHECK( current.y > 1.0f );
8025   DALI_TEST_CHECK( current.z > 1.0f );
8026   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8027   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8028   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8029
8030   application.SendNotification();
8031   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8032
8033   // We did expect the animation to finish
8034   application.SendNotification();
8035   finishCheck.CheckSignalReceived();
8036   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8037
8038   // Reset everything
8039   finishCheck.Reset();
8040   actor.SetScale(Vector3::ONE);
8041   application.SendNotification();
8042   application.Render(0);
8043   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8044
8045   // Repeat with a delay
8046   float delay = 0.5f;
8047   animation = Animation::New(durationSeconds);
8048   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
8049   animation.FinishedSignal().Connect(&application, finishCheck);
8050   animation.Play();
8051
8052   application.SendNotification();
8053   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8054
8055   // We didn't expect the animation to finish yet
8056   application.SendNotification();
8057   finishCheck.CheckSignalNotReceived();
8058   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
8059
8060   application.SendNotification();
8061   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8062
8063   // We did expect the animation to finish
8064   application.SendNotification();
8065   finishCheck.CheckSignalReceived();
8066   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
8067   END_TEST;
8068 }
8069
8070 int UtcDaliAnimationAnimateToActorScaleXP(void)
8071 {
8072   TestApplication application;
8073
8074   Actor actor = Actor::New();
8075   Stage::GetCurrent().Add(actor);
8076   float startValue(1.0f);
8077   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
8078   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8079   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8080   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8081   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8082   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8083   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8084
8085   // Build the animation
8086   float durationSeconds(1.0f);
8087   Animation animation = Animation::New(durationSeconds);
8088   float targetX(10.0f);
8089   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8090
8091   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8092
8093   // Start the animation
8094   animation.Play();
8095
8096   // Target value should be retrievable straight away
8097   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8098   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8099
8100   bool signalReceived(false);
8101   AnimationFinishCheck finishCheck(signalReceived);
8102   animation.FinishedSignal().Connect(&application, finishCheck);
8103
8104   application.SendNotification();
8105   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8106
8107   // We didn't expect the animation to finish yet
8108   application.SendNotification();
8109   finishCheck.CheckSignalNotReceived();
8110   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
8111   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8112   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8113   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8114
8115   application.SendNotification();
8116   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8117
8118   // We did expect the animation to finish
8119   application.SendNotification();
8120   finishCheck.CheckSignalReceived();
8121   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
8122   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8123   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8124   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8125   END_TEST;
8126 }
8127
8128 int UtcDaliAnimationAnimateToActorScaleYP(void)
8129 {
8130   TestApplication application;
8131
8132   Actor actor = Actor::New();
8133   Stage::GetCurrent().Add(actor);
8134   float startValue(1.0f);
8135   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
8136   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8137   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8138   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8139   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8140   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8141   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8142
8143   // Build the animation
8144   float durationSeconds(1.0f);
8145   Animation animation = Animation::New(durationSeconds);
8146   float targetY(1000.0f);
8147   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8148
8149   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8150
8151   // Start the animation
8152   animation.Play();
8153
8154   // Target value should be retrievable straight away
8155   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8156   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8157
8158   bool signalReceived(false);
8159   AnimationFinishCheck finishCheck(signalReceived);
8160   animation.FinishedSignal().Connect(&application, finishCheck);
8161
8162   application.SendNotification();
8163   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8164
8165   // We didn't expect the animation to finish yet
8166   application.SendNotification();
8167   finishCheck.CheckSignalNotReceived();
8168   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
8169   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8170   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8171   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8172
8173   application.SendNotification();
8174   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8175
8176   // We did expect the animation to finish
8177   application.SendNotification();
8178   finishCheck.CheckSignalReceived();
8179   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
8180   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8181   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8182   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8183   END_TEST;
8184 }
8185
8186 int UtcDaliAnimationAnimateToActorScaleZP(void)
8187 {
8188   TestApplication application;
8189
8190   Actor actor = Actor::New();
8191   Stage::GetCurrent().Add(actor);
8192   float startValue(1.0f);
8193   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
8194   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8195   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8196   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8197   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8198   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8199   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8200
8201   // Build the animation
8202   float durationSeconds(1.0f);
8203   Animation animation = Animation::New(durationSeconds);
8204   float targetZ(-1000.0f);
8205   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8206
8207   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8208
8209   // Start the animation
8210   animation.Play();
8211
8212   // Target value should be retrievable straight away
8213   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8214   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8215
8216   bool signalReceived(false);
8217   AnimationFinishCheck finishCheck(signalReceived);
8218   animation.FinishedSignal().Connect(&application, finishCheck);
8219
8220   application.SendNotification();
8221   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8222
8223   // We didn't expect the animation to finish yet
8224   application.SendNotification();
8225   finishCheck.CheckSignalNotReceived();
8226   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
8227   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8228   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8229   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8230
8231   application.SendNotification();
8232   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8233
8234   // We did expect the animation to finish
8235   application.SendNotification();
8236   finishCheck.CheckSignalReceived();
8237   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
8238   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8239   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8240   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8241   END_TEST;
8242 }
8243
8244 int UtcDaliAnimationAnimateToActorColorP(void)
8245 {
8246   TestApplication application;
8247
8248   Actor actor = Actor::New();
8249   Stage::GetCurrent().Add(actor);
8250   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8251
8252   // Build the animation
8253   float durationSeconds(1.0f);
8254   Animation animation = Animation::New(durationSeconds);
8255   Vector4 targetColor(Color::RED);
8256   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8257
8258   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8259   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8260
8261   // Start the animation
8262   animation.Play();
8263
8264   // Target value should be retrievable straight away
8265   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8266   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8267   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8268   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8269   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8270   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8271
8272   bool signalReceived(false);
8273   AnimationFinishCheck finishCheck(signalReceived);
8274   animation.FinishedSignal().Connect(&application, finishCheck);
8275
8276   application.SendNotification();
8277   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8278
8279   // We didn't expect the animation to finish yet
8280   application.SendNotification();
8281   finishCheck.CheckSignalNotReceived();
8282   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
8283
8284   application.SendNotification();
8285   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8286
8287   // We did expect the animation to finish
8288   application.SendNotification();
8289   finishCheck.CheckSignalReceived();
8290   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8291
8292   // Reset everything
8293   finishCheck.Reset();
8294   actor.SetColor(Color::WHITE);
8295   application.SendNotification();
8296   application.Render(0);
8297   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8298
8299   // Repeat with a different (ease-in) alpha function
8300   animation = Animation::New(durationSeconds);
8301   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8302   animation.FinishedSignal().Connect(&application, finishCheck);
8303   animation.Play();
8304
8305   application.SendNotification();
8306   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8307
8308   // We didn't expect the animation to finish yet
8309   application.SendNotification();
8310   finishCheck.CheckSignalNotReceived();
8311
8312   // The color should have changed less, than with a linear alpha function
8313   Vector4 current(actor.GetCurrentColor());
8314   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8315   DALI_TEST_CHECK( current.y < 1.0f );
8316   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8317   DALI_TEST_CHECK( current.z  < 1.0f );
8318   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8319   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8320
8321   application.SendNotification();
8322   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8323
8324   // We did expect the animation to finish
8325   application.SendNotification();
8326   finishCheck.CheckSignalReceived();
8327   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8328
8329   // Reset everything
8330   finishCheck.Reset();
8331   actor.SetColor(Color::WHITE);
8332   application.SendNotification();
8333   application.Render(0);
8334   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
8335
8336   // Repeat with a shorter animator duration
8337   float animatorDuration = 0.5f;
8338   animation = Animation::New(durationSeconds);
8339   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8340   animation.FinishedSignal().Connect(&application, finishCheck);
8341   animation.Play();
8342
8343   application.SendNotification();
8344   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8345
8346   // We didn't expect the animation to finish yet
8347   application.SendNotification();
8348   finishCheck.CheckSignalNotReceived();
8349   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
8350
8351   application.SendNotification();
8352   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8353
8354   // We didn't expect the animation to finish yet
8355   application.SendNotification();
8356   finishCheck.CheckSignalNotReceived();
8357   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8358
8359   application.SendNotification();
8360   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8361
8362   // We did expect the animation to finish
8363   application.SendNotification();
8364   finishCheck.CheckSignalReceived();
8365   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
8366   END_TEST;
8367 }
8368
8369 int UtcDaliAnimationAnimateToActorColorRedP(void)
8370 {
8371   TestApplication application;
8372
8373   Actor actor = Actor::New();
8374   Stage::GetCurrent().Add(actor);
8375   float startValue(1.0f);
8376   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
8377   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8378   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8379   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8380   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8381   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8382   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8383   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8384   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8385
8386   // Build the animation
8387   float durationSeconds(1.0f);
8388   Animation animation = Animation::New(durationSeconds);
8389   float targetRed(0.5f);
8390   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8391
8392   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8393
8394   // Start the animation
8395   animation.Play();
8396
8397   // Target value should be retrievable straight away
8398   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8399   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8400
8401   bool signalReceived(false);
8402   AnimationFinishCheck finishCheck(signalReceived);
8403   animation.FinishedSignal().Connect(&application, finishCheck);
8404
8405   application.SendNotification();
8406   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8407
8408   // We didn't expect the animation to finish yet
8409   application.SendNotification();
8410   finishCheck.CheckSignalNotReceived();
8411   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8412   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8413   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8414   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8415   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8416
8417   application.SendNotification();
8418   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8419
8420   // We did expect the animation to finish
8421   application.SendNotification();
8422   finishCheck.CheckSignalReceived();
8423   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8424   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8425   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8426   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8427   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8428   END_TEST;
8429 }
8430
8431 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8432 {
8433   TestApplication application;
8434
8435   Actor actor = Actor::New();
8436   Stage::GetCurrent().Add(actor);
8437   float startValue(1.0f);
8438   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8439   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8440   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8441   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8442   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8443   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8444   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8445   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8446   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8447
8448   // Build the animation
8449   float durationSeconds(1.0f);
8450   Animation animation = Animation::New(durationSeconds);
8451   float targetGreen(0.5f);
8452   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8453
8454   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8455
8456   // Start the animation
8457   animation.Play();
8458
8459   // Target value should be retrievable straight away
8460   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8461   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8462
8463   bool signalReceived(false);
8464   AnimationFinishCheck finishCheck(signalReceived);
8465   animation.FinishedSignal().Connect(&application, finishCheck);
8466
8467   application.SendNotification();
8468   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8469
8470   // We didn't expect the animation to finish yet
8471   application.SendNotification();
8472   finishCheck.CheckSignalNotReceived();
8473   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8474   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8475   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8476   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8477   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8478
8479   application.SendNotification();
8480   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8481
8482   // We did expect the animation to finish
8483   application.SendNotification();
8484   finishCheck.CheckSignalReceived();
8485   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8488   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8489   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8490   END_TEST;
8491 }
8492
8493 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8494 {
8495   TestApplication application;
8496
8497   Actor actor = Actor::New();
8498   Stage::GetCurrent().Add(actor);
8499   float startValue(1.0f);
8500   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8501   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8502   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8503   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8504   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8505   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8506   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8507   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8508   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8509
8510   // Build the animation
8511   float durationSeconds(1.0f);
8512   Animation animation = Animation::New(durationSeconds);
8513   float targetBlue(0.5f);
8514   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8515
8516   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8517
8518   // Start the animation
8519   animation.Play();
8520
8521   // Target value should be retrievable straight away
8522   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8523   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8524
8525   bool signalReceived(false);
8526   AnimationFinishCheck finishCheck(signalReceived);
8527   animation.FinishedSignal().Connect(&application, finishCheck);
8528
8529   application.SendNotification();
8530   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8531
8532   // We didn't expect the animation to finish yet
8533   application.SendNotification();
8534   finishCheck.CheckSignalNotReceived();
8535   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8536   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8537   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8538   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8539   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8540
8541   application.SendNotification();
8542   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8543
8544   // We did expect the animation to finish
8545   application.SendNotification();
8546   finishCheck.CheckSignalReceived();
8547   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8548   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8549   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8550   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8552   END_TEST;
8553 }
8554
8555 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8556 {
8557   TestApplication application;
8558
8559   Actor actor = Actor::New();
8560   Stage::GetCurrent().Add(actor);
8561   float startValue(1.0f);
8562   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8563   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8564   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8565   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8566   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, 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 ), startValue, TEST_LOCATION );
8571
8572   // Build the animation
8573   float durationSeconds(1.0f);
8574   Animation animation = Animation::New(durationSeconds);
8575   float targetAlpha(0.5f);
8576   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8577
8578   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8579
8580   // Start the animation
8581   animation.Play();
8582
8583   // Target value should be retrievable straight away
8584   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8585   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8586   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8587
8588   bool signalReceived(false);
8589   AnimationFinishCheck finishCheck(signalReceived);
8590   animation.FinishedSignal().Connect(&application, finishCheck);
8591
8592   application.SendNotification();
8593   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8594
8595   // We didn't expect the animation to finish yet
8596   application.SendNotification();
8597   finishCheck.CheckSignalNotReceived();
8598   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8599   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8600   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8601   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8602   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8603
8604   application.SendNotification();
8605   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8606
8607   // We did expect the animation to finish
8608   application.SendNotification();
8609   finishCheck.CheckSignalReceived();
8610   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8611   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8612   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8613   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8614   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8615   END_TEST;
8616 }
8617
8618 int UtcDaliAnimationKeyFrames01P(void)
8619 {
8620   TestApplication application;
8621
8622   KeyFrames keyFrames = KeyFrames::New();
8623   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8624
8625   keyFrames.Add(0.0f, 0.1f);
8626
8627   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8628
8629   KeyFrames keyFrames2( keyFrames);
8630   DALI_TEST_CHECK( keyFrames2 );
8631   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8632
8633   KeyFrames keyFrames3 = KeyFrames::New();
8634   keyFrames3.Add(0.6f, true);
8635   DALI_TEST_CHECK( keyFrames3 );
8636   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8637
8638   keyFrames3 = keyFrames;
8639   DALI_TEST_CHECK( keyFrames3 );
8640   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8641
8642   END_TEST;
8643 }
8644
8645 int UtcDaliAnimationKeyFrames02P(void)
8646 {
8647   TestApplication application;
8648
8649   KeyFrames keyFrames = KeyFrames::New();
8650   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8651
8652   keyFrames.Add(0.0f, 0.1f);
8653   keyFrames.Add(0.2f, 0.5f);
8654   keyFrames.Add(0.4f, 0.0f);
8655   keyFrames.Add(0.6f, 1.0f);
8656   keyFrames.Add(0.8f, 0.7f);
8657   keyFrames.Add(1.0f, 0.9f);
8658
8659   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8660
8661   try
8662   {
8663     keyFrames.Add(1.9f, false);
8664   }
8665   catch (Dali::DaliException& e)
8666   {
8667     DALI_TEST_PRINT_ASSERT( e );
8668     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8669   }
8670   END_TEST;
8671 }
8672
8673 int UtcDaliAnimationKeyFrames03P(void)
8674 {
8675   TestApplication application;
8676
8677   KeyFrames keyFrames = KeyFrames::New();
8678   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8679
8680   keyFrames.Add(0.0f, true);
8681   keyFrames.Add(0.2f, false);
8682   keyFrames.Add(0.4f, false);
8683   keyFrames.Add(0.6f, true);
8684   keyFrames.Add(0.8f, true);
8685   keyFrames.Add(1.0f, false);
8686
8687   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8688
8689   try
8690   {
8691     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8692   }
8693   catch (Dali::DaliException& e)
8694   {
8695     DALI_TEST_PRINT_ASSERT( e );
8696     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8697   }
8698   END_TEST;
8699 }
8700
8701 int UtcDaliAnimationKeyFrames04P(void)
8702 {
8703   TestApplication application;
8704
8705   KeyFrames keyFrames = KeyFrames::New();
8706   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8707
8708   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8709   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8710   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8711   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8712   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8713   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8714
8715   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8716
8717   try
8718   {
8719     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8720   }
8721   catch (Dali::DaliException& e)
8722   {
8723     DALI_TEST_PRINT_ASSERT( e );
8724     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8725   }
8726   END_TEST;
8727 }
8728
8729 int UtcDaliAnimationKeyFrames05P(void)
8730 {
8731   TestApplication application;
8732
8733   KeyFrames keyFrames = KeyFrames::New();
8734   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8735
8736   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8737   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8738   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8739   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8740   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8741   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8742
8743   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8744
8745   try
8746   {
8747     keyFrames.Add(0.7f, 1.0f);
8748   }
8749   catch (Dali::DaliException& e)
8750   {
8751     DALI_TEST_PRINT_ASSERT( e );
8752     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8753   }
8754   END_TEST;
8755 }
8756
8757 int UtcDaliAnimationKeyFrames06P(void)
8758 {
8759   TestApplication application;
8760
8761   KeyFrames keyFrames = KeyFrames::New();
8762   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8763
8764   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8765   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8766   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8767   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8768   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8769   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8770
8771   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8772
8773   try
8774   {
8775     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8776   }
8777   catch (Dali::DaliException& e)
8778   {
8779     DALI_TEST_PRINT_ASSERT( e );
8780     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8781   }
8782   END_TEST;
8783 }
8784
8785 int UtcDaliAnimationKeyFrames07P(void)
8786 {
8787   TestApplication application;
8788
8789   KeyFrames keyFrames = KeyFrames::New();
8790   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8791
8792   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8793   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8794   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8795   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8796   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8797   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8798
8799   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8800
8801   try
8802   {
8803     keyFrames.Add(0.7f, 1.1f);
8804   }
8805   catch (Dali::DaliException& e)
8806   {
8807     DALI_TEST_PRINT_ASSERT( e );
8808     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8809   }
8810   END_TEST;
8811 }
8812
8813 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8814 {
8815   TestApplication application;
8816
8817   float startValue(1.0f);
8818   Actor actor = Actor::New();
8819   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8820   Stage::GetCurrent().Add(actor);
8821
8822   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8823   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8824   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8827   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8828   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8829   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8830   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8831
8832   // Build the animation
8833   float durationSeconds(1.0f);
8834   Animation animation = Animation::New(durationSeconds);
8835
8836   KeyFrames keyFrames = KeyFrames::New();
8837   keyFrames.Add(0.0f, 0.1f);
8838   keyFrames.Add(0.2f, 0.5f);
8839   keyFrames.Add(0.4f, 0.0f);
8840   keyFrames.Add(0.6f, 1.0f);
8841   keyFrames.Add(0.8f, 0.7f);
8842   keyFrames.Add(1.0f, 0.9f);
8843
8844   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8845
8846   // Start the animation
8847   animation.Play();
8848
8849   // Final key frame value should be retrievable straight away
8850   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8851
8852   bool signalReceived(false);
8853   AnimationFinishCheck finishCheck(signalReceived);
8854   animation.FinishedSignal().Connect(&application, finishCheck);
8855   application.SendNotification();
8856   application.Render(0);
8857   application.SendNotification();
8858   finishCheck.CheckSignalNotReceived();
8859   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8860
8861   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8862   application.SendNotification();
8863   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8864   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8865   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8866   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8867   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8868
8869   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8870   application.SendNotification();
8871   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8872   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8873   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8874   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8875   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8876
8877   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8878   application.SendNotification();
8879   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8880   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8881   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8882   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8883   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8884
8885   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8886   application.SendNotification();
8887   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8888   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8889   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8890   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8891   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8892
8893   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8894   application.SendNotification();
8895   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8896   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8897   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8898   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8899   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8900
8901   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8902   application.SendNotification();
8903   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8904   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8906   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8907   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8908
8909   // We did expect the animation to finish
8910
8911   finishCheck.CheckSignalReceived();
8912   END_TEST;
8913 }
8914
8915 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8916 {
8917   TestApplication application;
8918
8919   float startValue(1.0f);
8920   Actor actor = Actor::New();
8921   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8922   Stage::GetCurrent().Add(actor);
8923
8924   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8925   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8926   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8927   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8928   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8929   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8930   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8932   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8933
8934   // Build the animation
8935   float durationSeconds(1.0f);
8936   Animation animation = Animation::New(durationSeconds);
8937
8938   KeyFrames keyFrames = KeyFrames::New();
8939   keyFrames.Add(0.0f, 0.1f);
8940   keyFrames.Add(0.2f, 0.5f);
8941   keyFrames.Add(0.4f, 0.0f);
8942   keyFrames.Add(0.6f, 1.0f);
8943   keyFrames.Add(0.8f, 0.7f);
8944   keyFrames.Add(1.0f, 0.9f);
8945
8946   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8947
8948   // Start the animation
8949   animation.Play();
8950
8951   bool signalReceived(false);
8952   AnimationFinishCheck finishCheck(signalReceived);
8953   animation.FinishedSignal().Connect(&application, finishCheck);
8954   application.SendNotification();
8955   application.Render(0);
8956   application.SendNotification();
8957   finishCheck.CheckSignalNotReceived();
8958   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8959
8960   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8961   application.SendNotification();
8962   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8963   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8964   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8965   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8966   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8967
8968   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8969   application.SendNotification();
8970   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8971   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8972   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8973   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8974   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8975
8976   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8977   application.SendNotification();
8978   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8979   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8980   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8981   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8982   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8983
8984   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8985   application.SendNotification();
8986   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8987   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8988   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8989   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8990   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8991
8992   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8993   application.SendNotification();
8994   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8995   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8996   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8997   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8998   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8999
9000   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
9001   application.SendNotification();
9002   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9003   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9004   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9005   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
9006   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
9007
9008   // We did expect the animation to finish
9009
9010   finishCheck.CheckSignalReceived();
9011   END_TEST;
9012 }
9013
9014 int UtcDaliAnimationAnimateBetweenActorColorP(void)
9015 {
9016   TestApplication application;
9017
9018   float startValue(1.0f);
9019   Actor actor = Actor::New();
9020   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9021   Stage::GetCurrent().Add(actor);
9022
9023   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9024   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9025   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9026   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9027   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9028   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9029   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9030   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9031   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9032
9033   // Build the animation
9034   float durationSeconds(1.0f);
9035   Animation animation = Animation::New(durationSeconds);
9036
9037   KeyFrames keyFrames = KeyFrames::New();
9038   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9039   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9040   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9041
9042   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
9043
9044   // Start the animation
9045   animation.Play();
9046
9047   bool signalReceived(false);
9048   AnimationFinishCheck finishCheck(signalReceived);
9049   animation.FinishedSignal().Connect(&application, finishCheck);
9050   application.SendNotification();
9051   application.Render(0);
9052   application.SendNotification();
9053   finishCheck.CheckSignalNotReceived();
9054   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9055   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9056   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9057   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9058
9059   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9060   application.SendNotification();
9061   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9062   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9063   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9064   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9065
9066   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9067   application.SendNotification();
9068   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9069   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9070   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9071   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9072
9073   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9074   application.SendNotification();
9075   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9076   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9077   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9078   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9079
9080   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9081   application.SendNotification();
9082   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9083   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9084   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9086
9087   // We did expect the animation to finish
9088
9089   finishCheck.CheckSignalReceived();
9090   END_TEST;
9091 }
9092
9093 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9094 {
9095   TestApplication application;
9096
9097   float startValue(1.0f);
9098   Actor actor = Actor::New();
9099   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9100   Stage::GetCurrent().Add(actor);
9101
9102   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9103   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9104   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9105   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9106   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9107   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9108   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9109   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9110   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9111
9112   // Build the animation
9113   float durationSeconds(1.0f);
9114   Animation animation = Animation::New(durationSeconds);
9115
9116   KeyFrames keyFrames = KeyFrames::New();
9117   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9118   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9119   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9120
9121   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9122
9123   // Start the animation
9124   animation.Play();
9125
9126   bool signalReceived(false);
9127   AnimationFinishCheck finishCheck(signalReceived);
9128   animation.FinishedSignal().Connect(&application, finishCheck);
9129   application.SendNotification();
9130   application.Render(0);
9131   application.SendNotification();
9132   finishCheck.CheckSignalNotReceived();
9133   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9134   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9135   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9136   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9137
9138   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9139   application.SendNotification();
9140   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9141   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9142   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9143   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9144
9145   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9146   application.SendNotification();
9147   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9148   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9149   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9150   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9151
9152   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9153   application.SendNotification();
9154   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9155   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9156   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9157   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9158
9159   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9160   application.SendNotification();
9161   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9162   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9163   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9164   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9165
9166   // We did expect the animation to finish
9167
9168   finishCheck.CheckSignalReceived();
9169   END_TEST;
9170 }
9171
9172 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9173 {
9174   TestApplication application;
9175
9176   Actor actor = Actor::New();
9177   AngleAxis aa(Degree(90), Vector3::XAXIS);
9178   actor.SetOrientation(aa.angle, aa.axis);
9179   Stage::GetCurrent().Add(actor);
9180
9181   application.SendNotification();
9182   application.Render(0);
9183
9184   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9185
9186   // Build the animation
9187   float durationSeconds(1.0f);
9188   Animation animation = Animation::New(durationSeconds);
9189
9190   KeyFrames keyFrames = KeyFrames::New();
9191   keyFrames.Add(0.0f, false);
9192   keyFrames.Add(0.2f, true);
9193   keyFrames.Add(0.4f, true);
9194   keyFrames.Add(0.8f, false);
9195   keyFrames.Add(1.0f, true);
9196
9197   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9198
9199   // Start the animation
9200   animation.Play();
9201
9202   // Final key frame value should be retrievable straight away
9203   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9204
9205   bool signalReceived(false);
9206   AnimationFinishCheck finishCheck(signalReceived);
9207   animation.FinishedSignal().Connect(&application, finishCheck);
9208   application.SendNotification();
9209   application.SendNotification();
9210   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9211   application.SendNotification();
9212   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9213   application.SendNotification();
9214
9215   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9216   finishCheck.CheckSignalReceived();
9217   END_TEST;
9218 }
9219
9220 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9221 {
9222   TestApplication application;
9223
9224   Actor actor = Actor::New();
9225   AngleAxis aa(Degree(90), Vector3::XAXIS);
9226   actor.SetOrientation(aa.angle, aa.axis);
9227   Stage::GetCurrent().Add(actor);
9228
9229   application.SendNotification();
9230   application.Render(0);
9231
9232   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
9233
9234   // Build the animation
9235   float durationSeconds(1.0f);
9236   Animation animation = Animation::New(durationSeconds);
9237
9238   KeyFrames keyFrames = KeyFrames::New();
9239   keyFrames.Add(0.0f, false);
9240   keyFrames.Add(0.2f, true);
9241   keyFrames.Add(0.4f, true);
9242   keyFrames.Add(0.8f, false);
9243   keyFrames.Add(1.0f, true);
9244
9245   //Cubic interpolation for boolean values should be ignored
9246   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9247
9248   // Start the animation
9249   animation.Play();
9250
9251   bool signalReceived(false);
9252   AnimationFinishCheck finishCheck(signalReceived);
9253   animation.FinishedSignal().Connect(&application, finishCheck);
9254   application.SendNotification();
9255   application.SendNotification();
9256   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9257   application.SendNotification();
9258   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9259   application.SendNotification();
9260
9261   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
9262   finishCheck.CheckSignalReceived();
9263   END_TEST;
9264 }
9265
9266 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9267 {
9268   TestApplication application;
9269
9270   Actor actor = Actor::New();
9271   AngleAxis aa(Degree(90), Vector3::XAXIS);
9272   actor.SetOrientation(aa.angle, aa.axis);
9273   Stage::GetCurrent().Add(actor);
9274
9275   application.SendNotification();
9276   application.Render(0);
9277   Quaternion start(Radian(aa.angle), aa.axis);
9278   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9279
9280   // Build the animation
9281   float durationSeconds(1.0f);
9282   Animation animation = Animation::New(durationSeconds);
9283
9284   KeyFrames keyFrames = KeyFrames::New();
9285   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9286
9287   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9288
9289   // Start the animation
9290   animation.Play();
9291
9292   // Final key frame value should be retrievable straight away
9293   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9294
9295   bool signalReceived(false);
9296   AnimationFinishCheck finishCheck(signalReceived);
9297   animation.FinishedSignal().Connect(&application, finishCheck);
9298   application.SendNotification();
9299   application.SendNotification();
9300   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9301   application.SendNotification();
9302   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9303   application.SendNotification();
9304
9305   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9306
9307   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9308   finishCheck.CheckSignalReceived();
9309   END_TEST;
9310 }
9311
9312 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9313 {
9314   TestApplication application;
9315
9316   Actor actor = Actor::New();
9317   AngleAxis aa(Degree(90), Vector3::XAXIS);
9318   actor.SetOrientation(aa.angle, aa.axis);
9319   application.SendNotification();
9320   application.Render(0);
9321   Stage::GetCurrent().Add(actor);
9322
9323   Quaternion start(Radian(aa.angle), aa.axis);
9324   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9325
9326   // Build the animation
9327   float durationSeconds(1.0f);
9328   Animation animation = Animation::New(durationSeconds);
9329
9330   KeyFrames keyFrames = KeyFrames::New();
9331   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9332   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9333   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9334
9335   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9336
9337   // Start the animation
9338   animation.Play();
9339
9340   bool signalReceived(false);
9341   AnimationFinishCheck finishCheck(signalReceived);
9342   animation.FinishedSignal().Connect(&application, finishCheck);
9343   application.SendNotification();
9344   application.Render(0);
9345   application.SendNotification();
9346   finishCheck.CheckSignalNotReceived();
9347
9348   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9349   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9350
9351   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9352   application.SendNotification();
9353   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9354   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9355
9356   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9357   application.SendNotification();
9358   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9359   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9360
9361   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9362   application.SendNotification();
9363   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9364   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9365
9366   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9367   application.SendNotification();
9368   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9369   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9370
9371   // We did expect the animation to finish
9372
9373   finishCheck.CheckSignalReceived();
9374   END_TEST;
9375 }
9376
9377 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9378 {
9379   TestApplication application;
9380
9381   Actor actor = Actor::New();
9382   AngleAxis aa(Degree(90), Vector3::XAXIS);
9383   actor.SetOrientation(aa.angle, aa.axis);
9384   Stage::GetCurrent().Add(actor);
9385
9386   application.SendNotification();
9387   application.Render(0);
9388   Quaternion start(Radian(aa.angle), aa.axis);
9389   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9390
9391   // Build the animation
9392   float durationSeconds(1.0f);
9393   Animation animation = Animation::New(durationSeconds);
9394
9395   KeyFrames keyFrames = KeyFrames::New();
9396   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9397
9398   //Cubic interpolation should be ignored for quaternions
9399   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9400
9401   // Start the animation
9402   animation.Play();
9403
9404   bool signalReceived(false);
9405   AnimationFinishCheck finishCheck(signalReceived);
9406   animation.FinishedSignal().Connect(&application, finishCheck);
9407   application.SendNotification();
9408   application.SendNotification();
9409   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9410   application.SendNotification();
9411   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9412   application.SendNotification();
9413
9414   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9415
9416   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9417   finishCheck.CheckSignalReceived();
9418   END_TEST;
9419 }
9420
9421 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9422 {
9423   TestApplication application;
9424
9425   Actor actor = Actor::New();
9426   AngleAxis aa(Degree(90), Vector3::XAXIS);
9427   actor.SetOrientation(aa.angle, aa.axis);
9428   application.SendNotification();
9429   application.Render(0);
9430   Stage::GetCurrent().Add(actor);
9431
9432   Quaternion start(Radian(aa.angle), aa.axis);
9433   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9434
9435   // Build the animation
9436   float durationSeconds(1.0f);
9437   Animation animation = Animation::New(durationSeconds);
9438
9439   KeyFrames keyFrames = KeyFrames::New();
9440   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9441   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9442   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9443
9444   //Cubic interpolation should be ignored for quaternions
9445   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9446
9447   // Start the animation
9448   animation.Play();
9449
9450   bool signalReceived(false);
9451   AnimationFinishCheck finishCheck(signalReceived);
9452   animation.FinishedSignal().Connect(&application, finishCheck);
9453   application.SendNotification();
9454   application.Render(0);
9455   application.SendNotification();
9456   finishCheck.CheckSignalNotReceived();
9457
9458   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9459   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9460
9461   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9462   application.SendNotification();
9463   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9464   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9465
9466   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9467   application.SendNotification();
9468   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9469   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9470
9471   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9472   application.SendNotification();
9473   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9474   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9475
9476   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9477   application.SendNotification();
9478   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9479   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9480
9481   // We did expect the animation to finish
9482
9483   finishCheck.CheckSignalReceived();
9484   END_TEST;
9485 }
9486
9487 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9488 {
9489   TestApplication application;
9490
9491   float startValue(1.0f);
9492   Actor actor = Actor::New();
9493   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9494   Stage::GetCurrent().Add(actor);
9495
9496   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9497   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9498   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9499   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9500   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9502   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9503   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9504   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9505
9506   // Build the animation
9507   float durationSeconds(1.0f);
9508   Animation animation = Animation::New(durationSeconds);
9509
9510   KeyFrames keyFrames = KeyFrames::New();
9511   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9512   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9513   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9514
9515   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9516
9517   // Start the animation
9518   animation.Play();
9519
9520   bool signalReceived(false);
9521   AnimationFinishCheck finishCheck(signalReceived);
9522   animation.FinishedSignal().Connect(&application, finishCheck);
9523   application.SendNotification();
9524   application.Render(0);
9525   application.SendNotification();
9526   finishCheck.CheckSignalNotReceived();
9527   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9528   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9529   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9530   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9531
9532   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9533   application.SendNotification();
9534   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9535   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9536   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9537   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9538
9539   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9540   application.SendNotification();
9541   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9542   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9543   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9544   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9545
9546   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9547   application.SendNotification();
9548   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9549   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9550   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9552
9553   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9554   application.SendNotification();
9555   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9556   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9557   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9559
9560   // We did expect the animation to finish
9561
9562   finishCheck.CheckSignalReceived();
9563   END_TEST;
9564 }
9565
9566 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9567 {
9568   TestApplication application;
9569
9570   float startValue(1.0f);
9571   Actor actor = Actor::New();
9572   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9573   Stage::GetCurrent().Add(actor);
9574
9575   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9576   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9577   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9578   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9579   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9581   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9582   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9583   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9584
9585   // Build the animation
9586   float durationSeconds(1.0f);
9587   Animation animation = Animation::New(durationSeconds);
9588
9589   KeyFrames keyFrames = KeyFrames::New();
9590   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9591   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9592   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9593
9594   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9595
9596   // Start the animation
9597   animation.Play();
9598
9599   bool signalReceived(false);
9600   AnimationFinishCheck finishCheck(signalReceived);
9601   animation.FinishedSignal().Connect(&application, finishCheck);
9602   application.SendNotification();
9603   application.Render(0);
9604   application.SendNotification();
9605   finishCheck.CheckSignalNotReceived();
9606   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9607   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9608   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9609   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9610
9611   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9612   application.SendNotification();
9613   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9614   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9615   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9616   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9617
9618   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9619   application.SendNotification();
9620   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9621   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9622   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9623   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9624
9625   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9626   application.SendNotification();
9627   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9628   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9629   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9630   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9631
9632   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9633   application.SendNotification();
9634   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9635   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9636   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9637   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9638
9639   // We did expect the animation to finish
9640
9641   finishCheck.CheckSignalReceived();
9642   END_TEST;
9643 }
9644
9645 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9646 {
9647   TestApplication application;
9648
9649   float startValue(1.0f);
9650   Actor actor = Actor::New();
9651   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9652   Stage::GetCurrent().Add(actor);
9653
9654   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9655   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9656   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9657   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9658   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9659   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9662   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9663
9664   // Build the animation
9665   float durationSeconds(1.0f);
9666   float delay = 0.5f;
9667   Animation animation = Animation::New(durationSeconds);
9668
9669   KeyFrames keyFrames = KeyFrames::New();
9670   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9671   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9672   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9673
9674   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9675
9676   // Start the animation
9677   animation.Play();
9678
9679   bool signalReceived(false);
9680   AnimationFinishCheck finishCheck(signalReceived);
9681   animation.FinishedSignal().Connect(&application, finishCheck);
9682   application.SendNotification();
9683
9684   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9685   application.SendNotification();
9686   finishCheck.CheckSignalNotReceived();
9687   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9688   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9689   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9690   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9691
9692   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9693   application.SendNotification();
9694   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9695   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9696   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9697   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9698
9699   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9700   application.SendNotification();
9701   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9702   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9703   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9704   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9705
9706   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9707   application.SendNotification();
9708   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9709   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9710   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9711   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9712
9713   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9714   application.SendNotification();
9715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9716   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9717   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9718   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9719
9720   // We did expect the animation to finish
9721
9722   finishCheck.CheckSignalReceived();
9723   END_TEST;
9724 }
9725
9726 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9727 {
9728   TestApplication application;
9729
9730   float startValue(1.0f);
9731   Actor actor = Actor::New();
9732   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9733   Stage::GetCurrent().Add(actor);
9734
9735   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9736   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9737   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9738   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9739   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9740   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9741   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9742   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9743   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9744
9745   // Build the animation
9746   float durationSeconds(1.0f);
9747   float delay = 0.5f;
9748   Animation animation = Animation::New(durationSeconds);
9749
9750   KeyFrames keyFrames = KeyFrames::New();
9751   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9752   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9753   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9754
9755   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9756
9757   // Start the animation
9758   animation.Play();
9759
9760   bool signalReceived(false);
9761   AnimationFinishCheck finishCheck(signalReceived);
9762   animation.FinishedSignal().Connect(&application, finishCheck);
9763   application.SendNotification();
9764
9765   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9766   application.SendNotification();
9767   finishCheck.CheckSignalNotReceived();
9768   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9770   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9771   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9772
9773   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9774   application.SendNotification();
9775   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9776   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9777   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9778   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9779
9780   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9781   application.SendNotification();
9782   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9783   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9784   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9785   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9786
9787   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9788   application.SendNotification();
9789   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9790   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9791   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9792   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9793
9794   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9795   application.SendNotification();
9796   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9797   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9798   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9799   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9800
9801   // We did expect the animation to finish
9802
9803   finishCheck.CheckSignalReceived();
9804   END_TEST;
9805 }
9806
9807 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9808 {
9809   TestApplication application;
9810
9811   float startValue(1.0f);
9812   float delay = 0.5f;
9813   Actor actor = Actor::New();
9814   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9815   Stage::GetCurrent().Add(actor);
9816
9817   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9818   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9819   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9820   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9821   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9823   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9824   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9825   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9826
9827   // Build the animation
9828   float durationSeconds(1.0f);
9829   Animation animation = Animation::New(durationSeconds);
9830
9831   KeyFrames keyFrames = KeyFrames::New();
9832   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9833   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9834   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9835
9836   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9837
9838   // Start the animation
9839   animation.Play();
9840
9841   bool signalReceived(false);
9842   AnimationFinishCheck finishCheck(signalReceived);
9843   animation.FinishedSignal().Connect(&application, finishCheck);
9844   application.SendNotification();
9845
9846   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9847   application.SendNotification();
9848   finishCheck.CheckSignalNotReceived();
9849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9850   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9851   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9852   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9853
9854   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9855   application.SendNotification();
9856   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9857   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9858   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9859   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9860
9861   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9862   application.SendNotification();
9863   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9864   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9865   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9866   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9867
9868   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9869   application.SendNotification();
9870   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9871   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9872   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9873   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9874
9875   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9876   application.SendNotification();
9877   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9878   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9879   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9880   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9881
9882   // We did expect the animation to finish
9883
9884   finishCheck.CheckSignalReceived();
9885   END_TEST;
9886 }
9887
9888 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9889 {
9890   TestApplication application;
9891
9892   float startValue(1.0f);
9893   Actor actor = Actor::New();
9894   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9895   Stage::GetCurrent().Add(actor);
9896
9897   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9899   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9900   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9901   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9902   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9903   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9904   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9906
9907
9908   // Build the animation
9909   float durationSeconds(1.0f);
9910   float delay = 0.5f;
9911   Animation animation = Animation::New(durationSeconds);
9912
9913   KeyFrames keyFrames = KeyFrames::New();
9914   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9915   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9916   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9917
9918   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9919
9920   // Start the animation
9921   animation.Play();
9922
9923   bool signalReceived(false);
9924   AnimationFinishCheck finishCheck(signalReceived);
9925   animation.FinishedSignal().Connect(&application, finishCheck);
9926   application.SendNotification();
9927
9928   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9929   application.SendNotification();
9930   finishCheck.CheckSignalNotReceived();
9931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9932   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9933   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9934   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9935
9936   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9937   application.SendNotification();
9938   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9939   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9940   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9941   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9942
9943   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9944   application.SendNotification();
9945   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9946   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9947   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9948   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9949
9950   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9951   application.SendNotification();
9952   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9953   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9954   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9955   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9956
9957   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9958   application.SendNotification();
9959   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9960   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9961   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9962   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9963
9964   // We did expect the animation to finish
9965
9966   finishCheck.CheckSignalReceived();
9967   END_TEST;
9968 }
9969
9970 int UtcDaliAnimationAnimateP(void)
9971 {
9972   TestApplication application;
9973
9974   Actor actor = Actor::New();
9975   Stage::GetCurrent().Add(actor);
9976
9977   //Build the path
9978   Vector3 position0( 30.0,  80.0,  0.0);
9979   Vector3 position1( 70.0,  120.0, 0.0);
9980   Vector3 position2( 100.0, 100.0, 0.0);
9981
9982   Dali::Path path = Dali::Path::New();
9983   path.AddPoint(position0);
9984   path.AddPoint(position1);
9985   path.AddPoint(position2);
9986
9987   //Control points for first segment
9988   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9989   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9990
9991   //Control points for second segment
9992   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9993   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9994
9995   // Build the animation
9996   float durationSeconds( 1.0f );
9997   Animation animation = Animation::New(durationSeconds);
9998   animation.Animate(actor, path, Vector3::XAXIS);
9999
10000   // Start the animation
10001   animation.Play();
10002
10003   bool signalReceived(false);
10004   AnimationFinishCheck finishCheck(signalReceived);
10005   animation.FinishedSignal().Connect(&application, finishCheck);
10006   application.SendNotification();
10007   application.Render(0);
10008   application.SendNotification();
10009   finishCheck.CheckSignalNotReceived();
10010   Vector3 position, tangent;
10011   Quaternion rotation;
10012   path.Sample( 0.0f, position, tangent );
10013   rotation = Quaternion( Vector3::XAXIS, tangent );
10014   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10015   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10016
10017   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10018   application.SendNotification();
10019   path.Sample( 0.25f, position, tangent );
10020   rotation = Quaternion( Vector3::XAXIS, tangent );
10021   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10022   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10023
10024   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10025   application.SendNotification();
10026   path.Sample( 0.5f, position, tangent );
10027   rotation = Quaternion( Vector3::XAXIS, tangent );
10028   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10029   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10030
10031   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10032   application.SendNotification();
10033   path.Sample( 0.75f, position, tangent );
10034   rotation = Quaternion( Vector3::XAXIS, tangent );
10035   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10036   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10037
10038   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10039   application.SendNotification();
10040   path.Sample( 1.0f, position, tangent );
10041   rotation = Quaternion( Vector3::XAXIS, tangent );
10042   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10043   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10044
10045   finishCheck.CheckSignalReceived();
10046   END_TEST;
10047 }
10048
10049 int UtcDaliAnimationAnimateAlphaFunctionP(void)
10050 {
10051   TestApplication application;
10052
10053   Actor actor = Actor::New();
10054   Stage::GetCurrent().Add(actor);
10055
10056   //Build the path
10057   Vector3 position0( 30.0,  80.0,  0.0);
10058   Vector3 position1( 70.0,  120.0, 0.0);
10059   Vector3 position2( 100.0, 100.0, 0.0);
10060
10061   Dali::Path path = Dali::Path::New();
10062   path.AddPoint(position0);
10063   path.AddPoint(position1);
10064   path.AddPoint(position2);
10065
10066   //Control points for first segment
10067   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10068   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10069
10070   //Control points for second segment
10071   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10072   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10073
10074   // Build the animation
10075   float durationSeconds( 1.0f );
10076   Animation animation = Animation::New(durationSeconds);
10077   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10078
10079   // Start the animation
10080   animation.Play();
10081
10082   bool signalReceived(false);
10083   AnimationFinishCheck finishCheck(signalReceived);
10084   animation.FinishedSignal().Connect(&application, finishCheck);
10085   application.SendNotification();
10086   application.Render(0);
10087   application.SendNotification();
10088   finishCheck.CheckSignalNotReceived();
10089   Vector3 position, tangent;
10090   Quaternion rotation;
10091   path.Sample( 0.0f, position, tangent );
10092   rotation = Quaternion( Vector3::XAXIS, tangent );
10093   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10094   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10095
10096   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10097   application.SendNotification();
10098   path.Sample( 0.25f, position, tangent );
10099   rotation = Quaternion( Vector3::XAXIS, tangent );
10100   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10101   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10102
10103   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10104   application.SendNotification();
10105   path.Sample( 0.5f, position, tangent );
10106   rotation = Quaternion( Vector3::XAXIS, tangent );
10107   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10108   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10109
10110   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10111   application.SendNotification();
10112   path.Sample( 0.75f, position, tangent );
10113   rotation = Quaternion( Vector3::XAXIS, tangent );
10114   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10115   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10116
10117   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10118   application.SendNotification();
10119   path.Sample( 1.0f, position, tangent );
10120   rotation = Quaternion( Vector3::XAXIS, tangent );
10121   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10122   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10123
10124   finishCheck.CheckSignalReceived();
10125   END_TEST;
10126 }
10127
10128 int UtcDaliAnimationAnimateTimePeriodP(void)
10129 {
10130   TestApplication application;
10131
10132   Actor actor = Actor::New();
10133   Stage::GetCurrent().Add(actor);
10134
10135   //Build the path
10136   Vector3 position0( 30.0,  80.0,  0.0);
10137   Vector3 position1( 70.0,  120.0, 0.0);
10138   Vector3 position2( 100.0, 100.0, 0.0);
10139
10140   Dali::Path path = Dali::Path::New();
10141   path.AddPoint(position0);
10142   path.AddPoint(position1);
10143   path.AddPoint(position2);
10144
10145   //Control points for first segment
10146   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10147   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10148
10149   //Control points for second segment
10150   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10151   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10152
10153   // Build the animation
10154   float durationSeconds( 1.0f );
10155   Animation animation = Animation::New(durationSeconds);
10156   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10157
10158   // Start the animation
10159   animation.Play();
10160
10161   bool signalReceived(false);
10162   AnimationFinishCheck finishCheck(signalReceived);
10163   animation.FinishedSignal().Connect(&application, finishCheck);
10164   application.SendNotification();
10165   application.Render(0);
10166   application.SendNotification();
10167   finishCheck.CheckSignalNotReceived();
10168   Vector3 position, tangent;
10169   Quaternion rotation;
10170   path.Sample( 0.0f, position, tangent );
10171   rotation = Quaternion( Vector3::XAXIS, tangent );
10172   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10173   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10174
10175   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10176   application.SendNotification();
10177   path.Sample( 0.25f, position, tangent );
10178   rotation = Quaternion( Vector3::XAXIS, tangent );
10179   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10180   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10181
10182   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10183   application.SendNotification();
10184   path.Sample( 0.5f, position, tangent );
10185   rotation = Quaternion( Vector3::XAXIS, tangent );
10186   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10187   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10188
10189   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10190   application.SendNotification();
10191   path.Sample( 0.75f, position, tangent );
10192   rotation = Quaternion( Vector3::XAXIS, tangent );
10193   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10194   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10195
10196   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10197   application.SendNotification();
10198   path.Sample( 1.0f, position, tangent );
10199   rotation = Quaternion( Vector3::XAXIS, tangent );
10200   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10201   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10202
10203   finishCheck.CheckSignalReceived();
10204   END_TEST;
10205 }
10206
10207 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10208 {
10209   TestApplication application;
10210
10211   Actor actor = Actor::New();
10212   Stage::GetCurrent().Add(actor);
10213
10214   //Build the path
10215   Vector3 position0( 30.0,  80.0,  0.0);
10216   Vector3 position1( 70.0,  120.0, 0.0);
10217   Vector3 position2( 100.0, 100.0, 0.0);
10218
10219   Dali::Path path = Dali::Path::New();
10220   path.AddPoint(position0);
10221   path.AddPoint(position1);
10222   path.AddPoint(position2);
10223
10224   //Control points for first segment
10225   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10226   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10227
10228   //Control points for second segment
10229   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10230   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10231
10232   // Build the animation
10233   float durationSeconds( 1.0f );
10234   Animation animation = Animation::New(durationSeconds);
10235   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10236
10237   // Start the animation
10238   animation.Play();
10239
10240   bool signalReceived(false);
10241   AnimationFinishCheck finishCheck(signalReceived);
10242   animation.FinishedSignal().Connect(&application, finishCheck);
10243   application.SendNotification();
10244   application.Render(0);
10245   application.SendNotification();
10246   finishCheck.CheckSignalNotReceived();
10247   Vector3 position, tangent;
10248   Quaternion rotation;
10249   path.Sample( 0.0f, position, tangent );
10250   rotation = Quaternion( Vector3::XAXIS, tangent );
10251   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10252   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10253
10254   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10255   application.SendNotification();
10256   path.Sample( 0.25f, position, tangent );
10257   rotation = Quaternion( Vector3::XAXIS, tangent );
10258   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10259   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10260
10261   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10262   application.SendNotification();
10263   path.Sample( 0.5f, position, tangent );
10264   rotation = Quaternion( Vector3::XAXIS, tangent );
10265   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10266   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10267
10268   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10269   application.SendNotification();
10270   path.Sample( 0.75f, position, tangent );
10271   rotation = Quaternion( Vector3::XAXIS, tangent );
10272   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10273   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10274
10275   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10276   application.SendNotification();
10277   path.Sample( 1.0f, position, tangent );
10278   rotation = Quaternion( Vector3::XAXIS, tangent );
10279   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
10280   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
10281
10282   finishCheck.CheckSignalReceived();
10283   END_TEST;
10284 }
10285
10286 int UtcDaliAnimationShowP(void)
10287 {
10288   TestApplication application;
10289
10290   Actor actor = Actor::New();
10291   actor.SetVisible(false);
10292   application.SendNotification();
10293   application.Render(0);
10294   DALI_TEST_CHECK( !actor.IsVisible() );
10295   Stage::GetCurrent().Add(actor);
10296
10297   // Start the animation
10298   float durationSeconds(10.0f);
10299   Animation animation = Animation::New(durationSeconds);
10300   animation.Show(actor, durationSeconds*0.5f);
10301   animation.Play();
10302
10303   bool signalReceived(false);
10304   AnimationFinishCheck finishCheck(signalReceived);
10305   animation.FinishedSignal().Connect(&application, finishCheck);
10306
10307   application.SendNotification();
10308   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10309
10310   // We didn't expect the animation to finish yet
10311   application.SendNotification();
10312   finishCheck.CheckSignalNotReceived();
10313   DALI_TEST_CHECK( !actor.IsVisible() );
10314
10315   application.SendNotification();
10316   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10317
10318   // We didn't expect the animation to finish yet
10319   application.SendNotification();
10320   finishCheck.CheckSignalNotReceived();
10321   DALI_TEST_CHECK( actor.IsVisible() );
10322
10323   application.SendNotification();
10324   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10325
10326   // We did expect the animation to finish
10327   application.SendNotification();
10328   finishCheck.CheckSignalReceived();
10329   DALI_TEST_CHECK( actor.IsVisible() );
10330   END_TEST;
10331 }
10332
10333 int UtcDaliAnimationHideP(void)
10334 {
10335   TestApplication application;
10336
10337   Actor actor = Actor::New();
10338   DALI_TEST_CHECK( actor.IsVisible() );
10339   Stage::GetCurrent().Add(actor);
10340
10341   // Start the animation
10342   float durationSeconds(10.0f);
10343   Animation animation = Animation::New(durationSeconds);
10344   animation.Hide(actor, durationSeconds*0.5f);
10345   animation.Play();
10346
10347   bool signalReceived(false);
10348   AnimationFinishCheck finishCheck(signalReceived);
10349   animation.FinishedSignal().Connect(&application, finishCheck);
10350
10351   application.SendNotification();
10352   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10353
10354   // We didn't expect the animation to finish yet
10355   application.SendNotification();
10356   finishCheck.CheckSignalNotReceived();
10357   DALI_TEST_CHECK( actor.IsVisible() );
10358
10359   application.SendNotification();
10360   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10361
10362   // We didn't expect the animation to finish yet
10363   application.SendNotification();
10364   finishCheck.CheckSignalNotReceived();
10365   DALI_TEST_CHECK( !actor.IsVisible() );
10366
10367   application.SendNotification();
10368   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10369
10370   // We did expect the animation to finish
10371   application.SendNotification();
10372   finishCheck.CheckSignalReceived();
10373   DALI_TEST_CHECK( !actor.IsVisible() );
10374   END_TEST;
10375 }
10376
10377 int UtcDaliAnimationShowHideAtEndP(void)
10378 {
10379   // Test that show/hide delay can be the same as animation duration
10380   // i.e. to show/hide at the end of the animation
10381
10382   TestApplication application;
10383
10384   Actor actor = Actor::New();
10385   DALI_TEST_CHECK( actor.IsVisible() );
10386   Stage::GetCurrent().Add(actor);
10387
10388   // Start Hide animation
10389   float durationSeconds(10.0f);
10390   Animation animation = Animation::New(durationSeconds);
10391   animation.Hide(actor, durationSeconds/*Hide at end*/);
10392   animation.Play();
10393
10394   bool signalReceived(false);
10395   AnimationFinishCheck finishCheck(signalReceived);
10396   animation.FinishedSignal().Connect(&application, finishCheck);
10397
10398   application.SendNotification();
10399   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10400
10401   // We did expect the animation to finish
10402   application.SendNotification();
10403   finishCheck.CheckSignalReceived();
10404   DALI_TEST_CHECK( !actor.IsVisible() );
10405
10406   // Start Show animation
10407   animation = Animation::New(durationSeconds);
10408   animation.Show(actor, durationSeconds/*Show at end*/);
10409   animation.FinishedSignal().Connect(&application, finishCheck);
10410   animation.Play();
10411
10412   application.SendNotification();
10413   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10414
10415   // We did expect the animation to finish
10416   application.SendNotification();
10417   finishCheck.CheckSignalReceived();
10418   DALI_TEST_CHECK( actor.IsVisible() );
10419   END_TEST;
10420 }
10421
10422 int UtcDaliKeyFramesCreateDestroyP(void)
10423 {
10424   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10425
10426   KeyFrames* keyFrames = new KeyFrames;
10427   delete keyFrames;
10428   DALI_TEST_CHECK( true );
10429   END_TEST;
10430 }
10431
10432 int UtcDaliKeyFramesDownCastP(void)
10433 {
10434   TestApplication application;
10435   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10436
10437   KeyFrames keyFrames = KeyFrames::New();
10438   BaseHandle object(keyFrames);
10439
10440   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10441   DALI_TEST_CHECK(keyFrames2);
10442
10443   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10444   DALI_TEST_CHECK(keyFrames3);
10445
10446   BaseHandle unInitializedObject;
10447   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10448   DALI_TEST_CHECK(!keyFrames4);
10449
10450   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10451   DALI_TEST_CHECK(!keyFrames5);
10452   END_TEST;
10453 }
10454
10455 int UtcDaliAnimationCreateDestroyP(void)
10456 {
10457   TestApplication application;
10458   Animation* animation = new Animation;
10459   DALI_TEST_CHECK( animation );
10460   delete animation;
10461   END_TEST;
10462 }
10463
10464 struct UpdateManagerTestConstraint
10465 {
10466   UpdateManagerTestConstraint(TestApplication& application)
10467   : mApplication(application)
10468   {
10469   }
10470
10471   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10472   {
10473     mApplication.SendNotification();  // Process events
10474   }
10475
10476   TestApplication& mApplication;
10477 };
10478
10479 int UtcDaliAnimationUpdateManagerP(void)
10480 {
10481   TestApplication application;
10482
10483   Actor actor = Actor::New();
10484   Stage::GetCurrent().Add( actor );
10485
10486   // Build the animation
10487   Animation animation = Animation::New( 0.0f );
10488
10489   bool signalReceived = false;
10490   AnimationFinishCheck finishCheck( signalReceived );
10491   animation.FinishedSignal().Connect( &application, finishCheck );
10492
10493   Vector3 startValue(1.0f, 1.0f, 1.0f);
10494   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10495   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10496   constraint.Apply();
10497
10498   // Apply animation to actor
10499   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10500   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10501
10502   animation.Play();
10503
10504   application.SendNotification();
10505   application.UpdateOnly( 16 );
10506
10507   finishCheck.CheckSignalNotReceived();
10508
10509   application.SendNotification();   // Process events
10510
10511   finishCheck.CheckSignalReceived();
10512
10513   END_TEST;
10514 }
10515
10516 int UtcDaliAnimationSignalOrderP(void)
10517 {
10518   TestApplication application;
10519
10520   Actor actor = Actor::New();
10521   Stage::GetCurrent().Add( actor );
10522
10523   // Build the animations
10524   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10525   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10526
10527   bool signal1Received = false;
10528   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10529
10530   bool signal2Received = false;
10531   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10532
10533   // Apply animations to actor
10534   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10535   animation1.Play();
10536   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10537   animation2.Play();
10538
10539   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10540   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10541
10542   application.SendNotification();
10543   application.UpdateOnly( 10 ); // 10ms progress
10544
10545   // no notifications yet
10546   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10547   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10548
10549   application.SendNotification();
10550
10551   // first completed
10552   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10553   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10554   signal1Received = false;
10555
10556   // 1st animation is complete now, do another update with no ProcessEvents in between
10557   application.UpdateOnly( 20 ); // 20ms progress
10558
10559   // ProcessEvents
10560   application.SendNotification();
10561
10562   // 2nd should complete now
10563   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10564   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10565
10566   END_TEST;
10567 }
10568
10569 int UtcDaliAnimationExtendDurationP(void)
10570 {
10571   TestApplication application;
10572
10573   Actor actor = Actor::New();
10574
10575   // Register a float property
10576   float startValue(10.0f);
10577   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10578   Stage::GetCurrent().Add(actor);
10579   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10581
10582   // Build the animation
10583   float initialDurationSeconds(1.0f);
10584   float animatorDelay = 5.0f;
10585   float animatorDurationSeconds(5.0f);
10586   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10587   Animation animation = Animation::New(initialDurationSeconds);
10588   float targetValue(30.0f);
10589   float relativeValue(targetValue - startValue);
10590
10591   animation.AnimateTo(Property(actor, index),
10592                       targetValue,
10593                       TimePeriod(animatorDelay, animatorDurationSeconds));
10594
10595   // The duration should have been extended
10596   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10597
10598   // Start the animation
10599   animation.Play();
10600
10601   bool signalReceived(false);
10602   AnimationFinishCheck finishCheck(signalReceived);
10603   animation.FinishedSignal().Connect(&application, finishCheck);
10604
10605   application.SendNotification();
10606   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10607
10608   // We didn't expect the animation to finish yet, but cached value should be the final one
10609   application.SendNotification();
10610   finishCheck.CheckSignalNotReceived();
10611   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10612   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10613
10614   application.SendNotification();
10615   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10616
10617   // We didn't expect the animation to finish yet
10618   application.SendNotification();
10619   finishCheck.CheckSignalNotReceived();
10620   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10621
10622   application.SendNotification();
10623   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10624
10625   // We did expect the animation to finish
10626   application.SendNotification();
10627   finishCheck.CheckSignalReceived();
10628   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10629   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10630   END_TEST;
10631 }
10632
10633 int UtcDaliAnimationCustomIntProperty(void)
10634 {
10635   TestApplication application;
10636
10637   Actor actor = Actor::New();
10638   Stage::GetCurrent().Add(actor);
10639   int startValue(0u);
10640
10641   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10642   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10643   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10644
10645   // Build the animation
10646   float durationSeconds(1.0f);
10647   Animation animation = Animation::New(durationSeconds);
10648   animation.AnimateTo( Property(actor, index), 20 );
10649
10650   // Start the animation
10651   animation.Play();
10652
10653   // Target value should be retrievable straight away
10654   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10655
10656   bool signalReceived(false);
10657   AnimationFinishCheck finishCheck(signalReceived);
10658   animation.FinishedSignal().Connect(&application, finishCheck);
10659
10660   application.SendNotification();
10661   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10662
10663   // We didn't expect the animation to finish yet
10664   application.SendNotification();
10665   finishCheck.CheckSignalNotReceived();
10666   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10667
10668   application.SendNotification();
10669   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10670
10671   // We did expect the animation to finish
10672   application.SendNotification();
10673   finishCheck.CheckSignalReceived();
10674   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10675   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10676   END_TEST;
10677 }
10678
10679 int UtcDaliAnimationDuration(void)
10680 {
10681   TestApplication application;
10682
10683   Actor actor = Actor::New();
10684   Stage::GetCurrent().Add(actor);
10685
10686   Animation animation = Animation::New( 0.0f );
10687   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10688
10689   // The animation duration should automatically increase depending on the animator time period
10690
10691   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10692   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10693
10694   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10695   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10696
10697   END_TEST;
10698 }
10699
10700 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10701 {
10702   TestApplication application;
10703
10704   Actor actor = Actor::New();
10705
10706   // Register an integer property
10707   int startValue(1);
10708   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10709   Stage::GetCurrent().Add(actor);
10710   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10711
10712   try
10713   {
10714     // Build the animation
10715     Animation animation = Animation::New( 2.0f );
10716     std::string relativeValue = "relative string";
10717     animation.AnimateBy( Property(actor, index), relativeValue );
10718     tet_result(TET_FAIL);
10719   }
10720   catch ( Dali::DaliException& e )
10721   {
10722     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10723   }
10724
10725
10726   END_TEST;
10727 }
10728
10729
10730 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10731 {
10732   TestApplication application;
10733
10734   Actor actor = Actor::New();
10735
10736   // Register an integer property
10737   int startValue(1);
10738   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10739   Stage::GetCurrent().Add(actor);
10740   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10741
10742   try
10743   {
10744     // Build the animation
10745     Animation animation = Animation::New( 2.0f );
10746     std::string relativeValue = "relative string";
10747     animation.AnimateTo( Property(actor, index), relativeValue );
10748
10749     tet_result(TET_FAIL);
10750   }
10751   catch ( Dali::DaliException& e )
10752   {
10753    DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10754   }
10755
10756   END_TEST;
10757 }
10758
10759 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10760 {
10761   TestApplication application;
10762
10763   Actor actor = Actor::New();
10764
10765   // Register an integer property
10766   int startValue(1);
10767   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10768   Stage::GetCurrent().Add(actor);
10769   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10770
10771   try
10772   {
10773     // Build the animation
10774     KeyFrames keyFrames = KeyFrames::New();
10775     keyFrames.Add( 0.0f, std::string("relative string1") );
10776     keyFrames.Add( 1.0f, std::string("relative string2") );
10777     // no need to really create the animation as keyframes do the check
10778
10779     tet_result(TET_FAIL);
10780   }
10781   catch ( Dali::DaliException& e )
10782   {
10783     DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
10784   }
10785
10786   END_TEST;
10787 }
10788
10789 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10790 {
10791   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10792
10793   TestApplication application;
10794
10795   tet_infoline("Set initial position and set up animation to re-position actor");
10796
10797   Actor actor = Actor::New();
10798   Stage::GetCurrent().Add(actor);
10799   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10800   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10801
10802   // Build the animation
10803   Animation animation = Animation::New(2.0f);
10804
10805   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10806   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10807   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10808
10809   tet_infoline("Set target position in animation without intiating play");
10810
10811   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10812   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10813
10814   application.SendNotification();
10815   application.Render();
10816
10817   tet_infoline("Ensure position of actor is still at intial value");
10818
10819   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10820   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10821   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10822
10823   tet_infoline("Play animation and ensure actor position is now target");
10824
10825   animation.Play();
10826   application.SendNotification();
10827   application.Render(1000u);
10828
10829   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10830
10831   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10832   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10833   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10834
10835   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10836
10837   application.Render(2000u);
10838
10839   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10840
10841   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10842   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10843   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10844
10845   END_TEST;
10846 }
10847
10848 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10849 {
10850   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10851
10852   TestApplication application;
10853
10854   std::vector<Vector3> targetPositions;
10855
10856   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10857   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10858   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10859
10860   tet_infoline("Set initial position and set up animation to re-position actor");
10861
10862   Actor actor = Actor::New();
10863   Stage::GetCurrent().Add(actor);
10864   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10865   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10866
10867   // Build the animation
10868   Animation animation = Animation::New(2.0f);
10869
10870   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10871   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10872   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10873
10874   tet_infoline("Set target position in animation without intiating play");
10875
10876   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10877   {
10878     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10879   }
10880
10881   application.SendNotification();
10882   application.Render();
10883
10884   tet_infoline("Ensure position of actor is still at intial value");
10885
10886   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10887   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10888   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10889
10890   tet_infoline("Play animation and ensure actor position is now target");
10891
10892   animation.Play();
10893   application.SendNotification();
10894   application.Render(1000u);
10895
10896   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10897
10898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10899   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10900   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10901
10902   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10903
10904   application.Render(2000u);
10905
10906   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10907
10908   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10909   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10910   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10911
10912   END_TEST;
10913 }
10914
10915 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10916 {
10917   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");
10918
10919   TestApplication application;
10920
10921   std::vector<Vector3> targetSizes;
10922   std::vector<Vector3> targetPositions;
10923
10924   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10925   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10926
10927   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10928
10929   tet_infoline("Set initial position and set up animation to re-position actor");
10930
10931   Actor actor = Actor::New();
10932   Stage::GetCurrent().Add(actor);
10933   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10934   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10935
10936   actor.SetProperty( Actor::Property::SIZE, initialSize );
10937   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10938
10939   // Build the animation
10940   Animation animation = Animation::New(2.0f);
10941
10942   tet_infoline("Set target size in animation without intiating play");
10943   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10944   tet_infoline("Set target position in animation without intiating play");
10945   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10946   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10947
10948   application.SendNotification();
10949   application.Render();
10950
10951   tet_infoline("Ensure position of actor is still at intial size and position");
10952
10953   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10954   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10955   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10956
10957   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10958   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10960
10961   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10962
10963   animation.Play();
10964   application.SendNotification();
10965   application.Render(2000u);
10966
10967   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10968
10969   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10970   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10971   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10972
10973   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10974   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10975   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10976
10977   END_TEST;
10978 }
10979
10980 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10981 {
10982   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10983
10984   TestApplication application;
10985
10986   std::vector<Vector3> targetSizes;
10987   std::vector<float> targetColors;
10988
10989   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10990   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10991
10992   targetColors.push_back( 1.0f );
10993
10994   tet_infoline("Set initial position and set up animation to re-position actor");
10995
10996   Actor actor = Actor::New();
10997   Stage::GetCurrent().Add(actor);
10998   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10999
11000   actor.SetProperty( Actor::Property::SIZE, initialSize );
11001
11002   // Build the animation
11003   Animation animation = Animation::New(2.0f);
11004
11005   tet_infoline("Set target size in animation without initiating play");
11006   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
11007   tet_infoline("Set target position in animation without intiating play");
11008   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
11009   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
11010
11011   application.SendNotification();
11012   application.Render();
11013
11014   tet_infoline("Ensure position of actor is still at initial size and position");
11015
11016   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
11017   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
11018   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
11019
11020   tet_infoline("Play animation and ensure actor position and size is now matches targets");
11021
11022   animation.Play();
11023   application.SendNotification();
11024   application.Render(2000u);
11025
11026   tet_infoline("Ensure position and size of actor is at target value when animation playing");
11027
11028   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
11029   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
11030   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
11031
11032   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
11033
11034   END_TEST;
11035 }
11036
11037 int UtcDaliAnimationTimePeriodOrder(void)
11038 {
11039   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
11040
11041   TestApplication application;
11042
11043   Actor actor = Actor::New();
11044   Stage::GetCurrent().Add( actor );
11045
11046   application.SendNotification();
11047   application.Render();
11048
11049   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11050   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11051   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11052   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11053   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11054
11055   //////////////////////////////////////////////////////////////////////////////////
11056
11057   tet_infoline( "With two AnimateTo calls" );
11058
11059   Animation animation = Animation::New( 0.0f );
11060   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11061   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11062   animation.Play();
11063
11064   tet_infoline( "The target position should change instantly" );
11065   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11066   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11067
11068   application.SendNotification();
11069   application.Render(5000); // After the animation is complete
11070
11071   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11072   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11073   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11074
11075   //////////////////////////////////////////////////////////////////////////////////
11076
11077   tet_infoline( "Same animation again but in a different order - should yield the same result" );
11078
11079   actor.SetX( 0.0f );
11080   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11081   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11082
11083   application.SendNotification();
11084   application.Render();
11085
11086   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11087   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11088   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11089
11090   animation = Animation::New( 0.0f );
11091   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11092   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11093   animation.Play();
11094
11095   tet_infoline( "The target position should change instantly" );
11096   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11097   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11098
11099   application.SendNotification();
11100   application.Render(5000); // After the animation is complete
11101
11102   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11103   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11104   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11105
11106   END_TEST;
11107 }
11108
11109 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11110 {
11111   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" );
11112
11113   TestApplication application;
11114
11115   Actor actor = Actor::New();
11116   Stage::GetCurrent().Add( actor );
11117
11118   application.SendNotification();
11119   application.Render();
11120
11121   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11122   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11123   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11124   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11125   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11126
11127   //////////////////////////////////////////////////////////////////////////////////
11128
11129   tet_infoline( "" );
11130
11131   Animation animation = Animation::New( 0.0f );
11132   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11133   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11134   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11135   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11136   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11137   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11138   animation.Play();
11139
11140   tet_infoline( "The target position should change instantly" );
11141   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11142   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11143
11144   application.SendNotification();
11145   application.Render(14000); // After the animation is complete
11146
11147   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11148   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11149   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11150
11151   //////////////////////////////////////////////////////////////////////////////////
11152
11153   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11154
11155   actor.SetX( 0.0f );
11156
11157   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11158   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11159
11160   application.SendNotification();
11161   application.Render();
11162
11163   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
11164   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11165   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11166
11167   animation = Animation::New( 0.0f );
11168   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11169   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11170   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11171   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11172   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11173   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11174   animation.Play();
11175
11176   tet_infoline( "The target position should change instantly" );
11177   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11178   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11179
11180   application.SendNotification();
11181   application.Render(14000); // After the animation is complete
11182
11183   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11184   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11185   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11186
11187   END_TEST;
11188 }
11189
11190 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11191 {
11192   TestApplication application;
11193
11194   int startValue(1);
11195   Actor actor = Actor::New();
11196   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11197   Stage::GetCurrent().Add(actor);
11198
11199   application.Render();
11200   application.SendNotification();
11201
11202   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11203
11204   // Build the animation
11205   float durationSeconds(1.0f);
11206   Animation animation = Animation::New(durationSeconds);
11207
11208   KeyFrames keyFrames = KeyFrames::New();
11209   keyFrames.Add(0.0f, 10);
11210   keyFrames.Add(0.2f, 20);
11211   keyFrames.Add(0.4f, 30);
11212   keyFrames.Add(0.6f, 40);
11213   keyFrames.Add(0.8f, 50);
11214   keyFrames.Add(1.0f, 60);
11215
11216   animation.AnimateBetween( Property(actor, index ), keyFrames );
11217
11218   // Start the animation
11219   animation.Play();
11220
11221   // Target value should change to the last key-frame's value straight away
11222   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11223
11224   END_TEST;
11225 }
11226
11227 int UtcDaliAnimationAnimateBetweenVector2P(void)
11228 {
11229   TestApplication application;
11230
11231   Vector2 startValue( 10.0f, 20.0f );
11232   Actor actor = Actor::New();
11233   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11234   Stage::GetCurrent().Add(actor);
11235
11236   application.Render();
11237   application.SendNotification();
11238
11239   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11240
11241   // Build the animation
11242   float durationSeconds(1.0f);
11243   Animation animation = Animation::New(durationSeconds);
11244
11245   KeyFrames keyFrames = KeyFrames::New();
11246   keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11247   keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11248   keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11249   keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11250   keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11251   keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11252
11253   animation.AnimateBetween( Property(actor, index ), keyFrames );
11254
11255   // Start the animation
11256   animation.Play();
11257
11258   // Target value should change to the last key-frame's value straight away
11259   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11260
11261   END_TEST;
11262 }
11263
11264 int UtcDaliAnimationProgressCallbackP(void)
11265 {
11266   TestApplication application;
11267
11268   Actor actor = Actor::New();
11269   Stage::GetCurrent().Add(actor);
11270
11271   // Build the animation
11272   Animation animation = Animation::New(0.0f);
11273
11274   //Set duration
11275   float durationSeconds(1.0f);
11276   animation.SetDuration(durationSeconds);
11277
11278   bool finishedSignalReceived(false);
11279   bool progressSignalReceived(false);
11280
11281   AnimationFinishCheck finishCheck(finishedSignalReceived);
11282   animation.FinishedSignal().Connect(&application, finishCheck);
11283
11284   AnimationProgressCheck progressCheck(progressSignalReceived);
11285   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
11286   application.SendNotification();
11287
11288   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11289   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
11290
11291   tet_infoline( "Animation Progress notification set to 30%" );
11292   DevelAnimation::SetProgressNotification( animation, 0.3f );
11293
11294   application.SendNotification();
11295   application.Render( );
11296
11297   DALI_TEST_EQUALS( 0.3f, DevelAnimation::GetProgressNotification( animation ), TEST_LOCATION );
11298
11299   progressCheck.CheckSignalNotReceived();
11300
11301   // Start the animation from 10% progress
11302   animation.SetCurrentProgress( 0.1f );
11303   animation.Play();
11304
11305   tet_infoline( "Animation Playing from 10%" );
11306
11307   application.SendNotification();
11308   application.Render(0); // start animation
11309   application.Render(durationSeconds*100.0f ); // 20% progress
11310
11311   tet_infoline( "Animation at 20%" );
11312
11313   progressCheck.CheckSignalNotReceived();
11314
11315   application.SendNotification();
11316   application.Render(durationSeconds*200.0f ); // 40% progress
11317   application.SendNotification();
11318   tet_infoline( "Animation at 40%" );
11319   DALI_TEST_EQUALS( 0.4f, animation.GetCurrentProgress(), TEST_LOCATION );
11320
11321   progressCheck.CheckSignalReceived();
11322
11323   tet_infoline( "Progress check reset" );
11324   progressCheck.Reset();
11325
11326   application.Render(durationSeconds*100.0f ); // 50% progress
11327   tet_infoline( "Animation at 50%" );
11328   application.SendNotification();
11329
11330   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
11331
11332   progressCheck.CheckSignalNotReceived();
11333
11334   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
11335   application.SendNotification();
11336
11337   tet_infoline( "Animation at 60%" );
11338
11339   finishCheck.CheckSignalNotReceived();
11340
11341   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
11342   application.SendNotification();
11343   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
11344   tet_infoline( "Animation at 80%" );
11345
11346   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
11347   // We did expect the animation to finish
11348   application.SendNotification();
11349   finishCheck.CheckSignalReceived();
11350   tet_infoline( "Animation finished" );
11351   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11352
11353   END_TEST;
11354 }
11355
11356 int UtcDaliAnimationPlayAfterP(void)
11357 {
11358   TestApplication application;
11359
11360   tet_printf("Testing that playing after 2 seconds\n");
11361
11362   {
11363     Actor actor = Actor::New();
11364     Stage::GetCurrent().Add(actor);
11365
11366     // Build the animation
11367     float durationSeconds(1.0f);
11368     Animation animation = Animation::New(durationSeconds);
11369
11370     bool signalReceived( false );
11371     AnimationFinishCheck finishCheck( signalReceived );
11372     animation.FinishedSignal().Connect( &application, finishCheck );
11373     application.SendNotification();
11374
11375     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11376     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11377
11378     // Play animation after the initial delay time
11379     animation.PlayAfter( 0.2f );
11380     application.SendNotification();
11381     application.Render(0); // start animation
11382
11383     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11384     application.SendNotification();
11385     finishCheck.CheckSignalNotReceived();
11386     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11387
11388     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11389
11390     // We didn't expect the animation to finish yet
11391     application.SendNotification();
11392     finishCheck.CheckSignalNotReceived();
11393     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11394
11395     application.SendNotification();
11396     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11397
11398     application.SendNotification();
11399     finishCheck.CheckSignalNotReceived();
11400     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11401
11402     application.SendNotification();
11403     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11404
11405     // We did expect the animation to finish
11406     application.SendNotification();
11407     finishCheck.CheckSignalReceived();
11408     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11409
11410     // Check that nothing has changed after a couple of buffer swaps
11411     application.Render(0);
11412     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11413   }
11414
11415   tet_printf("Testing that playing after 2 seconds with negative speedfactor\n");
11416   // SpeedFactor < 0
11417   {
11418     Actor actor = Actor::New();
11419     Stage::GetCurrent().Add(actor);
11420
11421     // Build the animation
11422     float durationSeconds(1.0f);
11423     Animation animation = Animation::New(durationSeconds);
11424     animation.SetSpeedFactor( -1.0f ); // Set SpeedFactor as < 0
11425
11426     bool signalReceived( false );
11427     AnimationFinishCheck finishCheck( signalReceived );
11428     animation.FinishedSignal().Connect( &application, finishCheck );
11429     application.SendNotification();
11430
11431     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11432     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11433
11434     // Play animation after the initial delay time
11435     animation.PlayAfter( 0.2f );
11436     application.SendNotification();
11437     application.Render(0); // start animation
11438
11439     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11440     application.SendNotification();
11441     finishCheck.CheckSignalNotReceived();
11442     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11443
11444     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11445
11446     // We didn't expect the animation to finish yet
11447     application.SendNotification();
11448     finishCheck.CheckSignalNotReceived();
11449     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11450
11451     application.SendNotification();
11452     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11453
11454     application.SendNotification();
11455     finishCheck.CheckSignalNotReceived();
11456     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11457
11458     application.SendNotification();
11459     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) + 1u/*just beyond the animation duration*/ );
11460
11461     // We did expect the animation to finish
11462     application.SendNotification();
11463     finishCheck.CheckSignalReceived();
11464     DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of Timeperiod in seconds
11465
11466     // Check that nothing has changed after a couple of buffer swaps
11467     application.Render(0);
11468     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11469   }
11470
11471   END_TEST;
11472 }
11473
11474 int UtcDaliAnimationPlayAfterP2(void)
11475 {
11476   TestApplication application;
11477
11478   tet_printf("Testing that playing after 2 seconds before looping\n");
11479
11480   {
11481     Actor actor = Actor::New();
11482     Stage::GetCurrent().Add(actor);
11483
11484     // Build the animation
11485     float durationSeconds(1.0f);
11486     Animation animation = Animation::New(durationSeconds);
11487     animation.SetLooping( true );
11488
11489     bool signalReceived( false );
11490     AnimationFinishCheck finishCheck( signalReceived );
11491     animation.FinishedSignal().Connect( &application, finishCheck );
11492     application.SendNotification();
11493
11494     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11495     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11496
11497     // Play animation after the initial delay time
11498     animation.PlayAfter( 0.2f );
11499     application.SendNotification();
11500     application.Render(0); // start animation
11501
11502     for( int iterations = 0; iterations < 3; ++iterations )
11503     {
11504       // The initial delay time of PlayAfter() applies only once in looping mode.
11505       if( iterations == 0 )
11506       {
11507         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11508         application.SendNotification();
11509         finishCheck.CheckSignalNotReceived();
11510         DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11511       }
11512
11513       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11514
11515       // We didn't expect the animation to finish yet
11516       application.SendNotification();
11517       finishCheck.CheckSignalNotReceived();
11518       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11519
11520       application.SendNotification();
11521       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11522
11523       application.SendNotification();
11524       finishCheck.CheckSignalNotReceived();
11525       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11526
11527       application.SendNotification();
11528       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) /* 100% progress */ );
11529
11530       // We did expect the animation to finish
11531       application.SendNotification();
11532       finishCheck.CheckSignalNotReceived();
11533       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11534     }
11535
11536     animation.SetLooping(false);
11537     application.SendNotification();
11538     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11539
11540     application.SendNotification();
11541     finishCheck.CheckSignalReceived();
11542     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11543   }
11544
11545   tet_printf("Testing that playing after 2 seconds before looping with negative speedfactor\n");
11546   // SpeedFactor < 0
11547   {
11548     Actor actor = Actor::New();
11549     Stage::GetCurrent().Add(actor);
11550
11551     // Build the animation
11552     float durationSeconds(1.0f);
11553     Animation animation = Animation::New(durationSeconds);
11554     animation.SetLooping( true );
11555     animation.SetSpeedFactor( -1.0f ); //Set SpeedFactor as < 0
11556
11557     bool signalReceived( false );
11558     AnimationFinishCheck finishCheck( signalReceived );
11559     animation.FinishedSignal().Connect( &application, finishCheck );
11560     application.SendNotification();
11561
11562     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11563     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11564
11565     // Play animation after the initial delay time
11566     animation.PlayAfter( 0.2f );
11567     application.SendNotification();
11568     application.Render(0); // start animation
11569
11570     for( int iterations = 0; iterations < 3; ++iterations )
11571     {
11572       // The initial delay time of PlayAfter() applies only once in looping mode.
11573       if( iterations == 0 )
11574       {
11575         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11576         application.SendNotification();
11577         finishCheck.CheckSignalNotReceived();
11578         DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11579       }
11580
11581       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11582
11583       // We didn't expect the animation to finish yet
11584       application.SendNotification();
11585       finishCheck.CheckSignalNotReceived();
11586       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11587
11588       application.SendNotification();
11589       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11590
11591       application.SendNotification();
11592       finishCheck.CheckSignalNotReceived();
11593       DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION );
11594
11595       application.SendNotification();
11596       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) /* 100% progress */ );
11597
11598       // We did expect the animation to finish
11599       application.SendNotification();
11600       finishCheck.CheckSignalNotReceived();
11601       DALI_TEST_EQUALS( actor.GetCurrentPosition(),  ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in second
11602     }
11603
11604     animation.SetLooping(false);
11605     application.SendNotification();
11606     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11607
11608     application.SendNotification();
11609     finishCheck.CheckSignalReceived();
11610     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11611   }
11612
11613   END_TEST;
11614 }
11615
11616 int UtcDaliAnimationPlayAfterP3(void)
11617 {
11618   TestApplication application;
11619
11620   tet_printf("Testing that PlayAfter with the negative delay seconds\n");
11621
11622   Actor actor = Actor::New();
11623   Stage::GetCurrent().Add(actor);
11624
11625   // Build the animation
11626   float durationSeconds(1.0f);
11627   Animation animation = Animation::New(durationSeconds);
11628
11629   bool signalReceived( false );
11630   AnimationFinishCheck finishCheck( signalReceived );
11631   animation.FinishedSignal().Connect( &application, finishCheck );
11632   application.SendNotification();
11633
11634   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11635   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11636
11637   // When the delay time is negative value, it would treat as play immediately.
11638   animation.PlayAfter( -2.0f );
11639   application.SendNotification();
11640   application.Render(0); // start animation
11641
11642   application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11643
11644   // We didn't expect the animation to finish yet
11645   application.SendNotification();
11646   finishCheck.CheckSignalNotReceived();
11647   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11648
11649   application.SendNotification();
11650   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11651
11652   application.SendNotification();
11653   finishCheck.CheckSignalNotReceived();
11654   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.5f ), TEST_LOCATION );
11655
11656   application.SendNotification();
11657   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11658
11659   // We did expect the animation to finish
11660   application.SendNotification();
11661   finishCheck.CheckSignalReceived();
11662   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11663
11664   // Check that nothing has changed after a couple of buffer swaps
11665   application.Render(0);
11666   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11667   END_TEST;
11668 }
11669
11670 int UtcDaliAnimationPlayAfterP4(void)
11671 {
11672   TestApplication application;
11673
11674   tet_printf("Testing that PlayAfter with progress value\n");
11675
11676   Actor actor = Actor::New();
11677   Stage::GetCurrent().Add(actor);
11678
11679   // Build the animation
11680   float durationSeconds(1.0f);
11681   Animation animation = Animation::New(durationSeconds);
11682
11683   bool signalReceived( false );
11684   AnimationFinishCheck finishCheck( signalReceived );
11685   animation.FinishedSignal().Connect( &application, finishCheck );
11686   application.SendNotification();
11687
11688   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11689   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11690
11691   // Delay time is 0.3s. So after duration times, progress must be 70%. animation will finished at 1.3s.
11692   animation.PlayAfter( durationSeconds * 0.3f );
11693   application.SendNotification();
11694   application.Render(0); // start animation
11695
11696   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 5/6 delay progress, 0% animation progress, 0% animator progress */ );
11697
11698   // We didn't expect the animation to finish yet
11699   application.SendNotification();
11700   finishCheck.CheckSignalNotReceived();
11701   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of PlayAfter
11702
11703   application.SendNotification();
11704   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 20% animation progress, 0% animator progress */ );
11705
11706   application.SendNotification();
11707   finishCheck.CheckSignalNotReceived();
11708   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11709
11710   application.SendNotification();
11711   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 45% animation progress, 0% animator progress */ );
11712
11713   application.SendNotification();
11714   finishCheck.CheckSignalNotReceived();
11715   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11716
11717   application.SendNotification();
11718   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 70% animation progress, 40% animator progress */ );
11719
11720   application.SendNotification();
11721   finishCheck.CheckSignalNotReceived();
11722   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.4f ), TEST_LOCATION ); // 40% of animator progress
11723
11724   application.SendNotification();
11725   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 95% animation progress, 90% animator progress */ );
11726
11727   application.SendNotification();
11728   finishCheck.CheckSignalNotReceived();
11729   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION ); // 90% of animator progress
11730
11731   application.SendNotification();
11732   application.Render( static_cast< unsigned int >( durationSeconds * 50.0f ) + 1u/*just beyond the animation duration*/ );
11733
11734   // We did expect the animation to finish
11735   application.SendNotification();
11736   finishCheck.CheckSignalReceived();
11737   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11738
11739   // Check that nothing has changed after a couple of buffer swaps
11740   application.Render(0);
11741   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11742   END_TEST;
11743 }
11744
11745 int UtcDaliAnimationSetLoopingModeP(void)
11746 {
11747   // Test Loop forever and Loop mode being set
11748   TestApplication application;
11749   Stage stage( Stage::GetCurrent() );
11750
11751   // Default: LoopingMode::RESTART
11752   {
11753     Actor actor = Actor::New();
11754     stage.Add( actor );
11755
11756     float durationSeconds( 1.0f );
11757     Animation animation = Animation::New( durationSeconds );
11758     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
11759
11760     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
11761     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11762
11763     // Start the animation
11764     animation.Play();
11765     application.SendNotification();
11766     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
11767
11768     actor.Unparent();
11769
11770     application.SendNotification();
11771     application.Render();
11772     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11773   }
11774
11775   // LoopingMode::AUTO_REVERSE
11776   {
11777     Actor actor = Actor::New();
11778     stage.Add( actor );
11779
11780     float durationSeconds( 1.0f );
11781     Animation animation = Animation::New( durationSeconds );
11782     animation.SetLooping( true );
11783
11784     bool signalReceived( false );
11785     AnimationFinishCheck finishCheck( signalReceived );
11786     animation.FinishedSignal().Connect( &application, finishCheck );
11787     application.SendNotification();
11788
11789     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11790     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11791
11792     animation.SetLoopingMode( Animation::LoopingMode::AUTO_REVERSE );
11793     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11794
11795     // Start the animation
11796     animation.Play();
11797     application.SendNotification();
11798     application.Render(0);
11799
11800     for( int iterations = 0; iterations < 3; ++iterations )
11801     {
11802       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11803       application.SendNotification();
11804       finishCheck.CheckSignalNotReceived();
11805
11806       // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11807       // and arrives at the beginning.
11808       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11809
11810       application.SendNotification();
11811       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11812
11813       // We did expect the animation to finish
11814       application.SendNotification();
11815       finishCheck.CheckSignalNotReceived();
11816       DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11817     }
11818
11819     animation.SetLooping( false );
11820     application.SendNotification();
11821     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11822
11823     application.SendNotification();
11824     finishCheck.CheckSignalReceived();
11825
11826     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11827   }
11828
11829   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11830   {
11831     Actor actor = Actor::New();
11832     stage.Add( actor );
11833
11834     float durationSeconds( 1.0f );
11835     Animation animation = Animation::New( durationSeconds );
11836     animation.SetLooping( true );
11837
11838     bool signalReceived( false );
11839     AnimationFinishCheck finishCheck( signalReceived );
11840     animation.FinishedSignal().Connect( &application, finishCheck );
11841     application.SendNotification();
11842
11843     // Specify a negative multiplier to play the animation in reverse
11844     animation.SetSpeedFactor( -1.0f );
11845
11846     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11847     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11848
11849     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11850     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11851
11852     // Start the animation
11853     animation.Play();
11854     application.SendNotification();
11855     application.Render(0);
11856
11857     for( int iterations = 0; iterations < 3; ++iterations )
11858     {
11859       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11860       application.SendNotification();
11861       finishCheck.CheckSignalNotReceived();
11862
11863       // Setting a negative speed factor is to play the animation in reverse.
11864       // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11865       // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11866       DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11867
11868       application.SendNotification();
11869       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11870
11871       // We did expect the animation to finish
11872       application.SendNotification();
11873       finishCheck.CheckSignalNotReceived();
11874       DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11875     }
11876
11877     animation.SetLooping( false );
11878     application.SendNotification();
11879     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11880
11881     application.SendNotification();
11882     finishCheck.CheckSignalReceived();
11883
11884     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
11885   }
11886
11887   END_TEST;
11888 }
11889
11890 int UtcDaliAnimationSetLoopingModeP2(void)
11891 {
11892   // Test Loop Count and Loop mode being set
11893   TestApplication application;
11894   Stage stage( Stage::GetCurrent() );
11895
11896   // LoopingMode::AUTO_REVERSE
11897   {
11898     Actor actor = Actor::New();
11899     stage.Add( actor );
11900
11901     float durationSeconds( 1.0f );
11902     Animation animation = Animation::New( durationSeconds );
11903     animation.SetLoopCount(3);
11904     DALI_TEST_CHECK(animation.IsLooping());
11905
11906     bool signalReceived( false );
11907     AnimationFinishCheck finishCheck( signalReceived );
11908     animation.FinishedSignal().Connect( &application, finishCheck );
11909     application.SendNotification();
11910
11911     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11912     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11913
11914     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11915     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11916
11917     // Start the animation
11918     animation.Play();
11919
11920     application.Render(0);
11921     application.SendNotification();
11922     application.Render(0);
11923     application.SendNotification();
11924     application.Render(0);
11925     application.SendNotification();
11926     application.Render(0);
11927     application.SendNotification();
11928
11929     // Loop
11930     float intervalSeconds = 3.0f;
11931
11932     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11933     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11934     // and arrives at the beginning.
11935     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11936
11937     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11938
11939     application.Render(0);
11940     application.SendNotification();
11941     application.Render(0);
11942     application.SendNotification();
11943     application.Render(0);
11944     application.SendNotification();
11945     application.Render(0);
11946     application.SendNotification();
11947     finishCheck.CheckSignalNotReceived();
11948
11949     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11950
11951     application.SendNotification();
11952     finishCheck.CheckSignalReceived();
11953     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11954
11955     finishCheck.Reset();
11956   }
11957
11958   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11959   {
11960     Actor actor = Actor::New();
11961     stage.Add( actor );
11962
11963     float durationSeconds( 1.0f );
11964     Animation animation = Animation::New( durationSeconds );
11965     animation.SetLoopCount(3);
11966     DALI_TEST_CHECK(animation.IsLooping());
11967
11968     bool signalReceived( false );
11969     AnimationFinishCheck finishCheck( signalReceived );
11970     animation.FinishedSignal().Connect( &application, finishCheck );
11971     application.SendNotification();
11972
11973     // Specify a negative multiplier to play the animation in reverse
11974     animation.SetSpeedFactor( -1.0f );
11975
11976     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11977     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11978
11979     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11980     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11981
11982     // Start the animation
11983     animation.Play();
11984
11985     application.Render(0);
11986     application.SendNotification();
11987     application.Render(0);
11988     application.SendNotification();
11989     application.Render(0);
11990     application.SendNotification();
11991     application.Render(0);
11992     application.SendNotification();
11993
11994     // Loop
11995     float intervalSeconds = 3.0f;
11996
11997     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
11998     // Setting a negative speed factor is to play the animation in reverse.
11999     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12000     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12001     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12002
12003     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12004
12005     application.Render(0);
12006     application.SendNotification();
12007     application.Render(0);
12008     application.SendNotification();
12009     application.Render(0);
12010     application.SendNotification();
12011     application.Render(0);
12012     application.SendNotification();
12013     finishCheck.CheckSignalNotReceived();
12014
12015     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12016
12017     application.SendNotification();
12018     finishCheck.CheckSignalReceived();
12019     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12020
12021     finishCheck.Reset();
12022   }
12023
12024   END_TEST;
12025 }
12026
12027 int UtcDaliAnimationSetLoopingModeP3(void)
12028 {
12029   // Test Loop Count is 1 (== default) and Loop mode being set
12030   TestApplication application;
12031   Stage stage( Stage::GetCurrent() );
12032
12033   // LoopingMode::AUTO_REVERSE
12034   {
12035     Actor actor = Actor::New();
12036     stage.Add( actor );
12037
12038     float durationSeconds( 1.0f );
12039     Animation animation = Animation::New( durationSeconds );
12040     DALI_TEST_CHECK(1 == animation.GetLoopCount());
12041
12042     bool signalReceived( false );
12043     AnimationFinishCheck finishCheck( signalReceived );
12044     animation.FinishedSignal().Connect( &application, finishCheck );
12045     application.SendNotification();
12046
12047     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12048     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12049
12050     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12051     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12052
12053     // Start the animation
12054     animation.Play();
12055     application.Render(0);
12056     application.SendNotification();
12057
12058     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12059     application.SendNotification();
12060     finishCheck.CheckSignalNotReceived();
12061
12062     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
12063     // and arrives at the beginning.
12064     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12065
12066     application.SendNotification();
12067     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12068
12069     application.SendNotification();
12070     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12071
12072     application.SendNotification();
12073     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12074
12075     application.SendNotification();
12076     application.Render(0);
12077     application.SendNotification();
12078     finishCheck.CheckSignalReceived();
12079
12080     // After all animation finished, arrives at the beginning.
12081     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12082
12083     finishCheck.Reset();
12084   }
12085
12086   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
12087   {
12088     Actor actor = Actor::New();
12089     stage.Add( actor );
12090
12091     float durationSeconds( 1.0f );
12092     Animation animation = Animation::New( durationSeconds );
12093     DALI_TEST_CHECK(1 == animation.GetLoopCount());
12094
12095     bool signalReceived( false );
12096     AnimationFinishCheck finishCheck( signalReceived );
12097     animation.FinishedSignal().Connect( &application, finishCheck );
12098     application.SendNotification();
12099
12100     // Specify a negative multiplier to play the animation in reverse
12101     animation.SetSpeedFactor( -1.0f );
12102
12103     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12104     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12105
12106     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12107     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12108
12109     // Start the animation
12110     animation.Play();
12111     application.Render(0);
12112     application.SendNotification();
12113
12114     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12115     application.SendNotification();
12116     finishCheck.CheckSignalNotReceived();
12117
12118     // Setting a negative speed factor is to play the animation in reverse.
12119     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12120     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12121     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12122
12123     application.SendNotification();
12124     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12125
12126     application.SendNotification();
12127     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12128
12129     application.SendNotification();
12130     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12131
12132     application.SendNotification();
12133     application.Render(0);
12134     application.SendNotification();
12135     finishCheck.CheckSignalReceived();
12136
12137     // After all animation finished, arrives at the target.
12138     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12139
12140     finishCheck.Reset();
12141   }
12142
12143   END_TEST;
12144 }
12145
12146 int UtcDaliAnimationGetLoopingModeP(void)
12147 {
12148   TestApplication application;
12149
12150   Animation animation = Animation::New(1.0f);
12151
12152   // default mode
12153   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
12154
12155   animation.SetLoopingMode( Animation::AUTO_REVERSE );
12156   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12157
12158   END_TEST;
12159 }
12160
12161 int UtcDaliAnimationProgressSignalConnectionWithoutProgressMarkerP(void)
12162 {
12163   TestApplication application;
12164
12165   tet_infoline( "Connect to ProgressReachedSignal but do not set a required Progress marker" );
12166
12167   Actor actor = Actor::New();
12168   Stage::GetCurrent().Add(actor);
12169
12170   // Build the animation
12171   Animation animation = Animation::New(0.0f);
12172
12173   //Set duration
12174   float durationSeconds(1.0f);
12175   animation.SetDuration(durationSeconds);
12176
12177   bool finishedSignalReceived(false);
12178   bool progressSignalReceived(false);
12179
12180   AnimationFinishCheck finishCheck(finishedSignalReceived);
12181   animation.FinishedSignal().Connect(&application, finishCheck);
12182
12183   AnimationProgressCheck progressCheck( progressSignalReceived );
12184   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12185   application.SendNotification();
12186
12187   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12188   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12189
12190   progressCheck.CheckSignalNotReceived();
12191
12192   animation.Play();
12193
12194   application.SendNotification();
12195   application.Render(0); // start animation
12196   application.Render(durationSeconds*100.0f ); // 10% progress
12197   application.SendNotification();
12198
12199   tet_infoline( "Ensure after animation has started playing that ProgressReachedSignal not emitted" );
12200   progressCheck.CheckSignalNotReceived();
12201
12202   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
12203
12204   application.SendNotification();
12205   finishCheck.CheckSignalReceived();
12206   tet_infoline( "Animation finished" );
12207   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
12208
12209   END_TEST;
12210 }
12211
12212 int UtcDaliAnimationMultipleProgressSignalsP(void)
12213 {
12214   tet_infoline( "Multiple animations with different progress markers" );
12215
12216   TestApplication application;
12217
12218   Actor actor = Actor::New();
12219   Stage::GetCurrent().Add(actor);
12220
12221   // Build the animation
12222   Animation animationAlpha = Animation::New(0.0f);
12223   Animation animationBeta = Animation::New(0.0f);
12224
12225   //Set duration
12226   float durationSeconds(1.0f);
12227   animationAlpha.SetDuration(durationSeconds);
12228   animationBeta.SetDuration(durationSeconds);
12229
12230   bool progressSignalReceivedAlpha(false);
12231   bool progressSignalReceivedBeta(false);
12232
12233   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12234   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12235
12236   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12237   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12238   application.SendNotification();
12239
12240   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12241   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12242   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12243
12244   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12245   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12246
12247   tet_infoline( "AnimationBeta Progress notification set to 50%" );
12248   DevelAnimation::SetProgressNotification( animationBeta, 0.5f );
12249
12250   application.SendNotification();
12251   application.Render( );
12252
12253   progressCheckAlpha.CheckSignalNotReceived();
12254   progressCheckBeta.CheckSignalNotReceived();
12255
12256   // Start the animations from 10% progress
12257   animationAlpha.SetCurrentProgress( 0.1f );
12258   animationBeta.SetCurrentProgress( 0.1f );
12259   animationAlpha.Play();
12260   animationBeta.Play();
12261
12262   tet_infoline( "Animation Playing from 10%" );
12263
12264   application.SendNotification();
12265   application.Render(0); // start animation
12266   application.Render(durationSeconds*100.0f ); // 20% progress
12267
12268   tet_infoline( "Animation at 20% - No signals to be received" );
12269
12270   progressCheckAlpha.CheckSignalNotReceived();
12271   progressCheckBeta.CheckSignalNotReceived();
12272
12273   application.SendNotification();
12274   application.Render(durationSeconds*200.0f ); // 40% progress
12275   application.SendNotification();
12276   tet_infoline( "Animation at 40% - Alpha signal should be received" );
12277   DALI_TEST_EQUALS( 0.4f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12278
12279   progressCheckAlpha.CheckSignalReceived();
12280   progressCheckBeta.CheckSignalNotReceived();
12281
12282   tet_infoline( "Progress check reset" );
12283   progressCheckAlpha.Reset();
12284   progressCheckBeta.Reset();
12285
12286   application.Render(durationSeconds*100.0f ); // 50% progress
12287   tet_infoline( "Animation at 50% - Beta should receive signal, Alpha should not" );
12288   application.SendNotification();
12289
12290   DALI_TEST_EQUALS( 0.5f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12291
12292   progressCheckAlpha.CheckSignalNotReceived();
12293   progressCheckBeta.CheckSignalReceived();
12294   tet_infoline( "Progress check reset" );
12295   progressCheckAlpha.Reset();
12296   progressCheckBeta.Reset();
12297
12298   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
12299   application.SendNotification();
12300
12301   tet_infoline( "Animation at 60%" );
12302
12303   progressCheckAlpha.CheckSignalNotReceived();
12304   progressCheckBeta.CheckSignalNotReceived();
12305
12306   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12307   application.SendNotification();
12308   tet_infoline( "Animation at 80%" );
12309
12310   progressCheckAlpha.CheckSignalNotReceived();
12311   progressCheckBeta.CheckSignalNotReceived();
12312
12313   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12314   // We did expect the animation to finish
12315   tet_infoline( "Animation finished" );
12316
12317   END_TEST;
12318 }
12319
12320 int UtcDaliAnimationMultipleProgressSignalsP2(void)
12321 {
12322   tet_infoline( "Multiple animations with different progress markers and big step time" );
12323
12324   TestApplication application;
12325
12326   Actor actor = Actor::New();
12327   Stage::GetCurrent().Add(actor);
12328
12329   // Build the animation
12330   Animation animationAlpha = Animation::New(0.0f);
12331   Animation animationBeta = Animation::New(0.0f);
12332
12333   //Set duration
12334   const float durationSeconds(1.0f);
12335   animationAlpha.SetDuration(durationSeconds);
12336   animationBeta.SetDuration(durationSeconds);
12337
12338   bool progressSignalReceivedAlpha(false);
12339   bool progressSignalReceivedBeta(false);
12340
12341   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12342   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12343
12344   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12345   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12346   application.SendNotification();
12347
12348   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12349   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12350   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12351
12352   tet_infoline( "AnimationAlpha Progress notification set to 1%" );
12353   DevelAnimation::SetProgressNotification( animationAlpha, 0.01f );
12354
12355   tet_infoline( "AnimationBeta Progress notification set to 99%" );
12356   DevelAnimation::SetProgressNotification( animationBeta, 0.99f );
12357
12358   application.SendNotification();
12359   application.Render( );
12360
12361   progressCheckAlpha.CheckSignalNotReceived();
12362   progressCheckBeta.CheckSignalNotReceived();
12363
12364   // Start the animations unlimited looping
12365   animationAlpha.SetLooping( true );
12366   animationBeta.SetLooping( true );
12367   animationAlpha.Play();
12368   animationBeta.Play();
12369
12370   application.SendNotification();
12371   application.Render(0); // start animation
12372   application.Render(durationSeconds*20.0f ); // 2% progress
12373   application.SendNotification();
12374   DALI_TEST_EQUALS( 0.02f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12375
12376   tet_infoline( "Animation at 2% - Alpha signals should be received, Beta should not." );
12377
12378   progressCheckAlpha.CheckSignalReceived();
12379   progressCheckBeta.CheckSignalNotReceived();
12380
12381   tet_infoline( "Progress check reset" );
12382   progressCheckAlpha.Reset();
12383   progressCheckBeta.Reset();
12384
12385   application.SendNotification();
12386   application.Render(durationSeconds*960.0f ); // 98% progress
12387   application.SendNotification();
12388   tet_infoline( "Animation at 98% - No signal received" );
12389   DALI_TEST_EQUALS( 0.98f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12390
12391   progressCheckAlpha.CheckSignalNotReceived();
12392   progressCheckBeta.CheckSignalNotReceived();
12393
12394   application.SendNotification();
12395   application.Render(durationSeconds*40.0f ); // 2% progress
12396   application.SendNotification();
12397   tet_infoline( "Animation loop once and now 2% - Alpha and Beta should receive signal" );
12398   application.SendNotification();
12399
12400   DALI_TEST_EQUALS( 0.02f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12401
12402   progressCheckAlpha.CheckSignalReceived();
12403   progressCheckBeta.CheckSignalReceived();
12404
12405   tet_infoline( "Progress check reset" );
12406   progressCheckAlpha.Reset();
12407   progressCheckBeta.Reset();
12408
12409   application.SendNotification();
12410   application.Render(durationSeconds*980.0f ); // 100% progress
12411   application.SendNotification();
12412   tet_infoline( "Animation loop one more time. and now 100% - Beta should receive signal, Alhpa sholud not" );
12413   application.SendNotification();
12414
12415   progressCheckAlpha.CheckSignalNotReceived();
12416   progressCheckBeta.CheckSignalReceived();
12417
12418   tet_infoline( "Progress check reset" );
12419   progressCheckAlpha.Reset();
12420   progressCheckBeta.Reset();
12421
12422   animationAlpha.SetLooping( false );
12423   animationBeta.SetLooping( false );
12424
12425   application.SendNotification();
12426   application.Render(static_cast<unsigned int>(durationSeconds*2000.0f) + 1u/*just beyond the animation duration*/);
12427   application.SendNotification();
12428
12429   // We did expect the animation to finish
12430   tet_infoline( "Animation finished" );
12431
12432   END_TEST;
12433 }
12434
12435 int UtcDaliAnimationProgressSignalWithPlayAfterP(void)
12436 {
12437   tet_infoline( "Multiple animations with different progress markers" );
12438
12439   TestApplication application;
12440
12441   Actor actor = Actor::New();
12442   Stage::GetCurrent().Add(actor);
12443
12444   // Build the animation
12445   Animation animationAlpha = Animation::New(0.0f);
12446   Animation animationBeta = Animation::New(0.0f);
12447
12448   //Set duration
12449   float durationSeconds(1.0f);
12450   float delaySeconds(0.5f);
12451   animationAlpha.SetDuration(durationSeconds);
12452   animationBeta.SetDuration(durationSeconds);
12453
12454   bool progressSignalReceivedAlpha(false);
12455   bool progressSignalReceivedBeta(false);
12456
12457   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12458   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12459
12460   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12461   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12462   application.SendNotification();
12463
12464   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12465   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12466   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12467
12468   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12469   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12470
12471   tet_infoline( "AnimationBeta Progress notification set to ~0% (==Notify when delay is done)" );
12472   DevelAnimation::SetProgressNotification( animationBeta, Math::MACHINE_EPSILON_1 );
12473
12474   application.SendNotification();
12475   application.Render( );
12476
12477   progressCheckAlpha.CheckSignalNotReceived();
12478   progressCheckBeta.CheckSignalNotReceived();
12479
12480   // Start the animations from 10% progress
12481   animationAlpha.PlayAfter(delaySeconds);
12482   animationBeta.PlayAfter(delaySeconds);
12483
12484   application.SendNotification();
12485   application.Render(0); // start animation
12486   application.Render(delaySeconds * 500.0f ); // 50% wait progress
12487
12488   tet_infoline( "Delay at 50% - No signals to be received" );
12489
12490   progressCheckAlpha.CheckSignalNotReceived();
12491   progressCheckBeta.CheckSignalNotReceived();
12492
12493   application.SendNotification();
12494   application.Render(delaySeconds * 500.0f + durationSeconds * 50.0f ); // 100% wait, 5% progress
12495   application.SendNotification();
12496   tet_infoline( "Delay at 100%, Animation at 5% - Beta signal should be received" );
12497   DALI_TEST_EQUALS( 0.05f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12498
12499   progressCheckBeta.CheckSignalReceived();
12500   progressCheckAlpha.CheckSignalNotReceived();
12501
12502   tet_infoline( "Progress check reset" );
12503   progressCheckAlpha.Reset();
12504   progressCheckBeta.Reset();
12505
12506   application.Render(durationSeconds * 200.0f ); // 25% progress
12507   tet_infoline( "Animation at 25% - No signals to be received" );
12508   application.SendNotification();
12509
12510   progressCheckAlpha.CheckSignalNotReceived();
12511   progressCheckBeta.CheckSignalNotReceived();
12512
12513   application.Render(durationSeconds * 200.0f ); // 45% progress
12514   tet_infoline( "Animation at 45% - Alpha should receive signal, Beta should not" );
12515   application.SendNotification();
12516
12517   DALI_TEST_EQUALS( 0.45f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12518
12519   progressCheckAlpha.CheckSignalReceived();
12520   progressCheckBeta.CheckSignalNotReceived();
12521
12522   tet_infoline( "Progress check reset" );
12523   progressCheckAlpha.Reset();
12524   progressCheckBeta.Reset();
12525
12526   application.Render(static_cast<unsigned int>(durationSeconds*150.0f)/* 60% progress */);
12527   application.SendNotification();
12528
12529   tet_infoline( "Animation at 60%" );
12530
12531   progressCheckAlpha.CheckSignalNotReceived();
12532   progressCheckBeta.CheckSignalNotReceived();
12533
12534   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12535   application.SendNotification();
12536   tet_infoline( "Animation at 80%" );
12537
12538   progressCheckAlpha.CheckSignalNotReceived();
12539   progressCheckBeta.CheckSignalNotReceived();
12540
12541   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12542   // We did expect the animation to finish
12543   tet_infoline( "Animation finished" );
12544
12545   END_TEST;
12546 }
12547
12548 int UtcDaliAnimationProgressCallbackWithLoopingP(void)
12549 {
12550   TestApplication application;
12551
12552   Actor actor = Actor::New();
12553   Stage::GetCurrent().Add(actor);
12554
12555   // Build the animation
12556   Animation animation = Animation::New(0.0f);
12557
12558   //Set duration
12559   const float durationSeconds(1.0f);
12560   animation.SetDuration(durationSeconds);
12561
12562   // Set Looping Count
12563   const int loopCount( 4 );
12564   animation.SetLoopCount( loopCount );
12565
12566   bool finishedSignalReceived(false);
12567   bool progressSignalReceived(false);
12568
12569   AnimationFinishCheck finishCheck(finishedSignalReceived);
12570   animation.FinishedSignal().Connect(&application, finishCheck);
12571
12572   AnimationProgressCheck progressCheck(progressSignalReceived);
12573   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12574   application.SendNotification();
12575
12576   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12577   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12578
12579   tet_infoline( "Animation Progress notification set to 50% with looping count 4" );
12580   DevelAnimation::SetProgressNotification( animation, 0.5f );
12581
12582   application.SendNotification();
12583   application.Render( );
12584
12585   progressCheck.CheckSignalNotReceived();
12586
12587   animation.Play();
12588
12589   for(int count = 0; count < loopCount; count++)
12590   {
12591     application.SendNotification();
12592     application.Render(0); // start animation
12593     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12594     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12595
12596     tet_infoline( "Animation at 25%" );
12597
12598     progressCheck.CheckSignalNotReceived();
12599
12600     application.SendNotification();
12601     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12602     application.SendNotification();
12603     tet_infoline( "Animation at 50%" );
12604     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12605
12606     progressCheck.CheckSignalReceived();
12607
12608     tet_infoline( "Progress check reset" );
12609     progressCheck.Reset();
12610
12611     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12612     tet_infoline( "Animation at 75%" );
12613     application.SendNotification();
12614
12615     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12616
12617     progressCheck.CheckSignalNotReceived();
12618
12619     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12620     tet_infoline( "Animation at 100%" );
12621     application.SendNotification();
12622
12623     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12624     application.SendNotification();
12625   }
12626   application.Render(10u);
12627   application.SendNotification();
12628   application.Render(0u);
12629   application.SendNotification();
12630
12631   finishCheck.CheckSignalReceived();
12632
12633   END_TEST;
12634 }
12635
12636 int UtcDaliAnimationProgressCallbackWithLoopingP2(void)
12637 {
12638   TestApplication application;
12639
12640   Actor actor = Actor::New();
12641   Stage::GetCurrent().Add(actor);
12642
12643   // Build the animation
12644   Animation animation = Animation::New(0.0f);
12645
12646   //Set duration
12647   const float durationSeconds(1.0f);
12648   animation.SetDuration(durationSeconds);
12649
12650   // Set Looping Unlmited
12651   animation.SetLooping( true );
12652
12653   bool finishedSignalReceived(false);
12654   bool progressSignalReceived(false);
12655
12656   AnimationFinishCheck finishCheck(finishedSignalReceived);
12657   animation.FinishedSignal().Connect(&application, finishCheck);
12658
12659   AnimationProgressCheck progressCheck(progressSignalReceived);
12660   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12661   application.SendNotification();
12662
12663   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12664   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12665
12666   tet_infoline( "Animation Progress notification set to 50% with unlimited looping" );
12667   DevelAnimation::SetProgressNotification( animation, 0.5f );
12668
12669   application.SendNotification();
12670   application.Render( );
12671
12672   progressCheck.CheckSignalNotReceived();
12673
12674   animation.Play();
12675
12676   for(int count = 0; count < 4; count++)
12677   {
12678     application.SendNotification();
12679     application.Render(0); // start animation
12680     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12681     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12682
12683     tet_infoline( "Animation at 25%" );
12684
12685     progressCheck.CheckSignalNotReceived();
12686
12687     application.SendNotification();
12688     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12689     application.SendNotification();
12690     tet_infoline( "Animation at 50%" );
12691     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12692
12693     progressCheck.CheckSignalReceived();
12694
12695     tet_infoline( "Progress check reset" );
12696     progressCheck.Reset();
12697
12698     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12699     tet_infoline( "Animation at 75%" );
12700     application.SendNotification();
12701
12702     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12703
12704     progressCheck.CheckSignalNotReceived();
12705
12706     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12707     tet_infoline( "Animation at 100%" );
12708     application.SendNotification();
12709
12710     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12711     finishCheck.CheckSignalNotReceived();
12712     application.SendNotification();
12713   }
12714   finishCheck.CheckSignalNotReceived();
12715
12716   animation.SetLooping( false );
12717   application.Render(0u);
12718   application.SendNotification();
12719   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 10u);
12720   application.SendNotification();
12721   application.Render(0u);
12722   application.SendNotification();
12723
12724   finishCheck.CheckSignalReceived();
12725
12726   END_TEST;
12727 }
12728
12729 int UtcDaliAnimationProgressCallbackNegativeSpeed(void)
12730 {
12731   TestApplication application;
12732
12733   Actor actor = Actor::New();
12734   Stage::GetCurrent().Add(actor);
12735
12736   // Build the animation
12737   Animation animation = Animation::New(0.0f);
12738
12739   //Set duration
12740   const float durationSeconds(1.0f);
12741   animation.SetDuration(durationSeconds);
12742
12743   //Set speed negative
12744   animation.SetSpeedFactor( -1.0f );
12745
12746   // Set Looping Unlmited
12747   animation.SetLooping( true );
12748
12749   bool finishedSignalReceived(false);
12750   bool progressSignalReceived(false);
12751
12752   AnimationFinishCheck finishCheck(finishedSignalReceived);
12753   animation.FinishedSignal().Connect(&application, finishCheck);
12754
12755   AnimationProgressCheck progressCheck(progressSignalReceived);
12756   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12757   application.SendNotification();
12758
12759   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12760   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12761
12762   tet_infoline( "Animation Progress notification set to 50%" );
12763   DevelAnimation::SetProgressNotification( animation, 0.5f );
12764
12765   application.SendNotification();
12766   application.Render( );
12767
12768   progressCheck.CheckSignalNotReceived();
12769
12770   animation.Play();
12771
12772   for(int count = 0; count < 4; count++)
12773   {
12774     application.SendNotification();
12775     application.Render(0); // start animation
12776     progressCheck.CheckSignalNotReceived();
12777
12778     application.SendNotification();
12779     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12780     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12781
12782     tet_infoline( "Animation at 25%" );
12783
12784     progressCheck.CheckSignalNotReceived();
12785
12786     application.SendNotification();
12787     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12788     application.SendNotification();
12789     tet_infoline( "Animation at 50%" );
12790     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12791
12792     progressCheck.CheckSignalReceived();
12793
12794     tet_infoline( "Progress check reset" );
12795     progressCheck.Reset();
12796
12797     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12798     tet_infoline( "Animation at 75%" );
12799     application.SendNotification();
12800
12801     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12802
12803     progressCheck.CheckSignalNotReceived();
12804
12805     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12806     tet_infoline( "Animation at 100%" );
12807     application.SendNotification();
12808
12809     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12810     finishCheck.CheckSignalNotReceived();
12811     application.SendNotification();
12812   }
12813   finishCheck.CheckSignalNotReceived();
12814
12815   animation.Stop();
12816   animation.SetLooping( false );
12817   animation.SetLoopCount( 4 );
12818   animation.Play();
12819   application.Render(0u);
12820   application.SendNotification();
12821
12822   for(int count = 0; count < 4; count++)
12823   {
12824     application.SendNotification();
12825     application.Render(0); // start animation
12826     progressCheck.CheckSignalNotReceived();
12827
12828     application.SendNotification();
12829     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12830     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12831
12832     tet_infoline( "Animation at 25%" );
12833
12834     progressCheck.CheckSignalNotReceived();
12835
12836     application.SendNotification();
12837     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12838     application.SendNotification();
12839     tet_infoline( "Animation at 50%" );
12840     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12841
12842     progressCheck.CheckSignalReceived();
12843
12844     tet_infoline( "Progress check reset" );
12845     progressCheck.Reset();
12846
12847     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12848     tet_infoline( "Animation at 75%" );
12849     application.SendNotification();
12850
12851     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12852
12853     progressCheck.CheckSignalNotReceived();
12854
12855     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12856     tet_infoline( "Animation at 100%" );
12857     application.SendNotification();
12858
12859     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12860     application.SendNotification();
12861   }
12862   application.Render(10u);
12863   application.SendNotification();
12864   application.Render(0u);
12865   application.SendNotification();
12866
12867   finishCheck.CheckSignalReceived();
12868
12869   END_TEST;
12870 }
12871
12872 int UtcDaliAnimationProgressCallbackInvalidSignalN(void)
12873 {
12874   TestApplication application;
12875
12876   Actor actor = Actor::New();
12877   Stage::GetCurrent().Add(actor);
12878
12879   // Build the animation
12880   Animation animation = Animation::New(0.0f);
12881
12882   //Set duration
12883   const float durationSeconds(1.0f);
12884   animation.SetDuration(durationSeconds);
12885
12886   bool finishedSignalReceived(false);
12887   bool progressSignalReceived(false);
12888
12889   AnimationFinishCheck finishCheck(finishedSignalReceived);
12890   animation.FinishedSignal().Connect(&application, finishCheck);
12891
12892   AnimationProgressCheck progressCheck(progressSignalReceived);
12893   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12894   application.SendNotification();
12895
12896   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12897   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12898
12899   tet_infoline( "Animation Progress PlayRange as 10% ~ 90%" );
12900   animation.SetPlayRange( Vector2( 0.1f, 0.9f ) );
12901
12902   tet_infoline( "Animation Progress notification set to >90% that never can notificated" );
12903   DevelAnimation::SetProgressNotification( animation, 0.9f + Math::MACHINE_EPSILON_1 );
12904
12905   application.SendNotification();
12906   application.Render( );
12907
12908   progressCheck.CheckSignalNotReceived();
12909
12910   animation.Play();
12911
12912   application.SendNotification();
12913   application.Render(0); // start animation
12914   application.Render(durationSeconds*0.25*1000.0f ); // 35% progress
12915   DALI_TEST_EQUALS( 0.35f, animation.GetCurrentProgress(), TEST_LOCATION );
12916
12917   tet_infoline( "Animation at 35%" );
12918
12919   progressCheck.CheckSignalNotReceived();
12920
12921   application.SendNotification();
12922   application.Render(durationSeconds*0.25*1000.0f ); // 60% progress
12923   application.SendNotification();
12924   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
12925
12926   tet_infoline( "Animation at 60%" );
12927
12928   progressCheck.CheckSignalNotReceived();
12929
12930   application.Render(durationSeconds*0.25*1000.0f ); // 85% progress
12931   tet_infoline( "Animation at 85%" );
12932   application.SendNotification();
12933   DALI_TEST_EQUALS( 0.85f, animation.GetCurrentProgress(), TEST_LOCATION );
12934
12935   progressCheck.CheckSignalNotReceived();
12936
12937   application.Render(durationSeconds*0.25*1000.0f ); // 90% progress
12938   tet_infoline( "Animation over 90%" );
12939   application.SendNotification();
12940
12941   // progress never signaled because playrange is 90%
12942   progressCheck.CheckSignalNotReceived();
12943
12944   END_TEST;
12945 }
12946
12947 int UtcDaliAnimationProgressCallbackLongDurationP(void)
12948 {
12949   TestApplication application;
12950
12951   Actor actor = Actor::New();
12952   Stage::GetCurrent().Add(actor);
12953
12954   // Build the animation
12955   Animation animation = Animation::New(0.0f);
12956
12957   //Set duration
12958   float durationSeconds(5.0f);
12959   animation.SetDuration(durationSeconds);
12960
12961   bool finishedSignalReceived(false);
12962   bool progressSignalReceived(false);
12963
12964   AnimationFinishCheck finishCheck(finishedSignalReceived);
12965   animation.FinishedSignal().Connect(&application, finishCheck);
12966
12967   AnimationProgressCheck progressCheck(progressSignalReceived);
12968   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12969   application.SendNotification();
12970
12971   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12972   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12973
12974   tet_infoline( "Animation Progress notification set to 50%" );
12975   DevelAnimation::SetProgressNotification( animation, 0.5f );
12976
12977   application.SendNotification();
12978   application.Render( );
12979
12980   progressCheck.CheckSignalNotReceived();
12981
12982   animation.Play();
12983
12984   application.SendNotification();
12985   application.Render(0); // start animation
12986   application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12987   DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12988
12989   tet_infoline( "Animation at 25%" );
12990
12991   progressCheck.CheckSignalNotReceived();
12992
12993   application.SendNotification();
12994   application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12995   application.SendNotification();
12996   tet_infoline( "Animation at 50%" );
12997   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12998
12999   progressCheck.CheckSignalReceived();
13000
13001   tet_infoline( "Progress check reset" );
13002   progressCheck.Reset();
13003
13004   application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
13005   tet_infoline( "Animation at 75%" );
13006   application.SendNotification();
13007
13008   DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
13009
13010   progressCheck.CheckSignalNotReceived();
13011
13012   END_TEST;
13013 }