e4c695e2758a2e8eb625663d3a79829926a04ac7
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2019 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 static const float VECTOR3_EPSILON = 0.0001f;
46
47 // Functor to test whether a Finish signal is emitted
48 struct AnimationFinishCheck
49 {
50   AnimationFinishCheck(bool& signalReceived)
51   : mSignalReceived(signalReceived)
52   {
53   }
54
55   void operator()(Animation& animation)
56   {
57     mSignalReceived = true;
58   }
59
60   void Reset()
61   {
62     mSignalReceived = false;
63   }
64
65   void CheckSignalReceived()
66   {
67     if (!mSignalReceived)
68     {
69       tet_printf("Expected Finish signal was not received\n");
70       tet_result(TET_FAIL);
71     }
72     else
73     {
74       tet_result(TET_PASS);
75     }
76   }
77
78   void CheckSignalNotReceived()
79   {
80     if (mSignalReceived)
81     {
82       tet_printf("Unexpected Finish signal was received\n");
83       tet_result(TET_FAIL);
84     }
85     else
86     {
87       tet_result(TET_PASS);
88     }
89   }
90
91   bool& mSignalReceived; // owned by individual tests
92 };
93
94 // Functor to test whether a Progress signal is emitted
95 struct AnimationProgressCheck
96 {
97   AnimationProgressCheck(bool& signalReceived, std::string name = " ")
98   : mSignalReceived(signalReceived),
99     mName( name )
100   {
101   }
102
103   void operator()(Animation& animation)
104   {
105     mSignalReceived = true;
106   }
107
108   void Reset()
109   {
110     mSignalReceived = false;
111   }
112
113   void CheckSignalReceived()
114   {
115     if (!mSignalReceived)
116     {
117       tet_printf("Expected Progress reached signal was not received %s \n", mName.c_str() );
118       tet_result(TET_FAIL);
119     }
120     else
121     {
122       tet_result(TET_PASS);
123     }
124   }
125
126   void CheckSignalNotReceived()
127   {
128     if (mSignalReceived)
129     {
130       tet_printf("Unexpected Progress reached signal was received %s \n", mName.c_str());
131       tet_result(TET_FAIL);
132     }
133     else
134     {
135       tet_result(TET_PASS);
136     }
137   }
138
139   bool& mSignalReceived; // owned by individual tests
140   std::string mName;
141 };
142
143 } // anon namespace
144
145 int UtcDaliAnimationConstructorP(void)
146 {
147   TestApplication application;
148
149   Animation animation;
150
151   DALI_TEST_CHECK( !animation );
152   END_TEST;
153 }
154
155 int UtcDaliAnimationNewP(void)
156 {
157   TestApplication application;
158
159   Animation animation = Animation::New( 1.0f );
160
161   DALI_TEST_CHECK(animation);
162   END_TEST;
163 }
164
165 int UtcDaliAnimationNewN(void)
166 {
167   TestApplication application;
168
169   Animation animation = Animation::New( -1.0f );
170
171   DALI_TEST_CHECK(animation);
172   DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
173   END_TEST;
174 }
175
176 int UtcDaliAnimationDownCastP(void)
177 {
178   TestApplication application;
179
180   tet_infoline("Testing Dali::Animation::DownCast()");
181
182   float durationSeconds(1.0f);
183   Animation animation = Animation::New(durationSeconds);
184
185   BaseHandle object(animation);
186
187   Animation animation2 = Animation::DownCast(object);
188   DALI_TEST_CHECK(animation2);
189
190   Animation animation3 = DownCast< Animation >(object);
191   DALI_TEST_CHECK(animation3);
192   END_TEST;
193 }
194
195 int UtcDaliAnimationDownCastN(void)
196 {
197   TestApplication application;
198
199   BaseHandle unInitializedObject;
200
201   Animation animation1 = Animation::DownCast( unInitializedObject );
202   DALI_TEST_CHECK( !animation1 );
203
204   Animation animation2 = DownCast< Animation >( unInitializedObject );
205   DALI_TEST_CHECK( !animation2 );
206   END_TEST;
207 }
208
209 int UtcDaliAnimationCopyConstructorP(void)
210 {
211   TestApplication application;
212
213   // Initialize an object, ref count == 1
214   Animation animation = Animation::New( 1.0f );
215
216   Animation copy( animation );
217   DALI_TEST_CHECK( copy );
218
219   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
220   END_TEST;
221 }
222
223 int UtcDaliAnimationAssignmentOperatorP(void)
224 {
225   TestApplication application;
226
227   Animation animation = Animation::New( 1.0f );
228
229   Animation copy = animation;
230   DALI_TEST_CHECK( copy );
231
232   DALI_TEST_CHECK( animation == copy );
233
234   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
235   END_TEST;
236 }
237
238 int UtcDaliAnimationSetDurationP(void)
239 {
240   TestApplication application;
241
242   Actor actor = Actor::New();
243   Stage::GetCurrent().Add(actor);
244
245   // Build the animation
246   float durationSeconds(1.0f);
247   Animation animation = Animation::New(durationSeconds);
248   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
249
250   // Start the animation
251   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
252   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
253   animation.Play();
254
255   bool signalReceived(false);
256   AnimationFinishCheck finishCheck(signalReceived);
257   animation.FinishedSignal().Connect(&application, finishCheck);
258
259   application.SendNotification();
260   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
261
262   // We didn't expect the animation to finish yet
263   application.SendNotification();
264   finishCheck.CheckSignalNotReceived();
265
266   application.Render(2u/*just beyond the animation duration*/);
267
268   // We did expect the animation to finish
269   application.SendNotification();
270   finishCheck.CheckSignalReceived();
271   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
272
273   // Restart the animation, with a different duration
274   finishCheck.Reset();
275   actor.SetPosition(Vector3::ZERO);
276   durationSeconds = 3.5f;
277   animation.SetDuration(durationSeconds);
278   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
279   animation.Play();
280
281   application.SendNotification();
282   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
283
284   // We didn't expect the animation to finish yet
285   application.SendNotification();
286   finishCheck.CheckSignalNotReceived();
287
288   application.Render(2u/*just beyond the animation duration*/);
289
290   // We did expect the animation to finish
291   application.SendNotification();
292   finishCheck.CheckSignalReceived();
293   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
294
295   // Check that nothing has changed after a couple of buffer swaps
296   application.Render(0);
297   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
298   application.Render(0);
299   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
300   END_TEST;
301 }
302
303 int UtcDaliAnimationSetDurationN(void)
304 {
305   TestApplication application;
306
307   Animation animation = Animation::New( 1.0f );
308   DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
309
310   animation.SetDuration( -1.0f );
311   DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
312   END_TEST;
313 }
314
315 int UtcDaliAnimationGetDurationP(void)
316 {
317   TestApplication application;
318
319   Animation animation = Animation::New(1.0f);
320   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
321
322   animation.SetDuration(2.0f);
323   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
324   END_TEST;
325 }
326
327 int UtcDaliAnimationSetLoopingP(void)
328 {
329   TestApplication application;
330
331   Actor actor = Actor::New();
332   Stage::GetCurrent().Add(actor);
333
334   // Build the animation
335   float durationSeconds(1.0f);
336   Animation animation = Animation::New(durationSeconds);
337   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
338   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
339
340   // Start the animation
341   animation.SetLooping(true);
342   DALI_TEST_CHECK(animation.IsLooping());
343   animation.Play();
344
345   bool signalReceived(false);
346   AnimationFinishCheck finishCheck(signalReceived);
347   animation.FinishedSignal().Connect(&application, finishCheck);
348
349   application.SendNotification();
350
351   // Loop 5 times
352   float intervalSeconds = 0.25f;
353   float progress = 0.0f;
354   for (int iterations = 0; iterations < 5;)
355   {
356     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
357
358     progress += intervalSeconds;
359     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001f, TEST_LOCATION );
360
361     if (progress >= 1.0f)
362     {
363       progress = progress - 1.0f;
364       ++iterations;
365     }
366   }
367
368   // We didn't expect the animation to finish yet
369   application.SendNotification();
370   finishCheck.CheckSignalNotReceived();
371
372   animation.SetLooping(false);
373   DALI_TEST_CHECK(!animation.IsLooping());
374
375   application.SendNotification();
376   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
377
378   // We did expect the animation to finish
379   application.SendNotification();
380   finishCheck.CheckSignalReceived();
381   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
382
383   // Check that nothing has changed after a couple of buffer swaps
384   application.Render(0);
385   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
386   application.Render(0);
387   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
388   END_TEST;
389 }
390
391 int UtcDaliAnimationSetLoopCountP(void)
392 {
393   TestApplication application;
394
395   Actor actor = Actor::New();
396   Stage::GetCurrent().Add(actor);
397
398   // Build the animation
399   float durationSeconds(1.0f);
400   Animation animation = Animation::New(durationSeconds);
401   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
402   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
403
404   // Start the animation
405   animation.SetLoopCount(3);
406   DALI_TEST_CHECK(animation.IsLooping());
407   animation.Play();
408
409   bool signalReceived(false);
410   AnimationFinishCheck finishCheck(signalReceived);
411   animation.FinishedSignal().Connect(&application, finishCheck);
412
413   application.Render(0);
414   application.SendNotification();
415   application.Render(0);
416   application.SendNotification();
417   application.Render(0);
418   application.SendNotification();
419   application.Render(0);
420   application.SendNotification();
421
422   // Loop
423   float intervalSeconds = 3.0f;
424
425   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
426   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
427
428   application.Render(0);
429   application.SendNotification();
430   application.Render(0);
431   application.SendNotification();
432   application.Render(0);
433   application.SendNotification();
434   application.Render(0);
435   application.SendNotification();
436   finishCheck.CheckSignalNotReceived();
437
438   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
439
440   application.SendNotification();
441   finishCheck.CheckSignalReceived();
442   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
443
444   finishCheck.Reset();
445
446   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
447   application.SendNotification();
448   finishCheck.CheckSignalNotReceived();
449
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.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
454   application.SendNotification();
455   finishCheck.CheckSignalNotReceived();
456
457   END_TEST;
458 }
459
460 int UtcDaliAnimationSetLoopCountP2(void)
461 {
462   TestApplication application;
463
464   //
465   // switching between forever and loop count
466   //
467
468   Actor actor = Actor::New();
469   Stage::GetCurrent().Add(actor);
470
471   // Build the animation
472   float durationSeconds(1.0f);
473   Animation animation = Animation::New(durationSeconds);
474   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
475   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
476   animation.SetEndAction(Animation::Discard);
477
478   // Start the animation
479   animation.SetLoopCount(3);
480   DALI_TEST_CHECK(animation.IsLooping());
481   animation.Play();
482
483   bool signalReceived(false);
484   AnimationFinishCheck finishCheck(signalReceived);
485   animation.FinishedSignal().Connect(&application, finishCheck);
486
487   float intervalSeconds = 3.0f;
488
489   application.SendNotification();
490   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
491   application.SendNotification();
492   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
493   application.SendNotification();
494   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
495   application.SendNotification();
496
497   application.SendNotification();
498   finishCheck.CheckSignalReceived();
499
500   finishCheck.Reset();
501
502   // Loop forever
503   animation.SetLooping(true);
504   DALI_TEST_CHECK(animation.IsLooping());
505
506   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
507   application.SendNotification();
508   finishCheck.CheckSignalNotReceived();
509
510   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
511   application.SendNotification();
512   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
513   application.SendNotification();
514   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
515   application.SendNotification();
516   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
517   application.SendNotification();
518   application.SendNotification();
519   finishCheck.CheckSignalNotReceived();
520
521   finishCheck.Reset();
522
523   // Loop N again
524   animation.SetLoopCount(3);
525   DALI_TEST_CHECK(animation.IsLooping());
526   animation.Play();
527
528   application.SendNotification();
529   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
530   application.SendNotification();
531   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
532   application.SendNotification();
533   finishCheck.CheckSignalNotReceived();
534
535   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
536   application.SendNotification();
537   finishCheck.CheckSignalReceived();
538
539   finishCheck.Reset();
540
541   // loop forever
542   animation.SetLooping(true);
543   DALI_TEST_CHECK(animation.IsLooping());
544
545   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
546   application.SendNotification();
547   finishCheck.CheckSignalNotReceived();
548
549   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
550   application.SendNotification();
551   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
552   application.SendNotification();
553   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
554   application.SendNotification();
555   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
556   application.SendNotification();
557   finishCheck.CheckSignalNotReceived();
558
559   finishCheck.Reset();
560
561   // Loop N again
562   animation.SetLoopCount(3);
563   DALI_TEST_CHECK(animation.IsLooping());
564
565   application.SendNotification();
566   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
567   application.SendNotification();
568   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
569   application.SendNotification();
570   finishCheck.CheckSignalNotReceived();
571
572   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
573   application.SendNotification();
574   finishCheck.CheckSignalNotReceived(); // we never hit play
575
576   finishCheck.Reset();
577
578
579   END_TEST;
580 }
581
582 int UtcDaliAnimationSetLoopCountP3(void)
583 {
584   TestApplication application;
585
586   //
587   // switching between forever and loop count
588   //
589   Actor actor = Actor::New();
590   Stage::GetCurrent().Add(actor);
591
592   // Build the animation
593   float durationSeconds(1.0f);
594   Animation animation = Animation::New(durationSeconds);
595   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
596   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
597   animation.SetEndAction(Animation::Discard);
598
599   float intervalSeconds = 3.0f;
600
601   bool signalReceived(false);
602   AnimationFinishCheck finishCheck(signalReceived);
603   animation.FinishedSignal().Connect(&application, finishCheck);
604
605   // loop forever
606   animation.SetLooping(true);
607   DALI_TEST_CHECK(animation.IsLooping());
608
609   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
610   application.SendNotification();
611   finishCheck.CheckSignalNotReceived();
612
613   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
614   application.SendNotification();
615   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
616   application.SendNotification();
617   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
618   application.SendNotification();
619   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
620   application.SendNotification();
621   finishCheck.CheckSignalNotReceived();
622
623   finishCheck.Reset();
624
625   // Loop N again
626   animation.SetLoopCount(3);
627   DALI_TEST_CHECK(animation.IsLooping());
628
629   application.SendNotification();
630   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
631   application.SendNotification();
632   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
633   application.SendNotification();
634   finishCheck.CheckSignalNotReceived();
635
636   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
637   application.SendNotification();
638   finishCheck.CheckSignalNotReceived(); // we never hit play
639
640   finishCheck.Reset();
641
642
643   END_TEST;
644 }
645
646 int UtcDaliAnimationSetLoopCountP4(void)
647 {
648   TestApplication application;
649
650   //
651   // ..and play again
652   //
653   Actor actor = Actor::New();
654   Stage::GetCurrent().Add(actor);
655
656   // Build the animation
657   float durationSeconds(1.0f);
658   Animation animation = Animation::New(durationSeconds);
659   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
660   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
661   animation.SetEndAction(Animation::Bake);
662
663   float intervalSeconds = 3.0f;
664
665   bool signalReceived(false);
666   AnimationFinishCheck finishCheck(signalReceived);
667   animation.FinishedSignal().Connect(&application, finishCheck);
668
669   animation.SetLoopCount(1);
670   animation.Play();
671   DALI_TEST_CHECK(!animation.IsLooping());
672
673   application.SendNotification();
674   finishCheck.CheckSignalNotReceived();
675   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
676   application.SendNotification();
677   finishCheck.CheckSignalReceived();
678
679   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
680   actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
681
682   finishCheck.Reset();
683
684   animation.Play(); // again
685   DALI_TEST_CHECK(!animation.IsLooping());
686
687   application.SendNotification();
688   finishCheck.CheckSignalNotReceived();
689   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
690   application.SendNotification();
691   finishCheck.CheckSignalReceived();
692
693   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
694
695   END_TEST;
696 }
697
698 int UtcDaliAnimationGetLoopCountP(void)
699 {
700   TestApplication application;
701
702   Actor actor = Actor::New();
703   Stage::GetCurrent().Add(actor);
704
705   // Build the animation
706   float durationSeconds(1.0f);
707   Animation animation = Animation::New(durationSeconds);
708   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
709   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
710
711   DALI_TEST_CHECK(1 == animation.GetLoopCount());
712
713   // Start the animation
714   animation.SetLoopCount(3);
715   DALI_TEST_CHECK(animation.IsLooping());
716   DALI_TEST_CHECK(3 == animation.GetLoopCount());
717
718   animation.Play();
719
720   application.Render(0);
721   application.SendNotification();
722
723   // Loop
724   float intervalSeconds = 3.0f;
725
726   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
727   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
728
729   application.Render(0);
730   application.SendNotification();
731
732   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
733   application.SendNotification();
734
735   animation.SetLoopCount(0);
736   DALI_TEST_CHECK(animation.IsLooping());
737   DALI_TEST_CHECK(0 == animation.GetLoopCount());
738
739   animation.SetLoopCount(1);
740   DALI_TEST_CHECK(!animation.IsLooping());
741   DALI_TEST_CHECK(1 == animation.GetLoopCount());
742
743   END_TEST;
744 }
745
746
747 int UtcDaliAnimationGetCurrentLoopP(void)
748 {
749   TestApplication application;
750
751   Actor actor = Actor::New();
752   Stage::GetCurrent().Add(actor);
753
754   // Build the animation
755   float durationSeconds(1.0f);
756   Animation animation = Animation::New(durationSeconds);
757   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
758   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
759
760   // Start the animation
761   animation.SetLoopCount(3);
762   DALI_TEST_CHECK(animation.IsLooping());
763   DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
764   animation.Play();
765
766   bool signalReceived(false);
767   AnimationFinishCheck finishCheck(signalReceived);
768   animation.FinishedSignal().Connect(&application, finishCheck);
769
770   application.SendNotification();
771
772   // Loop
773   float intervalSeconds = 3.0f;
774
775   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
776   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
777
778   application.SendNotification();
779   finishCheck.CheckSignalNotReceived();
780   DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
781
782   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
783
784   application.SendNotification();
785   finishCheck.CheckSignalReceived();
786   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
787   DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
788
789   finishCheck.Reset();
790
791   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
792   application.SendNotification();
793   finishCheck.CheckSignalNotReceived();
794   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
795
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.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
800   application.SendNotification();
801   finishCheck.CheckSignalNotReceived();
802   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
803
804   END_TEST;
805 }
806
807 int UtcDaliAnimationIsLoopingP(void)
808 {
809   TestApplication application;
810
811   Animation animation = Animation::New(1.0f);
812   DALI_TEST_CHECK(!animation.IsLooping());
813
814   animation.SetLooping(true);
815   DALI_TEST_CHECK(animation.IsLooping());
816   END_TEST;
817 }
818
819 int UtcDaliAnimationSetEndActionN(void)
820 {
821   TestApplication application;
822
823   Actor actor = Actor::New();
824   Stage::GetCurrent().Add(actor);
825
826   // Build the animation
827   float durationSeconds(1.0f);
828   Animation animation = Animation::New(durationSeconds);
829   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
830
831   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
832   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
833
834   // Start the animation
835   animation.Play();
836
837   bool signalReceived(false);
838   AnimationFinishCheck finishCheck(signalReceived);
839   animation.FinishedSignal().Connect(&application, finishCheck);
840
841   application.SendNotification();
842   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
843
844   // We did expect the animation to finish
845   application.SendNotification();
846   finishCheck.CheckSignalReceived();
847   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
848
849   // Go back to the start
850   actor.SetPosition(Vector3::ZERO);
851   application.SendNotification();
852   application.Render(0);
853   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
854
855   // Test BakeFinal, animate again, for half the duration
856   finishCheck.Reset();
857   animation.SetEndAction(Animation::BakeFinal);
858   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
859   animation.Play();
860
861   application.SendNotification();
862   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
863
864   // Stop the animation early
865   animation.Stop();
866
867   // We did NOT expect the animation to finish
868   application.SendNotification();
869   finishCheck.CheckSignalNotReceived();
870   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), VECTOR4_EPSILON, TEST_LOCATION );
871
872   // The position should be same with target position in the next frame
873   application.Render(0);
874   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
875
876   // Go back to the start
877   actor.SetPosition(Vector3::ZERO);
878   application.SendNotification();
879   application.Render(0);
880   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
881
882   // Test EndAction::Discard, animate again, but don't bake this time
883   finishCheck.Reset();
884   animation.SetEndAction(Animation::Discard);
885   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
886   animation.Play();
887
888   application.SendNotification();
889   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
890
891   // We did expect the animation to finish
892   application.SendNotification();
893   finishCheck.CheckSignalReceived();
894   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
895
896   // The position should be discarded in the next frame
897   application.Render(0);
898   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
899
900   // Check that nothing has changed after a couple of buffer swaps
901   application.Render(0);
902   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
903   application.Render(0);
904   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
905   END_TEST;
906 }
907
908 int UtcDaliAnimationGetEndActionP(void)
909 {
910   TestApplication application;
911
912   Animation animation = Animation::New(1.0f);
913   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
914
915   animation.SetEndAction(Animation::Discard);
916   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
917
918   animation.SetEndAction(Animation::BakeFinal);
919   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
920
921   END_TEST;
922 }
923
924 int UtcDaliAnimationSetDisconnectActionP(void)
925 {
926   TestApplication application;
927   Stage stage( Stage::GetCurrent() );
928
929   // Default: BakeFinal
930   {
931     Actor actor = Actor::New();
932     stage.Add(actor);
933
934     // Build the animation
935     float durationSeconds(1.0f);
936     Animation animation = Animation::New(durationSeconds);
937     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
938
939     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
940     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
941
942     // Start the animation
943     animation.Play();
944
945     application.SendNotification();
946     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
947
948     actor.Unparent();
949
950     application.SendNotification();
951     application.Render();
952
953     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
954   }
955
956   // Bake
957   {
958     Actor actor = Actor::New();
959     stage.Add(actor);
960
961     // Build the animation
962     float durationSeconds(1.0f);
963     Animation animation = Animation::New(durationSeconds);
964     animation.SetDisconnectAction( Animation::Bake );
965
966     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
967     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
968
969     // Start the animation
970     animation.Play();
971
972     application.SendNotification();
973     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
974
975     actor.Unparent();
976
977     application.SendNotification();
978     application.Render();
979
980     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition*0.5f, TEST_LOCATION );
981   }
982
983   // Discard
984   {
985     Actor actor = Actor::New();
986     stage.Add(actor);
987
988     // Build the animation
989     float durationSeconds(1.0f);
990     Animation animation = Animation::New(durationSeconds);
991     animation.SetDisconnectAction( Animation::Discard );
992
993     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
994     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
995
996     // Start the animation
997     animation.Play();
998
999     application.SendNotification();
1000     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1001
1002     actor.Unparent();
1003
1004     application.SendNotification();
1005     application.Render();
1006
1007     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
1008   }
1009
1010   // Don't play the animation: disconnect action should not be applied
1011   {
1012     Actor actor = Actor::New();
1013     stage.Add(actor);
1014
1015     // Build the animation
1016     float durationSeconds(1.0f);
1017     Animation animation = Animation::New(durationSeconds);
1018
1019     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
1020     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1021
1022     application.SendNotification();
1023     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
1024
1025     actor.Unparent();
1026
1027     application.SendNotification();
1028     application.Render();
1029
1030     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
1031   }
1032
1033   END_TEST;
1034 }
1035
1036 int UtcDaliAnimationGetDisconnectActionP(void)
1037 {
1038   TestApplication application;
1039   Animation animation = Animation::New(1.0f);
1040   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
1041
1042   animation.SetDisconnectAction(Animation::Discard);
1043   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
1044
1045   animation.SetDisconnectAction(Animation::Bake);
1046   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
1047
1048   END_TEST;
1049 }
1050
1051 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
1052 {
1053   TestApplication application;
1054
1055   Animation animation = Animation::New(1.0f);
1056   AlphaFunction func = animation.GetDefaultAlphaFunction();
1057   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1058
1059   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1060   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1061   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1062   END_TEST;
1063 }
1064
1065 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
1066 {
1067   TestApplication application;
1068
1069   Animation animation = Animation::New(1.0f);
1070   AlphaFunction func = animation.GetDefaultAlphaFunction();
1071
1072   // Test that the default is linear
1073   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1074
1075   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1076   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1077   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1078
1079   END_TEST;
1080 }
1081
1082 int UtcDaliAnimationSetCurrentProgressP(void)
1083 {
1084   TestApplication application;
1085
1086   Actor actor = Actor::New();
1087   Stage::GetCurrent().Add(actor);
1088
1089   // Build the animation
1090   Animation animation = Animation::New(0.0f);
1091
1092   //Set duration
1093   float durationSeconds(1.0f);
1094   animation.SetDuration(durationSeconds);
1095
1096   bool signalReceived(false);
1097   AnimationFinishCheck finishCheck(signalReceived);
1098   animation.FinishedSignal().Connect(&application, finishCheck);
1099   application.SendNotification();
1100
1101   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1102   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1103
1104   // Start the animation from 40% progress
1105   animation.SetCurrentProgress( 0.4f );
1106   animation.Play();
1107
1108   application.SendNotification();
1109   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1110
1111   // We didn't expect the animation to finish yet
1112   application.SendNotification();
1113   finishCheck.CheckSignalNotReceived();
1114   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
1115   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1116
1117   animation.Play(); // Test that calling play has no effect, when animation is already playing
1118   application.SendNotification();
1119
1120   //Set the progress to 70%
1121   animation.SetCurrentProgress( 0.7f );
1122   application.SendNotification();
1123   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1124   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1125
1126   application.SendNotification();
1127   finishCheck.CheckSignalNotReceived();
1128   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
1129   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1130
1131   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1132   // We did expect the animation to finish
1133   application.SendNotification();
1134   finishCheck.CheckSignalReceived();
1135   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
1136
1137   // Check that nothing has changed after a couple of buffer swaps
1138   application.Render(0);
1139   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1140   application.Render(0);
1141   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1142   END_TEST;
1143 }
1144
1145 int UtcDaliAnimationSetCurrentProgressN(void)
1146 {
1147   TestApplication application;
1148
1149   Actor actor = Actor::New();
1150   Stage::GetCurrent().Add(actor);
1151
1152   // Build the animation
1153   Animation animation = Animation::New(0.0f);
1154
1155   //Set duration
1156   float durationSeconds(1.0f);
1157   animation.SetDuration(durationSeconds);
1158
1159   bool signalReceived(false);
1160   AnimationFinishCheck finishCheck(signalReceived);
1161   animation.FinishedSignal().Connect(&application, finishCheck);
1162   application.SendNotification();
1163
1164   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1165   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1166
1167   //Trying to set the current cursor outside the range [0..1] is ignored
1168   animation.SetCurrentProgress( -1.0f);
1169   application.SendNotification();
1170   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1171
1172   animation.SetCurrentProgress( 100.0f);
1173   application.SendNotification();
1174   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1175   END_TEST;
1176 }
1177
1178 int UtcDaliAnimationGetCurrentProgressP(void)
1179 {
1180   TestApplication application;
1181
1182   Actor actor = Actor::New();
1183   Stage::GetCurrent().Add(actor);
1184
1185   // Build the animation
1186   Animation animation = Animation::New(0.0f);
1187   animation.Play();
1188
1189   //Test GetCurrentProgress return 0.0 as the duration is 0.0
1190   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1191
1192   animation.SetCurrentProgress( 0.5f );
1193   application.SendNotification();
1194   application.Render(static_cast<unsigned int>(100.0f));
1195
1196   //Progress should still be 0.0
1197   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1198
1199   //Set duration
1200   float durationSeconds(1.0f);
1201   animation.SetDuration(durationSeconds);
1202   application.SendNotification();
1203
1204   bool signalReceived(false);
1205   AnimationFinishCheck finishCheck(signalReceived);
1206   animation.FinishedSignal().Connect(&application, finishCheck);
1207   application.SendNotification();
1208
1209   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1210   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1211
1212   // Start the animation from 40% progress
1213   animation.SetCurrentProgress( 0.4f );
1214   animation.Play();
1215
1216   application.SendNotification();
1217   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1218
1219   // We didn't expect the animation to finish yet
1220   application.SendNotification();
1221   finishCheck.CheckSignalNotReceived();
1222   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1223
1224   animation.Play(); // Test that calling play has no effect, when animation is already playing
1225   application.SendNotification();
1226
1227   //Set the progress to 70%
1228   animation.SetCurrentProgress( 0.7f );
1229   application.SendNotification();
1230   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1231   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1232
1233   application.SendNotification();
1234   finishCheck.CheckSignalNotReceived();
1235   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1236
1237   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1238   // We did expect the animation to finish
1239   application.SendNotification();
1240   finishCheck.CheckSignalReceived();
1241   END_TEST;
1242 }
1243
1244 int UtcDaliAnimationSetSpeedFactorP1(void)
1245 {
1246   TestApplication application;
1247
1248   tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1249
1250   Actor actor = Actor::New();
1251   Stage::GetCurrent().Add(actor);
1252
1253   // Build the animation
1254   float durationSeconds(1.0f);
1255   Animation animation = Animation::New(durationSeconds);
1256
1257   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1258   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1259
1260   KeyFrames keyframes = KeyFrames::New();
1261   keyframes.Add( 0.0f, initialPosition);
1262   keyframes.Add( 1.0f, targetPosition );
1263   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1264
1265   //Set speed to be x2
1266   animation.SetSpeedFactor(2.0f);
1267
1268   // Start the animation
1269   animation.Play();
1270
1271   bool signalReceived(false);
1272   AnimationFinishCheck finishCheck(signalReceived);
1273   animation.FinishedSignal().Connect(&application, finishCheck);
1274
1275   application.SendNotification();
1276   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1277
1278   // We didn't expect the animation to finish yet
1279   application.SendNotification();
1280   finishCheck.CheckSignalNotReceived();
1281   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.4f), TEST_LOCATION );
1282
1283   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1284
1285   // We didn't expect the animation to finish yet
1286   application.SendNotification();
1287   finishCheck.CheckSignalNotReceived();
1288   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
1289
1290   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1291
1292   // We did expect the animation to finish
1293   application.SendNotification();
1294   finishCheck.CheckSignalReceived();
1295   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
1296
1297   // Check that nothing has changed after a couple of buffer swaps
1298   application.Render(0);
1299   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1300   application.Render(0);
1301   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1302
1303   END_TEST;
1304 }
1305
1306 int UtcDaliAnimationSetSpeedFactorP2(void)
1307 {
1308   TestApplication application;
1309
1310   Actor actor = Actor::New();
1311   Stage::GetCurrent().Add(actor);
1312
1313   // Build the animation
1314   float durationSeconds(1.0f);
1315   Animation animation = Animation::New(durationSeconds);
1316
1317   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1318   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1319
1320   KeyFrames keyframes = KeyFrames::New();
1321   keyframes.Add( 0.0f, initialPosition);
1322   keyframes.Add( 1.0f, targetPosition );
1323   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1324
1325   tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1326   animation.SetSpeedFactor( -1.0f );
1327
1328   // Start the animation
1329   animation.Play();
1330
1331   bool signalReceived(false);
1332   AnimationFinishCheck finishCheck(signalReceived);
1333   animation.FinishedSignal().Connect(&application, finishCheck);
1334
1335   application.SendNotification();
1336   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1337
1338   // We didn't expect the animation to finish yet
1339   application.SendNotification();
1340   finishCheck.CheckSignalNotReceived();
1341   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
1342
1343   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1344
1345   // We didn't expect the animation to finish yet
1346   application.SendNotification();
1347   finishCheck.CheckSignalNotReceived();
1348   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
1349
1350   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1351
1352   // We didn't expect the animation to finish yet
1353   application.SendNotification();
1354   finishCheck.CheckSignalNotReceived();
1355   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.4f), TEST_LOCATION );
1356
1357   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1358
1359   // We didn't expect the animation to finish yet
1360   application.SendNotification();
1361   finishCheck.CheckSignalNotReceived();
1362   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
1363
1364   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1365
1366   // We did expect the animation to finish
1367   application.SendNotification();
1368   finishCheck.CheckSignalReceived();
1369   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), initialPosition, TEST_LOCATION );
1370
1371   // Check that nothing has changed after a couple of buffer swaps
1372   application.Render(0);
1373   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1374   application.Render(0);
1375   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1376
1377   END_TEST;
1378 }
1379
1380 int UtcDaliAnimationSetSpeedFactorP3(void)
1381 {
1382   TestApplication application;
1383
1384   Actor actor = Actor::New();
1385   Stage::GetCurrent().Add(actor);
1386
1387   // Build the animation
1388   float durationSeconds(1.0f);
1389   Animation animation = Animation::New(durationSeconds);
1390
1391   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1392   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1393
1394   KeyFrames keyframes = KeyFrames::New();
1395   keyframes.Add( 0.0f, initialPosition);
1396   keyframes.Add( 1.0f, targetPosition );
1397   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1398
1399   bool signalReceived(false);
1400   AnimationFinishCheck finishCheck(signalReceived);
1401   animation.FinishedSignal().Connect(&application, finishCheck);
1402
1403   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1404
1405   //Set speed to be half of normal speed
1406   animation.SetSpeedFactor( 0.5f );
1407
1408   // Start the animation
1409   animation.Play();
1410
1411   application.SendNotification();
1412   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1413
1414   // We didn't expect the animation to finish yet
1415   application.SendNotification();
1416   finishCheck.CheckSignalNotReceived();
1417   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.1f), TEST_LOCATION );
1418
1419   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1420
1421   // We didn't expect the animation to finish yet
1422   application.SendNotification();
1423   finishCheck.CheckSignalNotReceived();
1424   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
1425
1426   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1427
1428   // We didn't expect the animation to finish yet
1429   application.SendNotification();
1430   finishCheck.CheckSignalNotReceived();
1431   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.3f), TEST_LOCATION );
1432
1433   application.SendNotification();
1434   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1435
1436   // We didn't expect the animation to finish yet
1437   application.SendNotification();
1438   finishCheck.CheckSignalNotReceived();
1439   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.4f), TEST_LOCATION );
1440
1441   application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1442
1443   // We did expect the animation to finish
1444   application.SendNotification();
1445   finishCheck.CheckSignalReceived();
1446   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
1447
1448   // Check that nothing has changed after a couple of buffer swaps
1449   application.Render(0);
1450   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1451   application.Render(0);
1452   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1453   END_TEST;
1454 }
1455
1456
1457 int UtcDaliAnimationSetSpeedFactorP4(void)
1458 {
1459   TestApplication application;
1460
1461   Actor actor = Actor::New();
1462   Stage::GetCurrent().Add(actor);
1463
1464   // Build the animation
1465   float durationSeconds(1.0f);
1466   Animation animation = Animation::New(durationSeconds);
1467
1468   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1469   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1470
1471   KeyFrames keyframes = KeyFrames::New();
1472   keyframes.Add( 0.0f, initialPosition);
1473   keyframes.Add( 1.0f, targetPosition );
1474   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1475
1476   bool signalReceived(false);
1477   AnimationFinishCheck finishCheck(signalReceived);
1478   animation.FinishedSignal().Connect(&application, finishCheck);
1479
1480   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1481
1482   tet_printf("Set speed to be half of normal speed\n");
1483   tet_printf("SetSpeedFactor(0.5f)\n");
1484   animation.SetSpeedFactor( 0.5f );
1485
1486   // Start the animation
1487   animation.Play();
1488
1489   application.SendNotification();
1490   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1491
1492   // We didn't expect the animation to finish yet
1493   application.SendNotification();
1494   finishCheck.CheckSignalNotReceived();
1495   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.1f), TEST_LOCATION );
1496
1497   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1498
1499   // We didn't expect the animation to finish yet
1500   application.SendNotification();
1501   finishCheck.CheckSignalNotReceived();
1502   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
1503
1504   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1505
1506   // We didn't expect the animation to finish yet
1507   application.SendNotification();
1508   finishCheck.CheckSignalNotReceived();
1509   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.3f), TEST_LOCATION );
1510
1511   tet_printf("Reverse direction of animation whilst playing\n");
1512   tet_printf("SetSpeedFactor(-0.5f)\n");
1513   animation.SetSpeedFactor(-0.5f);
1514
1515   application.SendNotification();
1516   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1517
1518   // We didn't expect the animation to finish yet
1519   application.SendNotification();
1520   finishCheck.CheckSignalNotReceived();
1521   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
1522
1523   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1524
1525   // We didn't expect the animation to finish yet
1526   application.SendNotification();
1527   finishCheck.CheckSignalNotReceived();
1528   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1529
1530   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1531
1532   // We did expect the animation to finish
1533   application.SendNotification();
1534   finishCheck.CheckSignalReceived();
1535   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), initialPosition, TEST_LOCATION );
1536
1537   // Check that nothing has changed after a couple of buffer swaps
1538   application.Render(0);
1539   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1540   application.Render(0);
1541   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1542   END_TEST;
1543 }
1544
1545 int UtcDaliAnimationSetSpeedFactorAndRange(void)
1546 {
1547   TestApplication application;
1548
1549   const unsigned int NUM_FRAMES(15);
1550
1551   struct TestData
1552   {
1553     float startTime;
1554     float endTime;
1555     float startX;
1556     float endX;
1557     float expected[NUM_FRAMES];
1558   };
1559
1560   TestData testData[] = {
1561     // ACTOR 0
1562     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1563     /*                       |----------PlayRange---------------|                 */
1564     /*                                            | reverse                       */
1565     { 0.0f,                                                                  1.0f, // TimePeriod
1566       0.0f,                                                                100.0f, // POS
1567       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1568        /**/                 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1569        /**/                               50.0f,
1570        /**/                        40.0f,
1571        /**/                 30.0f,
1572        /**/                                             70.0f,
1573        /**/                                      60.0f,
1574        /**/                               50.0f,
1575        /**/
1576       }
1577     },
1578
1579     // ACTOR 1 - Across start of range
1580     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1581     /*                       |----------PlayRange---------------|                 */
1582     /*                                            | reverse                       */
1583     {                0.2f,                0.5f,                               // TimePeriod
1584                      20.0f,               50.0f,                // POS
1585       {/**/                 30.0f, 40.0f, 50.0f, 50.0f, 50.0f,  /* Loop */
1586        /**/                 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1587        /**/                               50.0f,
1588        /**/                        40.0f,
1589        /**/                 30.0f,
1590        /**/                                             50.0f,
1591        /**/                                      50.0f,
1592        /**/                               50.0f
1593       }
1594     },
1595
1596     // ACTOR 2 - Across end of range
1597     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1598     /*                       |----------PlayRange---------------|                 */
1599     /*                                            | reverse                       */
1600     {/**/                                  0.5f,                      0.9f,   // TimePeriod
1601      /**/                                 50.0f,                      90.0f,  // POS
1602      { /**/                 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1603        /**/                 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1604        /**/                               50.0f,
1605        /**/                        50.0f,
1606        /**/                 50.0f,                      70.0f,
1607        /**/                                      60.0f,
1608        /**/                               50.0f,
1609       }
1610     },
1611
1612     // ACTOR 3 - Before beginning of range
1613     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1614     /*                       |----------PlayRange---------------|                 */
1615     /*                                            | reverse                       */
1616     {/**/     0.1f,      0.25f, // TimePeriod
1617      /**/     10.0f,     25.0f, // POS
1618      { /**/
1619        /**/ 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
1620        /**/
1621       }
1622     },
1623
1624     // ACTOR 4 - After end of range
1625     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1626     /*                       |----------PlayRange---------------|                 */
1627     /*                                            | reverse                       */
1628     {/**/                                                           0.85f,   1.0f, // TimePeriod
1629      /**/                                                           85.0f,  100.0f, // POS
1630      { /**/
1631        /**/ 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
1632        /**/
1633      }
1634     },
1635     // Actor 5 - Middle of range
1636     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1637     /*                       |----------PlayRange---------------|                 */
1638     /*                                            | reverse                       */
1639     {/**/                          0.4f,            0.65f, // Time Period
1640      /**/                         40.0f,            65.0f, // Position
1641      { /**/                40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1642        /**/                40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1643        /**/                              50.0f,
1644        /**/                       40.0f,
1645        /**/                40.0f,
1646        /**/                                            65.0f,
1647        /**/                                      60.0f,
1648        /**/                              50.0f,
1649      }
1650     }
1651   };
1652
1653   const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1654
1655   // Build the animation
1656   float durationSeconds(1.0f);
1657   Animation animation = Animation::New(durationSeconds);
1658   bool signalReceived(false);
1659   AnimationFinishCheck finishCheck(signalReceived);
1660   animation.FinishedSignal().Connect(&application, finishCheck);
1661
1662   std::vector<Dali::Actor> actors;
1663
1664   for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1665   {
1666     Actor actor = Actor::New();
1667     actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1668     actors.push_back(actor);
1669     Stage::GetCurrent().Add(actor);
1670
1671     if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1672     {
1673       KeyFrames keyframes = KeyFrames::New();
1674       keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1675       keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1676       animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1677     }
1678     else
1679     {
1680       animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1681     }
1682   }
1683
1684   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1685   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1686   tet_printf("SetSpeedFactor(0.5f)\n");
1687   animation.SetSpeedFactor( 0.5f );
1688   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1689   animation.SetLooping(true);
1690
1691   // Start the animation
1692   animation.Play();
1693   application.SendNotification();
1694   application.Render(0);   // Frame 0 tests initial values
1695
1696   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1697   {
1698     unsigned int actorIndex = 0u;
1699     for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1700     {
1701       DALI_TEST_EQUALS( actors[actorIndex].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1702       if( ! Equals(actors[actorIndex].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, testData[actorIndex].expected[frame]) )
1703       {
1704         tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1705       }
1706     }
1707
1708     if( frame == 8 )
1709     {
1710       tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1711       tet_printf("SetSpeedFactor(-0.5f)\n");
1712       animation.SetSpeedFactor(-0.5f);
1713       application.SendNotification();
1714     }
1715     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1716
1717     // We didn't expect the animation to finish yet
1718     application.SendNotification();
1719     finishCheck.CheckSignalNotReceived();
1720   }
1721
1722   END_TEST;
1723 }
1724
1725 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void)
1726 {
1727   TestApplication application;
1728
1729   const unsigned int NUM_FRAMES(15);
1730
1731   struct TestData
1732   {
1733     float startTime;
1734     float endTime;
1735     float startX;
1736     float endX;
1737     float expected[NUM_FRAMES];
1738   };
1739
1740   TestData testData =
1741     // ACTOR 0
1742     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1743     /*                       |----------PlayRange---------------|                 */
1744     { 0.0f,                                                                  1.0f, // TimePeriod
1745       0.0f,                                                                100.0f, // POS
1746       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1747        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1748        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1749        /**/
1750       }
1751     };
1752
1753
1754   // Build the animation
1755   float durationSeconds(1.0f);
1756   Animation animation = Animation::New(durationSeconds);
1757   bool signalReceived(false);
1758   AnimationFinishCheck finishCheck(signalReceived);
1759   animation.FinishedSignal().Connect(&application, finishCheck);
1760
1761   std::vector<Dali::Actor> actors;
1762
1763   Actor actor = Actor::New();
1764   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1765   actors.push_back(actor);
1766   Stage::GetCurrent().Add(actor);
1767
1768   KeyFrames keyframes = KeyFrames::New();
1769   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1770   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1771   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1772
1773   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1774   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1775   tet_printf("SetSpeedFactor(0.5f)\n");
1776   tet_printf("SetLoopCount(3)\n");
1777   animation.SetSpeedFactor( 0.5f );
1778   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1779   animation.SetLoopCount(3);
1780
1781   // Start the animation
1782   animation.Play();
1783   application.SendNotification();
1784   application.Render(0);   // Frame 0 tests initial values
1785
1786   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1787   {
1788     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, testData.expected[frame], 0.001, TEST_LOCATION );
1789
1790     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1791
1792     if( frame < NUM_FRAMES-1 )
1793     {
1794       // We didn't expect the animation to finish yet
1795       application.SendNotification();
1796       finishCheck.CheckSignalNotReceived();
1797     }
1798   }
1799
1800   // We did expect the animation to finish
1801   application.SendNotification();
1802   finishCheck.CheckSignalReceived();
1803   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, 80.0f, 0.001, TEST_LOCATION );
1804
1805   END_TEST;
1806 }
1807
1808 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void)
1809 {
1810   TestApplication application;
1811
1812   const unsigned int NUM_FRAMES(15);
1813
1814   struct TestData
1815   {
1816     float startTime;
1817     float endTime;
1818     float startX;
1819     float endX;
1820     float expected[NUM_FRAMES];
1821   };
1822
1823   TestData testData =
1824     // ACTOR 0
1825     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1826     /*                       |----------PlayRange---------------|                 */
1827     { 0.0f,                                                                  1.0f, // TimePeriod
1828       0.0f,                                                                100.0f, // POS
1829       {/**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1830        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1831        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1832       }
1833     };
1834
1835
1836   // Build the animation
1837   float durationSeconds(1.0f);
1838   Animation animation = Animation::New(durationSeconds);
1839   bool signalReceived(false);
1840   AnimationFinishCheck finishCheck(signalReceived);
1841   animation.FinishedSignal().Connect(&application, finishCheck);
1842
1843   std::vector<Dali::Actor> actors;
1844
1845   Actor actor = Actor::New();
1846   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1847   actors.push_back(actor);
1848   Stage::GetCurrent().Add(actor);
1849
1850   KeyFrames keyframes = KeyFrames::New();
1851   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1852   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1853   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1854
1855   tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1856   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1857   tet_printf("SetSpeedFactor(-0.5f)\n");
1858   tet_printf("SetLoopCount(3)\n");
1859   animation.SetSpeedFactor( -0.5f );
1860   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1861   animation.SetLoopCount(3);
1862
1863   // Start the animation
1864   animation.Play();
1865   application.SendNotification();
1866   application.Render(0);   // Frame 0 tests initial values
1867
1868   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1869   {
1870     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, testData.expected[frame], 0.001, TEST_LOCATION );
1871
1872     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1873
1874     if( frame < NUM_FRAMES-1 )
1875     {
1876       // We didn't expect the animation to finish yet
1877       application.SendNotification();
1878       finishCheck.CheckSignalNotReceived();
1879     }
1880   }
1881
1882   // We did expect the animation to finish
1883   application.SendNotification();
1884   finishCheck.CheckSignalReceived();
1885   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, 30.0f, 0.001, TEST_LOCATION );
1886
1887   END_TEST;
1888 }
1889
1890
1891 int UtcDaliAnimationGetSpeedFactorP(void)
1892 {
1893   TestApplication application;
1894
1895   Animation animation = Animation::New(1.0f);
1896   animation.SetSpeedFactor(0.5f);
1897   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1898
1899   animation.SetSpeedFactor(-2.5f);
1900   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1901   END_TEST;
1902 }
1903
1904 int UtcDaliAnimationSetPlayRangeP(void)
1905 {
1906   TestApplication application;
1907
1908   Actor actor = Actor::New();
1909   Stage::GetCurrent().Add( actor );
1910
1911   // Build the animation
1912   float durationSeconds( 1.0f );
1913   Animation animation = Animation::New( durationSeconds );
1914
1915   bool signalReceived( false );
1916   AnimationFinishCheck finishCheck( signalReceived );
1917   animation.FinishedSignal().Connect( &application, finishCheck );
1918   application.SendNotification();
1919
1920   // Set range between 0.4 and 0.8
1921   animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1922   application.SendNotification();
1923   DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1924
1925   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1926   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1927
1928   // Start the animation from 40% progress
1929   animation.Play();
1930
1931   application.SendNotification();
1932   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1933
1934   // We didn't expect the animation to finish yet
1935   application.SendNotification();
1936   finishCheck.CheckSignalNotReceived();
1937   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.6f ), TEST_LOCATION );
1938
1939   application.SendNotification();
1940   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1941
1942   application.SendNotification();
1943   finishCheck.CheckSignalNotReceived();
1944   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.8f ), TEST_LOCATION );
1945
1946   application.SendNotification();
1947   application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1948
1949   // We did expect the animation to finish
1950   application.SendNotification();
1951   finishCheck.CheckSignalReceived();
1952   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.9f ), TEST_LOCATION );
1953   END_TEST;
1954 }
1955
1956 int UtcDaliAnimationSetPlayRangeN(void)
1957 {
1958   TestApplication application;
1959
1960   Actor actor = Actor::New();
1961   Stage::GetCurrent().Add(actor);
1962
1963   // Build the animation
1964   Animation animation = Animation::New(0);
1965   application.SendNotification();
1966
1967   //PlayRange out of bounds
1968   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1969   application.SendNotification();
1970   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1971   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1972   application.SendNotification();
1973   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1974
1975   //If playRange is not in the correct order it has to be ordered
1976   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1977   application.SendNotification();
1978   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1979
1980   END_TEST;
1981 }
1982
1983 int UtcDaliAnimationGetPlayRangeP(void)
1984 {
1985   TestApplication application;
1986
1987   Actor actor = Actor::New();
1988   Stage::GetCurrent().Add( actor );
1989
1990   // Build the animation
1991   Animation animation = Animation::New( 1.0f );
1992   application.SendNotification();
1993
1994   //If PlayRange not specified it should be 0.0-1.0 by default
1995   DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1996
1997   // Set range between 0.4 and 0.8
1998   animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1999   application.SendNotification();
2000   DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
2001
2002   END_TEST;
2003 }
2004
2005 int UtcDaliAnimationPlayP(void)
2006 {
2007   TestApplication application;
2008
2009   Actor actor = Actor::New();
2010   Stage::GetCurrent().Add(actor);
2011
2012   // Build the animation
2013   float durationSeconds(1.0f);
2014   Animation animation = Animation::New(durationSeconds);
2015   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2016   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2017
2018   // Start the animation
2019   animation.Play();
2020
2021   bool signalReceived(false);
2022   AnimationFinishCheck finishCheck(signalReceived);
2023   animation.FinishedSignal().Connect(&application, finishCheck);
2024
2025   application.SendNotification();
2026   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2027
2028   // We didn't expect the animation to finish yet
2029   application.SendNotification();
2030   finishCheck.CheckSignalNotReceived();
2031   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2032
2033   animation.Play(); // Test that calling play has no effect, when animation is already playing
2034   application.SendNotification();
2035   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2036
2037   // We didn't expect the animation to finish yet
2038   application.SendNotification();
2039   finishCheck.CheckSignalNotReceived();
2040   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.4f), TEST_LOCATION );
2041
2042   animation.Play(); // Test that calling play has no effect, when animation is already playing
2043   application.SendNotification();
2044   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2045
2046   // We didn't expect the animation to finish yet
2047   application.SendNotification();
2048   finishCheck.CheckSignalNotReceived();
2049   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
2050
2051   animation.Play(); // Test that calling play has no effect, when animation is already playing
2052   application.SendNotification();
2053   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2054
2055   // We didn't expect the animation to finish yet
2056   application.SendNotification();
2057   finishCheck.CheckSignalNotReceived();
2058   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
2059
2060   animation.Play(); // Test that calling play has no effect, when animation is already playing
2061   application.SendNotification();
2062   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2063
2064   // We did expect the animation to finish
2065   application.SendNotification();
2066   finishCheck.CheckSignalReceived();
2067   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2068
2069   // Check that nothing has changed after a couple of buffer swaps
2070   application.Render(0);
2071   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2072   application.Render(0);
2073   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2074   END_TEST;
2075 }
2076
2077 int UtcDaliAnimationPlayOffStageDiscardP(void)
2078 {
2079   // Test that an animation can be played, when the actor is off-stage.
2080   // When the actor is added to the stage, it should appear at the current position
2081   // i.e. where it would have been anyway, if on-stage from the beginning.
2082
2083   TestApplication application;
2084
2085   Actor actor = Actor::New();
2086   Vector3 basePosition(Vector3::ZERO);
2087   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), basePosition, TEST_LOCATION );
2088   // Not added to the stage yet!
2089
2090   // Build the animation
2091   float durationSeconds(1.0f);
2092   Animation animation = Animation::New(durationSeconds);
2093   animation.SetDisconnectAction( Animation::Discard );
2094   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2095   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2096
2097   // Start the animation
2098   animation.Play();
2099
2100   bool signalReceived(false);
2101   AnimationFinishCheck finishCheck(signalReceived);
2102   animation.FinishedSignal().Connect(&application, finishCheck);
2103
2104   application.SendNotification();
2105   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2106
2107   // We didn't expect the animation to finish yet
2108   application.SendNotification();
2109   finishCheck.CheckSignalNotReceived();
2110   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(20,20,20), TEST_LOCATION );
2111
2112   // Add to the stage
2113   Stage::GetCurrent().Add(actor);
2114
2115   application.SendNotification();
2116   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2117
2118   // We didn't expect the animation to finish yet
2119   application.SendNotification();
2120   finishCheck.CheckSignalNotReceived();
2121   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(40,40,40)/*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.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO/*back to start position as disconnect behaviour is discard*/, TEST_LOCATION );
2133   // Check that nothing has changed after a couple of buffer swaps
2134   application.Render(0);
2135   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2136   application.Render(0);
2137   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2138   application.Render(0);
2139   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2140
2141   // Add to the stage
2142   Stage::GetCurrent().Add(actor);
2143
2144   application.SendNotification();
2145   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2146
2147   // We didn't expect the animation to finish yet
2148   application.SendNotification();
2149   finishCheck.CheckSignalNotReceived();
2150   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(80,80,80), TEST_LOCATION );
2151
2152   application.SendNotification();
2153   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2154
2155   // We did expect the animation to finish
2156   application.SendNotification();
2157   finishCheck.CheckSignalReceived();
2158   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2159
2160   // Check that nothing has changed after a couple of buffer swaps
2161   application.Render(0);
2162   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2163
2164
2165   application.Render(0);
2166   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2167   END_TEST;
2168 }
2169
2170 int UtcDaliAnimationPlayOffStageBakeFinalP(void)
2171 {
2172   // Test that an animation can be played, when the actor is off-stage.
2173   // When the actor is added to the stage, it should appear at the current position
2174   // i.e. where it would have been anyway, if on-stage from the beginning.
2175
2176   TestApplication application;
2177
2178   Actor actor = Actor::New();
2179   Vector3 basePosition(Vector3::ZERO);
2180   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), basePosition, TEST_LOCATION );
2181   // Not added to the stage!
2182
2183   // Build the animation
2184   float durationSeconds(1.0f);
2185   Animation animation = Animation::New(durationSeconds);
2186   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2187   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2188
2189   // Start the animation
2190   animation.Play();
2191
2192   bool signalReceived(false);
2193   AnimationFinishCheck finishCheck(signalReceived);
2194   animation.FinishedSignal().Connect(&application, finishCheck);
2195
2196   application.SendNotification();
2197   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2198
2199   // We didn't expect the animation to finish yet
2200   application.SendNotification();
2201   finishCheck.CheckSignalNotReceived();
2202   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(20,20,20), TEST_LOCATION );
2203
2204   // Add to the stage
2205   Stage::GetCurrent().Add(actor);
2206
2207   application.SendNotification();
2208   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2209
2210   // We didn't expect the animation to finish yet
2211   application.SendNotification();
2212   finishCheck.CheckSignalNotReceived();
2213   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(40,40,40)/*on-stage*/, TEST_LOCATION );
2214
2215   // Remove from the stage
2216   Stage::GetCurrent().Remove(actor);
2217
2218   application.SendNotification();
2219   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2220
2221   // We didn't expect the animation to finish yet
2222   application.SendNotification();
2223   finishCheck.CheckSignalNotReceived();
2224   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition /*bake final*/, TEST_LOCATION );
2225
2226   // Add to the stage
2227   Stage::GetCurrent().Add(actor);
2228
2229   application.SendNotification();
2230   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2231
2232   // We didn't expect the animation to finish yet
2233   application.SendNotification();
2234   finishCheck.CheckSignalNotReceived();
2235   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition /*bake final removed the */, TEST_LOCATION );
2236
2237   application.SendNotification();
2238   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2239
2240   // We did expect the animation to finish
2241   application.SendNotification();
2242   finishCheck.CheckSignalReceived();
2243   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2244
2245   // Check that nothing has changed after a couple of buffer swaps
2246   application.Render(0);
2247   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2248
2249   application.Render(0);
2250   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2251   END_TEST;
2252 }
2253
2254 int UtcDaliAnimationPlayOffStageBakeP(void)
2255 {
2256   // Test that an animation can be played, when the actor is off-stage.
2257   // When the actor is added to the stage, it should appear at the current position
2258   // i.e. where it would have been anyway, if on-stage from the beginning.
2259
2260   TestApplication application;
2261
2262   Actor actor = Actor::New();
2263   Vector3 basePosition(Vector3::ZERO);
2264   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), basePosition, TEST_LOCATION );
2265   // Not added to the stage!
2266
2267   // Build the animation
2268   float durationSeconds(1.0f);
2269   Animation animation = Animation::New(durationSeconds);
2270   animation.SetDisconnectAction( Animation::Bake );
2271   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2272   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2273
2274   // Start the animation
2275   animation.Play();
2276
2277   bool signalReceived(false);
2278   AnimationFinishCheck finishCheck(signalReceived);
2279   animation.FinishedSignal().Connect(&application, finishCheck);
2280
2281   application.SendNotification();
2282   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2283
2284   // We didn't expect the animation to finish yet
2285   application.SendNotification();
2286   finishCheck.CheckSignalNotReceived();
2287   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(20,20,20), TEST_LOCATION );
2288
2289   // Add to the stage
2290   Stage::GetCurrent().Add(actor);
2291
2292   application.SendNotification();
2293   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2294
2295   // We didn't expect the animation to finish yet
2296   application.SendNotification();
2297   finishCheck.CheckSignalNotReceived();
2298   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(40,40,40)/*on-stage*/, TEST_LOCATION );
2299
2300   // Remove from the stage
2301   Stage::GetCurrent().Remove(actor); // baked here
2302
2303   application.SendNotification();
2304   // this render is a no-op in this case as animator is disabled while off stage
2305   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2306   // We didn't expect the animation to finish yet
2307   application.SendNotification();
2308   finishCheck.CheckSignalNotReceived();
2309   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(40,40,40) /*baked value*/, TEST_LOCATION );
2310
2311   // Add back to the stage
2312   Stage::GetCurrent().Add(actor);
2313
2314   application.SendNotification();
2315   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2316   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /* animation restarted at 40,40,40 + 80%*60 */, TEST_LOCATION );
2317   application.Render(static_cast<unsigned int>(0.0f) );
2318   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
2319   application.Render(static_cast<unsigned int>(0.0f) );
2320   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
2321
2322   // Remove from the stage
2323   Stage::GetCurrent().Remove(actor); // baked here
2324
2325   application.SendNotification();
2326   // this render is a no-op in this case as animator is disabled while off stage
2327   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2328   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
2329   application.Render(static_cast<unsigned int>(0.0f) );
2330   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
2331   application.Render(static_cast<unsigned int>(0.0f) );
2332   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
2333
2334   // Add back to the stage
2335   Stage::GetCurrent().Add(actor);
2336
2337   // We didn't expect the animation to finish yet
2338   application.SendNotification();
2339   finishCheck.CheckSignalNotReceived();
2340   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(88,88,88) , TEST_LOCATION );
2341
2342   application.SendNotification();
2343   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2344
2345   // We did expect the animation to finish
2346   application.SendNotification();
2347   finishCheck.CheckSignalReceived();
2348   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2349
2350   // Check that nothing has changed after a couple of buffer swaps
2351   application.Render(0);
2352   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2353
2354   application.Render(0);
2355   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2356   END_TEST;
2357 }
2358
2359 int UtcDaliAnimationPlayDiscardHandleP(void)
2360 {
2361   TestApplication application;
2362
2363   Actor actor = Actor::New();
2364   Stage::GetCurrent().Add(actor);
2365
2366   // Build the animation
2367   float durationSeconds(1.0f);
2368   Animation animation = Animation::New(durationSeconds);
2369   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2370   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2371
2372   bool signalReceived(false);
2373   AnimationFinishCheck finishCheck(signalReceived);
2374   animation.FinishedSignal().Connect(&application, finishCheck);
2375
2376   // Start the animation
2377   animation.Play();
2378
2379   // This is a test of the "Fire and Forget" behaviour
2380   // Discard the animation handle!
2381   animation.Reset();
2382   DALI_TEST_CHECK( !animation );
2383
2384   application.SendNotification();
2385   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2386
2387   // We didn't expect the animation to finish yet
2388   application.SendNotification();
2389   finishCheck.CheckSignalNotReceived();
2390   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2391
2392   application.SendNotification();
2393   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2394
2395   // We didn't expect the animation to finish yet
2396   application.SendNotification();
2397   finishCheck.CheckSignalNotReceived();
2398   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.4f), TEST_LOCATION );
2399
2400   application.SendNotification();
2401   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2402
2403   // We didn't expect the animation to finish yet
2404   application.SendNotification();
2405   finishCheck.CheckSignalNotReceived();
2406   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
2407
2408   application.SendNotification();
2409   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2410
2411   // We didn't expect the animation to finish yet
2412   application.SendNotification();
2413   finishCheck.CheckSignalNotReceived();
2414   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
2415
2416   application.SendNotification();
2417   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2418
2419   // We did expect the animation to finish
2420   application.SendNotification();
2421   finishCheck.CheckSignalReceived();
2422   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2423
2424   // Check that nothing has changed after a couple of buffer swaps
2425   application.Render(0);
2426   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2427   application.Render(0);
2428   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2429   END_TEST;
2430 }
2431
2432 int UtcDaliAnimationPlayStopDiscardHandleP(void)
2433 {
2434   TestApplication application;
2435
2436   Actor actor = Actor::New();
2437   Stage::GetCurrent().Add(actor);
2438
2439   // Build the animation
2440   float durationSeconds(1.0f);
2441   Animation animation = Animation::New(durationSeconds);
2442   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2443   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2444
2445   // Start the animation
2446   animation.Play();
2447
2448   bool signalReceived(false);
2449   AnimationFinishCheck finishCheck(signalReceived);
2450   animation.FinishedSignal().Connect(&application, finishCheck);
2451
2452   application.SendNotification();
2453   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2454
2455   // We didn't expect the animation to finish yet
2456   application.SendNotification();
2457   finishCheck.CheckSignalNotReceived();
2458   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2459
2460   // This is a test of the "Fire and Forget" behaviour
2461   // Stop the animation, and Discard the animation handle!
2462   animation.Stop();
2463   animation.Reset();
2464   DALI_TEST_CHECK( !animation );
2465
2466   application.SendNotification();
2467   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2468
2469   // We expect the animation to finish at 20% progress
2470   application.SendNotification();
2471   finishCheck.CheckSignalReceived();
2472   finishCheck.Reset();
2473   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2474
2475   application.SendNotification();
2476   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2477
2478   // Check that nothing has changed
2479   application.SendNotification();
2480   finishCheck.CheckSignalNotReceived();
2481   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2482
2483   application.SendNotification();
2484   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2485
2486   // Check that nothing has changed
2487   application.SendNotification();
2488   finishCheck.CheckSignalNotReceived();
2489   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2490
2491   application.SendNotification();
2492   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2493
2494   // Check that nothing has changed
2495   application.SendNotification();
2496   finishCheck.CheckSignalNotReceived();
2497   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.2f), TEST_LOCATION );
2498   END_TEST;
2499 }
2500
2501 int UtcDaliAnimationPlayRangeP(void)
2502 {
2503   TestApplication application;
2504
2505   Actor actor = Actor::New();
2506   Stage::GetCurrent().Add(actor);
2507
2508   // Build the animation
2509   float durationSeconds(1.0f);
2510   Animation animation = Animation::New(durationSeconds);
2511   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2512   KeyFrames keyframes = KeyFrames::New();
2513   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2514   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2515
2516   animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2517
2518   // Set range between 0.4 and 0.8
2519   animation.SetPlayRange( Vector2(0.4f,0.8f) );
2520   animation.Play();
2521
2522   bool signalReceived(false);
2523   AnimationFinishCheck finishCheck(signalReceived);
2524   animation.FinishedSignal().Connect(&application, finishCheck);
2525
2526   //Test that setting progress outside the range doesn't work
2527   animation.SetCurrentProgress( 0.9f );
2528   application.SendNotification();
2529   application.Render(0);
2530   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2531   animation.SetCurrentProgress( 0.2f );
2532   application.SendNotification();
2533   application.Render(0);
2534   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2535
2536   application.SendNotification();
2537   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2538
2539   // We didn't expect the animation to finish yet
2540   application.SendNotification();
2541   finishCheck.CheckSignalNotReceived();
2542   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
2543
2544   animation.Play(); // Test that calling play has no effect, when animation is already playing
2545   application.SendNotification();
2546   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2547
2548   // We did expect the animation to finish
2549   application.SendNotification();
2550   finishCheck.CheckSignalReceived();
2551   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
2552
2553   // Check that nothing has changed after a couple of buffer swaps
2554   application.Render(0);
2555   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2556   application.Render(0);
2557   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2558
2559
2560   //Loop inside the range
2561   finishCheck.Reset();
2562   animation.SetLooping( true );
2563   animation.Play();
2564   application.SendNotification();
2565   float intervalSeconds = 0.1f;
2566   float progress = 0.4f;
2567   for (int iterations = 0; iterations < 10; ++iterations )
2568   {
2569     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2570
2571     progress += intervalSeconds;
2572     if (progress > 0.8f)
2573     {
2574       progress = progress - 0.4f;
2575     }
2576
2577     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001f, TEST_LOCATION );
2578   }
2579
2580   // We didn't expect the animation to finish yet
2581   application.SendNotification();
2582   finishCheck.CheckSignalNotReceived();
2583
2584
2585   //Test change range on the fly
2586   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2587   application.SendNotification();
2588
2589   for (int iterations = 0; iterations < 10; ++iterations )
2590   {
2591     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2592
2593     progress += intervalSeconds;
2594     if (progress > 0.9f)
2595     {
2596       progress = progress - 0.7f;
2597     }
2598
2599     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001f, TEST_LOCATION );
2600   }
2601
2602   END_TEST;
2603 }
2604
2605 int UtcDaliAnimationPlayFromP(void)
2606 {
2607   TestApplication application;
2608
2609   Actor actor = Actor::New();
2610   Stage::GetCurrent().Add(actor);
2611
2612   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
2613
2614   // Build the animation
2615   float durationSeconds(1.0f);
2616   Animation animation = Animation::New(durationSeconds);
2617   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2618   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2619
2620   // Start the animation from 40% progress
2621   animation.PlayFrom( 0.4f );
2622
2623   // Target value should be updated straight away
2624   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2625
2626   bool signalReceived(false);
2627   AnimationFinishCheck finishCheck(signalReceived);
2628   animation.FinishedSignal().Connect(&application, finishCheck);
2629
2630   application.SendNotification();
2631   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2632
2633   // We didn't expect the animation to finish yet
2634   application.SendNotification();
2635   finishCheck.CheckSignalNotReceived();
2636   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.6f), TEST_LOCATION );
2637
2638   animation.Play(); // Test that calling play has no effect, when animation is already playing
2639   application.SendNotification();
2640   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2641
2642   // We didn't expect the animation to finish yet
2643   application.SendNotification();
2644   finishCheck.CheckSignalNotReceived();
2645   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), (targetPosition * 0.8f), TEST_LOCATION );
2646
2647   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2648   // We did expect the animation to finish
2649   application.SendNotification();
2650   finishCheck.CheckSignalReceived();
2651   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2652
2653   // Check that nothing has changed after a couple of buffer swaps
2654   application.Render(0);
2655   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2656   application.Render(0);
2657   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2658   END_TEST;
2659 }
2660
2661 int UtcDaliAnimationPlayFromN(void)
2662 {
2663   TestApplication application;
2664
2665   Actor actor = Actor::New();
2666   Stage::GetCurrent().Add(actor);
2667
2668   // Build the animation
2669   float durationSeconds(1.0f);
2670   Animation animation = Animation::New(durationSeconds);
2671   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2672   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2673
2674   //PlayFrom with an argument outside the range [0..1] will be ignored
2675   animation.PlayFrom(-1.0f);
2676   application.SendNotification();
2677   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2678
2679   animation.PlayFrom(100.0f);
2680   application.SendNotification();
2681   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2682   END_TEST;
2683 }
2684
2685 int UtcDaliAnimationPauseP(void)
2686 {
2687   TestApplication application;
2688
2689   Actor actor = Actor::New();
2690   Stage::GetCurrent().Add(actor);
2691
2692   // Build the animation
2693   float durationSeconds(1.0f);
2694   Animation animation = Animation::New(durationSeconds);
2695   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2696   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2697
2698   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2699
2700   // Start the animation
2701   animation.Play();
2702
2703   bool signalReceived(false);
2704   AnimationFinishCheck finishCheck(signalReceived);
2705   animation.FinishedSignal().Connect(&application, finishCheck);
2706
2707   application.SendNotification();
2708   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2709
2710   // We didn't expect the animation to finish yet
2711   application.SendNotification();
2712   finishCheck.CheckSignalNotReceived();
2713   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress, TEST_LOCATION );
2714
2715   // Pause the animation
2716   animation.Pause();
2717   application.SendNotification();
2718
2719   // Loop 5 times
2720   for (int i=0; i<5; ++i)
2721   {
2722     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2723
2724     // We didn't expect the animation to finish yet
2725     application.SendNotification();
2726     finishCheck.CheckSignalNotReceived();
2727     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2728   }
2729
2730   // Keep going
2731   animation.Play();
2732   application.SendNotification();
2733   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2734
2735   // We didn't expect the animation to finish yet
2736   application.SendNotification();
2737   finishCheck.CheckSignalNotReceived();
2738
2739   application.SendNotification();
2740   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2741
2742   // We did expect the animation to finish
2743   application.SendNotification();
2744   finishCheck.CheckSignalReceived();
2745   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2746
2747   // Check that nothing has changed after a couple of buffer swaps
2748   application.Render(0);
2749   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2750   application.Render(0);
2751   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2752   END_TEST;
2753 }
2754
2755
2756 int UtcDaliAnimationGetStateP(void)
2757 {
2758   TestApplication application;
2759
2760   Actor actor = Actor::New();
2761   Stage::GetCurrent().Add(actor);
2762
2763   // Build the animation
2764   float durationSeconds(1.0f);
2765   Animation animation = Animation::New(durationSeconds);
2766   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2767   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2768   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2769
2770   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2771
2772   // Start the animation
2773   animation.Play();
2774
2775   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2776
2777   bool signalReceived(false);
2778   AnimationFinishCheck finishCheck(signalReceived);
2779   animation.FinishedSignal().Connect(&application, finishCheck);
2780
2781   application.SendNotification();
2782   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2783
2784   // We didn't expect the animation to finish yet
2785   application.SendNotification();
2786   finishCheck.CheckSignalNotReceived();
2787   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2788   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress, TEST_LOCATION );
2789
2790   // Pause the animation
2791   animation.Pause();
2792   DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2793   application.SendNotification();
2794   application.Render(0.f);
2795
2796   // Loop 5 times
2797   for (int i=0; i<5; ++i)
2798   {
2799     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2800
2801     // We didn't expect the animation to finish yet
2802     application.SendNotification();
2803     finishCheck.CheckSignalNotReceived();
2804     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2805     DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2806   }
2807
2808   // Keep going
2809   finishCheck.Reset();
2810   animation.Play();
2811   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2812   application.SendNotification();
2813   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2814   // We didn't expect the animation to finish yet
2815   application.SendNotification();
2816   finishCheck.CheckSignalNotReceived();
2817   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2818
2819   application.SendNotification();
2820   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2821
2822   // We did expect the animation to finish
2823   application.SendNotification();
2824   finishCheck.CheckSignalReceived();
2825   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
2826   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2827
2828   // Check that nothing has changed after a couple of buffer swaps
2829   application.Render(0);
2830   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2831   application.Render(0);
2832   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
2833   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2834
2835   // re-play
2836   finishCheck.Reset();
2837   animation.Play();
2838   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2839   application.SendNotification();
2840   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2841   application.SendNotification();
2842   finishCheck.CheckSignalNotReceived();
2843   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2844
2845
2846   END_TEST;
2847 }
2848
2849 int UtcDaliAnimationStopP(void)
2850 {
2851   TestApplication application;
2852
2853   Actor actor = Actor::New();
2854   Stage::GetCurrent().Add(actor);
2855
2856   // Build the animation
2857   float durationSeconds(1.0f);
2858   Animation animation = Animation::New(durationSeconds);
2859   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2860   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2861
2862   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2863
2864   // Start the animation
2865   animation.Play();
2866
2867   bool signalReceived(false);
2868   AnimationFinishCheck finishCheck(signalReceived);
2869   animation.FinishedSignal().Connect(&application, finishCheck);
2870
2871   application.SendNotification();
2872   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2873
2874   // We didn't expect the animation to finish yet
2875   application.SendNotification();
2876   finishCheck.CheckSignalNotReceived();
2877   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress, TEST_LOCATION );
2878
2879   // Stop the animation
2880   animation.Stop();
2881   application.SendNotification();
2882
2883   // Loop 5 times
2884   for (int i=0; i<5; ++i)
2885   {
2886     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2887
2888     // We did expect the animation to finish
2889     application.SendNotification();
2890     finishCheck.CheckSignalReceived();
2891     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2892   }
2893   END_TEST;
2894 }
2895
2896 int UtcDaliAnimationStopSetPositionP(void)
2897 {
2898   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2899   // i.e. to check that the animation does not interfere with the position set.
2900
2901   TestApplication application;
2902
2903   Actor actor = Actor::New();
2904   Stage::GetCurrent().Add(actor);
2905
2906   // Build the animation
2907   float durationSeconds(1.0f);
2908   Animation animation = Animation::New(durationSeconds);
2909   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2910   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2911
2912   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2913
2914   // Start the animation
2915   animation.Play();
2916
2917   bool signalReceived(false);
2918   AnimationFinishCheck finishCheck(signalReceived);
2919   animation.FinishedSignal().Connect(&application, finishCheck);
2920
2921   application.SendNotification();
2922   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2923
2924   // We didn't expect the animation to finish yet
2925   application.SendNotification();
2926   finishCheck.CheckSignalNotReceived();
2927   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress, TEST_LOCATION );
2928
2929   // Stop the animation
2930   animation.Stop();
2931   Vector3 positionSet(2.0f, 3.0f, 4.0f);
2932   actor.SetPosition(positionSet);
2933   application.SendNotification();
2934
2935   // Loop 5 times
2936   for (int i=0; i<5; ++i)
2937   {
2938     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2939
2940     // We did expect the animation to finish
2941     application.SendNotification();
2942     finishCheck.CheckSignalReceived();
2943     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2944   }
2945   END_TEST;
2946 }
2947
2948 int UtcDaliAnimationClearP(void)
2949 {
2950   TestApplication application;
2951
2952   Actor actor = Actor::New();
2953   Stage::GetCurrent().Add(actor);
2954
2955   // Build the animation
2956   float durationSeconds(1.0f);
2957   Animation animation = Animation::New(durationSeconds);
2958   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2959   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2960
2961   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2962
2963   // Start the animation
2964   animation.Play();
2965
2966   bool signalReceived(false);
2967   AnimationFinishCheck finishCheck(signalReceived);
2968   animation.FinishedSignal().Connect(&application, finishCheck);
2969
2970   application.SendNotification();
2971   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2972
2973   // We didn't expect the animation to finish yet
2974   application.SendNotification();
2975   finishCheck.CheckSignalNotReceived();
2976   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress, TEST_LOCATION );
2977
2978   // Clear the animation
2979   animation.Clear();
2980   application.SendNotification();
2981
2982   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2983
2984   // We don't expect the animation to finish now
2985   application.SendNotification();
2986   finishCheck.CheckSignalNotReceived();
2987   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2988
2989   // Restart as a scale animation; this should not move the actor's position
2990   finishCheck.Reset();
2991   actor.SetPosition(Vector3::ZERO);
2992   Vector3 targetScale(3.0f, 3.0f, 3.0f);
2993   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2994   animation.Play();
2995
2996   application.SendNotification();
2997   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2998
2999   // We didn't expect the animation to finish yet
3000   application.SendNotification();
3001   finishCheck.CheckSignalNotReceived();
3002   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
3003   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
3004
3005   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3006
3007   // We did expect the animation to finish
3008   application.SendNotification();
3009   finishCheck.CheckSignalReceived();
3010   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
3011   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
3012   END_TEST;
3013 }
3014
3015 int UtcDaliAnimationFinishedSignalP(void)
3016 {
3017   TestApplication application;
3018
3019   // Start the empty animation
3020   float durationSeconds(1.0f);
3021   Animation animation = Animation::New(durationSeconds);
3022   animation.Play();
3023
3024   bool signalReceived(false);
3025   AnimationFinishCheck finishCheck(signalReceived);
3026   animation.FinishedSignal().Connect(&application, finishCheck);
3027
3028   application.SendNotification();
3029   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
3030
3031   // We did expect the animation to finish
3032   application.SendNotification();
3033   finishCheck.CheckSignalReceived();
3034   END_TEST;
3035 }
3036
3037 int UtcDaliAnimationAnimateByBooleanP(void)
3038 {
3039   TestApplication application;
3040
3041   Actor actor = Actor::New();
3042
3043   // Register a boolean property
3044   bool startValue(false);
3045   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3046   Stage::GetCurrent().Add(actor);
3047   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3048   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3049
3050   // Build the animation
3051   float durationSeconds(2.0f);
3052   Animation animation = Animation::New(durationSeconds);
3053   const bool relativeValue(true);
3054   const bool finalValue( false || relativeValue );
3055   animation.AnimateBy(Property(actor, index), relativeValue);
3056
3057   // Start the animation
3058   animation.Play();
3059
3060   // Target value should be retrievable straight away
3061   DALI_TEST_EQUALS( actor.GetProperty< bool >( index ), finalValue, TEST_LOCATION );
3062
3063   bool signalReceived(false);
3064   AnimationFinishCheck finishCheck(signalReceived);
3065   animation.FinishedSignal().Connect(&application, finishCheck);
3066
3067   application.SendNotification();
3068   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3069
3070   // We didn't expect the animation to finish yet
3071   application.SendNotification();
3072   finishCheck.CheckSignalNotReceived();
3073   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3074
3075   application.SendNotification();
3076   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3077
3078   // We did expect the animation to finish
3079   application.SendNotification();
3080   finishCheck.CheckSignalReceived();
3081   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3082
3083   // Check that nothing has changed after a couple of buffer swaps
3084   application.Render(0);
3085   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3086   application.Render(0);
3087   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3088
3089   // Repeat with relative value "false" - this should be an NOOP
3090   animation = Animation::New(durationSeconds);
3091   bool noOpValue(false);
3092   animation.AnimateBy(Property(actor, index), noOpValue);
3093
3094   // Start the animation
3095   animation.Play();
3096
3097   finishCheck.Reset();
3098   animation.FinishedSignal().Connect(&application, finishCheck);
3099
3100   application.SendNotification();
3101   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3102
3103   // We didn't expect the animation to finish yet
3104   application.SendNotification();
3105   finishCheck.CheckSignalNotReceived();
3106   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3107
3108   application.SendNotification();
3109   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3110
3111   // We did expect the animation to finish
3112   application.SendNotification();
3113   finishCheck.CheckSignalReceived();
3114   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3115
3116   // Check that nothing has changed after a couple of buffer swaps
3117   application.Render(0);
3118   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3119   application.Render(0);
3120   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3121   END_TEST;
3122 }
3123
3124 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
3125 {
3126   TestApplication application;
3127
3128   Actor actor = Actor::New();
3129
3130   // Register a boolean property
3131   bool startValue(false);
3132   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3133   Stage::GetCurrent().Add(actor);
3134   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3135   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3136
3137   // Build the animation
3138   float durationSeconds(2.0f);
3139   Animation animation = Animation::New(durationSeconds);
3140   bool relativeValue(true);
3141   bool finalValue( false || relativeValue );
3142   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
3143
3144   // Start the animation
3145   animation.Play();
3146
3147   bool signalReceived(false);
3148   AnimationFinishCheck finishCheck(signalReceived);
3149   animation.FinishedSignal().Connect(&application, finishCheck);
3150
3151   application.SendNotification();
3152   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3153
3154   // We didn't expect the animation to finish yet
3155   application.SendNotification();
3156   finishCheck.CheckSignalNotReceived();
3157   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3158
3159   application.SendNotification();
3160   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3161
3162   // We did expect the animation to finish
3163   application.SendNotification();
3164   finishCheck.CheckSignalReceived();
3165   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3166
3167   // Check that nothing has changed after a couple of buffer swaps
3168   application.Render(0);
3169   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3170   application.Render(0);
3171   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3172
3173   // Repeat with relative value "false" - this should be an NOOP
3174   animation = Animation::New(durationSeconds);
3175   bool noOpValue(false);
3176   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
3177
3178   // Start the animation
3179   animation.Play();
3180
3181   finishCheck.Reset();
3182   animation.FinishedSignal().Connect(&application, finishCheck);
3183
3184   application.SendNotification();
3185   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3186
3187   // We didn't expect the animation to finish yet
3188   application.SendNotification();
3189   finishCheck.CheckSignalNotReceived();
3190   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3191
3192   application.SendNotification();
3193   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3194
3195   // We did expect the animation to finish
3196   application.SendNotification();
3197   finishCheck.CheckSignalReceived();
3198   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3199   END_TEST;
3200 }
3201
3202 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
3203 {
3204   TestApplication application;
3205
3206   Actor actor = Actor::New();
3207
3208   // Register a boolean property
3209   bool startValue(false);
3210   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3211   Stage::GetCurrent().Add(actor);
3212   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3213   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3214
3215   // Build the animation
3216   float durationSeconds(2.0f);
3217   Animation animation = Animation::New(durationSeconds);
3218   bool relativeValue(true);
3219   bool finalValue( false || relativeValue );
3220   float animatorDurationSeconds(durationSeconds * 0.5f);
3221   animation.AnimateBy( Property(actor, index),
3222                        relativeValue,
3223                        TimePeriod( animatorDurationSeconds ) );
3224
3225   // Start the animation
3226   animation.Play();
3227
3228   bool signalReceived(false);
3229   AnimationFinishCheck finishCheck(signalReceived);
3230   animation.FinishedSignal().Connect(&application, finishCheck);
3231
3232   application.SendNotification();
3233   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3234
3235   // We didn't expect the animation to finish yet
3236   application.SendNotification();
3237   finishCheck.CheckSignalNotReceived();
3238   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3239
3240   application.SendNotification();
3241   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3242
3243   // We didn't expect the animation to finish yet...
3244   application.SendNotification();
3245   finishCheck.CheckSignalNotReceived();
3246
3247   // ...however we should have reached the final value
3248   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3249
3250   application.SendNotification();
3251   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3252
3253   // We did expect the animation to finish
3254   application.SendNotification();
3255   finishCheck.CheckSignalReceived();
3256   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3257
3258   // Check that nothing has changed after a couple of buffer swaps
3259   application.Render(0);
3260   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3261   application.Render(0);
3262   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3263   END_TEST;
3264 }
3265
3266 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3267 {
3268   TestApplication application;
3269
3270   Actor actor = Actor::New();
3271
3272   // Register a boolean property
3273   bool startValue(false);
3274   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3275   Stage::GetCurrent().Add(actor);
3276   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3277   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3278
3279   // Build the animation
3280   float durationSeconds(2.0f);
3281   Animation animation = Animation::New(durationSeconds);
3282   bool relativeValue(true);
3283   bool finalValue( false || relativeValue );
3284   float animatorDurationSeconds(durationSeconds * 0.5f);
3285   animation.AnimateBy( Property(actor, index),
3286                        relativeValue,
3287                        AlphaFunction::EASE_IN_OUT,
3288                        TimePeriod( animatorDurationSeconds ) );
3289
3290   // Start the animation
3291   animation.Play();
3292
3293   bool signalReceived(false);
3294   AnimationFinishCheck finishCheck(signalReceived);
3295   animation.FinishedSignal().Connect(&application, finishCheck);
3296
3297   application.SendNotification();
3298   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3299
3300   // We didn't expect the animation to finish yet
3301   application.SendNotification();
3302   finishCheck.CheckSignalNotReceived();
3303   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3304
3305   application.SendNotification();
3306   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3307
3308   // We didn't expect the animation to finish yet...
3309   application.SendNotification();
3310   finishCheck.CheckSignalNotReceived();
3311
3312   // ...however we should have reached the final value
3313   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3314
3315   application.SendNotification();
3316   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3317
3318   // We did expect the animation to finish
3319   application.SendNotification();
3320   finishCheck.CheckSignalReceived();
3321   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3322
3323   // Check that nothing has changed after a couple of buffer swaps
3324   application.Render(0);
3325   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3326   application.Render(0);
3327   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3328   END_TEST;
3329 }
3330
3331 int UtcDaliAnimationAnimateByFloatP(void)
3332 {
3333   TestApplication application;
3334
3335   Actor actor = Actor::New();
3336
3337   // Register a float property
3338   float startValue(10.0f);
3339   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3340   Stage::GetCurrent().Add(actor);
3341   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3342   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3343
3344   // Build the animation
3345   float durationSeconds(2.0f);
3346   Animation animation = Animation::New(durationSeconds);
3347   float targetValue(50.0f);
3348   float relativeValue(targetValue - startValue);
3349   animation.AnimateBy(Property(actor, index), relativeValue);
3350
3351   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3352
3353   // Start the animation
3354   animation.Play();
3355
3356   // Target value should be retrievable straight away
3357   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
3358
3359   bool signalReceived(false);
3360   AnimationFinishCheck finishCheck(signalReceived);
3361   animation.FinishedSignal().Connect(&application, finishCheck);
3362
3363   application.SendNotification();
3364   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3365
3366   // We didn't expect the animation to finish yet
3367   application.SendNotification();
3368   finishCheck.CheckSignalNotReceived();
3369   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3370
3371   application.SendNotification();
3372   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3373
3374   // We did expect the animation to finish
3375   application.SendNotification();
3376   finishCheck.CheckSignalReceived();
3377   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3378
3379   // Check that nothing has changed after a couple of buffer swaps
3380   application.Render(0);
3381   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3382   application.Render(0);
3383   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3384   END_TEST;
3385 }
3386
3387 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3388 {
3389   TestApplication application;
3390
3391   Actor actor = Actor::New();
3392
3393   // Register a float property
3394   float startValue(10.0f);
3395   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3396   Stage::GetCurrent().Add(actor);
3397   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3398   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3399
3400   // Build the animation
3401   float durationSeconds(1.0f);
3402   Animation animation = Animation::New(durationSeconds);
3403   float targetValue(90.0f);
3404   float relativeValue(targetValue - startValue);
3405   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3406
3407   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3408
3409   // Start the animation
3410   animation.Play();
3411
3412   bool signalReceived(false);
3413   AnimationFinishCheck finishCheck(signalReceived);
3414   animation.FinishedSignal().Connect(&application, finishCheck);
3415
3416   application.SendNotification();
3417   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3418
3419   // We didn't expect the animation to finish yet
3420   application.SendNotification();
3421   finishCheck.CheckSignalNotReceived();
3422
3423   // The position should have moved more, than with a linear alpha function
3424   float current( actor.GetCurrentProperty< float >( index ) );
3425   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3426
3427   application.SendNotification();
3428   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3429
3430   // We did expect the animation to finish
3431   application.SendNotification();
3432   finishCheck.CheckSignalReceived();
3433   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3434
3435   // Check that nothing has changed after a couple of buffer swaps
3436   application.Render(0);
3437   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3438   application.Render(0);
3439   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3440   END_TEST;
3441 }
3442
3443 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3444 {
3445   TestApplication application;
3446
3447   Actor actor = Actor::New();
3448
3449   // Register a float property
3450   float startValue(10.0f);
3451   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3452   Stage::GetCurrent().Add(actor);
3453   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3454   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3455
3456   // Build the animation
3457   float durationSeconds(1.0f);
3458   Animation animation = Animation::New(durationSeconds);
3459   float targetValue(30.0f);
3460   float relativeValue(targetValue - startValue);
3461   float delay = 0.5f;
3462   animation.AnimateBy(Property(actor, index),
3463                       relativeValue,
3464                       TimePeriod(delay, durationSeconds - delay));
3465
3466   // Start the animation
3467   animation.Play();
3468
3469   bool signalReceived(false);
3470   AnimationFinishCheck finishCheck(signalReceived);
3471   animation.FinishedSignal().Connect(&application, finishCheck);
3472
3473   application.SendNotification();
3474   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3475
3476   // We didn't expect the animation to finish yet
3477   application.SendNotification();
3478   finishCheck.CheckSignalNotReceived();
3479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3480
3481   application.SendNotification();
3482   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3483
3484   // We didn't expect the animation to finish yet
3485   application.SendNotification();
3486   finishCheck.CheckSignalNotReceived();
3487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3488
3489   application.SendNotification();
3490   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3491
3492   // We did expect the animation to finish
3493   application.SendNotification();
3494   finishCheck.CheckSignalReceived();
3495   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3496
3497   // Check that nothing has changed after a couple of buffer swaps
3498   application.Render(0);
3499   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3500   application.Render(0);
3501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3502   END_TEST;
3503 }
3504
3505 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3506 {
3507   TestApplication application;
3508
3509   Actor actor = Actor::New();
3510
3511   // Register a float property
3512   float startValue(10.0f);
3513   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3514   Stage::GetCurrent().Add(actor);
3515   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3516   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3517
3518   // Build the animation
3519   float durationSeconds(1.0f);
3520   Animation animation = Animation::New(durationSeconds);
3521   float targetValue(30.0f);
3522   float relativeValue(targetValue - startValue);
3523   float delay = 0.5f;
3524   animation.AnimateBy(Property(actor, index),
3525                       relativeValue,
3526                       AlphaFunction::LINEAR,
3527                       TimePeriod(delay, durationSeconds - delay));
3528
3529   // Start the animation
3530   animation.Play();
3531
3532   bool signalReceived(false);
3533   AnimationFinishCheck finishCheck(signalReceived);
3534   animation.FinishedSignal().Connect(&application, finishCheck);
3535
3536   application.SendNotification();
3537   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3538
3539   // We didn't expect the animation to finish yet
3540   application.SendNotification();
3541   finishCheck.CheckSignalNotReceived();
3542   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3543
3544   application.SendNotification();
3545   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3546
3547   // We didn't expect the animation to finish yet
3548   application.SendNotification();
3549   finishCheck.CheckSignalNotReceived();
3550   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3551
3552   application.SendNotification();
3553   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3554
3555   // We did expect the animation to finish
3556   application.SendNotification();
3557   finishCheck.CheckSignalReceived();
3558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3559
3560   // Check that nothing has changed after a couple of buffer swaps
3561   application.Render(0);
3562   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3563   application.Render(0);
3564   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3565   END_TEST;
3566 }
3567
3568 int UtcDaliAnimationAnimateByIntegerP(void)
3569 {
3570   TestApplication application;
3571
3572   Actor actor = Actor::New();
3573
3574   // Register an integer property
3575   int startValue(1);
3576   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3577   Stage::GetCurrent().Add(actor);
3578   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3579   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3580
3581   // Build the animation
3582   float durationSeconds(2.0f);
3583   Animation animation = Animation::New(durationSeconds);
3584   int targetValue(50);
3585   int relativeValue(targetValue - startValue);
3586   animation.AnimateBy(Property(actor, index), relativeValue);
3587
3588   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3589
3590   // Start the animation
3591   animation.Play();
3592
3593   // Target value should be retrievable straight away
3594   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), targetValue, TEST_LOCATION );
3595
3596   bool signalReceived(false);
3597   AnimationFinishCheck finishCheck(signalReceived);
3598   animation.FinishedSignal().Connect(&application, finishCheck);
3599
3600   application.SendNotification();
3601   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3602
3603   // We didn't expect the animation to finish yet
3604   application.SendNotification();
3605   finishCheck.CheckSignalNotReceived();
3606   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3607
3608   application.SendNotification();
3609   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3610
3611   // We did expect the animation to finish
3612   application.SendNotification();
3613   finishCheck.CheckSignalReceived();
3614   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3615
3616   // Check that nothing has changed after a couple of buffer swaps
3617   application.Render(0);
3618   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3619   application.Render(0);
3620   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3621   END_TEST;
3622 }
3623
3624 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3625 {
3626   TestApplication application;
3627
3628   Actor actor = Actor::New();
3629
3630   // Register an integer property
3631   int startValue(1);
3632   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3633   Stage::GetCurrent().Add(actor);
3634   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3635   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3636
3637   // Build the animation
3638   float durationSeconds(1.0f);
3639   Animation animation = Animation::New(durationSeconds);
3640   int targetValue(90);
3641   int relativeValue(targetValue - startValue);
3642   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3643
3644   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3645
3646   // Start the animation
3647   animation.Play();
3648
3649   bool signalReceived(false);
3650   AnimationFinishCheck finishCheck(signalReceived);
3651   animation.FinishedSignal().Connect(&application, finishCheck);
3652
3653   application.SendNotification();
3654   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3655
3656   // We didn't expect the animation to finish yet
3657   application.SendNotification();
3658   finishCheck.CheckSignalNotReceived();
3659
3660   // The position should have moved more, than with a linear alpha function
3661   int current( actor.GetCurrentProperty< int >( index ) );
3662   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3663
3664   application.SendNotification();
3665   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3666
3667   // We did expect the animation to finish
3668   application.SendNotification();
3669   finishCheck.CheckSignalReceived();
3670   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3671
3672   // Check that nothing has changed after a couple of buffer swaps
3673   application.Render(0);
3674   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3675   application.Render(0);
3676   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3677   END_TEST;
3678 }
3679
3680 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3681 {
3682   TestApplication application;
3683
3684   Actor actor = Actor::New();
3685
3686   // Register an integer property
3687   int startValue(10);
3688   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3689   Stage::GetCurrent().Add(actor);
3690   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3691   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3692
3693   // Build the animation
3694   float durationSeconds(1.0f);
3695   Animation animation = Animation::New(durationSeconds);
3696   int targetValue(30);
3697   int relativeValue(targetValue - startValue);
3698   float delay = 0.5f;
3699   animation.AnimateBy(Property(actor, index),
3700                       relativeValue,
3701                       TimePeriod(delay, durationSeconds - delay));
3702
3703   // Start the animation
3704   animation.Play();
3705
3706   bool signalReceived(false);
3707   AnimationFinishCheck finishCheck(signalReceived);
3708   animation.FinishedSignal().Connect(&application, finishCheck);
3709
3710   application.SendNotification();
3711   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3712
3713   // We didn't expect the animation to finish yet
3714   application.SendNotification();
3715   finishCheck.CheckSignalNotReceived();
3716   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3717
3718   application.SendNotification();
3719   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3720
3721   // We didn't expect the animation to finish yet
3722   application.SendNotification();
3723   finishCheck.CheckSignalNotReceived();
3724   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3725
3726   application.SendNotification();
3727   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3728
3729   // We did expect the animation to finish
3730   application.SendNotification();
3731   finishCheck.CheckSignalReceived();
3732   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3733
3734   // Check that nothing has changed after a couple of buffer swaps
3735   application.Render(0);
3736   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3737   application.Render(0);
3738   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3739   END_TEST;
3740 }
3741
3742 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3743 {
3744   TestApplication application;
3745
3746   Actor actor = Actor::New();
3747
3748   // Register an integer property
3749   int startValue(10);
3750   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3751   Stage::GetCurrent().Add(actor);
3752   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3753   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3754
3755   // Build the animation
3756   float durationSeconds(1.0f);
3757   Animation animation = Animation::New(durationSeconds);
3758   int targetValue(30);
3759   int relativeValue(targetValue - startValue);
3760   float delay = 0.5f;
3761   animation.AnimateBy(Property(actor, index),
3762                       relativeValue,
3763                       AlphaFunction::LINEAR,
3764                       TimePeriod(delay, durationSeconds - delay));
3765
3766   // Start the animation
3767   animation.Play();
3768
3769   bool signalReceived(false);
3770   AnimationFinishCheck finishCheck(signalReceived);
3771   animation.FinishedSignal().Connect(&application, finishCheck);
3772
3773   application.SendNotification();
3774   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3775
3776   // We didn't expect the animation to finish yet
3777   application.SendNotification();
3778   finishCheck.CheckSignalNotReceived();
3779   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3780
3781   application.SendNotification();
3782   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3783
3784   // We didn't expect the animation to finish yet
3785   application.SendNotification();
3786   finishCheck.CheckSignalNotReceived();
3787   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3788
3789   application.SendNotification();
3790   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3791
3792   // We did expect the animation to finish
3793   application.SendNotification();
3794   finishCheck.CheckSignalReceived();
3795   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3796
3797   // Check that nothing has changed after a couple of buffer swaps
3798   application.Render(0);
3799   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3800   application.Render(0);
3801   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3802   END_TEST;
3803 }
3804
3805 int UtcDaliAnimationAnimateByQuaternionP(void)
3806 {
3807   TestApplication application;
3808
3809   Actor actor = Actor::New();
3810
3811   // Register a quaternion property
3812   const Quaternion startValue( Degree( 90 ), Vector3::XAXIS );
3813   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3814   Stage::GetCurrent().Add(actor);
3815   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3816   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3817
3818   // Build the animation
3819   float durationSeconds(2.0f);
3820   Animation animation = Animation::New(durationSeconds);
3821   const Quaternion relativeValue( Degree( 90 ), Vector3::ZAXIS );
3822   const Quaternion finalValue( startValue * relativeValue );
3823   animation.AnimateBy(Property(actor, index), relativeValue);
3824
3825   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == startValue );
3826   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == startValue );
3827
3828   // Start the animation
3829   animation.Play();
3830
3831   // Target value should be retrievable straight away
3832   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3833
3834   application.SendNotification();
3835   application.Render( 2000 ); // animation complete
3836
3837   DALI_TEST_CHECK( actor.GetProperty< Quaternion >(index) == finalValue );
3838   DALI_TEST_CHECK( actor.GetCurrentProperty< Quaternion >( index ) == finalValue );
3839
3840   END_TEST;
3841 }
3842
3843 int UtcDaliAnimationAnimateByVector2P(void)
3844 {
3845   TestApplication application;
3846
3847   Actor actor = Actor::New();
3848
3849   // Register a Vector2 property
3850   Vector2 startValue(10.0f, 10.0f);
3851   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3852   Stage::GetCurrent().Add(actor);
3853   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3854   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3855
3856   // Build the animation
3857   float durationSeconds(2.0f);
3858   Animation animation = Animation::New(durationSeconds);
3859   Vector2 targetValue(60.0f, 60.0f);
3860   Vector2 relativeValue(targetValue - startValue);
3861   animation.AnimateBy(Property(actor, index), relativeValue);
3862
3863   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3864
3865   // Start the animation
3866   animation.Play();
3867
3868   // Target value should be retrievable straight away
3869   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3870
3871   bool signalReceived(false);
3872   AnimationFinishCheck finishCheck(signalReceived);
3873   animation.FinishedSignal().Connect(&application, finishCheck);
3874
3875   application.SendNotification();
3876   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3877
3878   // We didn't expect the animation to finish yet
3879   application.SendNotification();
3880   finishCheck.CheckSignalNotReceived();
3881   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3882
3883   application.SendNotification();
3884   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3885
3886   // We did expect the animation to finish
3887   application.SendNotification();
3888   finishCheck.CheckSignalReceived();
3889   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3890
3891   // Check that nothing has changed after a couple of buffer swaps
3892   application.Render(0);
3893   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3894   application.Render(0);
3895   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3896   END_TEST;
3897 }
3898
3899 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3900 {
3901   TestApplication application;
3902
3903   Actor actor = Actor::New();
3904
3905   // Register a Vector2 property
3906   Vector2 startValue(100.0f, 100.0f);
3907   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3908   Stage::GetCurrent().Add(actor);
3909   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3910   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3911
3912   // Build the animation
3913   float durationSeconds(1.0f);
3914   Animation animation = Animation::New(durationSeconds);
3915   Vector2 targetValue(20.0f, 20.0f);
3916   Vector2 relativeValue(targetValue - startValue);
3917   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3918
3919   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3920
3921   // Start the animation
3922   animation.Play();
3923
3924   bool signalReceived(false);
3925   AnimationFinishCheck finishCheck(signalReceived);
3926   animation.FinishedSignal().Connect(&application, finishCheck);
3927
3928   application.SendNotification();
3929   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3930
3931   // We didn't expect the animation to finish yet
3932   application.SendNotification();
3933   finishCheck.CheckSignalNotReceived();
3934
3935   // The position should have moved more, than with a linear alpha function
3936   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3937   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3938   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3939
3940   application.SendNotification();
3941   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3942
3943   // We did expect the animation to finish
3944   application.SendNotification();
3945   finishCheck.CheckSignalReceived();
3946   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3947
3948   // Check that nothing has changed after a couple of buffer swaps
3949   application.Render(0);
3950   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3951   application.Render(0);
3952   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3953   END_TEST;
3954 }
3955
3956 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3957 {
3958   TestApplication application;
3959
3960   Actor actor = Actor::New();
3961
3962   // Register a Vector2 property
3963   Vector2 startValue(10.0f, 10.0f);
3964   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3965   Stage::GetCurrent().Add(actor);
3966   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3967   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3968
3969   // Build the animation
3970   float durationSeconds(1.0f);
3971   Animation animation = Animation::New(durationSeconds);
3972   Vector2 targetValue(30.0f, 30.0f);
3973   Vector2 relativeValue(targetValue - startValue);
3974   float delay = 0.5f;
3975   animation.AnimateBy(Property(actor, index),
3976                       relativeValue,
3977                       TimePeriod(delay, durationSeconds - delay));
3978
3979   // Start the animation
3980   animation.Play();
3981
3982   bool signalReceived(false);
3983   AnimationFinishCheck finishCheck(signalReceived);
3984   animation.FinishedSignal().Connect(&application, finishCheck);
3985
3986   application.SendNotification();
3987   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3988
3989   // We didn't expect the animation to finish yet
3990   application.SendNotification();
3991   finishCheck.CheckSignalNotReceived();
3992   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3993
3994   application.SendNotification();
3995   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3996
3997   // We didn't expect the animation to finish yet
3998   application.SendNotification();
3999   finishCheck.CheckSignalNotReceived();
4000   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4001
4002   application.SendNotification();
4003   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4004
4005   // We did expect the animation to finish
4006   application.SendNotification();
4007   finishCheck.CheckSignalReceived();
4008   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4009
4010   // Check that nothing has changed after a couple of buffer swaps
4011   application.Render(0);
4012   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4013   application.Render(0);
4014   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4015   END_TEST;
4016 }
4017
4018 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
4019 {
4020   TestApplication application;
4021
4022   Actor actor = Actor::New();
4023
4024   // Register a Vector2 property
4025   Vector2 startValue(5.0f, 5.0f);
4026   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4027   Stage::GetCurrent().Add(actor);
4028   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4029   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
4030
4031   // Build the animation
4032   float durationSeconds(1.0f);
4033   Animation animation = Animation::New(durationSeconds);
4034   Vector2 targetValue(10.0f, 10.0f);
4035   Vector2 relativeValue(targetValue - startValue);
4036   float delay = 0.5f;
4037   animation.AnimateBy(Property(actor, index),
4038                       relativeValue,
4039                       AlphaFunction::LINEAR,
4040                       TimePeriod(delay, durationSeconds - delay));
4041
4042   // Start the animation
4043   animation.Play();
4044
4045   bool signalReceived(false);
4046   AnimationFinishCheck finishCheck(signalReceived);
4047   animation.FinishedSignal().Connect(&application, finishCheck);
4048
4049   application.SendNotification();
4050   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4051
4052   // We didn't expect the animation to finish yet
4053   application.SendNotification();
4054   finishCheck.CheckSignalNotReceived();
4055   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
4056
4057   application.SendNotification();
4058   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4059
4060   // We didn't expect the animation to finish yet
4061   application.SendNotification();
4062   finishCheck.CheckSignalNotReceived();
4063   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4064
4065   application.SendNotification();
4066   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4067
4068   // We did expect the animation to finish
4069   application.SendNotification();
4070   finishCheck.CheckSignalReceived();
4071   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4072
4073   // Check that nothing has changed after a couple of buffer swaps
4074   application.Render(0);
4075   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4076   application.Render(0);
4077   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
4078   END_TEST;
4079 }
4080
4081 int UtcDaliAnimationAnimateByVector3P(void)
4082 {
4083   TestApplication application;
4084
4085   Actor actor = Actor::New();
4086
4087   // Register a Vector3 property
4088   Vector3 startValue(10.0f, 10.0f, 10.0f);
4089   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4090   Stage::GetCurrent().Add(actor);
4091   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4092   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4093
4094   // Build the animation
4095   float durationSeconds(2.0f);
4096   Animation animation = Animation::New(durationSeconds);
4097   Vector3 targetValue(60.0f, 60.0f, 60.0f);
4098   Vector3 relativeValue(targetValue - startValue);
4099   animation.AnimateBy(Property(actor, index), relativeValue);
4100
4101   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4102
4103   // Start the animation
4104   animation.Play();
4105
4106   // Target value should be retrievable straight away
4107   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4108
4109   bool signalReceived(false);
4110   AnimationFinishCheck finishCheck(signalReceived);
4111   animation.FinishedSignal().Connect(&application, finishCheck);
4112
4113   application.SendNotification();
4114   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4115
4116   // We didn't expect the animation to finish yet
4117   application.SendNotification();
4118   finishCheck.CheckSignalNotReceived();
4119   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4120
4121   application.SendNotification();
4122   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4123
4124   // We did expect the animation to finish
4125   application.SendNotification();
4126   finishCheck.CheckSignalReceived();
4127   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4128
4129   // Check that nothing has changed after a couple of buffer swaps
4130   application.Render(0);
4131   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4132   application.Render(0);
4133   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4134   END_TEST;
4135 }
4136
4137 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
4138 {
4139   TestApplication application;
4140
4141   Actor actor = Actor::New();
4142
4143   // Register a Vector3 property
4144   Vector3 startValue(100.0f, 100.0f, 100.0f);
4145   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4146   Stage::GetCurrent().Add(actor);
4147   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4148   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4149
4150   // Build the animation
4151   float durationSeconds(1.0f);
4152   Animation animation = Animation::New(durationSeconds);
4153   Vector3 targetValue(20.0f, 20.0f, 20.0f);
4154   Vector3 relativeValue(targetValue - startValue);
4155   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4156
4157   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4158
4159   // Start the animation
4160   animation.Play();
4161
4162   bool signalReceived(false);
4163   AnimationFinishCheck finishCheck(signalReceived);
4164   animation.FinishedSignal().Connect(&application, finishCheck);
4165
4166   application.SendNotification();
4167   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4168
4169   // We didn't expect the animation to finish yet
4170   application.SendNotification();
4171   finishCheck.CheckSignalNotReceived();
4172
4173   // The position should have moved more, than with a linear alpha function
4174   Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
4175   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4176   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4177   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4178
4179   application.SendNotification();
4180   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4181
4182   // We did expect the animation to finish
4183   application.SendNotification();
4184   finishCheck.CheckSignalReceived();
4185   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4186
4187   // Check that nothing has changed after a couple of buffer swaps
4188   application.Render(0);
4189   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4190   application.Render(0);
4191   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4192   END_TEST;
4193 }
4194
4195 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
4196 {
4197   TestApplication application;
4198
4199   Actor actor = Actor::New();
4200
4201   // Register a Vector3 property
4202   Vector3 startValue(10.0f, 10.0f, 10.0f);
4203   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4204   Stage::GetCurrent().Add(actor);
4205   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4206   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4207
4208   // Build the animation
4209   float durationSeconds(1.0f);
4210   Animation animation = Animation::New(durationSeconds);
4211   Vector3 targetValue(30.0f, 30.0f, 30.0f);
4212   Vector3 relativeValue(targetValue - startValue);
4213   float delay = 0.5f;
4214   animation.AnimateBy(Property(actor, index),
4215                       relativeValue,
4216                       TimePeriod(delay, durationSeconds - delay));
4217
4218   // Start the animation
4219   animation.Play();
4220
4221   bool signalReceived(false);
4222   AnimationFinishCheck finishCheck(signalReceived);
4223   animation.FinishedSignal().Connect(&application, finishCheck);
4224
4225   application.SendNotification();
4226   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4227
4228   // We didn't expect the animation to finish yet
4229   application.SendNotification();
4230   finishCheck.CheckSignalNotReceived();
4231   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4232
4233   application.SendNotification();
4234   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4235
4236   // We didn't expect the animation to finish yet
4237   application.SendNotification();
4238   finishCheck.CheckSignalNotReceived();
4239   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4240
4241   application.SendNotification();
4242   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4243
4244   // We did expect the animation to finish
4245   application.SendNotification();
4246   finishCheck.CheckSignalReceived();
4247   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4248
4249   // Check that nothing has changed after a couple of buffer swaps
4250   application.Render(0);
4251   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4252   application.Render(0);
4253   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4254   END_TEST;
4255 }
4256
4257 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
4258 {
4259   TestApplication application;
4260
4261   Actor actor = Actor::New();
4262
4263   // Register a Vector3 property
4264   Vector3 startValue(5.0f, 5.0f, 5.0f);
4265   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4266   Stage::GetCurrent().Add(actor);
4267   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4268   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4269
4270   // Build the animation
4271   float durationSeconds(1.0f);
4272   Animation animation = Animation::New(durationSeconds);
4273   Vector3 targetValue(10.0f, 10.0f, 10.0f);
4274   Vector3 relativeValue(targetValue - startValue);
4275   float delay = 0.5f;
4276   animation.AnimateBy(Property(actor, index),
4277                       relativeValue,
4278                       AlphaFunction::LINEAR,
4279                       TimePeriod(delay, durationSeconds - delay));
4280
4281   // Start the animation
4282   animation.Play();
4283
4284   bool signalReceived(false);
4285   AnimationFinishCheck finishCheck(signalReceived);
4286   animation.FinishedSignal().Connect(&application, finishCheck);
4287
4288   application.SendNotification();
4289   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4290
4291   // We didn't expect the animation to finish yet
4292   application.SendNotification();
4293   finishCheck.CheckSignalNotReceived();
4294   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
4295
4296   application.SendNotification();
4297   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4298
4299   // We didn't expect the animation to finish yet
4300   application.SendNotification();
4301   finishCheck.CheckSignalNotReceived();
4302   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4303
4304   application.SendNotification();
4305   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4306
4307   // We did expect the animation to finish
4308   application.SendNotification();
4309   finishCheck.CheckSignalReceived();
4310   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4311
4312   // Check that nothing has changed after a couple of buffer swaps
4313   application.Render(0);
4314   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4315   application.Render(0);
4316   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4317   END_TEST;
4318 }
4319
4320 int UtcDaliAnimationAnimateByVector4P(void)
4321 {
4322   TestApplication application;
4323
4324   Actor actor = Actor::New();
4325
4326   // Register a Vector4 property
4327   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4328   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4329   Stage::GetCurrent().Add(actor);
4330   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4331   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4332
4333   // Build the animation
4334   float durationSeconds(2.0f);
4335   Animation animation = Animation::New(durationSeconds);
4336   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4337   Vector4 relativeValue(targetValue - startValue);
4338   animation.AnimateBy(Property(actor, index), relativeValue);
4339
4340   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4341
4342   // Start the animation
4343   animation.Play();
4344
4345   // Target value should be retrievable straight away
4346   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4347
4348   bool signalReceived(false);
4349   AnimationFinishCheck finishCheck(signalReceived);
4350   animation.FinishedSignal().Connect(&application, finishCheck);
4351
4352   application.SendNotification();
4353   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4354
4355   // We didn't expect the animation to finish yet
4356   application.SendNotification();
4357   finishCheck.CheckSignalNotReceived();
4358   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4359
4360   application.SendNotification();
4361   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4362
4363   // We did expect the animation to finish
4364   application.SendNotification();
4365   finishCheck.CheckSignalReceived();
4366   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4367
4368   // Check that nothing has changed after a couple of buffer swaps
4369   application.Render(0);
4370   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4371   application.Render(0);
4372   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4373   END_TEST;
4374 }
4375
4376 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4377 {
4378   TestApplication application;
4379
4380   Actor actor = Actor::New();
4381
4382   // Register a Vector4 property
4383   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4384   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4385   Stage::GetCurrent().Add(actor);
4386   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4387   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4388
4389   // Build the animation
4390   float durationSeconds(1.0f);
4391   Animation animation = Animation::New(durationSeconds);
4392   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4393   Vector4 relativeValue(targetValue - startValue);
4394   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4395
4396   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4397
4398   // Start the animation
4399   animation.Play();
4400
4401   bool signalReceived(false);
4402   AnimationFinishCheck finishCheck(signalReceived);
4403   animation.FinishedSignal().Connect(&application, finishCheck);
4404
4405   application.SendNotification();
4406   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4407
4408   // We didn't expect the animation to finish yet
4409   application.SendNotification();
4410   finishCheck.CheckSignalNotReceived();
4411
4412   // The position should have moved more, than with a linear alpha function
4413   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4414   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4415   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4416   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4417   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4418
4419   application.SendNotification();
4420   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4421
4422   // We did expect the animation to finish
4423   application.SendNotification();
4424   finishCheck.CheckSignalReceived();
4425   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4426
4427   // Check that nothing has changed after a couple of buffer swaps
4428   application.Render(0);
4429   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4430   application.Render(0);
4431   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4432   END_TEST;
4433 }
4434
4435 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4436 {
4437   TestApplication application;
4438
4439   Actor actor = Actor::New();
4440
4441   // Register a Vector4 property
4442   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4443   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4444   Stage::GetCurrent().Add(actor);
4445   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4446   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4447
4448   // Build the animation
4449   float durationSeconds(1.0f);
4450   Animation animation = Animation::New(durationSeconds);
4451   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4452   Vector4 relativeValue(targetValue - startValue);
4453   float delay = 0.5f;
4454   animation.AnimateBy(Property(actor, index),
4455                       relativeValue,
4456                       TimePeriod(delay, durationSeconds - delay));
4457
4458   // Start the animation
4459   animation.Play();
4460
4461   bool signalReceived(false);
4462   AnimationFinishCheck finishCheck(signalReceived);
4463   animation.FinishedSignal().Connect(&application, finishCheck);
4464
4465   application.SendNotification();
4466   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4467
4468   // We didn't expect the animation to finish yet
4469   application.SendNotification();
4470   finishCheck.CheckSignalNotReceived();
4471   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4472
4473   application.SendNotification();
4474   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4475
4476   // We didn't expect the animation to finish yet
4477   application.SendNotification();
4478   finishCheck.CheckSignalNotReceived();
4479   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4480
4481   application.SendNotification();
4482   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4483
4484   // We did expect the animation to finish
4485   application.SendNotification();
4486   finishCheck.CheckSignalReceived();
4487   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4488
4489   // Check that nothing has changed after a couple of buffer swaps
4490   application.Render(0);
4491   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4492   application.Render(0);
4493   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4494   END_TEST;
4495 }
4496
4497 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4498 {
4499   TestApplication application;
4500
4501   Actor actor = Actor::New();
4502
4503   // Register a Vector4 property
4504   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4505   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4506   Stage::GetCurrent().Add(actor);
4507   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4508   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4509
4510   // Build the animation
4511   float durationSeconds(1.0f);
4512   Animation animation = Animation::New(durationSeconds);
4513   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4514   Vector4 relativeValue(targetValue - startValue);
4515   float delay = 0.5f;
4516   animation.AnimateBy(Property(actor, index),
4517                       relativeValue,
4518                       AlphaFunction::LINEAR,
4519                       TimePeriod(delay, durationSeconds - delay));
4520
4521   // Start the animation
4522   animation.Play();
4523
4524   bool signalReceived(false);
4525   AnimationFinishCheck finishCheck(signalReceived);
4526   animation.FinishedSignal().Connect(&application, finishCheck);
4527
4528   application.SendNotification();
4529   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4530
4531   // We didn't expect the animation to finish yet
4532   application.SendNotification();
4533   finishCheck.CheckSignalNotReceived();
4534   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4535
4536   application.SendNotification();
4537   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4538
4539   // We didn't expect the animation to finish yet
4540   application.SendNotification();
4541   finishCheck.CheckSignalNotReceived();
4542   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4543
4544   application.SendNotification();
4545   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4546
4547   // We did expect the animation to finish
4548   application.SendNotification();
4549   finishCheck.CheckSignalReceived();
4550   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4551
4552   // Check that nothing has changed after a couple of buffer swaps
4553   application.Render(0);
4554   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4555   application.Render(0);
4556   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4557   END_TEST;
4558 }
4559
4560 int UtcDaliAnimationAnimateByActorPositionP(void)
4561 {
4562   TestApplication application;
4563
4564   Actor actor = Actor::New();
4565   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4566   actor.SetPosition(startPosition);
4567   Stage::GetCurrent().Add(actor);
4568   application.SendNotification();
4569   application.Render(0);
4570   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4571
4572   // Build the animation
4573   float durationSeconds(1.0f);
4574   Animation animation = Animation::New(durationSeconds);
4575   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4576   Vector3 relativePosition(targetPosition - startPosition);
4577   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4578
4579   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4580
4581   // Start the animation
4582   animation.Play();
4583
4584   // Target value should be retrievable straight away
4585   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4586
4587   bool signalReceived(false);
4588   AnimationFinishCheck finishCheck(signalReceived);
4589   animation.FinishedSignal().Connect(&application, finishCheck);
4590
4591   application.SendNotification();
4592   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4593
4594   // We didn't expect the animation to finish yet
4595   application.SendNotification();
4596   finishCheck.CheckSignalNotReceived();
4597   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ninetyFivePercentProgress, TEST_LOCATION );
4598
4599   application.SendNotification();
4600   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4601
4602   // We did expect the animation to finish
4603   application.SendNotification();
4604   finishCheck.CheckSignalReceived();
4605   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4606
4607   // Check that nothing has changed after a couple of buffer swaps
4608   application.Render(0);
4609   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4610   application.Render(0);
4611   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4612   END_TEST;
4613 }
4614
4615 int UtcDaliAnimationAnimateByActorPositionComponentsP(void)
4616 {
4617   TestApplication application;
4618
4619   Actor actor = Actor::New();
4620   Stage::GetCurrent().Add(actor);
4621   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4622
4623   // Build the animation
4624   float durationSeconds(1.0f);
4625   Animation animation = Animation::New(durationSeconds);
4626   Vector3 targetPosition(200.0f, 300.0f, 400.0f);
4627   Vector3 relativePosition(targetPosition - Vector3::ZERO);
4628   animation.AnimateBy( Property( actor, Actor::Property::POSITION_X ), relativePosition.x );
4629   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Y ), relativePosition.y );
4630   animation.AnimateBy( Property( actor, Actor::Property::POSITION_Z ), relativePosition.z );
4631
4632   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4633   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
4634
4635   // Start the animation
4636   animation.Play();
4637
4638   // Target value should be retrievable straight away
4639   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4640   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
4641   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
4642   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
4643
4644   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
4645
4646   application.SendNotification();
4647   application.Render( 1000 ); // 1 second progress
4648
4649   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4650
4651   END_TEST;
4652 }
4653
4654 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4655 {
4656   TestApplication application;
4657
4658   Actor actor = Actor::New();
4659   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4660   actor.SetPosition(startPosition);
4661   Stage::GetCurrent().Add(actor);
4662   application.SendNotification();
4663   application.Render(0);
4664   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4665
4666   // Build the animation
4667   float durationSeconds(1.0f);
4668   Animation animation = Animation::New(durationSeconds);
4669   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4670   Vector3 relativePosition(targetPosition - startPosition);
4671   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4672
4673   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4674
4675   // Start the animation
4676   animation.Play();
4677
4678   bool signalReceived(false);
4679   AnimationFinishCheck finishCheck(signalReceived);
4680   animation.FinishedSignal().Connect(&application, finishCheck);
4681
4682   application.SendNotification();
4683   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4684
4685   // We didn't expect the animation to finish yet
4686   application.SendNotification();
4687   finishCheck.CheckSignalNotReceived();
4688
4689   // The position should have moved more, than with a linear alpha function
4690   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
4691   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4692   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4693   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4694
4695   application.SendNotification();
4696   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4697
4698   // We did expect the animation to finish
4699   application.SendNotification();
4700   finishCheck.CheckSignalReceived();
4701   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4702
4703   // Check that nothing has changed after a couple of buffer swaps
4704   application.Render(0);
4705   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4706   application.Render(0);
4707   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4708   END_TEST;
4709 }
4710
4711 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4712 {
4713   TestApplication application;
4714
4715   Actor actor = Actor::New();
4716   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4717   actor.SetPosition(startPosition);
4718   Stage::GetCurrent().Add(actor);
4719   application.SendNotification();
4720   application.Render(0);
4721   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4722
4723   // Build the animation
4724   float durationSeconds(1.0f);
4725   Animation animation = Animation::New(durationSeconds);
4726   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4727   Vector3 relativePosition(targetPosition - startPosition);
4728   float delay = 0.5f;
4729   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4730                       relativePosition,
4731                       TimePeriod(delay, durationSeconds - delay));
4732
4733   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4734
4735   // Start the animation
4736   animation.Play();
4737
4738   bool signalReceived(false);
4739   AnimationFinishCheck finishCheck(signalReceived);
4740   animation.FinishedSignal().Connect(&application, finishCheck);
4741
4742   application.SendNotification();
4743   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4744
4745   // We didn't expect the animation to finish yet
4746   application.SendNotification();
4747   finishCheck.CheckSignalNotReceived();
4748   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4749
4750   application.SendNotification();
4751   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4752
4753   // We did expect the animation to finish
4754   application.SendNotification();
4755   finishCheck.CheckSignalReceived();
4756   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4757
4758   // Check that nothing has changed after a couple of buffer swaps
4759   application.Render(0);
4760   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4761   application.Render(0);
4762   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4763   END_TEST;
4764 }
4765
4766 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4767 {
4768   TestApplication application;
4769
4770   Actor actor = Actor::New();
4771   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4772   actor.SetPosition(startPosition);
4773   Stage::GetCurrent().Add(actor);
4774   application.SendNotification();
4775   application.Render(0);
4776   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4777
4778   // Build the animation
4779   float durationSeconds(1.0f);
4780   Animation animation = Animation::New(durationSeconds);
4781   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4782   Vector3 relativePosition(targetPosition - startPosition);
4783   float delay = 0.5f;
4784   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4785                       relativePosition,
4786                       AlphaFunction::LINEAR,
4787                       TimePeriod(delay, durationSeconds - delay));
4788
4789   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4790
4791   // Start the animation
4792   animation.Play();
4793
4794   bool signalReceived(false);
4795   AnimationFinishCheck finishCheck(signalReceived);
4796   animation.FinishedSignal().Connect(&application, finishCheck);
4797
4798   application.SendNotification();
4799   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4800
4801   // We didn't expect the animation to finish yet
4802   application.SendNotification();
4803   finishCheck.CheckSignalNotReceived();
4804   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), startPosition, TEST_LOCATION );
4805
4806   application.SendNotification();
4807   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4808
4809   // We did expect the animation to finish
4810   application.SendNotification();
4811   finishCheck.CheckSignalReceived();
4812   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4813
4814   // Check that nothing has changed after a couple of buffer swaps
4815   application.Render(0);
4816   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4817   application.Render(0);
4818   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
4819   END_TEST;
4820 }
4821
4822 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4823 {
4824   TestApplication application;
4825
4826   Actor actor = Actor::New();
4827   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4828   Stage::GetCurrent().Add(actor);
4829   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4830
4831   // Build the animation
4832   float durationSeconds(1.0f);
4833   Animation animation = Animation::New(durationSeconds);
4834   Degree relativeRotationDegrees(360.0f);
4835   Radian relativeRotationRadians(relativeRotationDegrees);
4836   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4837
4838   // Start the animation
4839   animation.Play();
4840
4841   // Target value should be retrievable straight away
4842   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), TEST_LOCATION );
4843
4844   bool signalReceived(false);
4845   AnimationFinishCheck finishCheck(signalReceived);
4846   animation.FinishedSignal().Connect(&application, finishCheck);
4847
4848   application.SendNotification();
4849   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4850
4851   // We didn't expect the animation to finish yet
4852   application.SendNotification();
4853   finishCheck.CheckSignalNotReceived();
4854   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4855
4856   application.SendNotification();
4857   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4858
4859   // We didn't expect the animation to finish yet
4860   application.SendNotification();
4861   finishCheck.CheckSignalNotReceived();
4862   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4863
4864   application.SendNotification();
4865   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4866
4867   // We didn't expect the animation to finish yet
4868   application.SendNotification();
4869   finishCheck.CheckSignalNotReceived();
4870   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4871
4872   application.SendNotification();
4873   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4874
4875   // We did expect the animation to finish
4876   application.SendNotification();
4877   finishCheck.CheckSignalReceived();
4878   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4879   END_TEST;
4880 }
4881
4882 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4883 {
4884   TestApplication application;
4885
4886   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4887
4888   Actor actor = Actor::New();
4889   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4890   Stage::GetCurrent().Add(actor);
4891   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4892
4893   // Build the animation
4894   float durationSeconds(1.0f);
4895   Animation animation = Animation::New(durationSeconds);
4896   Degree relativeRotationDegrees(710.0f);
4897   Radian relativeRotationRadians(relativeRotationDegrees);
4898
4899   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4900
4901   // Start the animation
4902   animation.Play();
4903
4904   bool signalReceived(false);
4905   AnimationFinishCheck finishCheck(signalReceived);
4906   animation.FinishedSignal().Connect(&application, finishCheck);
4907
4908   application.SendNotification();
4909   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4910
4911   // We didn't expect the animation to finish yet
4912   application.SendNotification();
4913   finishCheck.CheckSignalNotReceived();
4914   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4915
4916   application.SendNotification();
4917   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4918
4919   // We didn't expect the animation to finish yet
4920   application.SendNotification();
4921   finishCheck.CheckSignalNotReceived();
4922   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4923
4924   application.SendNotification();
4925   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4926
4927   // We didn't expect the animation to finish yet
4928   application.SendNotification();
4929   finishCheck.CheckSignalNotReceived();
4930   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4931
4932   application.SendNotification();
4933   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4934
4935   // We did expect the animation to finish
4936   application.SendNotification();
4937   finishCheck.CheckSignalReceived();
4938   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4939   END_TEST;
4940 }
4941
4942
4943 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4944 {
4945   TestApplication application;
4946
4947   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4948
4949   Actor actor = Actor::New();
4950   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4951   Stage::GetCurrent().Add(actor);
4952   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4953
4954   // Build the animation
4955   float durationSeconds(1.0f);
4956   Animation animation = Animation::New(durationSeconds);
4957   Degree relativeRotationDegrees(730.0f);
4958   Radian relativeRotationRadians(relativeRotationDegrees);
4959
4960   Radian actualRotationRadians( Degree(10.0f) );
4961
4962   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4963
4964   // Start the animation
4965   animation.Play();
4966
4967   bool signalReceived(false);
4968   AnimationFinishCheck finishCheck(signalReceived);
4969   animation.FinishedSignal().Connect(&application, finishCheck);
4970
4971   application.SendNotification();
4972   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4973
4974   // We didn't expect the animation to finish yet
4975   application.SendNotification();
4976   finishCheck.CheckSignalNotReceived();
4977   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4978
4979   application.SendNotification();
4980   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4981
4982   // We didn't expect the animation to finish yet
4983   application.SendNotification();
4984   finishCheck.CheckSignalNotReceived();
4985   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4986
4987   application.SendNotification();
4988   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4989
4990   // We didn't expect the animation to finish yet
4991   application.SendNotification();
4992   finishCheck.CheckSignalNotReceived();
4993   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4994
4995   application.SendNotification();
4996   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4997
4998   // We did expect the animation to finish
4999   application.SendNotification();
5000   finishCheck.CheckSignalReceived();
5001   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
5002   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
5003   END_TEST;
5004 }
5005
5006
5007 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
5008 {
5009   TestApplication application;
5010
5011   Actor actor = Actor::New();
5012   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
5013   Stage::GetCurrent().Add(actor);
5014   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
5015
5016   // Build the animation
5017   float durationSeconds(1.0f);
5018   Animation animation = Animation::New(durationSeconds);
5019   Degree relativeRotationDegrees(360.0f);
5020   Radian relativeRotationRadians(relativeRotationDegrees);
5021   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
5022
5023   // Start the animation
5024   animation.Play();
5025
5026   bool signalReceived(false);
5027   AnimationFinishCheck finishCheck(signalReceived);
5028   animation.FinishedSignal().Connect(&application, finishCheck);
5029
5030   application.SendNotification();
5031   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5032
5033   // We didn't expect the animation to finish yet
5034   application.SendNotification();
5035   finishCheck.CheckSignalNotReceived();
5036   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5037
5038   application.SendNotification();
5039   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5040
5041   // We didn't expect the animation to finish yet
5042   application.SendNotification();
5043   finishCheck.CheckSignalNotReceived();
5044   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5045
5046   application.SendNotification();
5047   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5048
5049   // We didn't expect the animation to finish yet
5050   application.SendNotification();
5051   finishCheck.CheckSignalNotReceived();
5052   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5053
5054   application.SendNotification();
5055   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5056
5057   // We did expect the animation to finish
5058   application.SendNotification();
5059   finishCheck.CheckSignalReceived();
5060   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5061   END_TEST;
5062 }
5063
5064 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
5065 {
5066   TestApplication application;
5067
5068   Actor actor = Actor::New();
5069   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
5070   Stage::GetCurrent().Add(actor);
5071   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
5072
5073   // Build the animation
5074   float durationSeconds(1.0f);
5075   Animation animation = Animation::New(durationSeconds);
5076   Degree relativeRotationDegrees(360.0f);
5077   Radian relativeRotationRadians(relativeRotationDegrees);
5078   float delay = 0.3f;
5079   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
5080                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
5081
5082   // Start the animation
5083   animation.Play();
5084
5085   bool signalReceived(false);
5086   AnimationFinishCheck finishCheck(signalReceived);
5087   animation.FinishedSignal().Connect(&application, finishCheck);
5088
5089   application.SendNotification();
5090   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
5091
5092   // We didn't expect the animation to finish yet
5093   application.SendNotification();
5094   finishCheck.CheckSignalNotReceived();
5095   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
5096   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5097
5098   application.SendNotification();
5099   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
5100
5101   // We didn't expect the animation to finish yet
5102   application.SendNotification();
5103   finishCheck.CheckSignalNotReceived();
5104   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
5105   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5106
5107   application.SendNotification();
5108   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
5109
5110   // We didn't expect the animation to finish yet
5111   application.SendNotification();
5112   finishCheck.CheckSignalNotReceived();
5113   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
5114   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5115
5116   application.SendNotification();
5117   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5118
5119   // We did expect the animation to finish
5120   application.SendNotification();
5121   finishCheck.CheckSignalReceived();
5122   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
5123   END_TEST;
5124 }
5125
5126 int UtcDaliAnimationAnimateByActorScaleP(void)
5127 {
5128   TestApplication application;
5129
5130   Actor actor = Actor::New();
5131   Stage::GetCurrent().Add(actor);
5132   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5133
5134   // Build the animation
5135   float durationSeconds(1.0f);
5136   Animation animation = Animation::New(durationSeconds);
5137   Vector3 targetScale(2.0f, 2.0f, 2.0f);
5138   Vector3 relativeScale(targetScale - Vector3::ONE);
5139   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
5140
5141   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
5142
5143   // Start the animation
5144   animation.Play();
5145
5146   // Target value should be retrievable straight away
5147   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5148
5149   bool signalReceived(false);
5150   AnimationFinishCheck finishCheck(signalReceived);
5151   animation.FinishedSignal().Connect(&application, finishCheck);
5152
5153   application.SendNotification();
5154   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5155
5156   // We didn't expect the animation to finish yet
5157   application.SendNotification();
5158   finishCheck.CheckSignalNotReceived();
5159   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), ninetyNinePercentProgress, TEST_LOCATION );
5160
5161   application.SendNotification();
5162   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5163
5164   // We did expect the animation to finish
5165   application.SendNotification();
5166   finishCheck.CheckSignalReceived();
5167   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5168
5169   // Reset everything
5170   finishCheck.Reset();
5171   actor.SetScale(Vector3::ONE);
5172   application.SendNotification();
5173   application.Render(0);
5174   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5175
5176   // Repeat with a different (ease-in) alpha function
5177   animation = Animation::New(durationSeconds);
5178   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
5179   animation.FinishedSignal().Connect(&application, finishCheck);
5180   animation.Play();
5181
5182   application.SendNotification();
5183   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5184
5185   // We didn't expect the animation to finish yet
5186   application.SendNotification();
5187   finishCheck.CheckSignalNotReceived();
5188
5189   // The scale should have grown less, than with a linear alpha function
5190   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
5191   DALI_TEST_CHECK( current.x > 1.0f );
5192   DALI_TEST_CHECK( current.y > 1.0f );
5193   DALI_TEST_CHECK( current.z > 1.0f );
5194   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5195   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5196   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5197
5198   application.SendNotification();
5199   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5200
5201   // We did expect the animation to finish
5202   application.SendNotification();
5203   finishCheck.CheckSignalReceived();
5204   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5205
5206   // Reset everything
5207   finishCheck.Reset();
5208   actor.SetScale(Vector3::ONE);
5209   application.SendNotification();
5210   application.Render(0);
5211   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5212
5213   // Repeat with a delay
5214   float delay = 0.5f;
5215   animation = Animation::New(durationSeconds);
5216   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
5217   animation.FinishedSignal().Connect(&application, finishCheck);
5218   animation.Play();
5219
5220   application.SendNotification();
5221   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5222
5223   // We didn't expect the animation to finish yet
5224   application.SendNotification();
5225   finishCheck.CheckSignalNotReceived();
5226   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5227
5228   application.SendNotification();
5229   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5230
5231   // We did expect the animation to finish
5232   application.SendNotification();
5233   finishCheck.CheckSignalReceived();
5234   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5235   END_TEST;
5236 }
5237
5238 int UtcDaliAnimationAnimateByActorScaleComponentsP(void)
5239 {
5240   TestApplication application;
5241
5242   Actor actor = Actor::New();
5243   Stage::GetCurrent().Add(actor);
5244   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5245
5246   // Build the animation
5247   float durationSeconds(1.0f);
5248   Animation animation = Animation::New(durationSeconds);
5249   Vector3 targetScale(2.0f, 3.0f, 4.0f);
5250   Vector3 relativeScale(targetScale - Vector3::ONE);
5251   animation.AnimateBy( Property( actor, Actor::Property::SCALE_X ), relativeScale.x );
5252   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Y ), relativeScale.y );
5253   animation.AnimateBy( Property( actor, Actor::Property::SCALE_Z ), relativeScale.z );
5254
5255   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5256   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
5257
5258   // Start the animation
5259   animation.Play();
5260
5261   // Target value should be retrievable straight away
5262   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5263   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
5264   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
5265   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
5266
5267   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION ); // Not changed yet
5268
5269   application.SendNotification();
5270   application.Render( 1000 ); // 1 second progress
5271
5272   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
5273
5274   END_TEST;
5275 }
5276
5277 int UtcDaliAnimationAnimateByActorColorP(void)
5278 {
5279   TestApplication application;
5280
5281   Actor actor = Actor::New();
5282   Stage::GetCurrent().Add(actor);
5283   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5284
5285   // Build the animation
5286   float durationSeconds(1.0f);
5287   Animation animation = Animation::New(durationSeconds);
5288   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5289   Vector4 relativeColor( targetColor - Color::WHITE );
5290   animation.AnimateBy( Property( actor, Actor::Property::COLOR ), relativeColor );
5291
5292   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5293   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5294
5295   // Start the animation
5296   animation.Play();
5297
5298   // Target value should be retrievable straight away
5299   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5300   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5301   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5302   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5303   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5304
5305   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION ); // Not changed yet
5306
5307   application.SendNotification();
5308   application.Render( 1000 ); // 1 second progress
5309
5310   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5311
5312   END_TEST;
5313 }
5314
5315 int UtcDaliAnimationAnimateByActorColorComponentsP(void)
5316 {
5317   TestApplication application;
5318
5319   Actor actor = Actor::New();
5320   Stage::GetCurrent().Add(actor);
5321   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5322
5323   // Build the animation
5324   float durationSeconds(1.0f);
5325   Animation animation = Animation::New(durationSeconds);
5326   Vector4 targetColor( 0.5f, 0.75f, 0.8f, 0.1f );
5327   Vector4 relativeColor( targetColor - Color::WHITE );
5328   animation.AnimateBy( Property( actor, Actor::Property::COLOR_RED ), relativeColor.r );
5329   animation.AnimateBy( Property( actor, Actor::Property::COLOR_GREEN ), relativeColor.g );
5330   animation.AnimateBy( Property( actor, Actor::Property::COLOR_BLUE ), relativeColor.b );
5331   animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), relativeColor.a );
5332
5333   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5334   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
5335
5336   // Start the animation
5337   animation.Play();
5338
5339   // Target value should be retrievable straight away
5340   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5341   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
5342   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
5343   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
5344   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
5345
5346   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION ); // Not changed yet
5347
5348   application.SendNotification();
5349   application.Render( 1000 ); // 1 second progress
5350
5351   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
5352
5353   END_TEST;
5354 }
5355
5356 int UtcDaliAnimationAnimateByActorSizeP(void)
5357 {
5358   TestApplication application;
5359
5360   Actor actor = Actor::New();
5361   Stage::GetCurrent().Add(actor);
5362   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5363
5364   // Build the animation
5365   float durationSeconds(1.0f);
5366   Animation animation = Animation::New(durationSeconds);
5367   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5368   Vector3 relativeSize( targetSize - Vector3::ZERO );
5369   animation.AnimateBy( Property( actor, Actor::Property::SIZE ), relativeSize );
5370
5371   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5372   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5373
5374   // Start the animation
5375   animation.Play();
5376
5377   // Target value should be retrievable straight away
5378   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5379   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5380   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5381   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5382
5383   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5384
5385   application.SendNotification();
5386   application.Render( 1000 ); // 1 second progress
5387
5388   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5389
5390   END_TEST;
5391 }
5392
5393 int UtcDaliAnimationAnimateByActorSizeComponentsP(void)
5394 {
5395   TestApplication application;
5396
5397   Actor actor = Actor::New();
5398   Stage::GetCurrent().Add(actor);
5399   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5400
5401   // Build the animation
5402   float durationSeconds(1.0f);
5403   Animation animation = Animation::New(durationSeconds);
5404   Vector3 targetSize( 100.0f, 200.0f, 300.0f );
5405   Vector3 relativeSize( targetSize - Vector3::ZERO );
5406   animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), relativeSize.width );
5407   animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), relativeSize.height );
5408   animation.AnimateBy( Property( actor, Actor::Property::SIZE_DEPTH ), relativeSize.depth );
5409
5410   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5411   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
5412
5413   // Start the animation
5414   animation.Play();
5415
5416   // Target value should be retrievable straight away
5417   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5418   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
5419   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
5420   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
5421
5422   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION ); // Not changed yet
5423
5424   application.SendNotification();
5425   application.Render( 1000 ); // 1 second progress
5426
5427   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
5428
5429   END_TEST;
5430 }
5431
5432 int UtcDaliAnimationAnimateByActorVisibilityP(void)
5433 {
5434   TestApplication application;
5435
5436   Actor actor = Actor::New();
5437   Stage::GetCurrent().Add(actor);
5438   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
5439
5440   actor.SetProperty( Actor::Property::VISIBLE, false );
5441
5442   application.SendNotification();
5443   application.Render();
5444
5445   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5446
5447   // Build the animation
5448   float durationSeconds(1.0f);
5449   Animation animation = Animation::New(durationSeconds);
5450   bool targetVisibility( true );
5451   bool relativeVisibility( targetVisibility );
5452   animation.AnimateBy( Property( actor, Actor::Property::VISIBLE ), relativeVisibility );
5453
5454   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
5455
5456   // Start the animation
5457   animation.Play();
5458
5459   // Target value should be retrievable straight away
5460   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), targetVisibility, TEST_LOCATION );
5461   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION ); // Not changed yet
5462
5463   application.SendNotification();
5464   application.Render( 1000 ); // 1 second progress
5465
5466   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
5467
5468   END_TEST;
5469 }
5470
5471 int UtcDaliAnimationAnimateToBooleanP(void)
5472 {
5473   TestApplication application;
5474
5475   Actor actor = Actor::New();
5476
5477   // Register a boolean property
5478   const bool startValue(false);
5479   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5480   Stage::GetCurrent().Add(actor);
5481   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5482   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5483
5484   // Build the animation
5485   float durationSeconds(2.0f);
5486   Animation animation = Animation::New(durationSeconds);
5487   const bool targetValue( !startValue );
5488   animation.AnimateTo(Property(actor, index), targetValue);
5489
5490   // Start the animation
5491   animation.Play();
5492
5493   bool signalReceived(false);
5494   AnimationFinishCheck finishCheck(signalReceived);
5495   animation.FinishedSignal().Connect(&application, finishCheck);
5496
5497   application.SendNotification();
5498   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5499
5500   // We didn't expect the animation to finish yet
5501   application.SendNotification();
5502   finishCheck.CheckSignalNotReceived();
5503   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5504
5505   application.SendNotification();
5506   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5507
5508   // We did expect the animation to finish
5509   application.SendNotification();
5510   finishCheck.CheckSignalReceived();
5511   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5512
5513   // Check that nothing has changed after a couple of buffer swaps
5514   application.Render(0);
5515   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5516   application.Render(0);
5517   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5518
5519   // Repeat with target value "false"
5520   animation = Animation::New(durationSeconds);
5521   const bool finalValue( !targetValue );
5522   animation.AnimateTo(Property(actor, index), finalValue);
5523
5524   // Start the animation
5525   animation.Play();
5526
5527   finishCheck.Reset();
5528   animation.FinishedSignal().Connect(&application, finishCheck);
5529
5530   application.SendNotification();
5531   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5532
5533   // We didn't expect the animation to finish yet
5534   application.SendNotification();
5535   finishCheck.CheckSignalNotReceived();
5536   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5537
5538   application.SendNotification();
5539   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5540
5541   // We did expect the animation to finish
5542   application.SendNotification();
5543   finishCheck.CheckSignalReceived();
5544   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5545
5546   // Check that nothing has changed after a couple of buffer swaps
5547   application.Render(0);
5548   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5549   application.Render(0);
5550   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5551   END_TEST;
5552 }
5553
5554 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
5555 {
5556   TestApplication application;
5557
5558   Actor actor = Actor::New();
5559
5560   // Register a boolean property
5561   const bool startValue(false);
5562   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5563   Stage::GetCurrent().Add(actor);
5564   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5565   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5566
5567   // Build the animation
5568   float durationSeconds(2.0f);
5569   Animation animation = Animation::New(durationSeconds);
5570   const bool targetValue( !startValue );
5571   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5572
5573   // Start the animation
5574   animation.Play();
5575
5576   bool signalReceived(false);
5577   AnimationFinishCheck finishCheck(signalReceived);
5578   animation.FinishedSignal().Connect(&application, finishCheck);
5579
5580   application.SendNotification();
5581   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5582
5583   // We didn't expect the animation to finish yet
5584   application.SendNotification();
5585   finishCheck.CheckSignalNotReceived();
5586   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5587
5588   application.SendNotification();
5589   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5590
5591   // We did expect the animation to finish
5592   application.SendNotification();
5593   finishCheck.CheckSignalReceived();
5594   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5595
5596   // Check that nothing has changed after a couple of buffer swaps
5597   application.Render(0);
5598   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5599   application.Render(0);
5600   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5601
5602   // Repeat with target value "false"
5603   animation = Animation::New(durationSeconds);
5604   const bool finalValue( !targetValue );
5605   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5606
5607   // Start the animation
5608   animation.Play();
5609
5610   finishCheck.Reset();
5611   animation.FinishedSignal().Connect(&application, finishCheck);
5612
5613   application.SendNotification();
5614   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5615
5616   // We didn't expect the animation to finish yet
5617   application.SendNotification();
5618   finishCheck.CheckSignalNotReceived();
5619   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5620
5621   application.SendNotification();
5622   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5623
5624   // We did expect the animation to finish
5625   application.SendNotification();
5626   finishCheck.CheckSignalReceived();
5627   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5628
5629   // Check that nothing has changed after a couple of buffer swaps
5630   application.Render(0);
5631   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5632   application.Render(0);
5633   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5634   END_TEST;
5635 }
5636
5637 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5638 {
5639   TestApplication application;
5640
5641   Actor actor = Actor::New();
5642
5643   // Register a boolean property
5644   bool startValue(false);
5645   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5646   Stage::GetCurrent().Add(actor);
5647   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5648   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5649
5650   // Build the animation
5651   float durationSeconds(2.0f);
5652   Animation animation = Animation::New(durationSeconds);
5653   bool finalValue( !startValue );
5654   float animatorDurationSeconds(durationSeconds * 0.5f);
5655   animation.AnimateTo( Property(actor, index),
5656                        finalValue,
5657                        TimePeriod( animatorDurationSeconds ) );
5658
5659   // Start the animation
5660   animation.Play();
5661
5662   bool signalReceived(false);
5663   AnimationFinishCheck finishCheck(signalReceived);
5664   animation.FinishedSignal().Connect(&application, finishCheck);
5665
5666   application.SendNotification();
5667   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5668
5669   // We didn't expect the animation to finish yet
5670   application.SendNotification();
5671   finishCheck.CheckSignalNotReceived();
5672   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5673
5674   application.SendNotification();
5675   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5676
5677   // We didn't expect the animation to finish yet...
5678   application.SendNotification();
5679   finishCheck.CheckSignalNotReceived();
5680
5681   // ...however we should have reached the final value
5682   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5683
5684   application.SendNotification();
5685   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5686
5687   // We did expect the animation to finish
5688   application.SendNotification();
5689   finishCheck.CheckSignalReceived();
5690   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5691
5692   // Check that nothing has changed after a couple of buffer swaps
5693   application.Render(0);
5694   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5695   application.Render(0);
5696   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5697   END_TEST;
5698 }
5699
5700 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5701 {
5702   TestApplication application;
5703
5704   Actor actor = Actor::New();
5705
5706   // Register a boolean property
5707   bool startValue(false);
5708   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5709   Stage::GetCurrent().Add(actor);
5710   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5711   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5712
5713   // Build the animation
5714   float durationSeconds(2.0f);
5715   Animation animation = Animation::New(durationSeconds);
5716   bool finalValue( !startValue );
5717   float animatorDurationSeconds(durationSeconds * 0.5f);
5718   animation.AnimateTo( Property(actor, index),
5719                        finalValue,
5720                        AlphaFunction::LINEAR,
5721                        TimePeriod( animatorDurationSeconds ) );
5722
5723   // Start the animation
5724   animation.Play();
5725
5726   bool signalReceived(false);
5727   AnimationFinishCheck finishCheck(signalReceived);
5728   animation.FinishedSignal().Connect(&application, finishCheck);
5729
5730   application.SendNotification();
5731   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5732
5733   // We didn't expect the animation to finish yet
5734   application.SendNotification();
5735   finishCheck.CheckSignalNotReceived();
5736   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5737
5738   application.SendNotification();
5739   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5740
5741   // We didn't expect the animation to finish yet...
5742   application.SendNotification();
5743   finishCheck.CheckSignalNotReceived();
5744
5745   // ...however we should have reached the final value
5746   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5747
5748   application.SendNotification();
5749   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5750
5751   // We did expect the animation to finish
5752   application.SendNotification();
5753   finishCheck.CheckSignalReceived();
5754   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5755
5756   // Check that nothing has changed after a couple of buffer swaps
5757   application.Render(0);
5758   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5759   application.Render(0);
5760   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5761   END_TEST;
5762 }
5763
5764 int UtcDaliAnimationAnimateToFloatP(void)
5765 {
5766   TestApplication application;
5767
5768   Actor actor = Actor::New();
5769
5770   // Register a float property
5771   float startValue(10.0f);
5772   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5773   Stage::GetCurrent().Add(actor);
5774   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5775   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5776
5777   // Build the animation
5778   float durationSeconds(2.0f);
5779   Animation animation = Animation::New(durationSeconds);
5780   float targetValue(50.0f);
5781   float relativeValue(targetValue - startValue);
5782   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5783
5784   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5785
5786   // Start the animation
5787   animation.Play();
5788
5789   bool signalReceived(false);
5790   AnimationFinishCheck finishCheck(signalReceived);
5791   animation.FinishedSignal().Connect(&application, finishCheck);
5792
5793   application.SendNotification();
5794   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5795
5796   // We didn't expect the animation to finish yet
5797   application.SendNotification();
5798   finishCheck.CheckSignalNotReceived();
5799   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5800
5801   application.SendNotification();
5802   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5803
5804   // We did expect the animation to finish
5805   application.SendNotification();
5806   finishCheck.CheckSignalReceived();
5807   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5808   END_TEST;
5809 }
5810
5811 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5812 {
5813   TestApplication application;
5814
5815   Actor actor = Actor::New();
5816
5817   // Register a float property
5818   float startValue(10.0f);
5819   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5820   Stage::GetCurrent().Add(actor);
5821   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5822   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5823
5824   // Build the animation
5825   float durationSeconds(1.0f);
5826   Animation animation = Animation::New(durationSeconds);
5827   float targetValue(90.0f);
5828   float relativeValue(targetValue - startValue);
5829   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5830
5831   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5832
5833   // Start the animation
5834   animation.Play();
5835
5836   bool signalReceived(false);
5837   AnimationFinishCheck finishCheck(signalReceived);
5838   animation.FinishedSignal().Connect(&application, finishCheck);
5839
5840   application.SendNotification();
5841   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5842
5843   // We didn't expect the animation to finish yet
5844   application.SendNotification();
5845   finishCheck.CheckSignalNotReceived();
5846
5847   // The position should have moved more, than with a linear alpha function
5848   float current( actor.GetCurrentProperty< float >( index ) );
5849   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5850
5851   application.SendNotification();
5852   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5853
5854   // We did expect the animation to finish
5855   application.SendNotification();
5856   finishCheck.CheckSignalReceived();
5857   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5858   END_TEST;
5859 }
5860
5861 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5862 {
5863   TestApplication application;
5864
5865   Actor actor = Actor::New();
5866
5867   // Register a float property
5868   float startValue(10.0f);
5869   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5870   Stage::GetCurrent().Add(actor);
5871   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5872   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5873
5874   // Build the animation
5875   float durationSeconds(1.0f);
5876   Animation animation = Animation::New(durationSeconds);
5877   float targetValue(30.0f);
5878   float relativeValue(targetValue - startValue);
5879   float delay = 0.5f;
5880   animation.AnimateTo(Property(actor, index),
5881                       targetValue,
5882                       TimePeriod(delay, durationSeconds - delay));
5883
5884   // Start the animation
5885   animation.Play();
5886
5887   bool signalReceived(false);
5888   AnimationFinishCheck finishCheck(signalReceived);
5889   animation.FinishedSignal().Connect(&application, finishCheck);
5890
5891   application.SendNotification();
5892   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5893
5894   // We didn't expect the animation to finish yet
5895   application.SendNotification();
5896   finishCheck.CheckSignalNotReceived();
5897   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5898
5899   application.SendNotification();
5900   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5901
5902   // We didn't expect the animation to finish yet
5903   application.SendNotification();
5904   finishCheck.CheckSignalNotReceived();
5905   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5906
5907   application.SendNotification();
5908   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5909
5910   // We did expect the animation to finish
5911   application.SendNotification();
5912   finishCheck.CheckSignalReceived();
5913   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5914   END_TEST;
5915 }
5916
5917 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5918 {
5919   TestApplication application;
5920
5921   Actor actor = Actor::New();
5922
5923   // Register a float property
5924   float startValue(10.0f);
5925   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5926   Stage::GetCurrent().Add(actor);
5927   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5928   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5929
5930   // Build the animation
5931   float durationSeconds(1.0f);
5932   Animation animation = Animation::New(durationSeconds);
5933   float targetValue(30.0f);
5934   float relativeValue(targetValue - startValue);
5935   float delay = 0.5f;
5936   animation.AnimateTo(Property(actor, index),
5937                       targetValue,
5938                       AlphaFunction::LINEAR,
5939                       TimePeriod(delay, durationSeconds - delay));
5940
5941   // Start the animation
5942   animation.Play();
5943
5944   bool signalReceived(false);
5945   AnimationFinishCheck finishCheck(signalReceived);
5946   animation.FinishedSignal().Connect(&application, finishCheck);
5947
5948   application.SendNotification();
5949   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5950
5951   // We didn't expect the animation to finish yet
5952   application.SendNotification();
5953   finishCheck.CheckSignalNotReceived();
5954   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5955
5956   application.SendNotification();
5957   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5958
5959   // We didn't expect the animation to finish yet
5960   application.SendNotification();
5961   finishCheck.CheckSignalNotReceived();
5962   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5963
5964   application.SendNotification();
5965   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5966
5967   // We did expect the animation to finish
5968   application.SendNotification();
5969   finishCheck.CheckSignalReceived();
5970   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5971   END_TEST;
5972 }
5973
5974 int UtcDaliAnimationAnimateToIntegerP(void)
5975 {
5976   TestApplication application;
5977
5978   Actor actor = Actor::New();
5979
5980   // Register an integer property
5981   int startValue(10);
5982   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5983   Stage::GetCurrent().Add(actor);
5984   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5985   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5986
5987   // Build the animation
5988   float durationSeconds(2.0f);
5989   Animation animation = Animation::New(durationSeconds);
5990   int targetValue(50);
5991   int relativeValue(targetValue - startValue);
5992   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5993
5994   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5995
5996   // Start the animation
5997   animation.Play();
5998
5999   bool signalReceived(false);
6000   AnimationFinishCheck finishCheck(signalReceived);
6001   animation.FinishedSignal().Connect(&application, finishCheck);
6002
6003   application.SendNotification();
6004   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6005
6006   // We didn't expect the animation to finish yet
6007   application.SendNotification();
6008   finishCheck.CheckSignalNotReceived();
6009   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6010
6011   application.SendNotification();
6012   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6013
6014   // We did expect the animation to finish
6015   application.SendNotification();
6016   finishCheck.CheckSignalReceived();
6017   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
6018   END_TEST;
6019 }
6020
6021 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
6022 {
6023   TestApplication application;
6024
6025   Actor actor = Actor::New();
6026
6027   // Register an integer property
6028   int startValue(10);
6029   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6030   Stage::GetCurrent().Add(actor);
6031   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
6032   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
6033
6034   // Build the animation
6035   float durationSeconds(1.0f);
6036   Animation animation = Animation::New(durationSeconds);
6037   int targetValue(90);
6038   int relativeValue(targetValue - startValue);
6039   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6040
6041   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
6042
6043   // Start the animation
6044   animation.Play();
6045
6046   bool signalReceived(false);
6047   AnimationFinishCheck finishCheck(signalReceived);
6048   animation.FinishedSignal().Connect(&application, finishCheck);
6049
6050   application.SendNotification();
6051   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6052
6053   // We didn't expect the animation to finish yet
6054   application.SendNotification();
6055   finishCheck.CheckSignalNotReceived();
6056
6057   // The position should have moved more, than with a linear alpha function
6058   int current( actor.GetCurrentProperty< int >( index ) );
6059   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
6060
6061   application.SendNotification();
6062   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6063
6064   // We did expect the animation to finish
6065   application.SendNotification();
6066   finishCheck.CheckSignalReceived();
6067   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
6068   END_TEST;
6069 }
6070
6071 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
6072 {
6073   TestApplication application;
6074
6075   Actor actor = Actor::New();
6076
6077   // Register an integer property
6078   int startValue(10);
6079   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6080   Stage::GetCurrent().Add(actor);
6081   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
6082   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
6083
6084   // Build the animation
6085   float durationSeconds(1.0f);
6086   Animation animation = Animation::New(durationSeconds);
6087   int targetValue(30);
6088   int relativeValue(targetValue - startValue);
6089   float delay = 0.5f;
6090   animation.AnimateTo(Property(actor, index),
6091                       targetValue,
6092                       TimePeriod(delay, durationSeconds - delay));
6093
6094   // Start the animation
6095   animation.Play();
6096
6097   bool signalReceived(false);
6098   AnimationFinishCheck finishCheck(signalReceived);
6099   animation.FinishedSignal().Connect(&application, finishCheck);
6100
6101   application.SendNotification();
6102   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6103
6104   // We didn't expect the animation to finish yet
6105   application.SendNotification();
6106   finishCheck.CheckSignalNotReceived();
6107   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
6108
6109   application.SendNotification();
6110   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6111
6112   // We didn't expect the animation to finish yet
6113   application.SendNotification();
6114   finishCheck.CheckSignalNotReceived();
6115   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
6116
6117   application.SendNotification();
6118   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6119
6120   // We did expect the animation to finish
6121   application.SendNotification();
6122   finishCheck.CheckSignalReceived();
6123   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
6124   END_TEST;
6125 }
6126
6127 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
6128 {
6129   TestApplication application;
6130
6131   Actor actor = Actor::New();
6132
6133   // Register an integer property
6134   int startValue(10);
6135   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6136   Stage::GetCurrent().Add(actor);
6137   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
6138   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
6139
6140   // Build the animation
6141   float durationSeconds(1.0f);
6142   Animation animation = Animation::New(durationSeconds);
6143   int targetValue(30);
6144   int relativeValue(targetValue - startValue);
6145   float delay = 0.5f;
6146   animation.AnimateTo(Property(actor, index),
6147                       targetValue,
6148                       AlphaFunction::LINEAR,
6149                       TimePeriod(delay, durationSeconds - delay));
6150
6151   // Start the animation
6152   animation.Play();
6153
6154   bool signalReceived(false);
6155   AnimationFinishCheck finishCheck(signalReceived);
6156   animation.FinishedSignal().Connect(&application, finishCheck);
6157
6158   application.SendNotification();
6159   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6160
6161   // We didn't expect the animation to finish yet
6162   application.SendNotification();
6163   finishCheck.CheckSignalNotReceived();
6164   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
6165
6166   application.SendNotification();
6167   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6168
6169   // We didn't expect the animation to finish yet
6170   application.SendNotification();
6171   finishCheck.CheckSignalNotReceived();
6172   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
6173
6174   application.SendNotification();
6175   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6176
6177   // We did expect the animation to finish
6178   application.SendNotification();
6179   finishCheck.CheckSignalReceived();
6180   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
6181   END_TEST;
6182 }
6183
6184 int UtcDaliAnimationAnimateToVector2P(void)
6185 {
6186   TestApplication application;
6187
6188   Actor actor = Actor::New();
6189
6190   // Register a Vector2 property
6191   Vector2 startValue(-50.0f, -50.0f);
6192   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6193   Stage::GetCurrent().Add(actor);
6194   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6195   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6196
6197   // Build the animation
6198   float durationSeconds(2.0f);
6199   Animation animation = Animation::New(durationSeconds);
6200   Vector2 targetValue(50.0f, 50.0f);
6201   Vector2 relativeValue(targetValue - startValue);
6202   animation.AnimateTo(Property(actor, index), targetValue);
6203
6204   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6205
6206   // Start the animation
6207   animation.Play();
6208
6209   bool signalReceived(false);
6210   AnimationFinishCheck finishCheck(signalReceived);
6211   animation.FinishedSignal().Connect(&application, finishCheck);
6212
6213   application.SendNotification();
6214   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6215
6216   // We didn't expect the animation to finish yet
6217   application.SendNotification();
6218   finishCheck.CheckSignalNotReceived();
6219   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6220
6221   application.SendNotification();
6222   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6223
6224   // We did expect the animation to finish
6225   application.SendNotification();
6226   finishCheck.CheckSignalReceived();
6227   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6228   END_TEST;
6229 }
6230
6231 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
6232 {
6233   TestApplication application;
6234
6235   Actor actor = Actor::New();
6236
6237   // Register a Vector2 property
6238   Vector2 startValue(1000.0f, 1000.0f);
6239   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6240   Stage::GetCurrent().Add(actor);
6241   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6242   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6243
6244   // Build the animation
6245   float durationSeconds(1.0f);
6246   Animation animation = Animation::New(durationSeconds);
6247   Vector2 targetValue(9000.0f, 9000.0f);
6248   Vector2 relativeValue(targetValue - startValue);
6249   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
6250
6251   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6252
6253   // Start the animation
6254   animation.Play();
6255
6256   bool signalReceived(false);
6257   AnimationFinishCheck finishCheck(signalReceived);
6258   animation.FinishedSignal().Connect(&application, finishCheck);
6259
6260   application.SendNotification();
6261   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6262
6263   // We didn't expect the animation to finish yet
6264   application.SendNotification();
6265   finishCheck.CheckSignalNotReceived();
6266
6267   // The position should have moved more, than with a linear alpha function
6268   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
6269   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6270   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6271
6272   application.SendNotification();
6273   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6274
6275   // We did expect the animation to finish
6276   application.SendNotification();
6277   finishCheck.CheckSignalReceived();
6278   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6279   END_TEST;
6280 }
6281
6282 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
6283 {
6284   TestApplication application;
6285
6286   Actor actor = Actor::New();
6287
6288   // Register a Vector2 property
6289   Vector2 startValue(10.0f, 10.0f);
6290   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6291   Stage::GetCurrent().Add(actor);
6292   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6293   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6294
6295   // Build the animation
6296   float durationSeconds(1.0f);
6297   Animation animation = Animation::New(durationSeconds);
6298   Vector2 targetValue(-10.0f, 20.0f);
6299   Vector2 relativeValue(targetValue - startValue);
6300   float delay = 0.5f;
6301   animation.AnimateTo(Property(actor, index),
6302                       targetValue,
6303                       TimePeriod(delay, durationSeconds - delay));
6304
6305   // Start the animation
6306   animation.Play();
6307
6308   bool signalReceived(false);
6309   AnimationFinishCheck finishCheck(signalReceived);
6310   animation.FinishedSignal().Connect(&application, finishCheck);
6311
6312   application.SendNotification();
6313   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6314
6315   // We didn't expect the animation to finish yet
6316   application.SendNotification();
6317   finishCheck.CheckSignalNotReceived();
6318   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6319
6320   application.SendNotification();
6321   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6322
6323   // We didn't expect the animation to finish yet
6324   application.SendNotification();
6325   finishCheck.CheckSignalNotReceived();
6326   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6327
6328   application.SendNotification();
6329   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6330
6331   // We did expect the animation to finish
6332   application.SendNotification();
6333   finishCheck.CheckSignalReceived();
6334   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6335   END_TEST;
6336 }
6337
6338 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
6339 {
6340   TestApplication application;
6341
6342   Actor actor = Actor::New();
6343
6344   // Register a Vector2 property
6345   Vector2 startValue(10.0f, 10.0f);
6346   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6347   Stage::GetCurrent().Add(actor);
6348   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6349   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
6350
6351   // Build the animation
6352   float durationSeconds(1.0f);
6353   Animation animation = Animation::New(durationSeconds);
6354   Vector2 targetValue(30.0f, 30.0f);
6355   Vector2 relativeValue(targetValue - startValue);
6356   float delay = 0.5f;
6357   animation.AnimateTo(Property(actor, index),
6358                       targetValue,
6359                       AlphaFunction::LINEAR,
6360                       TimePeriod(delay, durationSeconds - delay));
6361
6362   // Start the animation
6363   animation.Play();
6364
6365   bool signalReceived(false);
6366   AnimationFinishCheck finishCheck(signalReceived);
6367   animation.FinishedSignal().Connect(&application, finishCheck);
6368
6369   application.SendNotification();
6370   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6371
6372   // We didn't expect the animation to finish yet, but cached value should be the final one
6373   application.SendNotification();
6374   finishCheck.CheckSignalNotReceived();
6375   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6376   DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
6377
6378   application.SendNotification();
6379   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6380
6381   // We didn't expect the animation to finish yet
6382   application.SendNotification();
6383   finishCheck.CheckSignalNotReceived();
6384   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6385
6386   application.SendNotification();
6387   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6388
6389   // We did expect the animation to finish
6390   application.SendNotification();
6391   finishCheck.CheckSignalReceived();
6392   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6393   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
6394   END_TEST;
6395 }
6396
6397 int UtcDaliAnimationAnimateToVector3P(void)
6398 {
6399   TestApplication application;
6400
6401   Actor actor = Actor::New();
6402
6403   // Register a Vector3 property
6404   Vector3 startValue(-50.0f, -50.0f, -50.0f);
6405   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6406   Stage::GetCurrent().Add(actor);
6407   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
6408   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6409
6410   // Build the animation
6411   float durationSeconds(2.0f);
6412   Animation animation = Animation::New(durationSeconds);
6413   Vector3 targetValue(50.0f, 50.0f, 50.0f);
6414   Vector3 relativeValue(targetValue - startValue);
6415   animation.AnimateTo(Property(actor, index), targetValue);
6416
6417   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6418
6419   // Start the animation
6420   animation.Play();
6421
6422   bool signalReceived(false);
6423   AnimationFinishCheck finishCheck(signalReceived);
6424   animation.FinishedSignal().Connect(&application, finishCheck);
6425
6426   application.SendNotification();
6427   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6428
6429   // We didn't expect the animation to finish yet
6430   application.SendNotification();
6431   finishCheck.CheckSignalNotReceived();
6432   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6433
6434   application.SendNotification();
6435   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6436
6437   // We did expect the animation to finish
6438   application.SendNotification();
6439   finishCheck.CheckSignalReceived();
6440   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6441   END_TEST;
6442 }
6443
6444 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
6445 {
6446   TestApplication application;
6447
6448   Actor actor = Actor::New();
6449
6450   // Register a Vector3 property
6451   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
6452   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6453   Stage::GetCurrent().Add(actor);
6454   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6455   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6456
6457   // Build the animation
6458   float durationSeconds(1.0f);
6459   Animation animation = Animation::New(durationSeconds);
6460   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
6461   Vector3 relativeValue(targetValue - startValue);
6462   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6463
6464   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6465
6466   // Start the animation
6467   animation.Play();
6468
6469   bool signalReceived(false);
6470   AnimationFinishCheck finishCheck(signalReceived);
6471   animation.FinishedSignal().Connect(&application, finishCheck);
6472
6473   application.SendNotification();
6474   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6475
6476   // We didn't expect the animation to finish yet
6477   application.SendNotification();
6478   finishCheck.CheckSignalNotReceived();
6479
6480   // The position should have moved more, than with a linear alpha function
6481   Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
6482   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6483   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6484   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6485
6486   application.SendNotification();
6487   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6488
6489   // We did expect the animation to finish
6490   application.SendNotification();
6491   finishCheck.CheckSignalReceived();
6492   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6493   END_TEST;
6494 }
6495
6496 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
6497 {
6498   TestApplication application;
6499
6500   Actor actor = Actor::New();
6501
6502   // Register a Vector3 property
6503   Vector3 startValue(10.0f, 10.0f, 10.0f);
6504   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6505   Stage::GetCurrent().Add(actor);
6506   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6507   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6508
6509   // Build the animation
6510   float durationSeconds(1.0f);
6511   Animation animation = Animation::New(durationSeconds);
6512   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
6513   Vector3 relativeValue(targetValue - startValue);
6514   float delay = 0.5f;
6515   animation.AnimateTo(Property(actor, index),
6516                       targetValue,
6517                       TimePeriod(delay, durationSeconds - delay));
6518
6519   // Start the animation
6520   animation.Play();
6521
6522   bool signalReceived(false);
6523   AnimationFinishCheck finishCheck(signalReceived);
6524   animation.FinishedSignal().Connect(&application, finishCheck);
6525
6526   application.SendNotification();
6527   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6528
6529   // We didn't expect the animation to finish yet
6530   application.SendNotification();
6531   finishCheck.CheckSignalNotReceived();
6532   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6533
6534   application.SendNotification();
6535   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6536
6537   // We didn't expect the animation to finish yet
6538   application.SendNotification();
6539   finishCheck.CheckSignalNotReceived();
6540   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6541
6542   application.SendNotification();
6543   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6544
6545   // We did expect the animation to finish
6546   application.SendNotification();
6547   finishCheck.CheckSignalReceived();
6548   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6549   END_TEST;
6550 }
6551
6552 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
6553 {
6554   TestApplication application;
6555
6556   Actor actor = Actor::New();
6557
6558   // Register a Vector3 property
6559   Vector3 startValue(10.0f, 10.0f, 10.0f);
6560   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6561   Stage::GetCurrent().Add(actor);
6562   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6563   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6564
6565   // Build the animation
6566   float durationSeconds(1.0f);
6567   Animation animation = Animation::New(durationSeconds);
6568   Vector3 targetValue(30.0f, 30.0f, 30.0f);
6569   Vector3 relativeValue(targetValue - startValue);
6570   float delay = 0.5f;
6571   animation.AnimateTo(Property(actor, "testProperty"),
6572                       targetValue,
6573                       AlphaFunction::LINEAR,
6574                       TimePeriod(delay, durationSeconds - delay));
6575
6576   // Start the animation
6577   animation.Play();
6578
6579   bool signalReceived(false);
6580   AnimationFinishCheck finishCheck(signalReceived);
6581   animation.FinishedSignal().Connect(&application, finishCheck);
6582
6583   application.SendNotification();
6584   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6585
6586   // We didn't expect the animation to finish yet
6587   application.SendNotification();
6588   finishCheck.CheckSignalNotReceived();
6589   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6590
6591   application.SendNotification();
6592   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6593
6594   // We didn't expect the animation to finish yet
6595   application.SendNotification();
6596   finishCheck.CheckSignalNotReceived();
6597   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6598
6599   application.SendNotification();
6600   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6601
6602   // We did expect the animation to finish
6603   application.SendNotification();
6604   finishCheck.CheckSignalReceived();
6605   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6606   END_TEST;
6607 }
6608
6609 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6610 {
6611   TestApplication application;
6612
6613   Actor actor = Actor::New();
6614
6615   // Register a Vector3 property
6616   Vector3 startValue(10.0f, 10.0f, 10.0f);
6617   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6618   Stage::GetCurrent().Add(actor);
6619   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6620   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6621
6622   // Build the animation
6623   float durationSeconds(1.0f);
6624   Animation animation = Animation::New(durationSeconds);
6625   Vector3 targetValue(30.0f, 30.0f, 10.0f);
6626   Vector3 relativeValue(targetValue - startValue);
6627   float delay = 0.5f;
6628   animation.AnimateTo(Property(actor, "testProperty",  0),
6629                       30.0f,
6630                       AlphaFunction::LINEAR,
6631                       TimePeriod(delay, durationSeconds - delay));
6632   animation.AnimateTo(Property(actor, index, 1),
6633                       30.0f,
6634                       AlphaFunction::LINEAR,
6635                       TimePeriod(delay, durationSeconds - delay));
6636
6637   // Start the animation
6638   animation.Play();
6639
6640   bool signalReceived(false);
6641   AnimationFinishCheck finishCheck(signalReceived);
6642   animation.FinishedSignal().Connect(&application, finishCheck);
6643
6644   application.SendNotification();
6645   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6646
6647   // We didn't expect the animation to finish yet
6648   application.SendNotification();
6649   finishCheck.CheckSignalNotReceived();
6650   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6651
6652   application.SendNotification();
6653   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6654
6655   // We didn't expect the animation to finish yet
6656   application.SendNotification();
6657   finishCheck.CheckSignalNotReceived();
6658   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6659
6660   application.SendNotification();
6661   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6662
6663   // We did expect the animation to finish
6664   application.SendNotification();
6665   finishCheck.CheckSignalReceived();
6666   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6667   END_TEST;
6668 }
6669
6670 int UtcDaliAnimationAnimateToVector4P(void)
6671 {
6672   TestApplication application;
6673
6674   Actor actor = Actor::New();
6675
6676   // Register a Vector4 property
6677   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6678   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6679   Stage::GetCurrent().Add(actor);
6680   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6681   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6682
6683   // Build the animation
6684   float durationSeconds(2.0f);
6685   Animation animation = Animation::New(durationSeconds);
6686   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6687   Vector4 relativeValue(targetValue - startValue);
6688   animation.AnimateTo(Property(actor, index), targetValue);
6689
6690   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6691
6692   // Start the animation
6693   animation.Play();
6694
6695   bool signalReceived(false);
6696   AnimationFinishCheck finishCheck(signalReceived);
6697   animation.FinishedSignal().Connect(&application, finishCheck);
6698
6699   application.SendNotification();
6700   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6701
6702   // We didn't expect the animation to finish yet
6703   application.SendNotification();
6704   finishCheck.CheckSignalNotReceived();
6705   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6706
6707   application.SendNotification();
6708   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6709
6710   // We did expect the animation to finish
6711   application.SendNotification();
6712   finishCheck.CheckSignalReceived();
6713   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6714   END_TEST;
6715 }
6716
6717 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6718 {
6719   TestApplication application;
6720
6721   Actor actor = Actor::New();
6722
6723   // Register a Vector4 property
6724   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6725   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6726   Stage::GetCurrent().Add(actor);
6727   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6728   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6729
6730   // Build the animation
6731   float durationSeconds(1.0f);
6732   Animation animation = Animation::New(durationSeconds);
6733   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6734   Vector4 relativeValue(targetValue - startValue);
6735   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6736
6737   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6738
6739   // Start the animation
6740   animation.Play();
6741
6742   bool signalReceived(false);
6743   AnimationFinishCheck finishCheck(signalReceived);
6744   animation.FinishedSignal().Connect(&application, finishCheck);
6745
6746   application.SendNotification();
6747   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6748
6749   // We didn't expect the animation to finish yet
6750   application.SendNotification();
6751   finishCheck.CheckSignalNotReceived();
6752
6753   // The position should have moved more, than with a linear alpha function
6754   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6755   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6756   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6757   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6758   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6759
6760   application.SendNotification();
6761   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6762
6763   // We did expect the animation to finish
6764   application.SendNotification();
6765   finishCheck.CheckSignalReceived();
6766   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6767   END_TEST;
6768 }
6769
6770 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6771 {
6772   TestApplication application;
6773
6774   Actor actor = Actor::New();
6775
6776   // Register a Vector4 property
6777   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6778   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6779   Stage::GetCurrent().Add(actor);
6780   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6781   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6782
6783   // Build the animation
6784   float durationSeconds(1.0f);
6785   Animation animation = Animation::New(durationSeconds);
6786   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6787   Vector4 relativeValue(targetValue - startValue);
6788   float delay = 0.5f;
6789   animation.AnimateTo(Property(actor, index),
6790                       targetValue,
6791                       TimePeriod(delay, durationSeconds - delay));
6792
6793   // Start the animation
6794   animation.Play();
6795
6796   bool signalReceived(false);
6797   AnimationFinishCheck finishCheck(signalReceived);
6798   animation.FinishedSignal().Connect(&application, finishCheck);
6799
6800   application.SendNotification();
6801   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6802
6803   // We didn't expect the animation to finish yet
6804   application.SendNotification();
6805   finishCheck.CheckSignalNotReceived();
6806   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6807
6808   application.SendNotification();
6809   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6810
6811   // We didn't expect the animation to finish yet
6812   application.SendNotification();
6813   finishCheck.CheckSignalNotReceived();
6814   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6815
6816   application.SendNotification();
6817   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6818
6819   // We did expect the animation to finish
6820   application.SendNotification();
6821   finishCheck.CheckSignalReceived();
6822   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6823   END_TEST;
6824 }
6825
6826 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6827 {
6828   TestApplication application;
6829
6830   Actor actor = Actor::New();
6831
6832   // Register a Vector4 property
6833   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6834   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6835   Stage::GetCurrent().Add(actor);
6836   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6837   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6838
6839   // Build the animation
6840   float durationSeconds(1.0f);
6841   Animation animation = Animation::New(durationSeconds);
6842   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6843   Vector4 relativeValue(targetValue - startValue);
6844   float delay = 0.5f;
6845   animation.AnimateTo(Property(actor, index),
6846                       targetValue,
6847                       AlphaFunction::LINEAR,
6848                       TimePeriod(delay, durationSeconds - delay));
6849
6850   // Start the animation
6851   animation.Play();
6852
6853   bool signalReceived(false);
6854   AnimationFinishCheck finishCheck(signalReceived);
6855   animation.FinishedSignal().Connect(&application, finishCheck);
6856
6857   application.SendNotification();
6858   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6859
6860   // We didn't expect the animation to finish yet
6861   application.SendNotification();
6862   finishCheck.CheckSignalNotReceived();
6863   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6864
6865   application.SendNotification();
6866   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6867
6868   // We didn't expect the animation to finish yet
6869   application.SendNotification();
6870   finishCheck.CheckSignalNotReceived();
6871   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6872
6873   application.SendNotification();
6874   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6875
6876   // We did expect the animation to finish
6877   application.SendNotification();
6878   finishCheck.CheckSignalReceived();
6879   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6880   END_TEST;
6881 }
6882
6883 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6884 {
6885   TestApplication application;
6886
6887   Actor actor = Actor::New();
6888   Stage::GetCurrent().Add(actor);
6889   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6890
6891   // Build the animation
6892   float durationSeconds(1.0f);
6893   Animation animation = Animation::New(durationSeconds);
6894   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6895
6896   DALI_TEST_ASSERTION(
6897   {
6898     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6899   }, "Property is not animatable" );
6900
6901   END_TEST;
6902 }
6903
6904 int UtcDaliAnimationAnimateToActorParentOriginXN(void)
6905 {
6906   TestApplication application;
6907
6908   Actor actor = Actor::New();
6909   Stage::GetCurrent().Add(actor);
6910   float startValue(0.0f);
6911   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).x, startValue, TEST_LOCATION );
6912   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6913
6914   // Build the animation
6915   float durationSeconds(1.0f);
6916   Animation animation = Animation::New(durationSeconds);
6917   float targetX(1.0f);
6918
6919   DALI_TEST_ASSERTION(
6920   {
6921     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6922   }, "Property is not animatable" );
6923
6924   END_TEST;
6925 }
6926
6927 int UtcDaliAnimationAnimateToActorParentOriginYN(void)
6928 {
6929   TestApplication application;
6930
6931   Actor actor = Actor::New();
6932   Stage::GetCurrent().Add(actor);
6933   float startValue(0.0f);
6934   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).y, startValue, TEST_LOCATION );
6935   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6936
6937   // Build the animation
6938   float durationSeconds(1.0f);
6939   Animation animation = Animation::New(durationSeconds);
6940   float targetY(1.0f);
6941
6942   DALI_TEST_ASSERTION(
6943   {
6944     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6945   }, "Property is not animatable" );
6946
6947   END_TEST;
6948 }
6949
6950 int UtcDaliAnimationAnimateToActorParentOriginZN(void)
6951 {
6952   TestApplication application;
6953
6954   Actor actor = Actor::New();
6955   Stage::GetCurrent().Add(actor);
6956   float startValue(0.5f);
6957   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).z, startValue, TEST_LOCATION );
6958   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6959
6960   // Build the animation
6961   float durationSeconds(1.0f);
6962   Animation animation = Animation::New(durationSeconds);
6963   float targetZ(1.0f);
6964
6965   DALI_TEST_ASSERTION(
6966   {
6967     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6968   }, "Property is not animatable" );
6969
6970   END_TEST;
6971 }
6972
6973 int UtcDaliAnimationAnimateToActorAnchorPointN(void)
6974 {
6975   TestApplication application;
6976
6977   Actor actor = Actor::New();
6978   Stage::GetCurrent().Add(actor);
6979   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), AnchorPoint::CENTER, TEST_LOCATION );
6980
6981   // Build the animation
6982   float durationSeconds(1.0f);
6983   Animation animation = Animation::New(durationSeconds);
6984   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6985
6986   DALI_TEST_ASSERTION(
6987   {
6988     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6989   }, "Property is not animatable" );
6990
6991   END_TEST;
6992 }
6993
6994 int UtcDaliAnimationAnimateToActorAnchorPointXN(void)
6995 {
6996   TestApplication application;
6997
6998   Actor actor = Actor::New();
6999   Stage::GetCurrent().Add(actor);
7000   float startValue(0.5f);
7001   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).x, startValue, TEST_LOCATION );
7002   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
7003
7004   // Build the animation
7005   float durationSeconds(1.0f);
7006   Animation animation = Animation::New(durationSeconds);
7007   float targetX(1.0f);
7008
7009   DALI_TEST_ASSERTION(
7010   {
7011     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
7012   }, "Property is not animatable" );
7013
7014   END_TEST;
7015 }
7016
7017 int UtcDaliAnimationAnimateToActorAnchorPointYN(void)
7018 {
7019   TestApplication application;
7020
7021   Actor actor = Actor::New();
7022   Stage::GetCurrent().Add(actor);
7023   float startValue(0.5f);
7024   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).y, startValue, TEST_LOCATION );
7025   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
7026
7027   // Build the animation
7028   float durationSeconds(1.0f);
7029   Animation animation = Animation::New(durationSeconds);
7030   float targetY(0.0f);
7031
7032   DALI_TEST_ASSERTION(
7033   {
7034     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
7035   }, "Property is not animatable" );
7036
7037   END_TEST;
7038 }
7039
7040 int UtcDaliAnimationAnimateToActorAnchorPointZN(void)
7041 {
7042   TestApplication application;
7043
7044   Actor actor = Actor::New();
7045   Stage::GetCurrent().Add(actor);
7046   float startValue(0.5f);
7047   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).z, startValue, TEST_LOCATION );
7048   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
7049
7050   // Build the animation
7051   float durationSeconds(1.0f);
7052   Animation animation = Animation::New(durationSeconds);
7053   float targetZ(100.0f);
7054
7055   DALI_TEST_ASSERTION(
7056   {
7057     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
7058   }, "Property is not animatable" );
7059
7060   END_TEST;
7061 }
7062
7063 int UtcDaliAnimationAnimateToActorSizeP(void)
7064 {
7065   TestApplication application;
7066
7067   Actor actor = Actor::New();
7068   Stage::GetCurrent().Add(actor);
7069   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7070
7071   // Build the animation
7072   float durationSeconds(1.0f);
7073   Animation animation = Animation::New(durationSeconds);
7074   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7075   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
7076
7077   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7078
7079   // Should return the initial properties before play
7080   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7081   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
7082   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
7083   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
7084
7085   // Start the animation
7086   animation.Play();
7087
7088   // Should return the target property after play
7089   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
7090   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
7091   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
7092   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
7093
7094   bool signalReceived(false);
7095   AnimationFinishCheck finishCheck(signalReceived);
7096   animation.FinishedSignal().Connect(&application, finishCheck);
7097
7098   application.SendNotification();
7099   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7100
7101   // We didn't expect the animation to finish yet
7102   application.SendNotification();
7103   finishCheck.CheckSignalNotReceived();
7104   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), ninetyNinePercentProgress, TEST_LOCATION );
7105
7106   application.SendNotification();
7107   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7108
7109   // We did expect the animation to finish
7110   application.SendNotification();
7111   finishCheck.CheckSignalReceived();
7112   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
7113
7114   // Reset everything
7115   finishCheck.Reset();
7116   actor.SetSize(Vector3::ZERO);
7117   application.SendNotification();
7118   application.Render(0);
7119   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7120
7121   // Repeat with a different (ease-in) alpha function
7122   animation = Animation::New(durationSeconds);
7123   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
7124   animation.FinishedSignal().Connect(&application, finishCheck);
7125   animation.Play();
7126
7127   application.SendNotification();
7128   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7129
7130   // We didn't expect the animation to finish yet
7131   application.SendNotification();
7132   finishCheck.CheckSignalNotReceived();
7133
7134   // The size should have travelled less, than with a linear alpha function
7135   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
7136   DALI_TEST_CHECK( current.x > 0.0f );
7137   DALI_TEST_CHECK( current.y > 0.0f );
7138   DALI_TEST_CHECK( current.z > 0.0f );
7139   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7140   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7141   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7142
7143   application.SendNotification();
7144   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7145
7146   // We did expect the animation to finish
7147   application.SendNotification();
7148   finishCheck.CheckSignalReceived();
7149   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
7150
7151   // Reset everything
7152   finishCheck.Reset();
7153   actor.SetSize(Vector3::ZERO);
7154   application.SendNotification();
7155   application.Render(0);
7156   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7157
7158   // Repeat with a delay
7159   float delay = 0.5f;
7160   animation = Animation::New(durationSeconds);
7161   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
7162   animation.FinishedSignal().Connect(&application, finishCheck);
7163   animation.Play();
7164
7165   application.SendNotification();
7166   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7167
7168   // We didn't expect the animation to finish yet
7169   application.SendNotification();
7170   finishCheck.CheckSignalNotReceived();
7171   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7172
7173   application.SendNotification();
7174   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7175
7176   // We did expect the animation to finish
7177   application.SendNotification();
7178   finishCheck.CheckSignalReceived();
7179   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
7180   END_TEST;
7181 }
7182
7183 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
7184 {
7185   TestApplication application;
7186
7187   Actor actor = Actor::New();
7188   Stage::GetCurrent().Add(actor);
7189   float startValue(0.0f);
7190   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, startValue, TEST_LOCATION );
7191   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
7192
7193   // Build the animation
7194   float durationSeconds(1.0f);
7195   Animation animation = Animation::New(durationSeconds);
7196   float targetWidth(10.0f);
7197   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
7198
7199   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
7200
7201   // Should return the initial properties before play
7202   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7203   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
7204
7205   // Start the animation
7206   animation.Play();
7207
7208   // Should return the target property after play
7209   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
7210   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
7211
7212   bool signalReceived(false);
7213   AnimationFinishCheck finishCheck(signalReceived);
7214   animation.FinishedSignal().Connect(&application, finishCheck);
7215
7216   application.SendNotification();
7217   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7218
7219   // We didn't expect the animation to finish yet
7220   application.SendNotification();
7221   finishCheck.CheckSignalNotReceived();
7222   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, fiftyPercentProgress, TEST_LOCATION );
7223
7224   application.SendNotification();
7225   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7226
7227   // We did expect the animation to finish
7228   application.SendNotification();
7229   finishCheck.CheckSignalReceived();
7230   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, targetWidth, TEST_LOCATION );
7231   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
7232   END_TEST;
7233 }
7234
7235 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
7236 {
7237   TestApplication application;
7238
7239   Actor actor = Actor::New();
7240   Stage::GetCurrent().Add(actor);
7241   float startValue(0.0f);
7242   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, startValue, TEST_LOCATION );
7243   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
7244
7245   // Build the animation
7246   float durationSeconds(1.0f);
7247   Animation animation = Animation::New(durationSeconds);
7248   float targetHeight(-10.0f);
7249   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
7250
7251   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
7252
7253   // Should return the initial properties before play
7254   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7255   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
7256
7257   // Start the animation
7258   animation.Play();
7259
7260   // Should return the target property after play
7261   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
7262   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
7263
7264   bool signalReceived(false);
7265   AnimationFinishCheck finishCheck(signalReceived);
7266   animation.FinishedSignal().Connect(&application, finishCheck);
7267
7268   application.SendNotification();
7269   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7270
7271   // We didn't expect the animation to finish yet
7272   application.SendNotification();
7273   finishCheck.CheckSignalNotReceived();
7274   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, fiftyPercentProgress, TEST_LOCATION );
7275
7276   application.SendNotification();
7277   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7278
7279   // We did expect the animation to finish
7280   application.SendNotification();
7281   finishCheck.CheckSignalReceived();
7282   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, targetHeight, TEST_LOCATION );
7283   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
7284   END_TEST;
7285 }
7286
7287 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
7288 {
7289   TestApplication application;
7290
7291   Actor actor = Actor::New();
7292   Stage::GetCurrent().Add(actor);
7293   float startValue(0.0f);
7294   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, startValue, TEST_LOCATION );
7295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
7296
7297   // Build the animation
7298   float durationSeconds(1.0f);
7299   Animation animation = Animation::New(durationSeconds);
7300   float targetDepth(-10.0f);
7301   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
7302
7303   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
7304
7305   // Should return the initial properties before play
7306   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7307   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
7308
7309   // Start the animation
7310   animation.Play();
7311
7312   // Should return the target property after play
7313   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
7314   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
7315
7316   bool signalReceived(false);
7317   AnimationFinishCheck finishCheck(signalReceived);
7318   animation.FinishedSignal().Connect(&application, finishCheck);
7319
7320   application.SendNotification();
7321   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7322
7323   // We didn't expect the animation to finish yet
7324   application.SendNotification();
7325   finishCheck.CheckSignalNotReceived();
7326   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, fiftyPercentProgress, TEST_LOCATION );
7327
7328   application.SendNotification();
7329   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7330
7331   // We did expect the animation to finish
7332   application.SendNotification();
7333   finishCheck.CheckSignalReceived();
7334   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, targetDepth, TEST_LOCATION );
7335   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
7336   END_TEST;
7337 }
7338
7339 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
7340 {
7341   TestApplication application;
7342
7343   Actor actor = Actor::New();
7344   Stage::GetCurrent().Add(actor);
7345   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7346
7347   // Build the animation
7348   float durationSeconds(1.0f);
7349   Animation animation = Animation::New(durationSeconds);
7350   Vector3 targetSize(100.0f, 100.0f, 100.0f);
7351   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
7352
7353   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
7354
7355   // Start the animation
7356   animation.Play();
7357
7358   bool signalReceived(false);
7359   AnimationFinishCheck finishCheck(signalReceived);
7360   animation.FinishedSignal().Connect(&application, finishCheck);
7361
7362   application.SendNotification();
7363   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7364
7365   // We didn't expect the animation to finish yet
7366   application.SendNotification();
7367   finishCheck.CheckSignalNotReceived();
7368   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), ninetyNinePercentProgress, TEST_LOCATION );
7369
7370   application.SendNotification();
7371   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7372
7373   // We did expect the animation to finish
7374   application.SendNotification();
7375   finishCheck.CheckSignalReceived();
7376   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
7377
7378   // Reset everything
7379   finishCheck.Reset();
7380   actor.SetSize(Vector3::ZERO);
7381   application.SendNotification();
7382   application.Render(0);
7383   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7384
7385   // Repeat with a different (ease-in) alpha function
7386   animation = Animation::New(durationSeconds);
7387   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
7388   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
7389   animation.FinishedSignal().Connect(&application, finishCheck);
7390   animation.Play();
7391
7392   application.SendNotification();
7393   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7394
7395   // We didn't expect the animation to finish yet
7396   application.SendNotification();
7397   finishCheck.CheckSignalNotReceived();
7398
7399   // The size should have travelled less, than with a linear alpha function
7400   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
7401   DALI_TEST_CHECK( current.x > 0.0f );
7402   DALI_TEST_CHECK( current.y > 0.0f );
7403   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7404   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7405
7406   application.SendNotification();
7407   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7408
7409   // We did expect the animation to finish
7410   application.SendNotification();
7411   finishCheck.CheckSignalReceived();
7412   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).x, targetSize.x, TEST_LOCATION );
7413   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, targetSize.y, TEST_LOCATION );
7414
7415   // Reset everything
7416   finishCheck.Reset();
7417   actor.SetSize(Vector3::ZERO);
7418   application.SendNotification();
7419   application.Render(0);
7420   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7421
7422   // Repeat with a delay
7423   float delay = 0.5f;
7424   animation = Animation::New(durationSeconds);
7425   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7426   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
7427   animation.FinishedSignal().Connect(&application, finishCheck);
7428   animation.Play();
7429
7430   application.SendNotification();
7431   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7432
7433   // We didn't expect the animation to finish yet
7434   application.SendNotification();
7435   finishCheck.CheckSignalNotReceived();
7436   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
7437
7438   application.SendNotification();
7439   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7440
7441   // We did expect the animation to finish
7442   application.SendNotification();
7443   finishCheck.CheckSignalReceived();
7444   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).x, targetSize.x, TEST_LOCATION );
7445   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, targetSize.y, TEST_LOCATION );
7446   END_TEST;
7447 }
7448
7449 int UtcDaliAnimationAnimateToActorPositionP(void)
7450 {
7451   TestApplication application;
7452
7453   Actor actor = Actor::New();
7454   Stage::GetCurrent().Add(actor);
7455   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7456
7457   // Build the animation
7458   float durationSeconds(1.0f);
7459   Animation animation = Animation::New(durationSeconds);
7460   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7461   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
7462
7463   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7464
7465   // Should return the initial properties before play
7466   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7467   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
7468   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
7469   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
7470
7471   // Start the animation
7472   animation.Play();
7473
7474   // Should return the target property after play
7475   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7476   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
7477   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
7478   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, 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*750.0f)/* 75% progress */);
7486
7487   // We didn't expect the animation to finish yet
7488   application.SendNotification();
7489   finishCheck.CheckSignalNotReceived();
7490   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), seventyFivePercentProgress, TEST_LOCATION );
7491
7492   application.SendNotification();
7493   application.Render(static_cast<unsigned int>(durationSeconds*250.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.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7499   END_TEST;
7500 }
7501
7502 int UtcDaliAnimationAnimateToActorPositionXP(void)
7503 {
7504   TestApplication application;
7505
7506   Actor actor = Actor::New();
7507   Stage::GetCurrent().Add(actor);
7508   float startValue(0.0f);
7509   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, startValue, TEST_LOCATION );
7510   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7511   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7512   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7513
7514   // Build the animation
7515   float durationSeconds(1.0f);
7516   Animation animation = Animation::New(durationSeconds);
7517   float targetX(1.0f);
7518   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
7519
7520   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7521
7522   // Should return the initial properties before play
7523   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7524   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
7525
7526   // Start the animation
7527   animation.Play();
7528
7529   // Should return the target property after play
7530   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
7531   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
7532
7533   bool signalReceived(false);
7534   AnimationFinishCheck finishCheck(signalReceived);
7535   animation.FinishedSignal().Connect(&application, finishCheck);
7536
7537   application.SendNotification();
7538   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7539
7540   // We didn't expect the animation to finish yet
7541   application.SendNotification();
7542   finishCheck.CheckSignalNotReceived();
7543   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, fiftyPercentProgress, TEST_LOCATION );
7544
7545   application.SendNotification();
7546   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7547
7548   // We did expect the animation to finish
7549   application.SendNotification();
7550   finishCheck.CheckSignalReceived();
7551   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, targetX, TEST_LOCATION );
7552   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
7553   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7554   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7555   END_TEST;
7556 }
7557
7558 int UtcDaliAnimationAnimateToActorPositionYP(void)
7559 {
7560   TestApplication application;
7561
7562   Actor actor = Actor::New();
7563   Stage::GetCurrent().Add(actor);
7564   float startValue(0.0f);
7565   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, startValue, TEST_LOCATION );
7566   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7567   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7568   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7569
7570   // Build the animation
7571   float durationSeconds(1.0f);
7572   Animation animation = Animation::New(durationSeconds);
7573   float targetY(10.0f);
7574   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7575
7576   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7577
7578   // Should return the initial properties before play
7579   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7580   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7581
7582   // Start the animation
7583   animation.Play();
7584
7585   // Should return the target property after play
7586   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7587   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7588
7589   bool signalReceived(false);
7590   AnimationFinishCheck finishCheck(signalReceived);
7591   animation.FinishedSignal().Connect(&application, finishCheck);
7592
7593   application.SendNotification();
7594   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7595
7596   // We didn't expect the animation to finish yet
7597   application.SendNotification();
7598   finishCheck.CheckSignalNotReceived();
7599   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, fiftyPercentProgress, TEST_LOCATION );
7600
7601   application.SendNotification();
7602   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7603
7604   // We did expect the animation to finish
7605   application.SendNotification();
7606   finishCheck.CheckSignalReceived();
7607   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, targetY, TEST_LOCATION );
7608   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7609   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7610   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7611   END_TEST;
7612 }
7613
7614 int UtcDaliAnimationAnimateToActorPositionZP(void)
7615 {
7616   TestApplication application;
7617
7618   Actor actor = Actor::New();
7619   Stage::GetCurrent().Add(actor);
7620   float startValue(0.0f);
7621   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, startValue, TEST_LOCATION );
7622   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7623   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7624   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7625
7626   // Build the animation
7627   float durationSeconds(1.0f);
7628   Animation animation = Animation::New(durationSeconds);
7629   float targetZ(-5.0f);
7630   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7631
7632   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7633
7634   // Should return the initial properties before play
7635   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7636   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7637
7638   // Start the animation
7639   animation.Play();
7640
7641   // Should return the target property after play
7642   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7643   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7644
7645   bool signalReceived(false);
7646   AnimationFinishCheck finishCheck(signalReceived);
7647   animation.FinishedSignal().Connect(&application, finishCheck);
7648
7649   application.SendNotification();
7650   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7651
7652   // We didn't expect the animation to finish yet
7653   application.SendNotification();
7654   finishCheck.CheckSignalNotReceived();
7655   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, fiftyPercentProgress, TEST_LOCATION );
7656
7657   application.SendNotification();
7658   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7659
7660   // We did expect the animation to finish
7661   application.SendNotification();
7662   finishCheck.CheckSignalReceived();
7663   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, targetZ, TEST_LOCATION );
7664   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7665   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7666   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7667   END_TEST;
7668 }
7669
7670 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7671 {
7672   TestApplication application;
7673
7674   Actor actor = Actor::New();
7675   Stage::GetCurrent().Add(actor);
7676   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7677
7678   // Build the animation
7679   float durationSeconds(1.0f);
7680   Animation animation = Animation::New(durationSeconds);
7681   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7682   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7683
7684   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7685
7686   // Start the animation
7687   animation.Play();
7688
7689   bool signalReceived(false);
7690   AnimationFinishCheck finishCheck(signalReceived);
7691   animation.FinishedSignal().Connect(&application, finishCheck);
7692
7693   application.SendNotification();
7694   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7695
7696   // We didn't expect the animation to finish yet
7697   application.SendNotification();
7698   finishCheck.CheckSignalNotReceived();
7699
7700   // The position should have moved less, than with a linear alpha function
7701   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
7702   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7703   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7704   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7705   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7706   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7707   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
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.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7716   END_TEST;
7717 }
7718
7719 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7720 {
7721   TestApplication application;
7722
7723   Actor actor = Actor::New();
7724   Stage::GetCurrent().Add(actor);
7725   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7726
7727   // Build the animation
7728   float durationSeconds(1.0f);
7729   Animation animation = Animation::New(durationSeconds);
7730   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7731   float delay = 0.5f;
7732   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7733                        targetPosition,
7734                        TimePeriod( delay, durationSeconds - delay ) );
7735
7736   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7737
7738   // Start the animation
7739   animation.Play();
7740
7741   bool signalReceived(false);
7742   AnimationFinishCheck finishCheck(signalReceived);
7743   animation.FinishedSignal().Connect(&application, finishCheck);
7744
7745   application.SendNotification();
7746   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7747
7748   // We didn't expect the animation to finish yet
7749   application.SendNotification();
7750   finishCheck.CheckSignalNotReceived();
7751   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7752
7753   application.SendNotification();
7754   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7755
7756   // We didn't expect the animation to finish yet
7757   application.SendNotification();
7758   finishCheck.CheckSignalNotReceived();
7759   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), seventyFivePercentProgress, TEST_LOCATION );
7760
7761   application.SendNotification();
7762   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7763
7764   // We did expect the animation to finish
7765   application.SendNotification();
7766   finishCheck.CheckSignalReceived();
7767   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7768   END_TEST;
7769 }
7770
7771 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7772 {
7773   TestApplication application;
7774
7775   Actor actor = Actor::New();
7776   Stage::GetCurrent().Add(actor);
7777   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7778
7779   // Build the animation
7780   float durationSeconds(1.0f);
7781   Animation animation = Animation::New(durationSeconds);
7782   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7783   float delay = 0.5f;
7784   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7785                        targetPosition,
7786                        AlphaFunction::LINEAR,
7787                        TimePeriod( delay, durationSeconds - delay ) );
7788
7789   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7790
7791   // Start the animation
7792   animation.Play();
7793
7794   bool signalReceived(false);
7795   AnimationFinishCheck finishCheck(signalReceived);
7796   animation.FinishedSignal().Connect(&application, finishCheck);
7797
7798   application.SendNotification();
7799   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7800
7801   // We didn't expect the animation to finish yet
7802   application.SendNotification();
7803   finishCheck.CheckSignalNotReceived();
7804   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7805
7806   application.SendNotification();
7807   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7808
7809   // We didn't expect the animation to finish yet
7810   application.SendNotification();
7811   finishCheck.CheckSignalNotReceived();
7812   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), seventyFivePercentProgress, TEST_LOCATION );
7813
7814   application.SendNotification();
7815   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7816
7817   // We did expect the animation to finish
7818   application.SendNotification();
7819   finishCheck.CheckSignalReceived();
7820   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
7821   END_TEST;
7822 }
7823
7824 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7825 {
7826   TestApplication application;
7827
7828   Actor actor = Actor::New();
7829   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7830   Stage::GetCurrent().Add(actor);
7831   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7832
7833   // Build the animation
7834   float durationSeconds(1.0f);
7835   Animation animation = Animation::New(durationSeconds);
7836   Degree targetRotationDegrees(90.0f);
7837   Radian targetRotationRadians(targetRotationDegrees);
7838   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7839
7840   // Start the animation
7841   animation.Play();
7842
7843   // Target value should be retrievable straight away
7844   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7845
7846   bool signalReceived(false);
7847   AnimationFinishCheck finishCheck(signalReceived);
7848   animation.FinishedSignal().Connect(&application, finishCheck);
7849
7850   application.SendNotification();
7851   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7852
7853   // We didn't expect the animation to finish yet
7854   application.SendNotification();
7855   finishCheck.CheckSignalNotReceived();
7856   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7857
7858   application.SendNotification();
7859   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7860
7861   // We didn't expect the animation to finish yet
7862   application.SendNotification();
7863   finishCheck.CheckSignalNotReceived();
7864   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7865
7866   application.SendNotification();
7867   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7868
7869   // We didn't expect the animation to finish yet
7870   application.SendNotification();
7871   finishCheck.CheckSignalNotReceived();
7872   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7873
7874   application.SendNotification();
7875   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7876
7877   // We did expect the animation to finish
7878   application.SendNotification();
7879   finishCheck.CheckSignalReceived();
7880   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7881   END_TEST;
7882 }
7883
7884 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7885 {
7886   TestApplication application;
7887
7888   Actor actor = Actor::New();
7889   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7890   Stage::GetCurrent().Add(actor);
7891   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7892
7893   // Build the animation
7894   float durationSeconds(1.0f);
7895   Animation animation = Animation::New(durationSeconds);
7896   Degree targetRotationDegrees(90.0f);
7897   Radian targetRotationRadians(targetRotationDegrees);
7898   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7899   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7900
7901   // Start the animation
7902   animation.Play();
7903
7904   bool signalReceived(false);
7905   AnimationFinishCheck finishCheck(signalReceived);
7906   animation.FinishedSignal().Connect(&application, finishCheck);
7907
7908   application.SendNotification();
7909   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7910
7911   // We didn't expect the animation to finish yet
7912   application.SendNotification();
7913   finishCheck.CheckSignalNotReceived();
7914   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7915
7916   application.SendNotification();
7917   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7918
7919   // We didn't expect the animation to finish yet
7920   application.SendNotification();
7921   finishCheck.CheckSignalNotReceived();
7922   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7923
7924   application.SendNotification();
7925   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7926
7927   // We didn't expect the animation to finish yet
7928   application.SendNotification();
7929   finishCheck.CheckSignalNotReceived();
7930   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7931
7932   application.SendNotification();
7933   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7934
7935   // We did expect the animation to finish
7936   application.SendNotification();
7937   finishCheck.CheckSignalReceived();
7938   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7939   END_TEST;
7940 }
7941
7942 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7943 {
7944   TestApplication application;
7945
7946   Actor actor = Actor::New();
7947   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7948   Stage::GetCurrent().Add(actor);
7949   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7950
7951   // Build the animation
7952   float durationSeconds(1.0f);
7953   Animation animation = Animation::New(durationSeconds);
7954   Degree targetRotationDegrees(90.0f);
7955   Radian targetRotationRadians(targetRotationDegrees);
7956   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7957
7958   // Start the animation
7959   animation.Play();
7960
7961   bool signalReceived(false);
7962   AnimationFinishCheck finishCheck(signalReceived);
7963   animation.FinishedSignal().Connect(&application, finishCheck);
7964
7965   application.SendNotification();
7966   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7967
7968   // We didn't expect the animation to finish yet
7969   application.SendNotification();
7970   finishCheck.CheckSignalNotReceived();
7971   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7972
7973   application.SendNotification();
7974   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7975
7976   // We didn't expect the animation to finish yet
7977   application.SendNotification();
7978   finishCheck.CheckSignalNotReceived();
7979   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7980
7981   application.SendNotification();
7982   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7983
7984   // We didn't expect the animation to finish yet
7985   application.SendNotification();
7986   finishCheck.CheckSignalNotReceived();
7987   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7988
7989   application.SendNotification();
7990   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7991
7992   // We did expect the animation to finish
7993   application.SendNotification();
7994   finishCheck.CheckSignalReceived();
7995   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7996   END_TEST;
7997 }
7998
7999 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
8000 {
8001   TestApplication application;
8002
8003   Actor actor = Actor::New();
8004   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
8005   Stage::GetCurrent().Add(actor);
8006   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
8007
8008   // Build the animation
8009   float durationSeconds(1.0f);
8010   Animation animation = Animation::New(durationSeconds);
8011   Degree targetRotationDegrees(90.0f);
8012   Radian targetRotationRadians(targetRotationDegrees);
8013   float delay(0.1f);
8014   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
8015
8016   // Start the animation
8017   animation.Play();
8018
8019   bool signalReceived(false);
8020   AnimationFinishCheck finishCheck(signalReceived);
8021   animation.FinishedSignal().Connect(&application, finishCheck);
8022
8023   application.SendNotification();
8024   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8025
8026   // We didn't expect the animation to finish yet
8027   application.SendNotification();
8028   finishCheck.CheckSignalNotReceived();
8029   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8030   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8031
8032   application.SendNotification();
8033   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8034
8035   // We didn't expect the animation to finish yet
8036   application.SendNotification();
8037   finishCheck.CheckSignalNotReceived();
8038   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8039   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8040
8041   application.SendNotification();
8042   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8043
8044   // We didn't expect the animation to finish yet
8045   application.SendNotification();
8046   finishCheck.CheckSignalNotReceived();
8047   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8048   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8049
8050   application.SendNotification();
8051   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8052
8053   // We did expect the animation to finish
8054   application.SendNotification();
8055   finishCheck.CheckSignalReceived();
8056   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8057   END_TEST;
8058 }
8059
8060 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
8061 {
8062   TestApplication application;
8063
8064   Actor actor = Actor::New();
8065   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
8066   Stage::GetCurrent().Add(actor);
8067   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
8068
8069   // Build the animation
8070   float durationSeconds(1.0f);
8071   Animation animation = Animation::New(durationSeconds);
8072   Degree targetRotationDegrees(90.0f);
8073   Radian targetRotationRadians(targetRotationDegrees);
8074   float delay(0.1f);
8075   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
8076
8077   // Start the animation
8078   animation.Play();
8079
8080   bool signalReceived(false);
8081   AnimationFinishCheck finishCheck(signalReceived);
8082   animation.FinishedSignal().Connect(&application, finishCheck);
8083
8084   application.SendNotification();
8085   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8086
8087   // We didn't expect the animation to finish yet
8088   application.SendNotification();
8089   finishCheck.CheckSignalNotReceived();
8090   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
8091   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8092
8093   application.SendNotification();
8094   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8095
8096   // We didn't expect the animation to finish yet
8097   application.SendNotification();
8098   finishCheck.CheckSignalNotReceived();
8099   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
8100   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8101
8102   application.SendNotification();
8103   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8104
8105   // We didn't expect the animation to finish yet
8106   application.SendNotification();
8107   finishCheck.CheckSignalNotReceived();
8108   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
8109   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8110
8111   application.SendNotification();
8112   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8113
8114   // We did expect the animation to finish
8115   application.SendNotification();
8116   finishCheck.CheckSignalReceived();
8117   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
8118   END_TEST;
8119 }
8120
8121 int UtcDaliAnimationAnimateToActorScaleP(void)
8122 {
8123   TestApplication application;
8124
8125   Actor actor = Actor::New();
8126   Stage::GetCurrent().Add(actor);
8127   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
8128
8129   // Build the animation
8130   float durationSeconds(1.0f);
8131   Animation animation = Animation::New(durationSeconds);
8132   Vector3 targetScale(2.0f, 2.0f, 2.0f);
8133   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
8134
8135   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
8136
8137   // Start the animation
8138   animation.Play();
8139
8140   // Target value should be retrievable straight away
8141   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
8142   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
8143   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
8144   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, TEST_LOCATION );
8145
8146   bool signalReceived(false);
8147   AnimationFinishCheck finishCheck(signalReceived);
8148   animation.FinishedSignal().Connect(&application, finishCheck);
8149
8150   application.SendNotification();
8151   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8152
8153   // We didn't expect the animation to finish yet
8154   application.SendNotification();
8155   finishCheck.CheckSignalNotReceived();
8156   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), ninetyNinePercentProgress, TEST_LOCATION );
8157
8158   application.SendNotification();
8159   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8160
8161   // We did expect the animation to finish
8162   application.SendNotification();
8163   finishCheck.CheckSignalReceived();
8164   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
8165
8166   // Reset everything
8167   finishCheck.Reset();
8168   actor.SetScale(Vector3::ONE);
8169   application.SendNotification();
8170   application.Render(0);
8171   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
8172
8173   // Repeat with a different (ease-in) alpha function
8174   animation = Animation::New(durationSeconds);
8175   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
8176   animation.FinishedSignal().Connect(&application, finishCheck);
8177   animation.Play();
8178
8179   application.SendNotification();
8180   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
8181
8182   // We didn't expect the animation to finish yet
8183   application.SendNotification();
8184   finishCheck.CheckSignalNotReceived();
8185
8186   // The scale should have grown less, than with a linear alpha function
8187   Vector3 current(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
8188   DALI_TEST_CHECK( current.x > 1.0f );
8189   DALI_TEST_CHECK( current.y > 1.0f );
8190   DALI_TEST_CHECK( current.z > 1.0f );
8191   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
8192   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
8193   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
8194
8195   application.SendNotification();
8196   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
8197
8198   // We did expect the animation to finish
8199   application.SendNotification();
8200   finishCheck.CheckSignalReceived();
8201   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
8202
8203   // Reset everything
8204   finishCheck.Reset();
8205   actor.SetScale(Vector3::ONE);
8206   application.SendNotification();
8207   application.Render(0);
8208   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
8209
8210   // Repeat with a delay
8211   float delay = 0.5f;
8212   animation = Animation::New(durationSeconds);
8213   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
8214   animation.FinishedSignal().Connect(&application, finishCheck);
8215   animation.Play();
8216
8217   application.SendNotification();
8218   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8219
8220   // We didn't expect the animation to finish yet
8221   application.SendNotification();
8222   finishCheck.CheckSignalNotReceived();
8223   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
8224
8225   application.SendNotification();
8226   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8227
8228   // We did expect the animation to finish
8229   application.SendNotification();
8230   finishCheck.CheckSignalReceived();
8231   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
8232   END_TEST;
8233 }
8234
8235 int UtcDaliAnimationAnimateToActorScaleXP(void)
8236 {
8237   TestApplication application;
8238
8239   Actor actor = Actor::New();
8240   Stage::GetCurrent().Add(actor);
8241   float startValue(1.0f);
8242   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, startValue, TEST_LOCATION );
8243   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8244   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8245   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8246   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8247   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8248   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8249
8250   // Build the animation
8251   float durationSeconds(1.0f);
8252   Animation animation = Animation::New(durationSeconds);
8253   float targetX(10.0f);
8254   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
8255
8256   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
8257
8258   // Start the animation
8259   animation.Play();
8260
8261   // Target value should be retrievable straight away
8262   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
8263   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8264
8265   bool signalReceived(false);
8266   AnimationFinishCheck finishCheck(signalReceived);
8267   animation.FinishedSignal().Connect(&application, finishCheck);
8268
8269   application.SendNotification();
8270   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8271
8272   // We didn't expect the animation to finish yet
8273   application.SendNotification();
8274   finishCheck.CheckSignalNotReceived();
8275   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, fiftyPercentProgress, TEST_LOCATION );
8276   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
8277   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8278   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8279
8280   application.SendNotification();
8281   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8282
8283   // We did expect the animation to finish
8284   application.SendNotification();
8285   finishCheck.CheckSignalReceived();
8286   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, targetX, TEST_LOCATION );
8287   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
8288   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8289   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8290   END_TEST;
8291 }
8292
8293 int UtcDaliAnimationAnimateToActorScaleYP(void)
8294 {
8295   TestApplication application;
8296
8297   Actor actor = Actor::New();
8298   Stage::GetCurrent().Add(actor);
8299   float startValue(1.0f);
8300   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, startValue, TEST_LOCATION );
8301   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8302   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8303   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8304   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8305   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8306   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8307
8308   // Build the animation
8309   float durationSeconds(1.0f);
8310   Animation animation = Animation::New(durationSeconds);
8311   float targetY(1000.0f);
8312   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
8313
8314   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
8315
8316   // Start the animation
8317   animation.Play();
8318
8319   // Target value should be retrievable straight away
8320   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
8321   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8322
8323   bool signalReceived(false);
8324   AnimationFinishCheck finishCheck(signalReceived);
8325   animation.FinishedSignal().Connect(&application, finishCheck);
8326
8327   application.SendNotification();
8328   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8329
8330   // We didn't expect the animation to finish yet
8331   application.SendNotification();
8332   finishCheck.CheckSignalNotReceived();
8333   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, fiftyPercentProgress, TEST_LOCATION );
8334   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8335   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
8336   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8337
8338   application.SendNotification();
8339   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8340
8341   // We did expect the animation to finish
8342   application.SendNotification();
8343   finishCheck.CheckSignalReceived();
8344   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, targetY, TEST_LOCATION );
8345   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8346   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
8347   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8348   END_TEST;
8349 }
8350
8351 int UtcDaliAnimationAnimateToActorScaleZP(void)
8352 {
8353   TestApplication application;
8354
8355   Actor actor = Actor::New();
8356   Stage::GetCurrent().Add(actor);
8357   float startValue(1.0f);
8358   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, startValue, TEST_LOCATION );
8359   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
8360   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
8361   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
8362   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8363   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8364   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
8365
8366   // Build the animation
8367   float durationSeconds(1.0f);
8368   Animation animation = Animation::New(durationSeconds);
8369   float targetZ(-1000.0f);
8370   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
8371
8372   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
8373
8374   // Start the animation
8375   animation.Play();
8376
8377   // Target value should be retrievable straight away
8378   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
8379   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8380
8381   bool signalReceived(false);
8382   AnimationFinishCheck finishCheck(signalReceived);
8383   animation.FinishedSignal().Connect(&application, finishCheck);
8384
8385   application.SendNotification();
8386   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8387
8388   // We didn't expect the animation to finish yet
8389   application.SendNotification();
8390   finishCheck.CheckSignalNotReceived();
8391   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, fiftyPercentProgress, TEST_LOCATION );
8392   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8393   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8394   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
8395
8396   application.SendNotification();
8397   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8398
8399   // We did expect the animation to finish
8400   application.SendNotification();
8401   finishCheck.CheckSignalReceived();
8402   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, targetZ, TEST_LOCATION );
8403   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
8404   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
8405   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
8406   END_TEST;
8407 }
8408
8409 int UtcDaliAnimationAnimateToActorColorP(void)
8410 {
8411   TestApplication application;
8412
8413   Actor actor = Actor::New();
8414   Stage::GetCurrent().Add(actor);
8415   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
8416
8417   // Build the animation
8418   float durationSeconds(1.0f);
8419   Animation animation = Animation::New(durationSeconds);
8420   Vector4 targetColor(Color::RED);
8421   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
8422
8423   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
8424   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
8425
8426   // Start the animation
8427   animation.Play();
8428
8429   // Target value should be retrievable straight away
8430   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8431   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
8432   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
8433   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
8434   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
8435   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
8436
8437   bool signalReceived(false);
8438   AnimationFinishCheck finishCheck(signalReceived);
8439   animation.FinishedSignal().Connect(&application, finishCheck);
8440
8441   application.SendNotification();
8442   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8443
8444   // We didn't expect the animation to finish yet
8445   application.SendNotification();
8446   finishCheck.CheckSignalNotReceived();
8447   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), tenPercentProgress, TEST_LOCATION );
8448
8449   application.SendNotification();
8450   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8451
8452   // We did expect the animation to finish
8453   application.SendNotification();
8454   finishCheck.CheckSignalReceived();
8455   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8456
8457   // Reset everything
8458   finishCheck.Reset();
8459   actor.SetProperty( Actor::Property::COLOR,Color::WHITE);
8460   application.SendNotification();
8461   application.Render(0);
8462   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
8463
8464   // Repeat with a different (ease-in) alpha function
8465   animation = Animation::New(durationSeconds);
8466   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
8467   animation.FinishedSignal().Connect(&application, finishCheck);
8468   animation.Play();
8469
8470   application.SendNotification();
8471   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8472
8473   // We didn't expect the animation to finish yet
8474   application.SendNotification();
8475   finishCheck.CheckSignalNotReceived();
8476
8477   // The color should have changed less, than with a linear alpha function
8478   Vector4 current(actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
8479   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
8480   DALI_TEST_CHECK( current.y < 1.0f );
8481   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
8482   DALI_TEST_CHECK( current.z  < 1.0f );
8483   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
8484   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
8485
8486   application.SendNotification();
8487   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
8488
8489   // We did expect the animation to finish
8490   application.SendNotification();
8491   finishCheck.CheckSignalReceived();
8492   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8493
8494   // Reset everything
8495   finishCheck.Reset();
8496   actor.SetProperty( Actor::Property::COLOR,Color::WHITE);
8497   application.SendNotification();
8498   application.Render(0);
8499   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
8500
8501   // Repeat with a shorter animator duration
8502   float animatorDuration = 0.5f;
8503   animation = Animation::New(durationSeconds);
8504   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
8505   animation.FinishedSignal().Connect(&application, finishCheck);
8506   animation.Play();
8507
8508   application.SendNotification();
8509   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
8510
8511   // We didn't expect the animation to finish yet
8512   application.SendNotification();
8513   finishCheck.CheckSignalNotReceived();
8514   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), twentyPercentProgress, TEST_LOCATION );
8515
8516   application.SendNotification();
8517   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
8518
8519   // We didn't expect the animation to finish yet
8520   application.SendNotification();
8521   finishCheck.CheckSignalNotReceived();
8522   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8523
8524   application.SendNotification();
8525   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8526
8527   // We did expect the animation to finish
8528   application.SendNotification();
8529   finishCheck.CheckSignalReceived();
8530   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
8531   END_TEST;
8532 }
8533
8534 int UtcDaliAnimationAnimateToActorColorRedP(void)
8535 {
8536   TestApplication application;
8537
8538   Actor actor = Actor::New();
8539   Stage::GetCurrent().Add(actor);
8540   float startValue(1.0f);
8541   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, startValue, TEST_LOCATION );
8542   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8543   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8544   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8545   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8546   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8547   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8548   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8549   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8550
8551   // Build the animation
8552   float durationSeconds(1.0f);
8553   Animation animation = Animation::New(durationSeconds);
8554   float targetRed(0.5f);
8555   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
8556
8557   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8558
8559   // Start the animation
8560   animation.Play();
8561
8562   // Target value should be retrievable straight away
8563   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8564   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8565
8566   bool signalReceived(false);
8567   AnimationFinishCheck finishCheck(signalReceived);
8568   animation.FinishedSignal().Connect(&application, finishCheck);
8569
8570   application.SendNotification();
8571   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8572
8573   // We didn't expect the animation to finish yet
8574   application.SendNotification();
8575   finishCheck.CheckSignalNotReceived();
8576   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, fiftyPercentProgress, TEST_LOCATION );
8577   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8579   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8580   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8581
8582   application.SendNotification();
8583   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8584
8585   // We did expect the animation to finish
8586   application.SendNotification();
8587   finishCheck.CheckSignalReceived();
8588   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, targetRed, TEST_LOCATION );
8589   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8590   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8591   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8592   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8593   END_TEST;
8594 }
8595
8596 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8597 {
8598   TestApplication application;
8599
8600   Actor actor = Actor::New();
8601   Stage::GetCurrent().Add(actor);
8602   float startValue(1.0f);
8603   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, startValue, TEST_LOCATION );
8604   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8605   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8606   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8607   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8608   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8609   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8610   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8611   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8612
8613   // Build the animation
8614   float durationSeconds(1.0f);
8615   Animation animation = Animation::New(durationSeconds);
8616   float targetGreen(0.5f);
8617   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8618
8619   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8620
8621   // Start the animation
8622   animation.Play();
8623
8624   // Target value should be retrievable straight away
8625   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8626   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8627
8628   bool signalReceived(false);
8629   AnimationFinishCheck finishCheck(signalReceived);
8630   animation.FinishedSignal().Connect(&application, finishCheck);
8631
8632   application.SendNotification();
8633   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8634
8635   // We didn't expect the animation to finish yet
8636   application.SendNotification();
8637   finishCheck.CheckSignalNotReceived();
8638   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, fiftyPercentProgress, TEST_LOCATION );
8639   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8640   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8641   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8642   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8643
8644   application.SendNotification();
8645   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8646
8647   // We did expect the animation to finish
8648   application.SendNotification();
8649   finishCheck.CheckSignalReceived();
8650   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, targetGreen, TEST_LOCATION );
8651   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8652   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8653   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8654   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8655   END_TEST;
8656 }
8657
8658 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8659 {
8660   TestApplication application;
8661
8662   Actor actor = Actor::New();
8663   Stage::GetCurrent().Add(actor);
8664   float startValue(1.0f);
8665   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, startValue, TEST_LOCATION );
8666   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8667   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8668   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8669   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8670   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8671   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8672   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8673   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8674
8675   // Build the animation
8676   float durationSeconds(1.0f);
8677   Animation animation = Animation::New(durationSeconds);
8678   float targetBlue(0.5f);
8679   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8680
8681   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8682
8683   // Start the animation
8684   animation.Play();
8685
8686   // Target value should be retrievable straight away
8687   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8688   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8689
8690   bool signalReceived(false);
8691   AnimationFinishCheck finishCheck(signalReceived);
8692   animation.FinishedSignal().Connect(&application, finishCheck);
8693
8694   application.SendNotification();
8695   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8696
8697   // We didn't expect the animation to finish yet
8698   application.SendNotification();
8699   finishCheck.CheckSignalNotReceived();
8700   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, fiftyPercentProgress, TEST_LOCATION );
8701   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8702   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8703   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8704   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8705
8706   application.SendNotification();
8707   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8708
8709   // We did expect the animation to finish
8710   application.SendNotification();
8711   finishCheck.CheckSignalReceived();
8712   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, targetBlue, TEST_LOCATION );
8713   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8714   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8716   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8717   END_TEST;
8718 }
8719
8720 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8721 {
8722   TestApplication application;
8723
8724   Actor actor = Actor::New();
8725   Stage::GetCurrent().Add(actor);
8726   float startValue(1.0f);
8727   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
8728   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8729   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8730   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8731   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8732   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8733   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8734   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8735   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8736
8737   // Build the animation
8738   float durationSeconds(1.0f);
8739   Animation animation = Animation::New(durationSeconds);
8740   float targetAlpha(0.5f);
8741   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8742
8743   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8744
8745   // Start the animation
8746   animation.Play();
8747
8748   // Target value should be retrievable straight away
8749   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8750   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8751   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8752
8753   bool signalReceived(false);
8754   AnimationFinishCheck finishCheck(signalReceived);
8755   animation.FinishedSignal().Connect(&application, finishCheck);
8756
8757   application.SendNotification();
8758   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8759
8760   // We didn't expect the animation to finish yet
8761   application.SendNotification();
8762   finishCheck.CheckSignalNotReceived();
8763   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, fiftyPercentProgress, TEST_LOCATION );
8764   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8765   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8766   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8767   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8768
8769   application.SendNotification();
8770   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8771
8772   // We did expect the animation to finish
8773   application.SendNotification();
8774   finishCheck.CheckSignalReceived();
8775   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, targetAlpha, TEST_LOCATION );
8776   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8777   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8778   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8779   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8780   END_TEST;
8781 }
8782
8783 int UtcDaliAnimationKeyFrames01P(void)
8784 {
8785   TestApplication application;
8786
8787   KeyFrames keyFrames = KeyFrames::New();
8788   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8789
8790   keyFrames.Add(0.0f, 0.1f);
8791
8792   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8793
8794   KeyFrames keyFrames2( keyFrames);
8795   DALI_TEST_CHECK( keyFrames2 );
8796   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8797
8798   KeyFrames keyFrames3 = KeyFrames::New();
8799   keyFrames3.Add(0.6f, true);
8800   DALI_TEST_CHECK( keyFrames3 );
8801   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8802
8803   keyFrames3 = keyFrames;
8804   DALI_TEST_CHECK( keyFrames3 );
8805   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8806
8807   END_TEST;
8808 }
8809
8810 int UtcDaliAnimationKeyFrames02N(void)
8811 {
8812   TestApplication application;
8813
8814   KeyFrames keyFrames = KeyFrames::New();
8815   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8816
8817   keyFrames.Add(0.0f, 0.1f);
8818   keyFrames.Add(0.2f, 0.5f);
8819   keyFrames.Add(0.4f, 0.0f);
8820   keyFrames.Add(0.6f, 1.0f);
8821   keyFrames.Add(0.8f, 0.7f);
8822   keyFrames.Add(1.0f, 0.9f);
8823
8824   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8825
8826   DALI_TEST_ASSERTION(
8827   {
8828     keyFrames.Add(1.9f, false);
8829   }, "mType == value.GetType()" );
8830
8831   END_TEST;
8832 }
8833
8834 int UtcDaliAnimationKeyFrames03N(void)
8835 {
8836   TestApplication application;
8837
8838   KeyFrames keyFrames = KeyFrames::New();
8839   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8840
8841   keyFrames.Add(0.0f, true);
8842   keyFrames.Add(0.2f, false);
8843   keyFrames.Add(0.4f, false);
8844   keyFrames.Add(0.6f, true);
8845   keyFrames.Add(0.8f, true);
8846   keyFrames.Add(1.0f, false);
8847
8848   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8849
8850   DALI_TEST_ASSERTION(
8851   {
8852     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8853   }, "mType == value.GetType()" );
8854
8855   END_TEST;
8856 }
8857
8858 int UtcDaliAnimationKeyFrames04N(void)
8859 {
8860   TestApplication application;
8861
8862   KeyFrames keyFrames = KeyFrames::New();
8863   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8864
8865   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8866   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8867   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8868   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8869   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8870   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8871
8872   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8873
8874   DALI_TEST_ASSERTION(
8875   {
8876     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8877   }, "mType == value.GetType()" );
8878
8879   END_TEST;
8880 }
8881
8882 int UtcDaliAnimationKeyFrames05N(void)
8883 {
8884   TestApplication application;
8885
8886   KeyFrames keyFrames = KeyFrames::New();
8887   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8888
8889   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8890   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8891   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8892   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8893   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8894   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8895
8896   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8897
8898   DALI_TEST_ASSERTION(
8899   {
8900     keyFrames.Add(0.7f, 1.0f);
8901   }, "mType == value.GetType()" );
8902
8903   END_TEST;
8904 }
8905
8906 int UtcDaliAnimationKeyFrames06N(void)
8907 {
8908   TestApplication application;
8909
8910   KeyFrames keyFrames = KeyFrames::New();
8911   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8912
8913   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8914   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8915   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8916   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8917   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8918   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8919
8920   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8921
8922   DALI_TEST_ASSERTION(
8923   {
8924     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8925   }, "mType == value.GetType()" );
8926
8927   END_TEST;
8928 }
8929
8930 int UtcDaliAnimationKeyFrames07N(void)
8931 {
8932   TestApplication application;
8933
8934   KeyFrames keyFrames = KeyFrames::New();
8935   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8936
8937   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8938   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8939   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8940   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8941   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8942   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8943
8944   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8945
8946   DALI_TEST_ASSERTION(
8947   {
8948     keyFrames.Add(0.7f, 1.1f);
8949   }, "mType == value.GetType()" );
8950
8951   END_TEST;
8952 }
8953
8954 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8955 {
8956   TestApplication application;
8957
8958   float startValue(1.0f);
8959   Actor actor = Actor::New();
8960   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
8961   Stage::GetCurrent().Add(actor);
8962
8963   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
8964   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8965   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8966   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8967   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8968   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8969   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8970   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8971   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8972
8973   // Build the animation
8974   float durationSeconds(1.0f);
8975   Animation animation = Animation::New(durationSeconds);
8976
8977   KeyFrames keyFrames = KeyFrames::New();
8978   keyFrames.Add(0.0f, 0.1f);
8979   keyFrames.Add(0.2f, 0.5f);
8980   keyFrames.Add(0.4f, 0.0f);
8981   keyFrames.Add(0.6f, 1.0f);
8982   keyFrames.Add(0.8f, 0.7f);
8983   keyFrames.Add(1.0f, 0.9f);
8984
8985   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8986
8987   // Start the animation
8988   animation.Play();
8989
8990   // Final key frame value should be retrievable straight away
8991   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, TEST_LOCATION );
8992
8993   bool signalReceived(false);
8994   AnimationFinishCheck finishCheck(signalReceived);
8995   animation.FinishedSignal().Connect(&application, finishCheck);
8996   application.SendNotification();
8997   application.Render(0);
8998   application.SendNotification();
8999   finishCheck.CheckSignalNotReceived();
9000   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.1f, TEST_LOCATION );
9001
9002   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
9003   application.SendNotification();
9004   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9005   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9006   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9007   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
9008   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.3f, 0.01f, TEST_LOCATION );
9009
9010   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
9011   application.SendNotification();
9012   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9013   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9014   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9015   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
9016   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.25f, 0.01f, TEST_LOCATION );
9017
9018   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
9019   application.SendNotification();
9020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9022   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9023   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
9024   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.0f, 0.01f, TEST_LOCATION );
9025
9026   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
9027   application.SendNotification();
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), 0.7f, 0.01f, TEST_LOCATION );
9032   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.7f, 0.01f, TEST_LOCATION );
9033
9034   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
9035   application.SendNotification();
9036   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9037   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9038   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9039   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
9040   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.8f, 0.01f, TEST_LOCATION );
9041
9042   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
9043   application.SendNotification();
9044   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9045   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9046   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9047   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
9048   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.9f, 0.01f, TEST_LOCATION );
9049
9050   // We did expect the animation to finish
9051
9052   finishCheck.CheckSignalReceived();
9053   END_TEST;
9054 }
9055
9056 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
9057 {
9058   TestApplication application;
9059
9060   float startValue(1.0f);
9061   Actor actor = Actor::New();
9062   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9063   Stage::GetCurrent().Add(actor);
9064
9065   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9066   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9067   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9068   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9069   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9070   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9071   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9072   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9073   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9074
9075   // Build the animation
9076   float durationSeconds(1.0f);
9077   Animation animation = Animation::New(durationSeconds);
9078
9079   KeyFrames keyFrames = KeyFrames::New();
9080   keyFrames.Add(0.0f, 0.1f);
9081   keyFrames.Add(0.2f, 0.5f);
9082   keyFrames.Add(0.4f, 0.0f);
9083   keyFrames.Add(0.6f, 1.0f);
9084   keyFrames.Add(0.8f, 0.7f);
9085   keyFrames.Add(1.0f, 0.9f);
9086
9087   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
9088
9089   // Start the animation
9090   animation.Play();
9091
9092   bool signalReceived(false);
9093   AnimationFinishCheck finishCheck(signalReceived);
9094   animation.FinishedSignal().Connect(&application, finishCheck);
9095   application.SendNotification();
9096   application.Render(0);
9097   application.SendNotification();
9098   finishCheck.CheckSignalNotReceived();
9099   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.1f, TEST_LOCATION );
9100
9101   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
9102   application.SendNotification();
9103   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9104   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9105   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9106   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
9107   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.36f, 0.01f, TEST_LOCATION );
9108
9109   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
9110   application.SendNotification();
9111   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9112   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9113   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9114   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
9115   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.21f, 0.01f, TEST_LOCATION );
9116
9117   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
9118   application.SendNotification();
9119   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9120   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9121   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9122   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
9123   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.0f, 0.01f, TEST_LOCATION );
9124
9125   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
9126   application.SendNotification();
9127   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9128   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9129   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9130   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
9131   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.7f, 0.01f, TEST_LOCATION );
9132
9133   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
9134   application.SendNotification();
9135   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9136   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9137   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9138   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
9139   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.76f, 0.01f, TEST_LOCATION );
9140
9141   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
9142   application.SendNotification();
9143   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9144   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9145   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9146   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
9147   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.9f, 0.01f, TEST_LOCATION );
9148
9149   // We did expect the animation to finish
9150
9151   finishCheck.CheckSignalReceived();
9152   END_TEST;
9153 }
9154
9155 int UtcDaliAnimationAnimateBetweenActorColorP(void)
9156 {
9157   TestApplication application;
9158
9159   float startValue(1.0f);
9160   Actor actor = Actor::New();
9161   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9162   Stage::GetCurrent().Add(actor);
9163
9164   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9165   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9166   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9167   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9168   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9169   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9170   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9171   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9172   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9173
9174   // Build the animation
9175   float durationSeconds(1.0f);
9176   Animation animation = Animation::New(durationSeconds);
9177
9178   KeyFrames keyFrames = KeyFrames::New();
9179   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9180   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9181   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9182
9183   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
9184
9185   // Start the animation
9186   animation.Play();
9187
9188   bool signalReceived(false);
9189   AnimationFinishCheck finishCheck(signalReceived);
9190   animation.FinishedSignal().Connect(&application, finishCheck);
9191   application.SendNotification();
9192   application.Render(0);
9193   application.SendNotification();
9194   finishCheck.CheckSignalNotReceived();
9195   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9196   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9197   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9198   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9199
9200   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9201   application.SendNotification();
9202   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9203   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9204   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9205   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9206
9207   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9208   application.SendNotification();
9209   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9210   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9211   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9212   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9213
9214   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9215   application.SendNotification();
9216   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9217   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9218   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9219   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9220
9221   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9222   application.SendNotification();
9223   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9224   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9225   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9226   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9227
9228   // We did expect the animation to finish
9229
9230   finishCheck.CheckSignalReceived();
9231   END_TEST;
9232 }
9233
9234 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
9235 {
9236   TestApplication application;
9237
9238   float startValue(1.0f);
9239   Actor actor = Actor::New();
9240   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9241   Stage::GetCurrent().Add(actor);
9242
9243   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9244   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9245   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9246   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9247   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9248   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9249   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9250   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9251   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9252
9253   // Build the animation
9254   float durationSeconds(1.0f);
9255   Animation animation = Animation::New(durationSeconds);
9256
9257   KeyFrames keyFrames = KeyFrames::New();
9258   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9259   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9260   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9261
9262   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
9263
9264   // Start the animation
9265   animation.Play();
9266
9267   bool signalReceived(false);
9268   AnimationFinishCheck finishCheck(signalReceived);
9269   animation.FinishedSignal().Connect(&application, finishCheck);
9270   application.SendNotification();
9271   application.Render(0);
9272   application.SendNotification();
9273   finishCheck.CheckSignalNotReceived();
9274   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9275   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9276   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9277   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9278
9279   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9280   application.SendNotification();
9281   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9282   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9283   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9284   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9285
9286   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9287   application.SendNotification();
9288   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9289   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9290   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9291   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9292
9293   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9294   application.SendNotification();
9295   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9296   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9297   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9298   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9299
9300   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9301   application.SendNotification();
9302   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9303   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9304   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9305   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9306
9307   // We did expect the animation to finish
9308
9309   finishCheck.CheckSignalReceived();
9310   END_TEST;
9311 }
9312
9313 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
9314 {
9315   TestApplication application;
9316
9317   Actor actor = Actor::New();
9318   AngleAxis aa(Degree(90), Vector3::XAXIS);
9319   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9320   Stage::GetCurrent().Add(actor);
9321
9322   application.SendNotification();
9323   application.Render(0);
9324
9325   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9326
9327   // Build the animation
9328   float durationSeconds(1.0f);
9329   Animation animation = Animation::New(durationSeconds);
9330
9331   KeyFrames keyFrames = KeyFrames::New();
9332   keyFrames.Add(0.0f, false);
9333   keyFrames.Add(0.2f, true);
9334   keyFrames.Add(0.4f, true);
9335   keyFrames.Add(0.8f, false);
9336   keyFrames.Add(1.0f, true);
9337
9338   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
9339
9340   // Start the animation
9341   animation.Play();
9342
9343   // Final key frame value should be retrievable straight away
9344   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9345
9346   bool signalReceived(false);
9347   AnimationFinishCheck finishCheck(signalReceived);
9348   animation.FinishedSignal().Connect(&application, finishCheck);
9349   application.SendNotification();
9350   application.SendNotification();
9351   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9352   application.SendNotification();
9353   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9354   application.SendNotification();
9355
9356   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION);
9357   finishCheck.CheckSignalReceived();
9358   END_TEST;
9359 }
9360
9361 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
9362 {
9363   TestApplication application;
9364
9365   Actor actor = Actor::New();
9366   AngleAxis aa(Degree(90), Vector3::XAXIS);
9367   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9368   Stage::GetCurrent().Add(actor);
9369
9370   application.SendNotification();
9371   application.Render(0);
9372
9373   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
9374
9375   // Build the animation
9376   float durationSeconds(1.0f);
9377   Animation animation = Animation::New(durationSeconds);
9378
9379   KeyFrames keyFrames = KeyFrames::New();
9380   keyFrames.Add(0.0f, false);
9381   keyFrames.Add(0.2f, true);
9382   keyFrames.Add(0.4f, true);
9383   keyFrames.Add(0.8f, false);
9384   keyFrames.Add(1.0f, true);
9385
9386   //Cubic interpolation for boolean values should be ignored
9387   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
9388
9389   // Start the animation
9390   animation.Play();
9391
9392   bool signalReceived(false);
9393   AnimationFinishCheck finishCheck(signalReceived);
9394   animation.FinishedSignal().Connect(&application, finishCheck);
9395   application.SendNotification();
9396   application.SendNotification();
9397   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9398   application.SendNotification();
9399   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9400   application.SendNotification();
9401
9402   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION);
9403   finishCheck.CheckSignalReceived();
9404   END_TEST;
9405 }
9406
9407 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
9408 {
9409   TestApplication application;
9410
9411   Actor actor = Actor::New();
9412   AngleAxis aa(Degree(90), Vector3::XAXIS);
9413   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9414   Stage::GetCurrent().Add(actor);
9415
9416   application.SendNotification();
9417   application.Render(0);
9418   Quaternion start(Radian(aa.angle), aa.axis);
9419   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), start, 0.001f, TEST_LOCATION );
9420
9421   // Build the animation
9422   float durationSeconds(1.0f);
9423   Animation animation = Animation::New(durationSeconds);
9424
9425   KeyFrames keyFrames = KeyFrames::New();
9426   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9427
9428   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9429
9430   // Start the animation
9431   animation.Play();
9432
9433   // Final key frame value should be retrievable straight away
9434   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Degree( 60 ), Vector3::ZAXIS ), TEST_LOCATION );
9435
9436   bool signalReceived(false);
9437   AnimationFinishCheck finishCheck(signalReceived);
9438   animation.FinishedSignal().Connect(&application, finishCheck);
9439   application.SendNotification();
9440   application.SendNotification();
9441   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9442   application.SendNotification();
9443   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9444   application.SendNotification();
9445
9446   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9447
9448   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9449   finishCheck.CheckSignalReceived();
9450   END_TEST;
9451 }
9452
9453 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
9454 {
9455   TestApplication application;
9456
9457   Actor actor = Actor::New();
9458   AngleAxis aa(Degree(90), Vector3::XAXIS);
9459   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9460   application.SendNotification();
9461   application.Render(0);
9462   Stage::GetCurrent().Add(actor);
9463
9464   Quaternion start(Radian(aa.angle), aa.axis);
9465   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), start, 0.001f, TEST_LOCATION );
9466
9467   // Build the animation
9468   float durationSeconds(1.0f);
9469   Animation animation = Animation::New(durationSeconds);
9470
9471   KeyFrames keyFrames = KeyFrames::New();
9472   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9473   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9474   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9475
9476   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
9477
9478   // Start the animation
9479   animation.Play();
9480
9481   bool signalReceived(false);
9482   AnimationFinishCheck finishCheck(signalReceived);
9483   animation.FinishedSignal().Connect(&application, finishCheck);
9484   application.SendNotification();
9485   application.Render(0);
9486   application.SendNotification();
9487   finishCheck.CheckSignalNotReceived();
9488
9489   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9490   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9491
9492   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9493   application.SendNotification();
9494   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9495   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9496
9497   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9498   application.SendNotification();
9499   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9500   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9501
9502   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9503   application.SendNotification();
9504   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
9505   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9506
9507   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9508   application.SendNotification();
9509   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9510   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9511
9512   // We did expect the animation to finish
9513
9514   finishCheck.CheckSignalReceived();
9515   END_TEST;
9516 }
9517
9518 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
9519 {
9520   TestApplication application;
9521
9522   Actor actor = Actor::New();
9523   AngleAxis aa(Degree(90), Vector3::XAXIS);
9524   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9525   Stage::GetCurrent().Add(actor);
9526
9527   application.SendNotification();
9528   application.Render(0);
9529   Quaternion start(Radian(aa.angle), aa.axis);
9530   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), start, 0.001f, TEST_LOCATION );
9531
9532   // Build the animation
9533   float durationSeconds(1.0f);
9534   Animation animation = Animation::New(durationSeconds);
9535
9536   KeyFrames keyFrames = KeyFrames::New();
9537   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
9538
9539   //Cubic interpolation should be ignored for quaternions
9540   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9541
9542   // Start the animation
9543   animation.Play();
9544
9545   bool signalReceived(false);
9546   AnimationFinishCheck finishCheck(signalReceived);
9547   animation.FinishedSignal().Connect(&application, finishCheck);
9548   application.SendNotification();
9549   application.SendNotification();
9550   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9551   application.SendNotification();
9552   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9553   application.SendNotification();
9554
9555   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9556
9557   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9558   finishCheck.CheckSignalReceived();
9559   END_TEST;
9560 }
9561
9562 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9563 {
9564   TestApplication application;
9565
9566   Actor actor = Actor::New();
9567   AngleAxis aa(Degree(90), Vector3::XAXIS);
9568   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(aa.angle, aa.axis) );
9569   application.SendNotification();
9570   application.Render(0);
9571   Stage::GetCurrent().Add(actor);
9572
9573   Quaternion start(Radian(aa.angle), aa.axis);
9574   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), start, 0.001f, TEST_LOCATION );
9575
9576   // Build the animation
9577   float durationSeconds(1.0f);
9578   Animation animation = Animation::New(durationSeconds);
9579
9580   KeyFrames keyFrames = KeyFrames::New();
9581   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9582   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9583   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9584
9585   //Cubic interpolation should be ignored for quaternions
9586   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9587
9588   // Start the animation
9589   animation.Play();
9590
9591   bool signalReceived(false);
9592   AnimationFinishCheck finishCheck(signalReceived);
9593   animation.FinishedSignal().Connect(&application, finishCheck);
9594   application.SendNotification();
9595   application.Render(0);
9596   application.SendNotification();
9597   finishCheck.CheckSignalNotReceived();
9598
9599   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9600   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9601
9602   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9603   application.SendNotification();
9604   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9605   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9606
9607   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9608   application.SendNotification();
9609   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9610   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9611
9612   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9613   application.SendNotification();
9614   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9615   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9616
9617   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9618   application.SendNotification();
9619   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9620   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), check, 0.001f, TEST_LOCATION );
9621
9622   // We did expect the animation to finish
9623
9624   finishCheck.CheckSignalReceived();
9625   END_TEST;
9626 }
9627
9628 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9629 {
9630   TestApplication application;
9631
9632   float startValue(1.0f);
9633   Actor actor = Actor::New();
9634   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9635   Stage::GetCurrent().Add(actor);
9636
9637   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9638   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9639   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9640   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9641   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9642   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9643   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9644   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9645   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9646
9647   // Build the animation
9648   float durationSeconds(1.0f);
9649   Animation animation = Animation::New(durationSeconds);
9650
9651   KeyFrames keyFrames = KeyFrames::New();
9652   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9653   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9654   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9655
9656   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9657
9658   // Start the animation
9659   animation.Play();
9660
9661   bool signalReceived(false);
9662   AnimationFinishCheck finishCheck(signalReceived);
9663   animation.FinishedSignal().Connect(&application, finishCheck);
9664   application.SendNotification();
9665   application.Render(0);
9666   application.SendNotification();
9667   finishCheck.CheckSignalNotReceived();
9668   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9669   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9670   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9671   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9672
9673   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9674   application.SendNotification();
9675   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9676   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9677   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9678   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9679
9680   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9681   application.SendNotification();
9682   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9683   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9684   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9685   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9686
9687   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9688   application.SendNotification();
9689   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9690   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9691   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9692   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9693
9694   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9695   application.SendNotification();
9696   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9697   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9698   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9699   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9700
9701   // We did expect the animation to finish
9702
9703   finishCheck.CheckSignalReceived();
9704   END_TEST;
9705 }
9706
9707 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9708 {
9709   TestApplication application;
9710
9711   float startValue(1.0f);
9712   Actor actor = Actor::New();
9713   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9714   Stage::GetCurrent().Add(actor);
9715
9716   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9717   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9718   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9719   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9720   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9722   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9723   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9724   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9725
9726   // Build the animation
9727   float durationSeconds(1.0f);
9728   Animation animation = Animation::New(durationSeconds);
9729
9730   KeyFrames keyFrames = KeyFrames::New();
9731   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9732   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9733   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9734
9735   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9736
9737   // Start the animation
9738   animation.Play();
9739
9740   bool signalReceived(false);
9741   AnimationFinishCheck finishCheck(signalReceived);
9742   animation.FinishedSignal().Connect(&application, finishCheck);
9743   application.SendNotification();
9744   application.Render(0);
9745   application.SendNotification();
9746   finishCheck.CheckSignalNotReceived();
9747   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9748   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9749   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9750   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9751
9752   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9753   application.SendNotification();
9754   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9755   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9756   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9757   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9758
9759   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9760   application.SendNotification();
9761   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9762   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9763   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9764   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9765
9766   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9767   application.SendNotification();
9768   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9770   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9771   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9772
9773   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9774   application.SendNotification();
9775   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9776   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9777   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9778   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9779
9780   // We did expect the animation to finish
9781
9782   finishCheck.CheckSignalReceived();
9783   END_TEST;
9784 }
9785
9786 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9787 {
9788   TestApplication application;
9789
9790   float startValue(1.0f);
9791   Actor actor = Actor::New();
9792   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9793   Stage::GetCurrent().Add(actor);
9794
9795   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9796   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9797   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9798   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9799   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9800   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9801   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9802   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9803   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9804
9805   // Build the animation
9806   float durationSeconds(1.0f);
9807   float delay = 0.5f;
9808   Animation animation = Animation::New(durationSeconds);
9809
9810   KeyFrames keyFrames = KeyFrames::New();
9811   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9812   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9813   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9814
9815   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9816
9817   // Start the animation
9818   animation.Play();
9819
9820   bool signalReceived(false);
9821   AnimationFinishCheck finishCheck(signalReceived);
9822   animation.FinishedSignal().Connect(&application, finishCheck);
9823   application.SendNotification();
9824
9825   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9826   application.SendNotification();
9827   finishCheck.CheckSignalNotReceived();
9828   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9829   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9830   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9831   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9832
9833   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9834   application.SendNotification();
9835   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9836   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9837   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9838   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9839
9840   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9841   application.SendNotification();
9842   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9843   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9844   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9845   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9846
9847   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9848   application.SendNotification();
9849   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9850   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9851   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9852   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9853
9854   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9855   application.SendNotification();
9856   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9857   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9858   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9859   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9860
9861   // We did expect the animation to finish
9862
9863   finishCheck.CheckSignalReceived();
9864   END_TEST;
9865 }
9866
9867 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9868 {
9869   TestApplication application;
9870
9871   float startValue(1.0f);
9872   Actor actor = Actor::New();
9873   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9874   Stage::GetCurrent().Add(actor);
9875
9876   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9877   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9878   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9879   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9880   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9881   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9882   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9883   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9884   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9885
9886   // Build the animation
9887   float durationSeconds(1.0f);
9888   float delay = 0.5f;
9889   Animation animation = Animation::New(durationSeconds);
9890
9891   KeyFrames keyFrames = KeyFrames::New();
9892   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9893   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9894   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9895
9896   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9897
9898   // Start the animation
9899   animation.Play();
9900
9901   bool signalReceived(false);
9902   AnimationFinishCheck finishCheck(signalReceived);
9903   animation.FinishedSignal().Connect(&application, finishCheck);
9904   application.SendNotification();
9905
9906   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9907   application.SendNotification();
9908   finishCheck.CheckSignalNotReceived();
9909   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9910   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9911   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9912   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9913
9914   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9915   application.SendNotification();
9916   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9917   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9918   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9919   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9920
9921   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9922   application.SendNotification();
9923   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9924   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9925   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9926   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9927
9928   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9929   application.SendNotification();
9930   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9931   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9932   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9933   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9934
9935   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9936   application.SendNotification();
9937   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9938   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9939   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9940   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9941
9942   // We did expect the animation to finish
9943
9944   finishCheck.CheckSignalReceived();
9945   END_TEST;
9946 }
9947
9948 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9949 {
9950   TestApplication application;
9951
9952   float startValue(1.0f);
9953   float delay = 0.5f;
9954   Actor actor = Actor::New();
9955   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
9956   Stage::GetCurrent().Add(actor);
9957
9958   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
9959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9960   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9961   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9962   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9963   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9964   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9965   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9966   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9967
9968   // Build the animation
9969   float durationSeconds(1.0f);
9970   Animation animation = Animation::New(durationSeconds);
9971
9972   KeyFrames keyFrames = KeyFrames::New();
9973   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9974   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9975   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9976
9977   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9978
9979   // Start the animation
9980   animation.Play();
9981
9982   bool signalReceived(false);
9983   AnimationFinishCheck finishCheck(signalReceived);
9984   animation.FinishedSignal().Connect(&application, finishCheck);
9985   application.SendNotification();
9986
9987   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9988   application.SendNotification();
9989   finishCheck.CheckSignalNotReceived();
9990   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9991   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9992   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9993   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9994
9995   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9996   application.SendNotification();
9997   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9998   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9999   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
10000   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
10001
10002   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
10003   application.SendNotification();
10004   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
10005   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
10006   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
10007   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
10008
10009   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
10010   application.SendNotification();
10011   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
10012   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
10013   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
10014   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
10015
10016   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
10017   application.SendNotification();
10018   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
10019   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
10020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
10021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
10022
10023   // We did expect the animation to finish
10024
10025   finishCheck.CheckSignalReceived();
10026   END_TEST;
10027 }
10028
10029 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
10030 {
10031   TestApplication application;
10032
10033   float startValue(1.0f);
10034   Actor actor = Actor::New();
10035   actor.SetProperty( Actor::Property::COLOR,Vector4(startValue, startValue, startValue, startValue));
10036   Stage::GetCurrent().Add(actor);
10037
10038   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, startValue, TEST_LOCATION );
10039   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
10040   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
10041   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
10042   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
10043   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
10044   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
10045   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
10046   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
10047
10048
10049   // Build the animation
10050   float durationSeconds(1.0f);
10051   float delay = 0.5f;
10052   Animation animation = Animation::New(durationSeconds);
10053
10054   KeyFrames keyFrames = KeyFrames::New();
10055   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
10056   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
10057   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
10058
10059   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
10060
10061   // Start the animation
10062   animation.Play();
10063
10064   bool signalReceived(false);
10065   AnimationFinishCheck finishCheck(signalReceived);
10066   animation.FinishedSignal().Connect(&application, finishCheck);
10067   application.SendNotification();
10068
10069   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
10070   application.SendNotification();
10071   finishCheck.CheckSignalNotReceived();
10072   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
10073   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
10074   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
10075   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
10076
10077   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
10078   application.SendNotification();
10079   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
10080   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
10081   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
10082   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
10083
10084   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
10085   application.SendNotification();
10086   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
10087   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
10088   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
10089   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
10090
10091   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
10092   application.SendNotification();
10093   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
10094   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
10095   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
10096   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
10097
10098   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
10099   application.SendNotification();
10100   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
10101   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
10102   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
10103   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
10104
10105   // We did expect the animation to finish
10106
10107   finishCheck.CheckSignalReceived();
10108   END_TEST;
10109 }
10110
10111 int UtcDaliAnimationAnimateP(void)
10112 {
10113   TestApplication application;
10114
10115   Actor actor = Actor::New();
10116   Stage::GetCurrent().Add(actor);
10117
10118   //Build the path
10119   Vector3 position0( 30.0,  80.0,  0.0);
10120   Vector3 position1( 70.0,  120.0, 0.0);
10121   Vector3 position2( 100.0, 100.0, 0.0);
10122
10123   Dali::Path path = Dali::Path::New();
10124   path.AddPoint(position0);
10125   path.AddPoint(position1);
10126   path.AddPoint(position2);
10127
10128   //Control points for first segment
10129   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10130   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10131
10132   //Control points for second segment
10133   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10134   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10135
10136   // Build the animation
10137   float durationSeconds( 1.0f );
10138   Animation animation = Animation::New(durationSeconds);
10139   animation.Animate(actor, path, Vector3::XAXIS);
10140
10141   // Start the animation
10142   animation.Play();
10143
10144   bool signalReceived(false);
10145   AnimationFinishCheck finishCheck(signalReceived);
10146   animation.FinishedSignal().Connect(&application, finishCheck);
10147   application.SendNotification();
10148   application.Render(0);
10149   application.SendNotification();
10150   finishCheck.CheckSignalNotReceived();
10151   Vector3 position, tangent;
10152   Quaternion rotation;
10153   path.Sample( 0.0f, position, tangent );
10154   rotation = Quaternion( Vector3::XAXIS, tangent );
10155   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10156   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10157
10158   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10159   application.SendNotification();
10160   path.Sample( 0.25f, position, tangent );
10161   rotation = Quaternion( Vector3::XAXIS, tangent );
10162   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10163   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10164
10165   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10166   application.SendNotification();
10167   path.Sample( 0.5f, position, tangent );
10168   rotation = Quaternion( Vector3::XAXIS, tangent );
10169   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10170   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10171
10172   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10173   application.SendNotification();
10174   path.Sample( 0.75f, position, tangent );
10175   rotation = Quaternion( Vector3::XAXIS, tangent );
10176   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10177   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10178
10179   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10180   application.SendNotification();
10181   path.Sample( 1.0f, position, tangent );
10182   rotation = Quaternion( Vector3::XAXIS, tangent );
10183   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10184   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10185
10186   finishCheck.CheckSignalReceived();
10187   END_TEST;
10188 }
10189
10190 int UtcDaliAnimationAnimateAlphaFunctionP(void)
10191 {
10192   TestApplication application;
10193
10194   Actor actor = Actor::New();
10195   Stage::GetCurrent().Add(actor);
10196
10197   //Build the path
10198   Vector3 position0( 30.0,  80.0,  0.0);
10199   Vector3 position1( 70.0,  120.0, 0.0);
10200   Vector3 position2( 100.0, 100.0, 0.0);
10201
10202   Dali::Path path = Dali::Path::New();
10203   path.AddPoint(position0);
10204   path.AddPoint(position1);
10205   path.AddPoint(position2);
10206
10207   //Control points for first segment
10208   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10209   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10210
10211   //Control points for second segment
10212   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10213   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10214
10215   // Build the animation
10216   float durationSeconds( 1.0f );
10217   Animation animation = Animation::New(durationSeconds);
10218   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
10219
10220   // Start the animation
10221   animation.Play();
10222
10223   bool signalReceived(false);
10224   AnimationFinishCheck finishCheck(signalReceived);
10225   animation.FinishedSignal().Connect(&application, finishCheck);
10226   application.SendNotification();
10227   application.Render(0);
10228   application.SendNotification();
10229   finishCheck.CheckSignalNotReceived();
10230   Vector3 position, tangent;
10231   Quaternion rotation;
10232   path.Sample( 0.0f, position, tangent );
10233   rotation = Quaternion( Vector3::XAXIS, tangent );
10234   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10235   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10236
10237   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10238   application.SendNotification();
10239   path.Sample( 0.25f, position, tangent );
10240   rotation = Quaternion( Vector3::XAXIS, tangent );
10241   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10242   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10243
10244   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10245   application.SendNotification();
10246   path.Sample( 0.5f, position, tangent );
10247   rotation = Quaternion( Vector3::XAXIS, tangent );
10248   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10249   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10250
10251   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10252   application.SendNotification();
10253   path.Sample( 0.75f, position, tangent );
10254   rotation = Quaternion( Vector3::XAXIS, tangent );
10255   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10256   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10257
10258   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10259   application.SendNotification();
10260   path.Sample( 1.0f, position, tangent );
10261   rotation = Quaternion( Vector3::XAXIS, tangent );
10262   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10263   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10264
10265   finishCheck.CheckSignalReceived();
10266   END_TEST;
10267 }
10268
10269 int UtcDaliAnimationAnimateTimePeriodP(void)
10270 {
10271   TestApplication application;
10272
10273   Actor actor = Actor::New();
10274   Stage::GetCurrent().Add(actor);
10275
10276   //Build the path
10277   Vector3 position0( 30.0,  80.0,  0.0);
10278   Vector3 position1( 70.0,  120.0, 0.0);
10279   Vector3 position2( 100.0, 100.0, 0.0);
10280
10281   Dali::Path path = Dali::Path::New();
10282   path.AddPoint(position0);
10283   path.AddPoint(position1);
10284   path.AddPoint(position2);
10285
10286   //Control points for first segment
10287   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10288   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10289
10290   //Control points for second segment
10291   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10292   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10293
10294   // Build the animation
10295   float durationSeconds( 1.0f );
10296   Animation animation = Animation::New(durationSeconds);
10297   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
10298
10299   // Start the animation
10300   animation.Play();
10301
10302   bool signalReceived(false);
10303   AnimationFinishCheck finishCheck(signalReceived);
10304   animation.FinishedSignal().Connect(&application, finishCheck);
10305   application.SendNotification();
10306   application.Render(0);
10307   application.SendNotification();
10308   finishCheck.CheckSignalNotReceived();
10309   Vector3 position, tangent;
10310   Quaternion rotation;
10311   path.Sample( 0.0f, position, tangent );
10312   rotation = Quaternion( Vector3::XAXIS, tangent );
10313   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10314   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10315
10316   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10317   application.SendNotification();
10318   path.Sample( 0.25f, position, tangent );
10319   rotation = Quaternion( Vector3::XAXIS, tangent );
10320   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10321   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10322
10323   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10324   application.SendNotification();
10325   path.Sample( 0.5f, position, tangent );
10326   rotation = Quaternion( Vector3::XAXIS, tangent );
10327   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10328   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10329
10330   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10331   application.SendNotification();
10332   path.Sample( 0.75f, position, tangent );
10333   rotation = Quaternion( Vector3::XAXIS, tangent );
10334   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10335   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10336
10337   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10338   application.SendNotification();
10339   path.Sample( 1.0f, position, tangent );
10340   rotation = Quaternion( Vector3::XAXIS, tangent );
10341   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10342   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10343
10344   finishCheck.CheckSignalReceived();
10345   END_TEST;
10346 }
10347
10348 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
10349 {
10350   TestApplication application;
10351
10352   Actor actor = Actor::New();
10353   Stage::GetCurrent().Add(actor);
10354
10355   //Build the path
10356   Vector3 position0( 30.0,  80.0,  0.0);
10357   Vector3 position1( 70.0,  120.0, 0.0);
10358   Vector3 position2( 100.0, 100.0, 0.0);
10359
10360   Dali::Path path = Dali::Path::New();
10361   path.AddPoint(position0);
10362   path.AddPoint(position1);
10363   path.AddPoint(position2);
10364
10365   //Control points for first segment
10366   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
10367   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
10368
10369   //Control points for second segment
10370   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
10371   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
10372
10373   // Build the animation
10374   float durationSeconds( 1.0f );
10375   Animation animation = Animation::New(durationSeconds);
10376   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
10377
10378   // Start the animation
10379   animation.Play();
10380
10381   bool signalReceived(false);
10382   AnimationFinishCheck finishCheck(signalReceived);
10383   animation.FinishedSignal().Connect(&application, finishCheck);
10384   application.SendNotification();
10385   application.Render(0);
10386   application.SendNotification();
10387   finishCheck.CheckSignalNotReceived();
10388   Vector3 position, tangent;
10389   Quaternion rotation;
10390   path.Sample( 0.0f, position, tangent );
10391   rotation = Quaternion( Vector3::XAXIS, tangent );
10392   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10393   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10394
10395   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
10396   application.SendNotification();
10397   path.Sample( 0.25f, position, tangent );
10398   rotation = Quaternion( Vector3::XAXIS, tangent );
10399   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10400   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10401
10402   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
10403   application.SendNotification();
10404   path.Sample( 0.5f, position, tangent );
10405   rotation = Quaternion( Vector3::XAXIS, tangent );
10406   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10407   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10408
10409   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
10410   application.SendNotification();
10411   path.Sample( 0.75f, position, tangent );
10412   rotation = Quaternion( Vector3::XAXIS, tangent );
10413   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10414   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10415
10416   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
10417   application.SendNotification();
10418   path.Sample( 1.0f, position, tangent );
10419   rotation = Quaternion( Vector3::XAXIS, tangent );
10420   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
10421   DALI_TEST_EQUALS( actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, TEST_LOCATION );
10422
10423   finishCheck.CheckSignalReceived();
10424   END_TEST;
10425 }
10426
10427 int UtcDaliAnimationShowP(void)
10428 {
10429   TestApplication application;
10430
10431   Actor actor = Actor::New();
10432   actor.SetProperty( Actor::Property::VISIBLE,false);
10433   application.SendNotification();
10434   application.Render(0);
10435   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10436   Stage::GetCurrent().Add(actor);
10437
10438   // Start the animation
10439   float durationSeconds(10.0f);
10440   Animation animation = Animation::New(durationSeconds);
10441   animation.Show(actor, durationSeconds*0.5f);
10442   animation.Play();
10443
10444   bool signalReceived(false);
10445   AnimationFinishCheck finishCheck(signalReceived);
10446   animation.FinishedSignal().Connect(&application, finishCheck);
10447
10448   application.SendNotification();
10449   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10450
10451   // We didn't expect the animation to finish yet
10452   application.SendNotification();
10453   finishCheck.CheckSignalNotReceived();
10454   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10455
10456   application.SendNotification();
10457   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
10458
10459   // We didn't expect the animation to finish yet
10460   application.SendNotification();
10461   finishCheck.CheckSignalNotReceived();
10462   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10463
10464   application.SendNotification();
10465   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10466
10467   // We did expect the animation to finish
10468   application.SendNotification();
10469   finishCheck.CheckSignalReceived();
10470   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10471   END_TEST;
10472 }
10473
10474 int UtcDaliAnimationHideP(void)
10475 {
10476   TestApplication application;
10477
10478   Actor actor = Actor::New();
10479   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10480   Stage::GetCurrent().Add(actor);
10481
10482   // Start the animation
10483   float durationSeconds(10.0f);
10484   Animation animation = Animation::New(durationSeconds);
10485   animation.Hide(actor, durationSeconds*0.5f);
10486   animation.Play();
10487
10488   bool signalReceived(false);
10489   AnimationFinishCheck finishCheck(signalReceived);
10490   animation.FinishedSignal().Connect(&application, finishCheck);
10491
10492   application.SendNotification();
10493   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
10494
10495   // We didn't expect the animation to finish yet
10496   application.SendNotification();
10497   finishCheck.CheckSignalNotReceived();
10498   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10499
10500   application.SendNotification();
10501   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
10502
10503   // We didn't expect the animation to finish yet
10504   application.SendNotification();
10505   finishCheck.CheckSignalNotReceived();
10506   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10507
10508   application.SendNotification();
10509   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10510
10511   // We did expect the animation to finish
10512   application.SendNotification();
10513   finishCheck.CheckSignalReceived();
10514   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10515   END_TEST;
10516 }
10517
10518 int UtcDaliAnimationShowHideAtEndP(void)
10519 {
10520   // Test that show/hide delay can be the same as animation duration
10521   // i.e. to show/hide at the end of the animation
10522
10523   TestApplication application;
10524
10525   Actor actor = Actor::New();
10526   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10527   Stage::GetCurrent().Add(actor);
10528
10529   // Start Hide animation
10530   float durationSeconds(10.0f);
10531   Animation animation = Animation::New(durationSeconds);
10532   animation.Hide(actor, durationSeconds/*Hide at end*/);
10533   animation.Play();
10534
10535   bool signalReceived(false);
10536   AnimationFinishCheck finishCheck(signalReceived);
10537   animation.FinishedSignal().Connect(&application, finishCheck);
10538
10539   application.SendNotification();
10540   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10541
10542   // We did expect the animation to finish
10543   application.SendNotification();
10544   finishCheck.CheckSignalReceived();
10545   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10546
10547   // Start Show animation
10548   animation = Animation::New(durationSeconds);
10549   animation.Show(actor, durationSeconds/*Show at end*/);
10550   animation.FinishedSignal().Connect(&application, finishCheck);
10551   animation.Play();
10552
10553   application.SendNotification();
10554   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10555
10556   // We did expect the animation to finish
10557   application.SendNotification();
10558   finishCheck.CheckSignalReceived();
10559   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
10560   END_TEST;
10561 }
10562
10563 int UtcDaliKeyFramesCreateDestroyP(void)
10564 {
10565   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10566
10567   KeyFrames* keyFrames = new KeyFrames;
10568   delete keyFrames;
10569   DALI_TEST_CHECK( true );
10570   END_TEST;
10571 }
10572
10573 int UtcDaliKeyFramesDownCastP(void)
10574 {
10575   TestApplication application;
10576   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10577
10578   KeyFrames keyFrames = KeyFrames::New();
10579   BaseHandle object(keyFrames);
10580
10581   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10582   DALI_TEST_CHECK(keyFrames2);
10583
10584   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10585   DALI_TEST_CHECK(keyFrames3);
10586
10587   BaseHandle unInitializedObject;
10588   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10589   DALI_TEST_CHECK(!keyFrames4);
10590
10591   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10592   DALI_TEST_CHECK(!keyFrames5);
10593   END_TEST;
10594 }
10595
10596 int UtcDaliAnimationCreateDestroyP(void)
10597 {
10598   TestApplication application;
10599   Animation* animation = new Animation;
10600   DALI_TEST_CHECK( animation );
10601   delete animation;
10602   END_TEST;
10603 }
10604
10605 struct UpdateManagerTestConstraint
10606 {
10607   UpdateManagerTestConstraint(TestApplication& application)
10608   : mApplication(application)
10609   {
10610   }
10611
10612   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10613   {
10614     mApplication.SendNotification();  // Process events
10615   }
10616
10617   TestApplication& mApplication;
10618 };
10619
10620 int UtcDaliAnimationUpdateManagerP(void)
10621 {
10622   TestApplication application;
10623
10624   Actor actor = Actor::New();
10625   Stage::GetCurrent().Add( actor );
10626
10627   // Build the animation
10628   Animation animation = Animation::New( 0.0f );
10629
10630   bool signalReceived = false;
10631   AnimationFinishCheck finishCheck( signalReceived );
10632   animation.FinishedSignal().Connect( &application, finishCheck );
10633
10634   Vector3 startValue(1.0f, 1.0f, 1.0f);
10635   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10636   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10637   constraint.Apply();
10638
10639   // Apply animation to actor
10640   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10641   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10642
10643   animation.Play();
10644
10645   application.SendNotification();
10646   application.UpdateOnly( 16 );
10647
10648   finishCheck.CheckSignalNotReceived();
10649
10650   application.SendNotification();   // Process events
10651
10652   finishCheck.CheckSignalReceived();
10653
10654   END_TEST;
10655 }
10656
10657 int UtcDaliAnimationSignalOrderP(void)
10658 {
10659   TestApplication application;
10660
10661   Actor actor = Actor::New();
10662   Stage::GetCurrent().Add( actor );
10663
10664   // Build the animations
10665   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10666   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10667
10668   bool signal1Received = false;
10669   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10670
10671   bool signal2Received = false;
10672   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10673
10674   // Apply animations to actor
10675   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10676   animation1.Play();
10677   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10678   animation2.Play();
10679
10680   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10681   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10682
10683   application.SendNotification();
10684   application.UpdateOnly( 10 ); // 10ms progress
10685
10686   // no notifications yet
10687   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10688   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10689
10690   application.SendNotification();
10691
10692   // first completed
10693   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10694   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10695   signal1Received = false;
10696
10697   // 1st animation is complete now, do another update with no ProcessEvents in between
10698   application.UpdateOnly( 20 ); // 20ms progress
10699
10700   // ProcessEvents
10701   application.SendNotification();
10702
10703   // 2nd should complete now
10704   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10705   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10706
10707   END_TEST;
10708 }
10709
10710 int UtcDaliAnimationExtendDurationP(void)
10711 {
10712   TestApplication application;
10713
10714   Actor actor = Actor::New();
10715
10716   // Register a float property
10717   float startValue(10.0f);
10718   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10719   Stage::GetCurrent().Add(actor);
10720   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10722
10723   // Build the animation
10724   float initialDurationSeconds(1.0f);
10725   float animatorDelay = 5.0f;
10726   float animatorDurationSeconds(5.0f);
10727   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10728   Animation animation = Animation::New(initialDurationSeconds);
10729   float targetValue(30.0f);
10730   float relativeValue(targetValue - startValue);
10731
10732   animation.AnimateTo(Property(actor, index),
10733                       targetValue,
10734                       TimePeriod(animatorDelay, animatorDurationSeconds));
10735
10736   // The duration should have been extended
10737   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10738
10739   // Start the animation
10740   animation.Play();
10741
10742   bool signalReceived(false);
10743   AnimationFinishCheck finishCheck(signalReceived);
10744   animation.FinishedSignal().Connect(&application, finishCheck);
10745
10746   application.SendNotification();
10747   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10748
10749   // We didn't expect the animation to finish yet, but cached value should be the final one
10750   application.SendNotification();
10751   finishCheck.CheckSignalNotReceived();
10752   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10753   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10754
10755   application.SendNotification();
10756   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10757
10758   // We didn't expect the animation to finish yet
10759   application.SendNotification();
10760   finishCheck.CheckSignalNotReceived();
10761   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10762
10763   application.SendNotification();
10764   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10765
10766   // We did expect the animation to finish
10767   application.SendNotification();
10768   finishCheck.CheckSignalReceived();
10769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10770   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10771   END_TEST;
10772 }
10773
10774 int UtcDaliAnimationCustomIntProperty(void)
10775 {
10776   TestApplication application;
10777
10778   Actor actor = Actor::New();
10779   Stage::GetCurrent().Add(actor);
10780   int startValue(0u);
10781
10782   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10783   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10784   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10785
10786   // Build the animation
10787   float durationSeconds(1.0f);
10788   Animation animation = Animation::New(durationSeconds);
10789   animation.AnimateTo( Property(actor, index), 20 );
10790
10791   // Start the animation
10792   animation.Play();
10793
10794   // Target value should be retrievable straight away
10795   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10796
10797   bool signalReceived(false);
10798   AnimationFinishCheck finishCheck(signalReceived);
10799   animation.FinishedSignal().Connect(&application, finishCheck);
10800
10801   application.SendNotification();
10802   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10803
10804   // We didn't expect the animation to finish yet
10805   application.SendNotification();
10806   finishCheck.CheckSignalNotReceived();
10807   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10808
10809   application.SendNotification();
10810   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10811
10812   // We did expect the animation to finish
10813   application.SendNotification();
10814   finishCheck.CheckSignalReceived();
10815   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10816   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10817   END_TEST;
10818 }
10819
10820 int UtcDaliAnimationDuration(void)
10821 {
10822   TestApplication application;
10823
10824   Actor actor = Actor::New();
10825   Stage::GetCurrent().Add(actor);
10826
10827   Animation animation = Animation::New( 0.0f );
10828   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10829
10830   // The animation duration should automatically increase depending on the animator time period
10831
10832   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10833   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10834
10835   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10836   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10837
10838   END_TEST;
10839 }
10840
10841 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10842 {
10843   TestApplication application;
10844
10845   Actor actor = Actor::New();
10846
10847   // Register an integer property
10848   int startValue(1);
10849   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10850   Stage::GetCurrent().Add(actor);
10851   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10852
10853   DALI_TEST_ASSERTION(
10854   {
10855     // Build the animation
10856     Animation animation = Animation::New( 2.0f );
10857     std::string relativeValue = "relative string";
10858     animation.AnimateBy( Property(actor, index), relativeValue );
10859     tet_result(TET_FAIL);
10860   }, "Target value is not animatable" );
10861
10862   END_TEST;
10863 }
10864
10865
10866 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10867 {
10868   TestApplication application;
10869
10870   Actor actor = Actor::New();
10871
10872   // Register an integer property
10873   int startValue(1);
10874   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10875   Stage::GetCurrent().Add(actor);
10876   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10877
10878   DALI_TEST_ASSERTION(
10879   {
10880     // Build the animation
10881     Animation animation = Animation::New( 2.0f );
10882     std::string relativeValue = "relative string";
10883     animation.AnimateTo( Property(actor, index), relativeValue );
10884   }, "Target value is not animatable" );
10885
10886   END_TEST;
10887 }
10888
10889 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10890 {
10891   TestApplication application;
10892
10893   Actor actor = Actor::New();
10894
10895   // Register an integer property
10896   int startValue(1);
10897   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10898   Stage::GetCurrent().Add(actor);
10899   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10900
10901   DALI_TEST_ASSERTION(
10902   {
10903     // Build the animation
10904     KeyFrames keyFrames = KeyFrames::New();
10905     keyFrames.Add( 0.0f, std::string("relative string1") );
10906     keyFrames.Add( 1.0f, std::string("relative string2") );
10907     // no need to really create the animation as keyframes do the check
10908   }, "Property type is not animatable" );
10909
10910   END_TEST;
10911 }
10912
10913 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10914 {
10915   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10916
10917   TestApplication application;
10918
10919   tet_infoline("Set initial position and set up animation to re-position actor");
10920
10921   Actor actor = Actor::New();
10922   Stage::GetCurrent().Add(actor);
10923   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10924   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10925
10926   // Build the animation
10927   Animation animation = Animation::New(2.0f);
10928
10929   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10930   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10931   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
10932
10933   tet_infoline("Set target position in animation without intiating play");
10934
10935   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10936   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10937
10938   application.SendNotification();
10939   application.Render();
10940
10941   tet_infoline("Ensure position of actor is still at intial value");
10942
10943   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10944   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10945   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10946
10947   tet_infoline("Play animation and ensure actor position is now target");
10948
10949   animation.Play();
10950   application.SendNotification();
10951   application.Render(1000u);
10952
10953   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10954
10955   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10956   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10957   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10958
10959   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x );
10960
10961   application.Render(2000u);
10962
10963   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10964
10965   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10966   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10967   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10968
10969   END_TEST;
10970 }
10971
10972 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10973 {
10974   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10975
10976   TestApplication application;
10977
10978   std::vector<Vector3> targetPositions;
10979
10980   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10981   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10982   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10983
10984   tet_infoline("Set initial position and set up animation to re-position actor");
10985
10986   Actor actor = Actor::New();
10987   Stage::GetCurrent().Add(actor);
10988   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10989   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10990
10991   // Build the animation
10992   Animation animation = Animation::New(2.0f);
10993
10994   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10995   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10996   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
10997
10998   tet_infoline("Set target position in animation without intiating play");
10999
11000   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
11001   {
11002     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
11003   }
11004
11005   application.SendNotification();
11006   application.Render();
11007
11008   tet_infoline("Ensure position of actor is still at intial value");
11009
11010   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
11011   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
11012   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
11013
11014   tet_infoline("Play animation and ensure actor position is now target");
11015
11016   animation.Play();
11017   application.SendNotification();
11018   application.Render(1000u);
11019
11020   tet_infoline("Ensure position of actor is at target value when aninmation half way");
11021
11022   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
11023   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
11024   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
11025
11026   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x );
11027
11028   application.Render(2000u);
11029
11030   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
11031
11032   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
11033   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
11034   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
11035
11036   END_TEST;
11037 }
11038
11039 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
11040 {
11041   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");
11042
11043   TestApplication application;
11044
11045   std::vector<Vector3> targetSizes;
11046   std::vector<Vector3> targetPositions;
11047
11048   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
11049   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
11050
11051   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
11052
11053   tet_infoline("Set initial position and set up animation to re-position actor");
11054
11055   Actor actor = Actor::New();
11056   Stage::GetCurrent().Add(actor);
11057   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
11058   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
11059
11060   actor.SetProperty( Actor::Property::SIZE, initialSize );
11061   actor.SetProperty( Actor::Property::POSITION, initialPosition );
11062
11063   // Build the animation
11064   Animation animation = Animation::New(2.0f);
11065
11066   tet_infoline("Set target size in animation without intiating play");
11067   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
11068   tet_infoline("Set target position in animation without intiating play");
11069   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
11070   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
11071
11072   application.SendNotification();
11073   application.Render();
11074
11075   tet_infoline("Ensure position of actor is still at intial size and position");
11076
11077   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
11078   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
11079   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
11080
11081   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
11082   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
11083   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
11084
11085   tet_infoline("Play animation and ensure actor position and size is now matches targets");
11086
11087   animation.Play();
11088   application.SendNotification();
11089   application.Render(2000u);
11090
11091   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
11092
11093   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
11094   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
11095   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
11096
11097   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
11098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
11099   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
11100
11101   END_TEST;
11102 }
11103
11104 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
11105 {
11106   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
11107
11108   TestApplication application;
11109
11110   std::vector<Vector3> targetSizes;
11111   std::vector<float> targetColors;
11112
11113   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
11114   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
11115
11116   targetColors.push_back( 1.0f );
11117
11118   tet_infoline("Set initial position and set up animation to re-position actor");
11119
11120   Actor actor = Actor::New();
11121   Stage::GetCurrent().Add(actor);
11122   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
11123
11124   actor.SetProperty( Actor::Property::SIZE, initialSize );
11125
11126   // Build the animation
11127   Animation animation = Animation::New(2.0f);
11128
11129   tet_infoline("Set target size in animation without initiating play");
11130   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
11131   tet_infoline("Set target position in animation without intiating play");
11132   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
11133   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
11134
11135   application.SendNotification();
11136   application.Render();
11137
11138   tet_infoline("Ensure position of actor is still at initial size and position");
11139
11140   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
11141   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
11142   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
11143
11144   tet_infoline("Play animation and ensure actor position and size is now matches targets");
11145
11146   animation.Play();
11147   application.SendNotification();
11148   application.Render(2000u);
11149
11150   tet_infoline("Ensure position and size of actor is at target value when animation playing");
11151
11152   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
11153   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
11154   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
11155
11156   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
11157
11158   END_TEST;
11159 }
11160
11161 int UtcDaliAnimationTimePeriodOrder(void)
11162 {
11163   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
11164
11165   TestApplication application;
11166
11167   Actor actor = Actor::New();
11168   Stage::GetCurrent().Add( actor );
11169
11170   application.SendNotification();
11171   application.Render();
11172
11173   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11174   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11175   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11176   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11177   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11178
11179   //////////////////////////////////////////////////////////////////////////////////
11180
11181   tet_infoline( "With two AnimateTo calls" );
11182
11183   Animation animation = Animation::New( 0.0f );
11184   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11185   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11186   animation.Play();
11187
11188   tet_infoline( "The target position should change instantly" );
11189   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11190   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11191
11192   application.SendNotification();
11193   application.Render(5000); // After the animation is complete
11194
11195   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11196   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11197   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11198
11199   //////////////////////////////////////////////////////////////////////////////////
11200
11201   tet_infoline( "Same animation again but in a different order - should yield the same result" );
11202
11203   actor.SetX( 0.0f );
11204   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11205   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11206
11207   application.SendNotification();
11208   application.Render();
11209
11210   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11211   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11212   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11213
11214   animation = Animation::New( 0.0f );
11215   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
11216   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
11217   animation.Play();
11218
11219   tet_infoline( "The target position should change instantly" );
11220   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11221   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11222
11223   application.SendNotification();
11224   application.Render(5000); // After the animation is complete
11225
11226   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11227   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
11228   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
11229
11230   END_TEST;
11231 }
11232
11233 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
11234 {
11235   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" );
11236
11237   TestApplication application;
11238
11239   Actor actor = Actor::New();
11240   Stage::GetCurrent().Add( actor );
11241
11242   application.SendNotification();
11243   application.Render();
11244
11245   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11246   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11247   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11248   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11249   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11250
11251   //////////////////////////////////////////////////////////////////////////////////
11252
11253   tet_infoline( "" );
11254
11255   Animation animation = Animation::New( 0.0f );
11256   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11257   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11258   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11259   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11260   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11261   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11262   animation.Play();
11263
11264   tet_infoline( "The target position should change instantly" );
11265   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11266   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11267
11268   application.SendNotification();
11269   application.Render(14000); // After the animation is complete
11270
11271   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11272   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11273   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11274
11275   //////////////////////////////////////////////////////////////////////////////////
11276
11277   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
11278
11279   actor.SetX( 0.0f );
11280
11281   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11282   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11283
11284   application.SendNotification();
11285   application.Render();
11286
11287   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11288   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
11289   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
11290
11291   animation = Animation::New( 0.0f );
11292   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
11293   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
11294   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
11295   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
11296   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
11297   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
11298   animation.Play();
11299
11300   tet_infoline( "The target position should change instantly" );
11301   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11302   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11303
11304   application.SendNotification();
11305   application.Render(14000); // After the animation is complete
11306
11307   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11308   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
11309   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
11310
11311   END_TEST;
11312 }
11313
11314 int UtcDaliAnimationAnimateBetweenIntegerP(void)
11315 {
11316   TestApplication application;
11317
11318   int startValue(1);
11319   Actor actor = Actor::New();
11320   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11321   Stage::GetCurrent().Add(actor);
11322
11323   application.Render();
11324   application.SendNotification();
11325
11326   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
11327
11328   // Build the animation
11329   float durationSeconds(1.0f);
11330   Animation animation = Animation::New(durationSeconds);
11331
11332   KeyFrames keyFrames = KeyFrames::New();
11333   keyFrames.Add(0.0f, 10);
11334   keyFrames.Add(0.2f, 20);
11335   keyFrames.Add(0.4f, 30);
11336   keyFrames.Add(0.6f, 40);
11337   keyFrames.Add(0.8f, 50);
11338   keyFrames.Add(1.0f, 60);
11339
11340   animation.AnimateBetween( Property(actor, index ), keyFrames );
11341
11342   // Start the animation
11343   animation.Play();
11344
11345   // Target value should change to the last key-frame's value straight away
11346   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 60, TEST_LOCATION );
11347
11348   END_TEST;
11349 }
11350
11351 int UtcDaliAnimationAnimateBetweenVector2P(void)
11352 {
11353   TestApplication application;
11354
11355   Vector2 startValue( 10.0f, 20.0f );
11356   Actor actor = Actor::New();
11357   const Property::Index index = actor.RegisterProperty("customProperty", startValue );
11358   Stage::GetCurrent().Add(actor);
11359
11360   application.Render();
11361   application.SendNotification();
11362
11363   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
11364
11365   // Build the animation
11366   float durationSeconds(1.0f);
11367   Animation animation = Animation::New(durationSeconds);
11368
11369   KeyFrames keyFrames = KeyFrames::New();
11370   keyFrames.Add( 0.0f, Vector2( 0.0f, 5.0f ) );
11371   keyFrames.Add( 0.2f, Vector2( 30.0f, 25.0f ) );
11372   keyFrames.Add( 0.4f, Vector2( 40.0f, 35.0f ) );
11373   keyFrames.Add( 0.6f, Vector2( 50.0f, 45.0f ) );
11374   keyFrames.Add( 0.8f, Vector2( 60.0f, 55.0f ) );
11375   keyFrames.Add( 1.0f, Vector2( 70.0f, 65.0f ) );
11376
11377   animation.AnimateBetween( Property(actor, index ), keyFrames );
11378
11379   // Start the animation
11380   animation.Play();
11381
11382   // Target value should change to the last key-frame's value straight away
11383   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), Vector2( 70.0f, 65.0f ), TEST_LOCATION );
11384
11385   END_TEST;
11386 }
11387
11388 int UtcDaliAnimationProgressCallbackP(void)
11389 {
11390   TestApplication application;
11391
11392   Actor actor = Actor::New();
11393   Stage::GetCurrent().Add(actor);
11394
11395   // Build the animation
11396   Animation animation = Animation::New(0.0f);
11397
11398   //Set duration
11399   float durationSeconds(1.0f);
11400   animation.SetDuration(durationSeconds);
11401
11402   bool finishedSignalReceived(false);
11403   bool progressSignalReceived(false);
11404
11405   AnimationFinishCheck finishCheck(finishedSignalReceived);
11406   animation.FinishedSignal().Connect(&application, finishCheck);
11407
11408   AnimationProgressCheck progressCheck(progressSignalReceived);
11409   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
11410   application.SendNotification();
11411
11412   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11413   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
11414
11415   tet_infoline( "Animation Progress notification set to 30%" );
11416   DevelAnimation::SetProgressNotification( animation, 0.3f );
11417
11418   application.SendNotification();
11419   application.Render( );
11420
11421   DALI_TEST_EQUALS( 0.3f, DevelAnimation::GetProgressNotification( animation ), TEST_LOCATION );
11422
11423   progressCheck.CheckSignalNotReceived();
11424
11425   // Start the animation from 10% progress
11426   animation.SetCurrentProgress( 0.1f );
11427   animation.Play();
11428
11429   tet_infoline( "Animation Playing from 10%" );
11430
11431   application.SendNotification();
11432   application.Render(0); // start animation
11433   application.Render(durationSeconds*100.0f ); // 20% progress
11434
11435   tet_infoline( "Animation at 20%" );
11436
11437   progressCheck.CheckSignalNotReceived();
11438
11439   application.SendNotification();
11440   application.Render(durationSeconds*200.0f ); // 40% progress
11441   application.SendNotification();
11442   tet_infoline( "Animation at 40%" );
11443   DALI_TEST_EQUALS( 0.4f, animation.GetCurrentProgress(), TEST_LOCATION );
11444
11445   progressCheck.CheckSignalReceived();
11446
11447   tet_infoline( "Progress check reset" );
11448   progressCheck.Reset();
11449
11450   application.Render(durationSeconds*100.0f ); // 50% progress
11451   tet_infoline( "Animation at 50%" );
11452   application.SendNotification();
11453
11454   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
11455
11456   progressCheck.CheckSignalNotReceived();
11457
11458   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
11459   application.SendNotification();
11460
11461   tet_infoline( "Animation at 60%" );
11462
11463   finishCheck.CheckSignalNotReceived();
11464
11465   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
11466   application.SendNotification();
11467   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
11468   tet_infoline( "Animation at 80%" );
11469
11470   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
11471   // We did expect the animation to finish
11472   application.SendNotification();
11473   finishCheck.CheckSignalReceived();
11474   tet_infoline( "Animation finished" );
11475   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11476
11477   END_TEST;
11478 }
11479
11480 int UtcDaliAnimationPlayAfterP(void)
11481 {
11482   TestApplication application;
11483
11484   tet_printf("Testing that playing after 2 seconds\n");
11485
11486   {
11487     Actor actor = Actor::New();
11488     Stage::GetCurrent().Add(actor);
11489
11490     // Build the animation
11491     float durationSeconds(1.0f);
11492     Animation animation = Animation::New(durationSeconds);
11493
11494     bool signalReceived( false );
11495     AnimationFinishCheck finishCheck( signalReceived );
11496     animation.FinishedSignal().Connect( &application, finishCheck );
11497     application.SendNotification();
11498
11499     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11500     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11501
11502     // Play animation after the initial delay time
11503     animation.PlayAfter( 0.2f );
11504     application.SendNotification();
11505     application.Render(0); // start animation
11506
11507     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11508     application.SendNotification();
11509     finishCheck.CheckSignalNotReceived();
11510     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11511
11512     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11513
11514     // We didn't expect the animation to finish yet
11515     application.SendNotification();
11516     finishCheck.CheckSignalNotReceived();
11517     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11518
11519     application.SendNotification();
11520     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11521
11522     application.SendNotification();
11523     finishCheck.CheckSignalNotReceived();
11524     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.5f ), TEST_LOCATION );
11525
11526     application.SendNotification();
11527     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11528
11529     // We did expect the animation to finish
11530     application.SendNotification();
11531     finishCheck.CheckSignalReceived();
11532     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11533
11534     // Check that nothing has changed after a couple of buffer swaps
11535     application.Render(0);
11536     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11537   }
11538
11539   tet_printf("Testing that playing after 2 seconds with negative speedfactor\n");
11540   // SpeedFactor < 0
11541   {
11542     Actor actor = Actor::New();
11543     Stage::GetCurrent().Add(actor);
11544
11545     // Build the animation
11546     float durationSeconds(1.0f);
11547     Animation animation = Animation::New(durationSeconds);
11548     animation.SetSpeedFactor( -1.0f ); // Set SpeedFactor as < 0
11549
11550     bool signalReceived( false );
11551     AnimationFinishCheck finishCheck( signalReceived );
11552     animation.FinishedSignal().Connect( &application, finishCheck );
11553     application.SendNotification();
11554
11555     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11556     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11557
11558     // Play animation after the initial delay time
11559     animation.PlayAfter( 0.2f );
11560     application.SendNotification();
11561     application.Render(0); // start animation
11562
11563     application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11564     application.SendNotification();
11565     finishCheck.CheckSignalNotReceived();
11566     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11567
11568     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11569
11570     // We didn't expect the animation to finish yet
11571     application.SendNotification();
11572     finishCheck.CheckSignalNotReceived();
11573     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.5f ), TEST_LOCATION );
11574
11575     application.SendNotification();
11576     application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11577
11578     application.SendNotification();
11579     finishCheck.CheckSignalNotReceived();
11580     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION );
11581
11582     application.SendNotification();
11583     application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) + 1u/*just beyond the animation duration*/ );
11584
11585     // We did expect the animation to finish
11586     application.SendNotification();
11587     finishCheck.CheckSignalReceived();
11588     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of Timeperiod in seconds
11589
11590     // Check that nothing has changed after a couple of buffer swaps
11591     application.Render(0);
11592     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11593   }
11594
11595   END_TEST;
11596 }
11597
11598 int UtcDaliAnimationPlayAfterP2(void)
11599 {
11600   TestApplication application;
11601
11602   tet_printf("Testing that playing after 2 seconds before looping\n");
11603
11604   {
11605     Actor actor = Actor::New();
11606     Stage::GetCurrent().Add(actor);
11607
11608     // Build the animation
11609     float durationSeconds(1.0f);
11610     Animation animation = Animation::New(durationSeconds);
11611     animation.SetLooping( true );
11612
11613     bool signalReceived( false );
11614     AnimationFinishCheck finishCheck( signalReceived );
11615     animation.FinishedSignal().Connect( &application, finishCheck );
11616     application.SendNotification();
11617
11618     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11619     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11620
11621     // Play animation after the initial delay time
11622     animation.PlayAfter( 0.2f );
11623     application.SendNotification();
11624     application.Render(0); // start animation
11625
11626     for( int iterations = 0; iterations < 3; ++iterations )
11627     {
11628       // The initial delay time of PlayAfter() applies only once in looping mode.
11629       if( iterations == 0 )
11630       {
11631         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11632         application.SendNotification();
11633         finishCheck.CheckSignalNotReceived();
11634         DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move
11635       }
11636
11637       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11638
11639       // We didn't expect the animation to finish yet
11640       application.SendNotification();
11641       finishCheck.CheckSignalNotReceived();
11642       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11643
11644       application.SendNotification();
11645       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11646
11647       application.SendNotification();
11648       finishCheck.CheckSignalNotReceived();
11649       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.5f ), TEST_LOCATION );
11650
11651       application.SendNotification();
11652       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) /* 100% progress */ );
11653
11654       // We did expect the animation to finish
11655       application.SendNotification();
11656       finishCheck.CheckSignalNotReceived();
11657       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11658     }
11659
11660     animation.SetLooping(false);
11661     application.SendNotification();
11662     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11663
11664     application.SendNotification();
11665     finishCheck.CheckSignalReceived();
11666     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11667   }
11668
11669   tet_printf("Testing that playing after 2 seconds before looping with negative speedfactor\n");
11670   // SpeedFactor < 0
11671   {
11672     Actor actor = Actor::New();
11673     Stage::GetCurrent().Add(actor);
11674
11675     // Build the animation
11676     float durationSeconds(1.0f);
11677     Animation animation = Animation::New(durationSeconds);
11678     animation.SetLooping( true );
11679     animation.SetSpeedFactor( -1.0f ); //Set SpeedFactor as < 0
11680
11681     bool signalReceived( false );
11682     AnimationFinishCheck finishCheck( signalReceived );
11683     animation.FinishedSignal().Connect( &application, finishCheck );
11684     application.SendNotification();
11685
11686     Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11687     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11688
11689     // Play animation after the initial delay time
11690     animation.PlayAfter( 0.2f );
11691     application.SendNotification();
11692     application.Render(0); // start animation
11693
11694     for( int iterations = 0; iterations < 3; ++iterations )
11695     {
11696       // The initial delay time of PlayAfter() applies only once in looping mode.
11697       if( iterations == 0 )
11698       {
11699         application.Render( durationSeconds * 200.f ); // The intial delay time of PlayAfter
11700         application.SendNotification();
11701         finishCheck.CheckSignalNotReceived();
11702         DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 1.0f ), TEST_LOCATION ); // Not move. NOTE SpeedFactor < 0 so 'targetPosition' is start position.
11703       }
11704
11705       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 25% animation progress, 50% animator progress */ );
11706
11707       // We didn't expect the animation to finish yet
11708       application.SendNotification();
11709       finishCheck.CheckSignalNotReceived();
11710       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.5f ), TEST_LOCATION );
11711
11712       application.SendNotification();
11713       application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 50% animation progress, 100% animator progress */ );
11714
11715       application.SendNotification();
11716       finishCheck.CheckSignalNotReceived();
11717       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION );
11718
11719       application.SendNotification();
11720       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f ) /* 100% progress */ );
11721
11722       // We did expect the animation to finish
11723       application.SendNotification();
11724       finishCheck.CheckSignalNotReceived();
11725       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ),  ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in second
11726     }
11727
11728     animation.SetLooping(false);
11729     application.SendNotification();
11730     application.Render( static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/ );
11731
11732     application.SendNotification();
11733     finishCheck.CheckSignalReceived();
11734     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(0.0, 0.0, 0.0), TEST_LOCATION );
11735   }
11736
11737   END_TEST;
11738 }
11739
11740 int UtcDaliAnimationPlayAfterP3(void)
11741 {
11742   TestApplication application;
11743
11744   tet_printf("Testing that PlayAfter with the negative delay seconds\n");
11745
11746   Actor actor = Actor::New();
11747   Stage::GetCurrent().Add(actor);
11748
11749   // Build the animation
11750   float durationSeconds(1.0f);
11751   Animation animation = Animation::New(durationSeconds);
11752
11753   bool signalReceived( false );
11754   AnimationFinishCheck finishCheck( signalReceived );
11755   animation.FinishedSignal().Connect( &application, finishCheck );
11756   application.SendNotification();
11757
11758   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11759   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11760
11761   // When the delay time is negative value, it would treat as play immediately.
11762   animation.PlayAfter( -2.0f );
11763   application.SendNotification();
11764   application.Render(0); // start animation
11765
11766   application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% animation progress, 0% animator progress */ );
11767
11768   // We didn't expect the animation to finish yet
11769   application.SendNotification();
11770   finishCheck.CheckSignalNotReceived();
11771   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11772
11773   application.SendNotification();
11774   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 75% animation progress, 50% animator progress */ );
11775
11776   application.SendNotification();
11777   finishCheck.CheckSignalNotReceived();
11778   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.5f ), TEST_LOCATION );
11779
11780   application.SendNotification();
11781   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f ) + 1u/*just beyond the animation duration*/ );
11782
11783   // We did expect the animation to finish
11784   application.SendNotification();
11785   finishCheck.CheckSignalReceived();
11786   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11787
11788   // Check that nothing has changed after a couple of buffer swaps
11789   application.Render(0);
11790   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11791   END_TEST;
11792 }
11793
11794 int UtcDaliAnimationPlayAfterP4(void)
11795 {
11796   TestApplication application;
11797
11798   tet_printf("Testing that PlayAfter with progress value\n");
11799
11800   Actor actor = Actor::New();
11801   Stage::GetCurrent().Add(actor);
11802
11803   // Build the animation
11804   float durationSeconds(1.0f);
11805   Animation animation = Animation::New(durationSeconds);
11806
11807   bool signalReceived( false );
11808   AnimationFinishCheck finishCheck( signalReceived );
11809   animation.FinishedSignal().Connect( &application, finishCheck );
11810   application.SendNotification();
11811
11812   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
11813   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR, TimePeriod( 0.5f, 0.5f ) );
11814
11815   // Delay time is 0.3s. So after duration times, progress must be 70%. animation will finished at 1.3s.
11816   animation.PlayAfter( durationSeconds * 0.3f );
11817   application.SendNotification();
11818   application.Render(0); // start animation
11819
11820   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 5/6 delay progress, 0% animation progress, 0% animator progress */ );
11821
11822   // We didn't expect the animation to finish yet
11823   application.SendNotification();
11824   finishCheck.CheckSignalNotReceived();
11825   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of PlayAfter
11826
11827   application.SendNotification();
11828   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 20% animation progress, 0% animator progress */ );
11829
11830   application.SendNotification();
11831   finishCheck.CheckSignalNotReceived();
11832   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11833
11834   application.SendNotification();
11835   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 45% animation progress, 0% animator progress */ );
11836
11837   application.SendNotification();
11838   finishCheck.CheckSignalNotReceived();
11839   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.0f ), TEST_LOCATION ); // Not move - A delay time of TimePeriod in seconds
11840
11841   application.SendNotification();
11842   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 70% animation progress, 40% animator progress */ );
11843
11844   application.SendNotification();
11845   finishCheck.CheckSignalNotReceived();
11846   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.4f ), TEST_LOCATION ); // 40% of animator progress
11847
11848   application.SendNotification();
11849   application.Render( static_cast< unsigned int >( durationSeconds * 250.0f )/* 100% delay progress, 95% animation progress, 90% animator progress */ );
11850
11851   application.SendNotification();
11852   finishCheck.CheckSignalNotReceived();
11853   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), ( targetPosition * 0.9f ), TEST_LOCATION ); // 90% of animator progress
11854
11855   application.SendNotification();
11856   application.Render( static_cast< unsigned int >( durationSeconds * 50.0f ) + 1u/*just beyond the animation duration*/ );
11857
11858   // We did expect the animation to finish
11859   application.SendNotification();
11860   finishCheck.CheckSignalReceived();
11861   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11862
11863   // Check that nothing has changed after a couple of buffer swaps
11864   application.Render(0);
11865   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11866   END_TEST;
11867 }
11868
11869 int UtcDaliAnimationSetLoopingModeP(void)
11870 {
11871   // Test Loop forever and Loop mode being set
11872   TestApplication application;
11873   Stage stage( Stage::GetCurrent() );
11874
11875   // Default: LoopingMode::RESTART
11876   {
11877     Actor actor = Actor::New();
11878     stage.Add( actor );
11879
11880     float durationSeconds( 1.0f );
11881     Animation animation = Animation::New( durationSeconds );
11882     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
11883
11884     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
11885     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11886
11887     // Start the animation
11888     animation.Play();
11889     application.SendNotification();
11890     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
11891
11892     actor.Unparent();
11893
11894     application.SendNotification();
11895     application.Render();
11896     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11897   }
11898
11899   // LoopingMode::AUTO_REVERSE
11900   {
11901     Actor actor = Actor::New();
11902     stage.Add( actor );
11903
11904     float durationSeconds( 1.0f );
11905     Animation animation = Animation::New( durationSeconds );
11906     animation.SetLooping( true );
11907
11908     bool signalReceived( false );
11909     AnimationFinishCheck finishCheck( signalReceived );
11910     animation.FinishedSignal().Connect( &application, finishCheck );
11911     application.SendNotification();
11912
11913     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11914     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11915
11916     animation.SetLoopingMode( Animation::LoopingMode::AUTO_REVERSE );
11917     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11918
11919     // Start the animation
11920     animation.Play();
11921     application.SendNotification();
11922     application.Render(0);
11923
11924     for( int iterations = 0; iterations < 3; ++iterations )
11925     {
11926       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11927       application.SendNotification();
11928       finishCheck.CheckSignalNotReceived();
11929
11930       // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
11931       // and arrives at the beginning.
11932       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11933
11934       application.SendNotification();
11935       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11936
11937       // We did expect the animation to finish
11938       application.SendNotification();
11939       finishCheck.CheckSignalNotReceived();
11940       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11941     }
11942
11943     animation.SetLooping( false );
11944     application.SendNotification();
11945     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
11946
11947     application.SendNotification();
11948     finishCheck.CheckSignalReceived();
11949
11950     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11951   }
11952
11953   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
11954   {
11955     Actor actor = Actor::New();
11956     stage.Add( actor );
11957
11958     float durationSeconds( 1.0f );
11959     Animation animation = Animation::New( durationSeconds );
11960     animation.SetLooping( true );
11961
11962     bool signalReceived( false );
11963     AnimationFinishCheck finishCheck( signalReceived );
11964     animation.FinishedSignal().Connect( &application, finishCheck );
11965     application.SendNotification();
11966
11967     // Specify a negative multiplier to play the animation in reverse
11968     animation.SetSpeedFactor( -1.0f );
11969
11970     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
11971     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
11972
11973     animation.SetLoopingMode( Animation::AUTO_REVERSE );
11974     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
11975
11976     // Start the animation
11977     animation.Play();
11978     application.SendNotification();
11979     application.Render(0);
11980
11981     for( int iterations = 0; iterations < 3; ++iterations )
11982     {
11983       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 50% time progress */ );
11984       application.SendNotification();
11985       finishCheck.CheckSignalNotReceived();
11986
11987       // Setting a negative speed factor is to play the animation in reverse.
11988       // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
11989       // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
11990       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
11991
11992       application.SendNotification();
11993       application.Render( static_cast< unsigned int >( durationSeconds * 500.0f )/* 100% time progress */ );
11994
11995       // We did expect the animation to finish
11996       application.SendNotification();
11997       finishCheck.CheckSignalNotReceived();
11998       DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
11999     }
12000
12001     animation.SetLooping( false );
12002     application.SendNotification();
12003     application.Render(static_cast< unsigned int >( durationSeconds * 1000.0f ) + 1u /*just beyond the animation duration*/);
12004
12005     application.SendNotification();
12006     finishCheck.CheckSignalReceived();
12007
12008     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12009   }
12010
12011   END_TEST;
12012 }
12013
12014 int UtcDaliAnimationSetLoopingModeP2(void)
12015 {
12016   // Test Loop Count and Loop mode being set
12017   TestApplication application;
12018   Stage stage( Stage::GetCurrent() );
12019
12020   // LoopingMode::AUTO_REVERSE
12021   {
12022     Actor actor = Actor::New();
12023     stage.Add( actor );
12024
12025     float durationSeconds( 1.0f );
12026     Animation animation = Animation::New( durationSeconds );
12027     animation.SetLoopCount(3);
12028     DALI_TEST_CHECK(animation.IsLooping());
12029
12030     bool signalReceived( false );
12031     AnimationFinishCheck finishCheck( signalReceived );
12032     animation.FinishedSignal().Connect( &application, finishCheck );
12033     application.SendNotification();
12034
12035     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12036     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12037
12038     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12039     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12040
12041     // Start the animation
12042     animation.Play();
12043
12044     application.Render(0);
12045     application.SendNotification();
12046     application.Render(0);
12047     application.SendNotification();
12048     application.Render(0);
12049     application.SendNotification();
12050     application.Render(0);
12051     application.SendNotification();
12052
12053     // Loop
12054     float intervalSeconds = 3.0f;
12055
12056     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12057     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
12058     // and arrives at the beginning.
12059     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12060
12061     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12062
12063     application.Render(0);
12064     application.SendNotification();
12065     application.Render(0);
12066     application.SendNotification();
12067     application.Render(0);
12068     application.SendNotification();
12069     application.Render(0);
12070     application.SendNotification();
12071     finishCheck.CheckSignalNotReceived();
12072
12073     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12074
12075     application.SendNotification();
12076     finishCheck.CheckSignalReceived();
12077     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12078
12079     finishCheck.Reset();
12080   }
12081
12082   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
12083   {
12084     Actor actor = Actor::New();
12085     stage.Add( actor );
12086
12087     float durationSeconds( 1.0f );
12088     Animation animation = Animation::New( durationSeconds );
12089     animation.SetLoopCount(3);
12090     DALI_TEST_CHECK(animation.IsLooping());
12091
12092     bool signalReceived( false );
12093     AnimationFinishCheck finishCheck( signalReceived );
12094     animation.FinishedSignal().Connect( &application, finishCheck );
12095     application.SendNotification();
12096
12097     // Specify a negative multiplier to play the animation in reverse
12098     animation.SetSpeedFactor( -1.0f );
12099
12100     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12101     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12102
12103     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12104     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12105
12106     // Start the animation
12107     animation.Play();
12108
12109     application.Render(0);
12110     application.SendNotification();
12111     application.Render(0);
12112     application.SendNotification();
12113     application.Render(0);
12114     application.SendNotification();
12115     application.Render(0);
12116     application.SendNotification();
12117
12118     // Loop
12119     float intervalSeconds = 3.0f;
12120
12121     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12122     // Setting a negative speed factor is to play the animation in reverse.
12123     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12124     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12125     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12126
12127     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12128
12129     application.Render(0);
12130     application.SendNotification();
12131     application.Render(0);
12132     application.SendNotification();
12133     application.Render(0);
12134     application.SendNotification();
12135     application.Render(0);
12136     application.SendNotification();
12137     finishCheck.CheckSignalNotReceived();
12138
12139     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
12140
12141     application.SendNotification();
12142     finishCheck.CheckSignalReceived();
12143     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12144
12145     finishCheck.Reset();
12146   }
12147
12148   END_TEST;
12149 }
12150
12151 int UtcDaliAnimationSetLoopingModeP3(void)
12152 {
12153   // Test Loop Count is 1 (== default) and Loop mode being set
12154   TestApplication application;
12155   Stage stage( Stage::GetCurrent() );
12156
12157   // LoopingMode::AUTO_REVERSE
12158   {
12159     Actor actor = Actor::New();
12160     stage.Add( actor );
12161
12162     float durationSeconds( 1.0f );
12163     Animation animation = Animation::New( durationSeconds );
12164     DALI_TEST_CHECK(1 == animation.GetLoopCount());
12165
12166     bool signalReceived( false );
12167     AnimationFinishCheck finishCheck( signalReceived );
12168     animation.FinishedSignal().Connect( &application, finishCheck );
12169     application.SendNotification();
12170
12171     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12172     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12173
12174     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12175     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12176
12177     // Start the animation
12178     animation.Play();
12179     application.Render(0);
12180     application.SendNotification();
12181
12182     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12183     application.SendNotification();
12184     finishCheck.CheckSignalNotReceived();
12185
12186     // AUTO_REVERSE mode means, for Animation duration time, the actor starts from the beginning, passes the targetPosition,
12187     // and arrives at the beginning.
12188     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12189
12190     application.SendNotification();
12191     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12192
12193     application.SendNotification();
12194     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12195
12196     application.SendNotification();
12197     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12198
12199     application.SendNotification();
12200     application.Render(0);
12201     application.SendNotification();
12202     finishCheck.CheckSignalReceived();
12203
12204     // After all animation finished, arrives at the beginning.
12205     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12206
12207     finishCheck.Reset();
12208   }
12209
12210   // LoopingMode::AUTO_REVERSE in Reverse mode, which begin from the end
12211   {
12212     Actor actor = Actor::New();
12213     stage.Add( actor );
12214
12215     float durationSeconds( 1.0f );
12216     Animation animation = Animation::New( durationSeconds );
12217     DALI_TEST_CHECK(1 == animation.GetLoopCount());
12218
12219     bool signalReceived( false );
12220     AnimationFinishCheck finishCheck( signalReceived );
12221     animation.FinishedSignal().Connect( &application, finishCheck );
12222     application.SendNotification();
12223
12224     // Specify a negative multiplier to play the animation in reverse
12225     animation.SetSpeedFactor( -1.0f );
12226
12227     Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12228     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition );
12229
12230     animation.SetLoopingMode( Animation::AUTO_REVERSE );
12231     DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12232
12233     // Start the animation
12234     animation.Play();
12235     application.Render(0);
12236     application.SendNotification();
12237
12238     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 50% time progress */ );
12239     application.SendNotification();
12240     finishCheck.CheckSignalNotReceived();
12241
12242     // Setting a negative speed factor is to play the animation in reverse.
12243     // So, when LoopingMode::AUTO_REVERSE and SetSpeedFactor( -1.0f ) is, for Animation duration time,
12244     // the actor starts from the targetPosition, passes the beginning, and arrives at the targetPosition.
12245     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
12246
12247     application.SendNotification();
12248     application.Render( static_cast< unsigned int >( durationSeconds * 0.5f * 1000.0f )/* 100% time progress */ );
12249
12250     application.SendNotification();
12251     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12252
12253     application.SendNotification();
12254     application.Render( static_cast< unsigned int >( durationSeconds * 1.0f * 1000.0f ) + 1u /*just beyond the animation duration*/ );
12255
12256     application.SendNotification();
12257     application.Render(0);
12258     application.SendNotification();
12259     finishCheck.CheckSignalReceived();
12260
12261     // After all animation finished, arrives at the target.
12262     DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12263
12264     finishCheck.Reset();
12265   }
12266
12267   END_TEST;
12268 }
12269
12270 int UtcDaliAnimationGetLoopingModeP(void)
12271 {
12272   TestApplication application;
12273
12274   Animation animation = Animation::New(1.0f);
12275
12276   // default mode
12277   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::RESTART );
12278
12279   animation.SetLoopingMode( Animation::AUTO_REVERSE );
12280   DALI_TEST_CHECK( animation.GetLoopingMode() == Animation::AUTO_REVERSE );
12281
12282   END_TEST;
12283 }
12284
12285 int UtcDaliAnimationProgressSignalConnectionWithoutProgressMarkerP(void)
12286 {
12287   TestApplication application;
12288
12289   tet_infoline( "Connect to ProgressReachedSignal but do not set a required Progress marker" );
12290
12291   Actor actor = Actor::New();
12292   Stage::GetCurrent().Add(actor);
12293
12294   // Build the animation
12295   Animation animation = Animation::New(0.0f);
12296
12297   //Set duration
12298   float durationSeconds(1.0f);
12299   animation.SetDuration(durationSeconds);
12300
12301   bool finishedSignalReceived(false);
12302   bool progressSignalReceived(false);
12303
12304   AnimationFinishCheck finishCheck(finishedSignalReceived);
12305   animation.FinishedSignal().Connect(&application, finishCheck);
12306
12307   AnimationProgressCheck progressCheck( progressSignalReceived );
12308   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12309   application.SendNotification();
12310
12311   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12312   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12313
12314   progressCheck.CheckSignalNotReceived();
12315
12316   animation.Play();
12317
12318   application.SendNotification();
12319   application.Render(0); // start animation
12320   application.Render(durationSeconds*100.0f ); // 10% progress
12321   application.SendNotification();
12322
12323   tet_infoline( "Ensure after animation has started playing that ProgressReachedSignal not emitted" );
12324   progressCheck.CheckSignalNotReceived();
12325
12326   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
12327
12328   application.SendNotification();
12329   finishCheck.CheckSignalReceived();
12330   tet_infoline( "Animation finished" );
12331   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
12332
12333   END_TEST;
12334 }
12335
12336 int UtcDaliAnimationMultipleProgressSignalsP(void)
12337 {
12338   tet_infoline( "Multiple animations with different progress markers" );
12339
12340   TestApplication application;
12341
12342   Actor actor = Actor::New();
12343   Stage::GetCurrent().Add(actor);
12344
12345   // Build the animation
12346   Animation animationAlpha = Animation::New(0.0f);
12347   Animation animationBeta = Animation::New(0.0f);
12348
12349   //Set duration
12350   float durationSeconds(1.0f);
12351   animationAlpha.SetDuration(durationSeconds);
12352   animationBeta.SetDuration(durationSeconds);
12353
12354   bool progressSignalReceivedAlpha(false);
12355   bool progressSignalReceivedBeta(false);
12356
12357   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12358   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12359
12360   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12361   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12362   application.SendNotification();
12363
12364   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12365   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12366   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12367
12368   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12369   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12370
12371   tet_infoline( "AnimationBeta Progress notification set to 50%" );
12372   DevelAnimation::SetProgressNotification( animationBeta, 0.5f );
12373
12374   application.SendNotification();
12375   application.Render( );
12376
12377   progressCheckAlpha.CheckSignalNotReceived();
12378   progressCheckBeta.CheckSignalNotReceived();
12379
12380   // Start the animations from 10% progress
12381   animationAlpha.SetCurrentProgress( 0.1f );
12382   animationBeta.SetCurrentProgress( 0.1f );
12383   animationAlpha.Play();
12384   animationBeta.Play();
12385
12386   tet_infoline( "Animation Playing from 10%" );
12387
12388   application.SendNotification();
12389   application.Render(0); // start animation
12390   application.Render(durationSeconds*100.0f ); // 20% progress
12391
12392   tet_infoline( "Animation at 20% - No signals to be received" );
12393
12394   progressCheckAlpha.CheckSignalNotReceived();
12395   progressCheckBeta.CheckSignalNotReceived();
12396
12397   application.SendNotification();
12398   application.Render(durationSeconds*200.0f ); // 40% progress
12399   application.SendNotification();
12400   tet_infoline( "Animation at 40% - Alpha signal should be received" );
12401   DALI_TEST_EQUALS( 0.4f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12402
12403   progressCheckAlpha.CheckSignalReceived();
12404   progressCheckBeta.CheckSignalNotReceived();
12405
12406   tet_infoline( "Progress check reset" );
12407   progressCheckAlpha.Reset();
12408   progressCheckBeta.Reset();
12409
12410   application.Render(durationSeconds*100.0f ); // 50% progress
12411   tet_infoline( "Animation at 50% - Beta should receive signal, Alpha should not" );
12412   application.SendNotification();
12413
12414   DALI_TEST_EQUALS( 0.5f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12415
12416   progressCheckAlpha.CheckSignalNotReceived();
12417   progressCheckBeta.CheckSignalReceived();
12418   tet_infoline( "Progress check reset" );
12419   progressCheckAlpha.Reset();
12420   progressCheckBeta.Reset();
12421
12422   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 60% progress */);
12423   application.SendNotification();
12424
12425   tet_infoline( "Animation at 60%" );
12426
12427   progressCheckAlpha.CheckSignalNotReceived();
12428   progressCheckBeta.CheckSignalNotReceived();
12429
12430   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12431   application.SendNotification();
12432   tet_infoline( "Animation at 80%" );
12433
12434   progressCheckAlpha.CheckSignalNotReceived();
12435   progressCheckBeta.CheckSignalNotReceived();
12436
12437   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12438   // We did expect the animation to finish
12439   tet_infoline( "Animation finished" );
12440
12441   END_TEST;
12442 }
12443
12444 int UtcDaliAnimationMultipleProgressSignalsP2(void)
12445 {
12446   tet_infoline( "Multiple animations with different progress markers and big step time" );
12447
12448   TestApplication application;
12449
12450   Actor actor = Actor::New();
12451   Stage::GetCurrent().Add(actor);
12452
12453   // Build the animation
12454   Animation animationAlpha = Animation::New(0.0f);
12455   Animation animationBeta = Animation::New(0.0f);
12456
12457   //Set duration
12458   const float durationSeconds(1.0f);
12459   animationAlpha.SetDuration(durationSeconds);
12460   animationBeta.SetDuration(durationSeconds);
12461
12462   bool progressSignalReceivedAlpha(false);
12463   bool progressSignalReceivedBeta(false);
12464
12465   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12466   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12467
12468   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12469   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12470   application.SendNotification();
12471
12472   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12473   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12474   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12475
12476   tet_infoline( "AnimationAlpha Progress notification set to 1%" );
12477   DevelAnimation::SetProgressNotification( animationAlpha, 0.01f );
12478
12479   tet_infoline( "AnimationBeta Progress notification set to 99%" );
12480   DevelAnimation::SetProgressNotification( animationBeta, 0.99f );
12481
12482   application.SendNotification();
12483   application.Render( );
12484
12485   progressCheckAlpha.CheckSignalNotReceived();
12486   progressCheckBeta.CheckSignalNotReceived();
12487
12488   // Start the animations unlimited looping
12489   animationAlpha.SetLooping( true );
12490   animationBeta.SetLooping( true );
12491   animationAlpha.Play();
12492   animationBeta.Play();
12493
12494   application.SendNotification();
12495   application.Render(0); // start animation
12496   application.Render(durationSeconds*20.0f ); // 2% progress
12497   application.SendNotification();
12498   DALI_TEST_EQUALS( 0.02f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12499
12500   tet_infoline( "Animation at 2% - Alpha signals should be received, Beta should not." );
12501
12502   progressCheckAlpha.CheckSignalReceived();
12503   progressCheckBeta.CheckSignalNotReceived();
12504
12505   tet_infoline( "Progress check reset" );
12506   progressCheckAlpha.Reset();
12507   progressCheckBeta.Reset();
12508
12509   application.SendNotification();
12510   application.Render(durationSeconds*960.0f ); // 98% progress
12511   application.SendNotification();
12512   tet_infoline( "Animation at 98% - No signal received" );
12513   DALI_TEST_EQUALS( 0.98f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12514
12515   progressCheckAlpha.CheckSignalNotReceived();
12516   progressCheckBeta.CheckSignalNotReceived();
12517
12518   application.SendNotification();
12519   application.Render(durationSeconds*40.0f ); // 2% progress
12520   application.SendNotification();
12521   tet_infoline( "Animation loop once and now 2% - Alpha and Beta should receive signal" );
12522   application.SendNotification();
12523
12524   DALI_TEST_EQUALS( 0.02f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12525
12526   progressCheckAlpha.CheckSignalReceived();
12527   progressCheckBeta.CheckSignalReceived();
12528
12529   tet_infoline( "Progress check reset" );
12530   progressCheckAlpha.Reset();
12531   progressCheckBeta.Reset();
12532
12533   application.SendNotification();
12534   application.Render(durationSeconds*980.0f ); // 100% progress
12535   application.SendNotification();
12536   tet_infoline( "Animation loop one more time. and now 100% - Beta should receive signal, Alhpa sholud not" );
12537   application.SendNotification();
12538
12539   progressCheckAlpha.CheckSignalNotReceived();
12540   progressCheckBeta.CheckSignalReceived();
12541
12542   tet_infoline( "Progress check reset" );
12543   progressCheckAlpha.Reset();
12544   progressCheckBeta.Reset();
12545
12546   animationAlpha.SetLooping( false );
12547   animationBeta.SetLooping( false );
12548
12549   application.SendNotification();
12550   application.Render(static_cast<unsigned int>(durationSeconds*2000.0f) + 1u/*just beyond the animation duration*/);
12551   application.SendNotification();
12552
12553   // We did expect the animation to finish
12554   tet_infoline( "Animation finished" );
12555
12556   END_TEST;
12557 }
12558
12559 int UtcDaliAnimationProgressSignalWithPlayAfterP(void)
12560 {
12561   tet_infoline( "Multiple animations with different progress markers" );
12562
12563   TestApplication application;
12564
12565   Actor actor = Actor::New();
12566   Stage::GetCurrent().Add(actor);
12567
12568   // Build the animation
12569   Animation animationAlpha = Animation::New(0.0f);
12570   Animation animationBeta = Animation::New(0.0f);
12571
12572   //Set duration
12573   float durationSeconds(1.0f);
12574   float delaySeconds(0.5f);
12575   animationAlpha.SetDuration(durationSeconds);
12576   animationBeta.SetDuration(durationSeconds);
12577
12578   bool progressSignalReceivedAlpha(false);
12579   bool progressSignalReceivedBeta(false);
12580
12581   AnimationProgressCheck progressCheckAlpha(progressSignalReceivedAlpha, "animation:Alpha");
12582   AnimationProgressCheck progressCheckBeta(progressSignalReceivedBeta, "animation:Beta" );
12583
12584   DevelAnimation::ProgressReachedSignal( animationAlpha ).Connect( &application, progressCheckAlpha );
12585   DevelAnimation::ProgressReachedSignal( animationBeta ).Connect( &application, progressCheckBeta);
12586   application.SendNotification();
12587
12588   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12589   animationAlpha.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12590   animationBeta.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12591
12592   tet_infoline( "AnimationAlpha Progress notification set to 30%" );
12593   DevelAnimation::SetProgressNotification( animationAlpha, 0.3f );
12594
12595   tet_infoline( "AnimationBeta Progress notification set to ~0% (==Notify when delay is done)" );
12596   DevelAnimation::SetProgressNotification( animationBeta, Math::MACHINE_EPSILON_1 );
12597
12598   application.SendNotification();
12599   application.Render( );
12600
12601   progressCheckAlpha.CheckSignalNotReceived();
12602   progressCheckBeta.CheckSignalNotReceived();
12603
12604   // Start the animations from 10% progress
12605   animationAlpha.PlayAfter(delaySeconds);
12606   animationBeta.PlayAfter(delaySeconds);
12607
12608   application.SendNotification();
12609   application.Render(0); // start animation
12610   application.Render(delaySeconds * 500.0f ); // 50% wait progress
12611
12612   tet_infoline( "Delay at 50% - No signals to be received" );
12613
12614   progressCheckAlpha.CheckSignalNotReceived();
12615   progressCheckBeta.CheckSignalNotReceived();
12616
12617   application.SendNotification();
12618   application.Render(delaySeconds * 500.0f + durationSeconds * 50.0f ); // 100% wait, 5% progress
12619   application.SendNotification();
12620   tet_infoline( "Delay at 100%, Animation at 5% - Beta signal should be received" );
12621   DALI_TEST_EQUALS( 0.05f, animationBeta.GetCurrentProgress(), TEST_LOCATION );
12622
12623   progressCheckBeta.CheckSignalReceived();
12624   progressCheckAlpha.CheckSignalNotReceived();
12625
12626   tet_infoline( "Progress check reset" );
12627   progressCheckAlpha.Reset();
12628   progressCheckBeta.Reset();
12629
12630   application.Render(durationSeconds * 200.0f ); // 25% progress
12631   tet_infoline( "Animation at 25% - No signals to be received" );
12632   application.SendNotification();
12633
12634   progressCheckAlpha.CheckSignalNotReceived();
12635   progressCheckBeta.CheckSignalNotReceived();
12636
12637   application.Render(durationSeconds * 200.0f ); // 45% progress
12638   tet_infoline( "Animation at 45% - Alpha should receive signal, Beta should not" );
12639   application.SendNotification();
12640
12641   DALI_TEST_EQUALS( 0.45f, animationAlpha.GetCurrentProgress(), TEST_LOCATION );
12642
12643   progressCheckAlpha.CheckSignalReceived();
12644   progressCheckBeta.CheckSignalNotReceived();
12645
12646   tet_infoline( "Progress check reset" );
12647   progressCheckAlpha.Reset();
12648   progressCheckBeta.Reset();
12649
12650   application.Render(static_cast<unsigned int>(durationSeconds*150.0f)/* 60% progress */);
12651   application.SendNotification();
12652
12653   tet_infoline( "Animation at 60%" );
12654
12655   progressCheckAlpha.CheckSignalNotReceived();
12656   progressCheckBeta.CheckSignalNotReceived();
12657
12658   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
12659   application.SendNotification();
12660   tet_infoline( "Animation at 80%" );
12661
12662   progressCheckAlpha.CheckSignalNotReceived();
12663   progressCheckBeta.CheckSignalNotReceived();
12664
12665   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
12666   // We did expect the animation to finish
12667   tet_infoline( "Animation finished" );
12668
12669   END_TEST;
12670 }
12671
12672 int UtcDaliAnimationProgressCallbackWithLoopingP(void)
12673 {
12674   TestApplication application;
12675
12676   Actor actor = Actor::New();
12677   Stage::GetCurrent().Add(actor);
12678
12679   // Build the animation
12680   Animation animation = Animation::New(0.0f);
12681
12682   //Set duration
12683   const float durationSeconds(1.0f);
12684   animation.SetDuration(durationSeconds);
12685
12686   // Set Looping Count
12687   const int loopCount( 4 );
12688   animation.SetLoopCount( loopCount );
12689
12690   bool finishedSignalReceived(false);
12691   bool progressSignalReceived(false);
12692
12693   AnimationFinishCheck finishCheck(finishedSignalReceived);
12694   animation.FinishedSignal().Connect(&application, finishCheck);
12695
12696   AnimationProgressCheck progressCheck(progressSignalReceived);
12697   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12698   application.SendNotification();
12699
12700   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12701   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12702
12703   tet_infoline( "Animation Progress notification set to 50% with looping count 4" );
12704   DevelAnimation::SetProgressNotification( animation, 0.5f );
12705
12706   application.SendNotification();
12707   application.Render( );
12708
12709   progressCheck.CheckSignalNotReceived();
12710
12711   animation.Play();
12712
12713   for(int count = 0; count < loopCount; count++)
12714   {
12715     application.SendNotification();
12716     application.Render(0); // start animation
12717     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12718     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12719
12720     tet_infoline( "Animation at 25%" );
12721
12722     progressCheck.CheckSignalNotReceived();
12723
12724     application.SendNotification();
12725     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12726     application.SendNotification();
12727     tet_infoline( "Animation at 50%" );
12728     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12729
12730     progressCheck.CheckSignalReceived();
12731
12732     tet_infoline( "Progress check reset" );
12733     progressCheck.Reset();
12734
12735     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12736     tet_infoline( "Animation at 75%" );
12737     application.SendNotification();
12738
12739     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12740
12741     progressCheck.CheckSignalNotReceived();
12742
12743     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12744     tet_infoline( "Animation at 100%" );
12745     application.SendNotification();
12746
12747     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12748     application.SendNotification();
12749   }
12750   application.Render(10u);
12751   application.SendNotification();
12752   application.Render(0u);
12753   application.SendNotification();
12754
12755   finishCheck.CheckSignalReceived();
12756
12757   END_TEST;
12758 }
12759
12760 int UtcDaliAnimationProgressCallbackWithLoopingP2(void)
12761 {
12762   TestApplication application;
12763
12764   Actor actor = Actor::New();
12765   Stage::GetCurrent().Add(actor);
12766
12767   // Build the animation
12768   Animation animation = Animation::New(0.0f);
12769
12770   //Set duration
12771   const float durationSeconds(1.0f);
12772   animation.SetDuration(durationSeconds);
12773
12774   // Set Looping Unlmited
12775   animation.SetLooping( true );
12776
12777   bool finishedSignalReceived(false);
12778   bool progressSignalReceived(false);
12779
12780   AnimationFinishCheck finishCheck(finishedSignalReceived);
12781   animation.FinishedSignal().Connect(&application, finishCheck);
12782
12783   AnimationProgressCheck progressCheck(progressSignalReceived);
12784   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12785   application.SendNotification();
12786
12787   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12788   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12789
12790   tet_infoline( "Animation Progress notification set to 50% with unlimited looping" );
12791   DevelAnimation::SetProgressNotification( animation, 0.5f );
12792
12793   application.SendNotification();
12794   application.Render( );
12795
12796   progressCheck.CheckSignalNotReceived();
12797
12798   animation.Play();
12799
12800   for(int count = 0; count < 4; count++)
12801   {
12802     application.SendNotification();
12803     application.Render(0); // start animation
12804     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12805     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12806
12807     tet_infoline( "Animation at 25%" );
12808
12809     progressCheck.CheckSignalNotReceived();
12810
12811     application.SendNotification();
12812     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12813     application.SendNotification();
12814     tet_infoline( "Animation at 50%" );
12815     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12816
12817     progressCheck.CheckSignalReceived();
12818
12819     tet_infoline( "Progress check reset" );
12820     progressCheck.Reset();
12821
12822     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12823     tet_infoline( "Animation at 75%" );
12824     application.SendNotification();
12825
12826     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12827
12828     progressCheck.CheckSignalNotReceived();
12829
12830     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12831     tet_infoline( "Animation at 100%" );
12832     application.SendNotification();
12833
12834     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12835     finishCheck.CheckSignalNotReceived();
12836     application.SendNotification();
12837   }
12838   finishCheck.CheckSignalNotReceived();
12839
12840   animation.SetLooping( false );
12841   application.Render(0u);
12842   application.SendNotification();
12843   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 10u);
12844   application.SendNotification();
12845   application.Render(0u);
12846   application.SendNotification();
12847
12848   finishCheck.CheckSignalReceived();
12849
12850   END_TEST;
12851 }
12852
12853 int UtcDaliAnimationProgressCallbackNegativeSpeed(void)
12854 {
12855   TestApplication application;
12856
12857   Actor actor = Actor::New();
12858   Stage::GetCurrent().Add(actor);
12859
12860   // Build the animation
12861   Animation animation = Animation::New(0.0f);
12862
12863   //Set duration
12864   const float durationSeconds(1.0f);
12865   animation.SetDuration(durationSeconds);
12866
12867   //Set speed negative
12868   animation.SetSpeedFactor( -1.0f );
12869
12870   // Set Looping Unlmited
12871   animation.SetLooping( true );
12872
12873   bool finishedSignalReceived(false);
12874   bool progressSignalReceived(false);
12875
12876   AnimationFinishCheck finishCheck(finishedSignalReceived);
12877   animation.FinishedSignal().Connect(&application, finishCheck);
12878
12879   AnimationProgressCheck progressCheck(progressSignalReceived);
12880   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
12881   application.SendNotification();
12882
12883   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
12884   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
12885
12886   tet_infoline( "Animation Progress notification set to 50%" );
12887   DevelAnimation::SetProgressNotification( animation, 0.5f );
12888
12889   application.SendNotification();
12890   application.Render( );
12891
12892   progressCheck.CheckSignalNotReceived();
12893
12894   animation.Play();
12895
12896   for(int count = 0; count < 4; count++)
12897   {
12898     application.SendNotification();
12899     application.Render(0); // start animation
12900     progressCheck.CheckSignalNotReceived();
12901
12902     application.SendNotification();
12903     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12904     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12905
12906     tet_infoline( "Animation at 25%" );
12907
12908     progressCheck.CheckSignalNotReceived();
12909
12910     application.SendNotification();
12911     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12912     application.SendNotification();
12913     tet_infoline( "Animation at 50%" );
12914     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12915
12916     progressCheck.CheckSignalReceived();
12917
12918     tet_infoline( "Progress check reset" );
12919     progressCheck.Reset();
12920
12921     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12922     tet_infoline( "Animation at 75%" );
12923     application.SendNotification();
12924
12925     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12926
12927     progressCheck.CheckSignalNotReceived();
12928
12929     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12930     tet_infoline( "Animation at 100%" );
12931     application.SendNotification();
12932
12933     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12934     finishCheck.CheckSignalNotReceived();
12935     application.SendNotification();
12936   }
12937   finishCheck.CheckSignalNotReceived();
12938
12939   animation.Stop();
12940   animation.SetLooping( false );
12941   animation.SetLoopCount( 4 );
12942   animation.Play();
12943   application.Render(0u);
12944   application.SendNotification();
12945
12946   for(int count = 0; count < 4; count++)
12947   {
12948     application.SendNotification();
12949     application.Render(0); // start animation
12950     progressCheck.CheckSignalNotReceived();
12951
12952     application.SendNotification();
12953     application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
12954     DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
12955
12956     tet_infoline( "Animation at 25%" );
12957
12958     progressCheck.CheckSignalNotReceived();
12959
12960     application.SendNotification();
12961     application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
12962     application.SendNotification();
12963     tet_infoline( "Animation at 50%" );
12964     DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
12965
12966     progressCheck.CheckSignalReceived();
12967
12968     tet_infoline( "Progress check reset" );
12969     progressCheck.Reset();
12970
12971     application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
12972     tet_infoline( "Animation at 75%" );
12973     application.SendNotification();
12974
12975     DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
12976
12977     progressCheck.CheckSignalNotReceived();
12978
12979     application.Render(durationSeconds*0.25*1000.0f ); // 100% progress
12980     tet_infoline( "Animation at 100%" );
12981     application.SendNotification();
12982
12983     //Nothing check at 100% progress. cause It can be both 100% and 0%.
12984     application.SendNotification();
12985   }
12986   application.Render(10u);
12987   application.SendNotification();
12988   application.Render(0u);
12989   application.SendNotification();
12990
12991   finishCheck.CheckSignalReceived();
12992
12993   END_TEST;
12994 }
12995
12996 int UtcDaliAnimationProgressCallbackInvalidSignalN(void)
12997 {
12998   TestApplication application;
12999
13000   Actor actor = Actor::New();
13001   Stage::GetCurrent().Add(actor);
13002
13003   // Build the animation
13004   Animation animation = Animation::New(0.0f);
13005
13006   //Set duration
13007   const float durationSeconds(1.0f);
13008   animation.SetDuration(durationSeconds);
13009
13010   bool finishedSignalReceived(false);
13011   bool progressSignalReceived(false);
13012
13013   AnimationFinishCheck finishCheck(finishedSignalReceived);
13014   animation.FinishedSignal().Connect(&application, finishCheck);
13015
13016   AnimationProgressCheck progressCheck(progressSignalReceived);
13017   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
13018   application.SendNotification();
13019
13020   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
13021   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
13022
13023   tet_infoline( "Animation Progress PlayRange as 10% ~ 90%" );
13024   animation.SetPlayRange( Vector2( 0.1f, 0.9f ) );
13025
13026   tet_infoline( "Animation Progress notification set to >90% that never can notificated" );
13027   DevelAnimation::SetProgressNotification( animation, 0.9f + Math::MACHINE_EPSILON_1 );
13028
13029   application.SendNotification();
13030   application.Render( );
13031
13032   progressCheck.CheckSignalNotReceived();
13033
13034   animation.Play();
13035
13036   application.SendNotification();
13037   application.Render(0); // start animation
13038   application.Render(durationSeconds*0.25*1000.0f ); // 35% progress
13039   DALI_TEST_EQUALS( 0.35f, animation.GetCurrentProgress(), TEST_LOCATION );
13040
13041   tet_infoline( "Animation at 35%" );
13042
13043   progressCheck.CheckSignalNotReceived();
13044
13045   application.SendNotification();
13046   application.Render(durationSeconds*0.25*1000.0f ); // 60% progress
13047   application.SendNotification();
13048   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
13049
13050   tet_infoline( "Animation at 60%" );
13051
13052   progressCheck.CheckSignalNotReceived();
13053
13054   application.Render(durationSeconds*0.25*1000.0f ); // 85% progress
13055   tet_infoline( "Animation at 85%" );
13056   application.SendNotification();
13057   DALI_TEST_EQUALS( 0.85f, animation.GetCurrentProgress(), TEST_LOCATION );
13058
13059   progressCheck.CheckSignalNotReceived();
13060
13061   application.Render(durationSeconds*0.25*1000.0f ); // 90% progress
13062   tet_infoline( "Animation over 90%" );
13063   application.SendNotification();
13064
13065   // progress never signaled because playrange is 90%
13066   progressCheck.CheckSignalNotReceived();
13067
13068   END_TEST;
13069 }
13070
13071 int UtcDaliAnimationProgressCallbackLongDurationP(void)
13072 {
13073   TestApplication application;
13074
13075   Actor actor = Actor::New();
13076   Stage::GetCurrent().Add(actor);
13077
13078   // Build the animation
13079   Animation animation = Animation::New(0.0f);
13080
13081   //Set duration
13082   float durationSeconds(5.0f);
13083   animation.SetDuration(durationSeconds);
13084
13085   bool finishedSignalReceived(false);
13086   bool progressSignalReceived(false);
13087
13088   AnimationFinishCheck finishCheck(finishedSignalReceived);
13089   animation.FinishedSignal().Connect(&application, finishCheck);
13090
13091   AnimationProgressCheck progressCheck(progressSignalReceived);
13092   DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck);
13093   application.SendNotification();
13094
13095   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
13096   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
13097
13098   tet_infoline( "Animation Progress notification set to 50%" );
13099   DevelAnimation::SetProgressNotification( animation, 0.5f );
13100
13101   application.SendNotification();
13102   application.Render( );
13103
13104   progressCheck.CheckSignalNotReceived();
13105
13106   animation.Play();
13107
13108   application.SendNotification();
13109   application.Render(0); // start animation
13110   application.Render(durationSeconds*0.25*1000.0f ); // 25% progress
13111   DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
13112
13113   tet_infoline( "Animation at 25%" );
13114
13115   progressCheck.CheckSignalNotReceived();
13116
13117   application.SendNotification();
13118   application.Render(durationSeconds*0.25*1000.0f ); // 50% progress
13119   application.SendNotification();
13120   tet_infoline( "Animation at 50%" );
13121   DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION );
13122
13123   progressCheck.CheckSignalReceived();
13124
13125   tet_infoline( "Progress check reset" );
13126   progressCheck.Reset();
13127
13128   application.Render(durationSeconds*0.25*1000.0f ); // 75% progress
13129   tet_infoline( "Animation at 75%" );
13130   application.SendNotification();
13131
13132   DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
13133
13134   progressCheck.CheckSignalNotReceived();
13135
13136   END_TEST;
13137 }
13138
13139 int UtcDaliAnimationAnimateByInvalidParameters(void)
13140 {
13141   TestApplication application;
13142
13143   Actor actor = Actor::New();
13144   Stage::GetCurrent().Add(actor);
13145
13146   // Create the animation
13147   Animation animation = Animation::New(1.0f);
13148
13149   DALI_TEST_ASSERTION(
13150   {
13151     // non animateable property (STRING)
13152     animation.AnimateBy( Property( actor, Actor::Property::LAYOUT_DIRECTION ), Property::Value( "new direction" ) );
13153   }, "Property type is not animatable" );
13154
13155   DALI_TEST_ASSERTION(
13156   {
13157     // non animateable property (MATRIX)
13158     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Dali::Matrix() ), Property::ANIMATABLE );
13159     animation.AnimateBy( Property( actor, index ), Property::Value( Property::MATRIX ) );
13160   }, "Property type is not animatable" );
13161
13162   // AnimateBy
13163   DALI_TEST_ASSERTION(
13164   {
13165     // non animateable target (NONE)
13166     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value() );
13167   }, "Target value is not animatable" );
13168
13169   DALI_TEST_ASSERTION(
13170   {
13171     // non animateable target (STRING)
13172     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value("foo") );
13173   }, "Target value is not animatable" );
13174
13175   DALI_TEST_ASSERTION(
13176   {
13177     // not mathing properties (VECTOR3, FLOAT)
13178     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( 10.f ) );
13179   }, "Property and target types don't match" );
13180
13181   DALI_TEST_ASSERTION(
13182   {
13183     // not mathing properties (VECTOR3.A, VECTOR2)
13184     animation.AnimateBy( Property( actor, Actor::Property::COLOR_ALPHA ), Property::Value( Property::VECTOR2 ) );
13185   }, "Property and target types don't match" );
13186
13187   DALI_TEST_ASSERTION(
13188   {
13189     // negative duration
13190     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
13191   }, "Duration must be >=0" );
13192
13193   END_TEST;
13194 }
13195
13196 int UtcDaliAnimationAnimateToInvalidParameters(void)
13197 {
13198   TestApplication application;
13199
13200   Actor actor = Actor::New();
13201   Stage::GetCurrent().Add(actor);
13202
13203   // Create the animation
13204   Animation animation = Animation::New(1.0f);
13205
13206   // AnimateTo
13207   DALI_TEST_ASSERTION(
13208   {
13209     // non animateable property (MAP)
13210     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::MAP ), Property::ANIMATABLE );
13211     animation.AnimateTo( Property( actor, index ), Property::Value( Property::MAP ) );
13212   }, "Property type is not animatable" );
13213
13214   DALI_TEST_ASSERTION(
13215   {
13216     // non animateable target (NONE)
13217     animation.AnimateTo( Property( actor, Actor::Property::CLIPPING_MODE ), Property::Value() );
13218   }, "Property type is not animatable" );
13219
13220   DALI_TEST_ASSERTION(
13221   {
13222     // non animateable target (ARRAY)
13223     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Property::ARRAY ) );
13224   }, "Target value is not animatable" );
13225
13226   DALI_TEST_ASSERTION(
13227   {
13228     // non animateable target (RECTANGLE)
13229     animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Property::Value( Rect<int32_t>() ) );
13230   }, "Target value is not animatable" );
13231
13232   DALI_TEST_ASSERTION(
13233   {
13234     // not mathing properties (FLOAT, INT)
13235     animation.AnimateTo( Property( actor, Actor::Property::SCALE_Y ), Property::Value(10) );
13236   }, "Property and target types don't match" );
13237
13238   DALI_TEST_ASSERTION(
13239   {
13240     // not mathing properties (VECTOR3, VECTOR2)
13241     animation.AnimateTo( Property( actor, Actor::Property::COLOR ), Property::Value( Property::VECTOR2 ) );
13242   }, "Property and target types don't match" );
13243
13244   DALI_TEST_ASSERTION(
13245   {
13246     // negative duration
13247     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Property::Value( Vector3(1,2,3) ), TimePeriod(-1) );
13248   }, "Duration must be >=0" );
13249
13250   END_TEST;
13251 }
13252
13253 int UtcDaliAnimationAnimateBetweenInvalidParameters(void)
13254 {
13255   TestApplication application;
13256
13257   Actor actor = Actor::New();
13258   Stage::GetCurrent().Add(actor);
13259
13260   // Create the animation
13261   Animation animation = Animation::New(1.0f);
13262
13263   // AnimateBetween
13264   DALI_TEST_ASSERTION(
13265   {
13266     // non animateable property (ARRAY)
13267     Property::Index index = actor.RegisterProperty( "Foobar", Property::Value( Property::ARRAY ), Property::ANIMATABLE );
13268     KeyFrames keyframes = KeyFrames::New();
13269     keyframes.Add( 0.5f, Property::Value( Property::ARRAY ) );
13270     animation.AnimateBetween( Property( actor, index ), keyframes );
13271   }, "Property type is not animatable" );
13272
13273   DALI_TEST_ASSERTION(
13274   {
13275     // non animateable target (NONE)
13276     KeyFrames keyframes = KeyFrames::New();
13277     keyframes.Add( 0.5f, Property::Value() );
13278     animation.AnimateBetween( Property( actor, Actor::Property::CLIPPING_MODE ), keyframes );
13279   }, "Property type is not animatable" );
13280
13281   DALI_TEST_ASSERTION(
13282   {
13283     // non animateable target (EXTENTS)
13284     KeyFrames keyframes = KeyFrames::New();
13285     keyframes.Add( 0.5f, Property::Value( Property::EXTENTS ) ); // throws
13286     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13287   }, "Property type is not animatable" );
13288
13289   DALI_TEST_ASSERTION(
13290   {
13291     // non animateable target (RECTANGLE)
13292     KeyFrames keyframes = KeyFrames::New();
13293     keyframes.Add( 0.5f, Property::Value( Property::MAP ) ); // throws
13294     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes );
13295   }, "Property type is not animatable" );
13296
13297   DALI_TEST_ASSERTION(
13298   {
13299     // not mathing properties (VECTOR2, VECTOR4)
13300     KeyFrames keyframes = KeyFrames::New();
13301     keyframes.Add( 0.5f, Property::Value( Vector4( 1, 2, 3, 4 ) ) );
13302     animation.AnimateBetween( Property( actor, Actor::Property::MAXIMUM_SIZE ), keyframes );
13303   }, "Property and target types don't match" );
13304
13305   DALI_TEST_ASSERTION(
13306   {
13307     // negative duration
13308     KeyFrames keyframes = KeyFrames::New();
13309     keyframes.Add( 0.5f, Property::Value(Vector3( 1, 2, 3 ) ) );
13310     animation.AnimateBetween( Property( actor, Actor::Property::POSITION ), keyframes, TimePeriod(-1) );
13311   }, "Duration must be >=0" );
13312
13313   END_TEST;
13314 }
13315
13316 namespace // Purposefully left this in the middle as the values in this namespace are only used for the subsequent two test cases
13317 {
13318 enum TestFunction
13319 {
13320   STOP,
13321   CLEAR
13322 };
13323
13324 void CheckPropertyValuesWhenCallingAnimationMethod( TestFunction functionToTest, const char * testName )
13325 {
13326   tet_printf( "Testing %s\n", testName );
13327
13328   // When an Animation::Stop() or Animation::Clear() is called, the event-side property needs to be updated appropriately
13329   // This test checks that that is being done
13330
13331   const float durationSeconds( 1.0f );
13332   unsigned int halfAnimationDuration( static_cast< unsigned int >( durationSeconds * 1000.0f * 0.5f ) );
13333   const Vector3 originalPosition( Vector3::ZERO );
13334   const Vector3 targetPosition( 10.0f, 10.0f, 10.0f );
13335   const Vector3 halfWayToTarget( targetPosition * 0.5f );
13336
13337   struct ExpectedValue
13338   {
13339     Animation::EndAction endAction;
13340     Vector3 expectedGetPropertyValue;
13341   };
13342
13343   ExpectedValue expectedValueTable[] =
13344   {
13345    { Animation::Bake,      halfWayToTarget  }, // When baking, the current value is the final value.
13346    { Animation::BakeFinal, targetPosition   }, // When BakeFinal, we should jump to the final value when clearing or stopping.
13347    { Animation::Discard,   originalPosition }, // When discarding, we should jump back to the original value when clearing or stopping.
13348   };
13349   const auto expectedValueTableCount = sizeof( expectedValueTable ) / sizeof( ExpectedValue );
13350
13351   for( auto i = 0u; i < expectedValueTableCount; ++i  )
13352   {
13353     TestApplication application;
13354
13355     Actor actor = Actor::New();
13356     Stage::GetCurrent().Add(actor);
13357
13358     // Build the animation
13359     Animation animation = Animation::New( durationSeconds );
13360     animation.SetEndAction( expectedValueTable[ i ].endAction );
13361     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
13362
13363     // Start the animation
13364     animation.Play();
13365
13366     application.SendNotification();
13367     application.Render( halfAnimationDuration );
13368
13369     // Stop or Clear the animation early, both have the same effect
13370     if( functionToTest == TestFunction::STOP )
13371     {
13372       animation.Stop();
13373     }
13374     else
13375     {
13376       animation.Clear();
13377     }
13378
13379     // The event side property should be set the expected value immediately, the update side property will still only be halfway as we haven't run an update yet
13380     DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION ).Get< Vector3 >(), expectedValueTable[ i ].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION );
13381     DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), halfWayToTarget, VECTOR3_EPSILON, TEST_LOCATION );
13382
13383     // After one frame, both values should match regardless of the End Action
13384     application.SendNotification();
13385     application.Render();
13386
13387     DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION ).Get< Vector3 >(), expectedValueTable[ i ].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION );
13388     DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), expectedValueTable[ i ].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION );
13389   }
13390 }
13391 } // unnamed namespace
13392
13393 int UtcDaliAnimationStopPropertyValue(void)
13394 {
13395   CheckPropertyValuesWhenCallingAnimationMethod( TestFunction::STOP, "UtcDaliAnimationStopPropertyValue" );
13396   END_TEST;
13397 }
13398
13399 int UtcDaliAnimationClearPropertyValue(void)
13400 {
13401   CheckPropertyValuesWhenCallingAnimationMethod( TestFunction::CLEAR, "UtcDaliAnimationStopPropertyValue" );
13402   END_TEST;
13403 }
13404
13405 int UtcDaliAnimationPausePropertyValue(void)
13406 {
13407   const float durationSeconds( 1.0f );
13408   unsigned int halfAnimationDuration( static_cast< unsigned int >( durationSeconds * 1000.0f * 0.5f ) );
13409   const Vector3 originalPosition( Vector3::ZERO );
13410   const Vector3 targetPosition( 10.0f, 10.0f, 10.0f );
13411   const Vector3 halfWayToTarget( targetPosition * 0.5f );
13412
13413   Animation::EndAction endActions[] =
13414   {
13415    Animation::Bake,
13416    Animation::BakeFinal,
13417    Animation::Discard,
13418   };
13419   const auto endActionCount = sizeof( endActions ) / sizeof( endActions[0] );
13420
13421   // For all end actions, when pausing, we stay at the current value
13422   for( auto i = 0u; i < endActionCount; ++i  )
13423   {
13424     TestApplication application;
13425
13426     Actor actor = Actor::New();
13427     Stage::GetCurrent().Add(actor);
13428
13429     // Build the animation
13430     Animation animation = Animation::New( durationSeconds );
13431     animation.SetEndAction( endActions[ i ] );
13432     animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
13433
13434     // Start the animation
13435     animation.Play();
13436
13437     application.SendNotification();
13438     application.Render( halfAnimationDuration );
13439
13440     // Puase the animation early
13441     animation.Pause();
13442
13443     // The event side property should be set the current value immediately, the update side property will still only be halfway
13444     DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION ).Get< Vector3 >(), halfWayToTarget, VECTOR3_EPSILON, TEST_LOCATION );
13445     DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), halfWayToTarget, VECTOR3_EPSILON, TEST_LOCATION );
13446
13447     // After one frame, both values should match regardless of the End Action
13448     application.SendNotification();
13449     application.Render();
13450
13451     DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION ).Get< Vector3 >(), halfWayToTarget, VECTOR3_EPSILON, TEST_LOCATION );
13452     DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), halfWayToTarget, VECTOR3_EPSILON, TEST_LOCATION );
13453   }
13454
13455   END_TEST;
13456 }
13457
13458 int UtcDaliAnimationPlayFromWithLoopCount(void)
13459 {
13460   TestApplication application;
13461
13462   auto actor = Actor::New();
13463   Stage::GetCurrent().Add( actor );
13464
13465   auto animation = Animation::New( 1.0f );
13466   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f );
13467   animation.SetLoopCount( 2 );
13468   animation.Play();
13469
13470   application.SendNotification();
13471   application.Render( 1001 );
13472
13473   // One loop completed
13474
13475   application.Render( 2005 );
13476   application.SendNotification();
13477
13478   // 2 loops should have completed
13479   DALI_TEST_EQUALS( animation.GetCurrentLoop(), 2u, TEST_LOCATION );
13480
13481   // Another render needs to occur after all the loops end
13482   application.SendNotification();
13483   application.Render( 1000 );
13484
13485   // Stop the animation and use PlayFrom, previously we got an Assert here
13486   animation.Stop();
13487   animation.PlayFrom( 0.5f );
13488
13489   application.SendNotification();
13490   application.Render( 1000 );
13491
13492   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
13493
13494   END_TEST;
13495 }
13496
13497 int UtcDaliAnimationCombineToAndByWithStop(void)
13498 {
13499   tet_infoline( "Ensure the Y Position is not modified when animating the X position using AnimateTo and AnimateBy");
13500
13501   TestApplication application;
13502
13503   auto actor = Actor::New();
13504   actor.SetPosition( 100.0f, 100.0f );
13505   Stage::GetCurrent().Add( actor );
13506
13507   auto animation = Animation::New( 1.0f );
13508   const float origY = actor.GetProperty( Actor::Property::POSITION_Y ).Get< float >();
13509   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 150.0f, origY, 0.0f ), TimePeriod( 1.0f ) );
13510   animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Vector3( -30.0f, 0.0f, 0.0f ), TimePeriod( 1.0f, 1.0f ) );
13511   animation.Play();
13512
13513   application.SendNotification();
13514   application.Render( 500 );
13515
13516   application.SendNotification();
13517   application.Render( 500 );
13518
13519   application.SendNotification();
13520   application.Render( 500 );
13521
13522   // Stop and clear the animation using the current values
13523   animation.Stop();
13524   animation.Clear();
13525
13526   // Check the y position, it should be the same as before
13527   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION_Y).Get< float >(), origY, TEST_LOCATION );
13528
13529   END_TEST;
13530 }