2ef1975868a7d464b658e388a28d7678091bdae5
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <algorithm>
20
21 #include <stdlib.h>
22 #include <dali/public-api/dali-core.h>
23 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali-test-suite-utils.h>
25
26 using std::max;
27 using namespace Dali;
28
29 void utc_dali_animation_startuP(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_animation_cleanuP(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 static const float ROTATION_EPSILON = 0.0001f;
43 static const float VECTOR4_EPSILON = 0.0001f;
44
45 // Functor to test whether a Finish signal is emitted
46 struct AnimationFinishCheck
47 {
48   AnimationFinishCheck(bool& signalReceived)
49   : mSignalReceived(signalReceived)
50   {
51   }
52
53   void operator()(Animation& animation)
54   {
55     mSignalReceived = true;
56   }
57
58   void Reset()
59   {
60     mSignalReceived = false;
61   }
62
63   void CheckSignalReceived()
64   {
65     if (!mSignalReceived)
66     {
67       tet_printf("Expected Finish signal was not received\n");
68       tet_result(TET_FAIL);
69     }
70     else
71     {
72       tet_result(TET_PASS);
73     }
74   }
75
76   void CheckSignalNotReceived()
77   {
78     if (mSignalReceived)
79     {
80       tet_printf("Unexpected Finish signal was received\n");
81       tet_result(TET_FAIL);
82     }
83     else
84     {
85       tet_result(TET_PASS);
86     }
87   }
88
89   bool& mSignalReceived; // owned by individual tests
90 };
91
92 } // anon namespace
93
94 int UtcDaliAnimationConstructorP(void)
95 {
96   TestApplication application;
97
98   Animation animation;
99
100   DALI_TEST_CHECK( !animation );
101   END_TEST;
102 }
103
104 int UtcDaliAnimationNewP(void)
105 {
106   TestApplication application;
107
108   Animation animation = Animation::New( 1.0f );
109
110   DALI_TEST_CHECK(animation);
111   END_TEST;
112 }
113
114 int UtcDaliAnimationNewN(void)
115 {
116   TestApplication application;
117
118   Animation animation = Animation::New( -1.0f );
119
120   DALI_TEST_CHECK(animation);
121   DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
122   END_TEST;
123 }
124
125 int UtcDaliAnimationDownCastP(void)
126 {
127   TestApplication application;
128
129   tet_infoline("Testing Dali::Animation::DownCast()");
130
131   float durationSeconds(1.0f);
132   Animation animation = Animation::New(durationSeconds);
133
134   BaseHandle object(animation);
135
136   Animation animation2 = Animation::DownCast(object);
137   DALI_TEST_CHECK(animation2);
138
139   Animation animation3 = DownCast< Animation >(object);
140   DALI_TEST_CHECK(animation3);
141   END_TEST;
142 }
143
144 int UtcDaliAnimationDownCastN(void)
145 {
146   TestApplication application;
147
148   BaseHandle unInitializedObject;
149
150   Animation animation1 = Animation::DownCast( unInitializedObject );
151   DALI_TEST_CHECK( !animation1 );
152
153   Animation animation2 = DownCast< Animation >( unInitializedObject );
154   DALI_TEST_CHECK( !animation2 );
155   END_TEST;
156 }
157
158 int UtcDaliAnimationCopyConstructorP(void)
159 {
160   TestApplication application;
161
162   // Initialize an object, ref count == 1
163   Animation animation = Animation::New( 1.0f );
164
165   Animation copy( animation );
166   DALI_TEST_CHECK( copy );
167
168   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
169   END_TEST;
170 }
171
172 int UtcDaliAnimationAssignmentOperatorP(void)
173 {
174   TestApplication application;
175
176   Animation animation = Animation::New( 1.0f );
177
178   Animation copy = animation;
179   DALI_TEST_CHECK( copy );
180
181   DALI_TEST_CHECK( animation == copy );
182
183   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
184   END_TEST;
185 }
186
187 int UtcDaliAnimationSetDurationP(void)
188 {
189   TestApplication application;
190
191   Actor actor = Actor::New();
192   Stage::GetCurrent().Add(actor);
193
194   // Build the animation
195   float durationSeconds(1.0f);
196   Animation animation = Animation::New(durationSeconds);
197   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
198
199   // Start the animation
200   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
201   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
202   animation.Play();
203
204   bool signalReceived(false);
205   AnimationFinishCheck finishCheck(signalReceived);
206   animation.FinishedSignal().Connect(&application, finishCheck);
207
208   application.SendNotification();
209   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
210
211   // We didn't expect the animation to finish yet
212   application.SendNotification();
213   finishCheck.CheckSignalNotReceived();
214
215   application.Render(2u/*just beyond the animation duration*/);
216
217   // We did expect the animation to finish
218   application.SendNotification();
219   finishCheck.CheckSignalReceived();
220   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
221
222   // Restart the animation, with a different duration
223   finishCheck.Reset();
224   actor.SetPosition(Vector3::ZERO);
225   durationSeconds = 3.5f;
226   animation.SetDuration(durationSeconds);
227   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
228   animation.Play();
229
230   application.SendNotification();
231   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
232
233   // We didn't expect the animation to finish yet
234   application.SendNotification();
235   finishCheck.CheckSignalNotReceived();
236
237   application.Render(2u/*just beyond the animation duration*/);
238
239   // We did expect the animation to finish
240   application.SendNotification();
241   finishCheck.CheckSignalReceived();
242   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
243
244   // Check that nothing has changed after a couple of buffer swaps
245   application.Render(0);
246   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
247   application.Render(0);
248   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
249   END_TEST;
250 }
251
252 int UtcDaliAnimationSetDurationN(void)
253 {
254   TestApplication application;
255
256   Animation animation = Animation::New( 1.0f );
257   DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
258
259   animation.SetDuration( -1.0f );
260   DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
261   END_TEST;
262 }
263
264 int UtcDaliAnimationGetDurationP(void)
265 {
266   TestApplication application;
267
268   Animation animation = Animation::New(1.0f);
269   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
270
271   animation.SetDuration(2.0f);
272   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
273   END_TEST;
274 }
275
276 int UtcDaliAnimationSetLoopingP(void)
277 {
278   TestApplication application;
279
280   Actor actor = Actor::New();
281   Stage::GetCurrent().Add(actor);
282
283   // Build the animation
284   float durationSeconds(1.0f);
285   Animation animation = Animation::New(durationSeconds);
286   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
287   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
288
289   // Start the animation
290   animation.SetLooping(true);
291   DALI_TEST_CHECK(animation.IsLooping());
292   animation.Play();
293
294   bool signalReceived(false);
295   AnimationFinishCheck finishCheck(signalReceived);
296   animation.FinishedSignal().Connect(&application, finishCheck);
297
298   application.SendNotification();
299
300   // Loop 5 times
301   float intervalSeconds = 0.25f;
302   float progress = 0.0f;
303   for (int iterations = 0; iterations < 5;)
304   {
305     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
306
307     progress += intervalSeconds;
308     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
309
310     if (progress >= 1.0f)
311     {
312       progress = progress - 1.0f;
313       ++iterations;
314     }
315   }
316
317   // We didn't expect the animation to finish yet
318   application.SendNotification();
319   finishCheck.CheckSignalNotReceived();
320
321   animation.SetLooping(false);
322   DALI_TEST_CHECK(!animation.IsLooping());
323
324   application.SendNotification();
325   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
326
327   // We did expect the animation to finish
328   application.SendNotification();
329   finishCheck.CheckSignalReceived();
330   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
331
332   // Check that nothing has changed after a couple of buffer swaps
333   application.Render(0);
334   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
335   application.Render(0);
336   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
337   END_TEST;
338 }
339
340 int UtcDaliAnimationSetLoopCountP(void)
341 {
342   TestApplication application;
343
344   Actor actor = Actor::New();
345   Stage::GetCurrent().Add(actor);
346
347   // Build the animation
348   float durationSeconds(1.0f);
349   Animation animation = Animation::New(durationSeconds);
350   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
351   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
352
353   // Start the animation
354   animation.SetLoopCount(3);
355   DALI_TEST_CHECK(animation.IsLooping());
356   animation.Play();
357
358   bool signalReceived(false);
359   AnimationFinishCheck finishCheck(signalReceived);
360   animation.FinishedSignal().Connect(&application, finishCheck);
361
362   application.Render(0);
363   application.SendNotification();
364   application.Render(0);
365   application.SendNotification();
366   application.Render(0);
367   application.SendNotification();
368   application.Render(0);
369   application.SendNotification();
370
371   // Loop
372   float intervalSeconds = 3.0f;
373
374   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
375   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
376
377   application.Render(0);
378   application.SendNotification();
379   application.Render(0);
380   application.SendNotification();
381   application.Render(0);
382   application.SendNotification();
383   application.Render(0);
384   application.SendNotification();
385   finishCheck.CheckSignalNotReceived();
386
387   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
388
389   application.SendNotification();
390   finishCheck.CheckSignalReceived();
391   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
392
393   finishCheck.Reset();
394
395   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
396   application.SendNotification();
397   finishCheck.CheckSignalNotReceived();
398
399   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
400   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
401   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
402   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
403   application.SendNotification();
404   finishCheck.CheckSignalNotReceived();
405
406   END_TEST;
407 }
408
409 int UtcDaliAnimationSetLoopCountP2(void)
410 {
411   TestApplication application;
412
413   //
414   // switching between forever and loop count
415   //
416
417   Actor actor = Actor::New();
418   Stage::GetCurrent().Add(actor);
419
420   // Build the animation
421   float durationSeconds(1.0f);
422   Animation animation = Animation::New(durationSeconds);
423   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
424   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
425   animation.SetEndAction(Animation::Discard);
426
427   // Start the animation
428   animation.SetLoopCount(3);
429   DALI_TEST_CHECK(animation.IsLooping());
430   animation.Play();
431
432   bool signalReceived(false);
433   AnimationFinishCheck finishCheck(signalReceived);
434   animation.FinishedSignal().Connect(&application, finishCheck);
435
436   float intervalSeconds = 3.0f;
437
438   application.SendNotification();
439   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
440   application.SendNotification();
441   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
442   application.SendNotification();
443   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
444   application.SendNotification();
445
446   application.SendNotification();
447   finishCheck.CheckSignalReceived();
448
449   finishCheck.Reset();
450
451   // Loop forever
452   animation.SetLooping(true);
453   DALI_TEST_CHECK(animation.IsLooping());
454
455   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
456   application.SendNotification();
457   finishCheck.CheckSignalNotReceived();
458
459   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
460   application.SendNotification();
461   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
462   application.SendNotification();
463   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
464   application.SendNotification();
465   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
466   application.SendNotification();
467   application.SendNotification();
468   finishCheck.CheckSignalNotReceived();
469
470   finishCheck.Reset();
471
472   // Loop N again
473   animation.SetLoopCount(3);
474   DALI_TEST_CHECK(animation.IsLooping());
475   animation.Play();
476
477   application.SendNotification();
478   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
479   application.SendNotification();
480   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
481   application.SendNotification();
482   finishCheck.CheckSignalNotReceived();
483
484   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
485   application.SendNotification();
486   finishCheck.CheckSignalReceived();
487
488   finishCheck.Reset();
489
490   // loop forever
491   animation.SetLooping(true);
492   DALI_TEST_CHECK(animation.IsLooping());
493
494   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
495   application.SendNotification();
496   finishCheck.CheckSignalNotReceived();
497
498   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
499   application.SendNotification();
500   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
501   application.SendNotification();
502   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
503   application.SendNotification();
504   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
505   application.SendNotification();
506   finishCheck.CheckSignalNotReceived();
507
508   finishCheck.Reset();
509
510   // Loop N again
511   animation.SetLoopCount(3);
512   DALI_TEST_CHECK(animation.IsLooping());
513
514   application.SendNotification();
515   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
516   application.SendNotification();
517   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
518   application.SendNotification();
519   finishCheck.CheckSignalNotReceived();
520
521   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
522   application.SendNotification();
523   finishCheck.CheckSignalNotReceived(); // we never hit play
524
525   finishCheck.Reset();
526
527
528   END_TEST;
529 }
530
531 int UtcDaliAnimationSetLoopCountP3(void)
532 {
533   TestApplication application;
534
535   //
536   // switching between forever and loop count
537   //
538   Actor actor = Actor::New();
539   Stage::GetCurrent().Add(actor);
540
541   // Build the animation
542   float durationSeconds(1.0f);
543   Animation animation = Animation::New(durationSeconds);
544   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
545   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
546   animation.SetEndAction(Animation::Discard);
547
548   float intervalSeconds = 3.0f;
549
550   bool signalReceived(false);
551   AnimationFinishCheck finishCheck(signalReceived);
552   animation.FinishedSignal().Connect(&application, finishCheck);
553
554   // loop forever
555   animation.SetLooping(true);
556   DALI_TEST_CHECK(animation.IsLooping());
557
558   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
559   application.SendNotification();
560   finishCheck.CheckSignalNotReceived();
561
562   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
563   application.SendNotification();
564   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
565   application.SendNotification();
566   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
567   application.SendNotification();
568   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
569   application.SendNotification();
570   finishCheck.CheckSignalNotReceived();
571
572   finishCheck.Reset();
573
574   // Loop N again
575   animation.SetLoopCount(3);
576   DALI_TEST_CHECK(animation.IsLooping());
577
578   application.SendNotification();
579   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
580   application.SendNotification();
581   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
582   application.SendNotification();
583   finishCheck.CheckSignalNotReceived();
584
585   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
586   application.SendNotification();
587   finishCheck.CheckSignalNotReceived(); // we never hit play
588
589   finishCheck.Reset();
590
591
592   END_TEST;
593 }
594
595 int UtcDaliAnimationSetLoopCountP4(void)
596 {
597   TestApplication application;
598
599   //
600   // ..and play again
601   //
602   Actor actor = Actor::New();
603   Stage::GetCurrent().Add(actor);
604
605   // Build the animation
606   float durationSeconds(1.0f);
607   Animation animation = Animation::New(durationSeconds);
608   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
609   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
610   animation.SetEndAction(Animation::Bake);
611
612   float intervalSeconds = 3.0f;
613
614   bool signalReceived(false);
615   AnimationFinishCheck finishCheck(signalReceived);
616   animation.FinishedSignal().Connect(&application, finishCheck);
617
618   animation.SetLoopCount(1);
619   animation.Play();
620   DALI_TEST_CHECK(!animation.IsLooping());
621
622   application.SendNotification();
623   finishCheck.CheckSignalNotReceived();
624   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
625   application.SendNotification();
626   finishCheck.CheckSignalReceived();
627
628   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
629   actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
630
631   finishCheck.Reset();
632
633   animation.Play(); // again
634   DALI_TEST_CHECK(!animation.IsLooping());
635
636   application.SendNotification();
637   finishCheck.CheckSignalNotReceived();
638   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
639   application.SendNotification();
640   finishCheck.CheckSignalReceived();
641
642   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
643
644   END_TEST;
645 }
646
647 int UtcDaliAnimationGetLoopCountP(void)
648 {
649   TestApplication application;
650
651   Actor actor = Actor::New();
652   Stage::GetCurrent().Add(actor);
653
654   // Build the animation
655   float durationSeconds(1.0f);
656   Animation animation = Animation::New(durationSeconds);
657   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
658   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
659
660   DALI_TEST_CHECK(1 == animation.GetLoopCount());
661
662   // Start the animation
663   animation.SetLoopCount(3);
664   DALI_TEST_CHECK(animation.IsLooping());
665   DALI_TEST_CHECK(3 == animation.GetLoopCount());
666
667   animation.Play();
668
669   application.Render(0);
670   application.SendNotification();
671
672   // Loop
673   float intervalSeconds = 3.0f;
674
675   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
676   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
677
678   application.Render(0);
679   application.SendNotification();
680
681   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
682   application.SendNotification();
683
684   animation.SetLoopCount(0);
685   DALI_TEST_CHECK(animation.IsLooping());
686   DALI_TEST_CHECK(0 == animation.GetLoopCount());
687
688   animation.SetLoopCount(1);
689   DALI_TEST_CHECK(!animation.IsLooping());
690   DALI_TEST_CHECK(1 == animation.GetLoopCount());
691
692   END_TEST;
693 }
694
695
696 int UtcDaliAnimationGetCurrentLoopP(void)
697 {
698   TestApplication application;
699
700   Actor actor = Actor::New();
701   Stage::GetCurrent().Add(actor);
702
703   // Build the animation
704   float durationSeconds(1.0f);
705   Animation animation = Animation::New(durationSeconds);
706   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
707   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
708
709   // Start the animation
710   animation.SetLoopCount(3);
711   DALI_TEST_CHECK(animation.IsLooping());
712   DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
713   animation.Play();
714
715   bool signalReceived(false);
716   AnimationFinishCheck finishCheck(signalReceived);
717   animation.FinishedSignal().Connect(&application, finishCheck);
718
719   application.SendNotification();
720
721   // Loop
722   float intervalSeconds = 3.0f;
723
724   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
725   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
726
727   application.SendNotification();
728   finishCheck.CheckSignalNotReceived();
729   DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
730
731   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
732
733   application.SendNotification();
734   finishCheck.CheckSignalReceived();
735   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
736   DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
737
738   finishCheck.Reset();
739
740   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
741   application.SendNotification();
742   finishCheck.CheckSignalNotReceived();
743   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
744
745   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
746   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
747   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
748   application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
749   application.SendNotification();
750   finishCheck.CheckSignalNotReceived();
751   DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
752
753   END_TEST;
754 }
755
756 int UtcDaliAnimationIsLoopingP(void)
757 {
758   TestApplication application;
759
760   Animation animation = Animation::New(1.0f);
761   DALI_TEST_CHECK(!animation.IsLooping());
762
763   animation.SetLooping(true);
764   DALI_TEST_CHECK(animation.IsLooping());
765   END_TEST;
766 }
767
768 int UtcDaliAnimationSetEndActioN(void)
769 {
770   TestApplication application;
771
772   Actor actor = Actor::New();
773   Stage::GetCurrent().Add(actor);
774
775   // Build the animation
776   float durationSeconds(1.0f);
777   Animation animation = Animation::New(durationSeconds);
778   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
779
780   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
781   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
782
783   // Start the animation
784   animation.Play();
785
786   bool signalReceived(false);
787   AnimationFinishCheck finishCheck(signalReceived);
788   animation.FinishedSignal().Connect(&application, finishCheck);
789
790   application.SendNotification();
791   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
792
793   // We did expect the animation to finish
794   application.SendNotification();
795   finishCheck.CheckSignalReceived();
796   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
797
798   // Go back to the start
799   actor.SetPosition(Vector3::ZERO);
800   application.SendNotification();
801   application.Render(0);
802   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
803
804   // Test BakeFinal, animate again, for half the duration
805   finishCheck.Reset();
806   animation.SetEndAction(Animation::BakeFinal);
807   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
808   animation.Play();
809
810   application.SendNotification();
811   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
812
813   // Stop the animation early
814   animation.Stop();
815
816   // We did NOT expect the animation to finish
817   application.SendNotification();
818   finishCheck.CheckSignalNotReceived();
819   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
820
821   // The position should be same with target position in the next frame
822   application.Render(0);
823   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
824
825   // Go back to the start
826   actor.SetPosition(Vector3::ZERO);
827   application.SendNotification();
828   application.Render(0);
829   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
830
831   // Test EndAction::Discard, animate again, but don't bake this time
832   finishCheck.Reset();
833   animation.SetEndAction(Animation::Discard);
834   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
835   animation.Play();
836
837   application.SendNotification();
838   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
839
840   // We did expect the animation to finish
841   application.SendNotification();
842   finishCheck.CheckSignalReceived();
843   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
844
845   // The position should be discarded in the next frame
846   application.Render(0);
847   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
848
849   // Check that nothing has changed after a couple of buffer swaps
850   application.Render(0);
851   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
852   application.Render(0);
853   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
854   END_TEST;
855 }
856
857 int UtcDaliAnimationGetEndActionP(void)
858 {
859   TestApplication application;
860
861   Animation animation = Animation::New(1.0f);
862   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
863
864   animation.SetEndAction(Animation::Discard);
865   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
866
867   animation.SetEndAction(Animation::BakeFinal);
868   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
869
870   END_TEST;
871 }
872
873 int UtcDaliAnimationSetDisconnectActionP(void)
874 {
875   TestApplication application;
876   Stage stage( Stage::GetCurrent() );
877
878   // Default: BakeFinal
879   {
880     Actor actor = Actor::New();
881     stage.Add(actor);
882
883     // Build the animation
884     float durationSeconds(1.0f);
885     Animation animation = Animation::New(durationSeconds);
886     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
887
888     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
889     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
890
891     // Start the animation
892     animation.Play();
893
894     application.SendNotification();
895     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
896
897     actor.Unparent();
898
899     application.SendNotification();
900     application.Render();
901
902     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
903   }
904
905   // Bake
906   {
907     Actor actor = Actor::New();
908     stage.Add(actor);
909
910     // Build the animation
911     float durationSeconds(1.0f);
912     Animation animation = Animation::New(durationSeconds);
913     animation.SetDisconnectAction( Animation::Bake );
914
915     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
916     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
917
918     // Start the animation
919     animation.Play();
920
921     application.SendNotification();
922     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
923
924     actor.Unparent();
925
926     application.SendNotification();
927     application.Render();
928
929     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
930   }
931
932   // Discard
933   {
934     Actor actor = Actor::New();
935     stage.Add(actor);
936
937     // Build the animation
938     float durationSeconds(1.0f);
939     Animation animation = Animation::New(durationSeconds);
940     animation.SetDisconnectAction( Animation::Discard );
941
942     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
943     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
944
945     // Start the animation
946     animation.Play();
947
948     application.SendNotification();
949     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
950
951     actor.Unparent();
952
953     application.SendNotification();
954     application.Render();
955
956     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
957   }
958
959   // Don't play the animation: disconnect action should not be applied
960   {
961     Actor actor = Actor::New();
962     stage.Add(actor);
963
964     // Build the animation
965     float durationSeconds(1.0f);
966     Animation animation = Animation::New(durationSeconds);
967
968     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
969     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
970
971     application.SendNotification();
972     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
973
974     actor.Unparent();
975
976     application.SendNotification();
977     application.Render();
978
979     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
980   }
981
982   END_TEST;
983 }
984
985 int UtcDaliAnimationGetDisconnectActionP(void)
986 {
987   TestApplication application;
988   Animation animation = Animation::New(1.0f);
989   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
990
991   animation.SetDisconnectAction(Animation::Discard);
992   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
993
994   animation.SetDisconnectAction(Animation::Bake);
995   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
996
997   END_TEST;
998 }
999
1000 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
1001 {
1002   TestApplication application;
1003
1004   Animation animation = Animation::New(1.0f);
1005   AlphaFunction func = animation.GetDefaultAlphaFunction();
1006   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1007
1008   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1009   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1010   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1011   END_TEST;
1012 }
1013
1014 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
1015 {
1016   TestApplication application;
1017
1018   Animation animation = Animation::New(1.0f);
1019   AlphaFunction func = animation.GetDefaultAlphaFunction();
1020
1021   // Test that the default is linear
1022   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
1023
1024   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
1025   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1026   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
1027
1028   END_TEST;
1029 }
1030
1031 int UtcDaliAnimationSetCurrentProgressP(void)
1032 {
1033   TestApplication application;
1034
1035   Actor actor = Actor::New();
1036   Stage::GetCurrent().Add(actor);
1037
1038   // Build the animation
1039   Animation animation = Animation::New(0.0f);
1040
1041   //Set duration
1042   float durationSeconds(1.0f);
1043   animation.SetDuration(durationSeconds);
1044
1045   bool signalReceived(false);
1046   AnimationFinishCheck finishCheck(signalReceived);
1047   animation.FinishedSignal().Connect(&application, finishCheck);
1048   application.SendNotification();
1049
1050   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1051   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1052
1053   // Start the animation from 40% progress
1054   animation.SetCurrentProgress( 0.4f );
1055   animation.Play();
1056
1057   application.SendNotification();
1058   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1059
1060   // We didn't expect the animation to finish yet
1061   application.SendNotification();
1062   finishCheck.CheckSignalNotReceived();
1063   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1064   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1065
1066   animation.Play(); // Test that calling play has no effect, when animation is already playing
1067   application.SendNotification();
1068
1069   //Set the progress to 70%
1070   animation.SetCurrentProgress( 0.7f );
1071   application.SendNotification();
1072   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1073   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1074
1075   application.SendNotification();
1076   finishCheck.CheckSignalNotReceived();
1077   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1078   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1079
1080   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1081   // We did expect the animation to finish
1082   application.SendNotification();
1083   finishCheck.CheckSignalReceived();
1084   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1085
1086   // Check that nothing has changed after a couple of buffer swaps
1087   application.Render(0);
1088   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1089   application.Render(0);
1090   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1091   END_TEST;
1092 }
1093
1094 int UtcDaliAnimationSetCurrentProgressN(void)
1095 {
1096   TestApplication application;
1097
1098   Actor actor = Actor::New();
1099   Stage::GetCurrent().Add(actor);
1100
1101   // Build the animation
1102   Animation animation = Animation::New(0.0f);
1103
1104   //Set duration
1105   float durationSeconds(1.0f);
1106   animation.SetDuration(durationSeconds);
1107
1108   bool signalReceived(false);
1109   AnimationFinishCheck finishCheck(signalReceived);
1110   animation.FinishedSignal().Connect(&application, finishCheck);
1111   application.SendNotification();
1112
1113   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1114   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1115
1116   //Trying to set the current cursor outside the range [0..1] is ignored
1117   animation.SetCurrentProgress( -1.0f);
1118   application.SendNotification();
1119   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1120
1121   animation.SetCurrentProgress( 100.0f);
1122   application.SendNotification();
1123   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1124   END_TEST;
1125 }
1126
1127 int UtcDaliAnimationGetCurrentProgressP(void)
1128 {
1129   TestApplication application;
1130
1131   Actor actor = Actor::New();
1132   Stage::GetCurrent().Add(actor);
1133
1134   // Build the animation
1135   Animation animation = Animation::New(0.0f);
1136   animation.Play();
1137
1138   //Test GetCurrentProgress return 0.0 as the duration is 0.0
1139   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1140
1141   animation.SetCurrentProgress( 0.5f );
1142   application.SendNotification();
1143   application.Render(static_cast<unsigned int>(100.0f));
1144
1145   //Progress should still be 0.0
1146   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1147
1148   //Set duration
1149   float durationSeconds(1.0f);
1150   animation.SetDuration(durationSeconds);
1151   application.SendNotification();
1152
1153   bool signalReceived(false);
1154   AnimationFinishCheck finishCheck(signalReceived);
1155   animation.FinishedSignal().Connect(&application, finishCheck);
1156   application.SendNotification();
1157
1158   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1159   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1160
1161   // Start the animation from 40% progress
1162   animation.SetCurrentProgress( 0.4f );
1163   animation.Play();
1164
1165   application.SendNotification();
1166   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1167
1168   // We didn't expect the animation to finish yet
1169   application.SendNotification();
1170   finishCheck.CheckSignalNotReceived();
1171   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1172
1173   animation.Play(); // Test that calling play has no effect, when animation is already playing
1174   application.SendNotification();
1175
1176   //Set the progress to 70%
1177   animation.SetCurrentProgress( 0.7f );
1178   application.SendNotification();
1179   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1180   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1181
1182   application.SendNotification();
1183   finishCheck.CheckSignalNotReceived();
1184   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1185
1186   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1187   // We did expect the animation to finish
1188   application.SendNotification();
1189   finishCheck.CheckSignalReceived();
1190   END_TEST;
1191 }
1192
1193 int UtcDaliAnimationSetSpeedFactorP1(void)
1194 {
1195   TestApplication application;
1196
1197   tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1198
1199   Actor actor = Actor::New();
1200   Stage::GetCurrent().Add(actor);
1201
1202   // Build the animation
1203   float durationSeconds(1.0f);
1204   Animation animation = Animation::New(durationSeconds);
1205
1206   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1207   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1208
1209   KeyFrames keyframes = KeyFrames::New();
1210   keyframes.Add( 0.0f, initialPosition);
1211   keyframes.Add( 1.0f, targetPosition );
1212   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1213
1214   //Set speed to be x2
1215   animation.SetSpeedFactor(2.0f);
1216
1217   // Start the animation
1218   animation.Play();
1219
1220   bool signalReceived(false);
1221   AnimationFinishCheck finishCheck(signalReceived);
1222   animation.FinishedSignal().Connect(&application, finishCheck);
1223
1224   application.SendNotification();
1225   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1226
1227   // We didn't expect the animation to finish yet
1228   application.SendNotification();
1229   finishCheck.CheckSignalNotReceived();
1230   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1231
1232   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1233
1234   // We didn't expect the animation to finish yet
1235   application.SendNotification();
1236   finishCheck.CheckSignalNotReceived();
1237   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1238
1239   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1240
1241   // We did expect the animation to finish
1242   application.SendNotification();
1243   finishCheck.CheckSignalReceived();
1244   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1245
1246   // Check that nothing has changed after a couple of buffer swaps
1247   application.Render(0);
1248   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1249   application.Render(0);
1250   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1251
1252   END_TEST;
1253 }
1254
1255 int UtcDaliAnimationSetSpeedFactorP2(void)
1256 {
1257   TestApplication application;
1258
1259   Actor actor = Actor::New();
1260   Stage::GetCurrent().Add(actor);
1261
1262   // Build the animation
1263   float durationSeconds(1.0f);
1264   Animation animation = Animation::New(durationSeconds);
1265
1266   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1267   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1268
1269   KeyFrames keyframes = KeyFrames::New();
1270   keyframes.Add( 0.0f, initialPosition);
1271   keyframes.Add( 1.0f, targetPosition );
1272   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1273
1274   tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1275   animation.SetSpeedFactor( -1.0f );
1276
1277   // Start the animation
1278   animation.Play();
1279
1280   bool signalReceived(false);
1281   AnimationFinishCheck finishCheck(signalReceived);
1282   animation.FinishedSignal().Connect(&application, finishCheck);
1283
1284   application.SendNotification();
1285   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1286
1287   // We didn't expect the animation to finish yet
1288   application.SendNotification();
1289   finishCheck.CheckSignalNotReceived();
1290   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1291
1292   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1293
1294   // We didn't expect the animation to finish yet
1295   application.SendNotification();
1296   finishCheck.CheckSignalNotReceived();
1297   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1298
1299   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1300
1301   // We didn't expect the animation to finish yet
1302   application.SendNotification();
1303   finishCheck.CheckSignalNotReceived();
1304   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1305
1306   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1307
1308   // We didn't expect the animation to finish yet
1309   application.SendNotification();
1310   finishCheck.CheckSignalNotReceived();
1311   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1312
1313   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1314
1315   // We did expect the animation to finish
1316   application.SendNotification();
1317   finishCheck.CheckSignalReceived();
1318   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1319
1320   // Check that nothing has changed after a couple of buffer swaps
1321   application.Render(0);
1322   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1323   application.Render(0);
1324   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1325
1326   END_TEST;
1327 }
1328
1329 int UtcDaliAnimationSetSpeedFactorP3(void)
1330 {
1331   TestApplication application;
1332
1333   Actor actor = Actor::New();
1334   Stage::GetCurrent().Add(actor);
1335
1336   // Build the animation
1337   float durationSeconds(1.0f);
1338   Animation animation = Animation::New(durationSeconds);
1339
1340   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1341   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1342
1343   KeyFrames keyframes = KeyFrames::New();
1344   keyframes.Add( 0.0f, initialPosition);
1345   keyframes.Add( 1.0f, targetPosition );
1346   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1347
1348   bool signalReceived(false);
1349   AnimationFinishCheck finishCheck(signalReceived);
1350   animation.FinishedSignal().Connect(&application, finishCheck);
1351
1352   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1353
1354   //Set speed to be half of normal speed
1355   animation.SetSpeedFactor( 0.5f );
1356
1357   // Start the animation
1358   animation.Play();
1359
1360   application.SendNotification();
1361   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1362
1363   // We didn't expect the animation to finish yet
1364   application.SendNotification();
1365   finishCheck.CheckSignalNotReceived();
1366   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1367
1368   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1369
1370   // We didn't expect the animation to finish yet
1371   application.SendNotification();
1372   finishCheck.CheckSignalNotReceived();
1373   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1374
1375   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1376
1377   // We didn't expect the animation to finish yet
1378   application.SendNotification();
1379   finishCheck.CheckSignalNotReceived();
1380   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1381
1382   application.SendNotification();
1383   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1384
1385   // We didn't expect the animation to finish yet
1386   application.SendNotification();
1387   finishCheck.CheckSignalNotReceived();
1388   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1389
1390   application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1391
1392   // We did expect the animation to finish
1393   application.SendNotification();
1394   finishCheck.CheckSignalReceived();
1395   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1396
1397   // Check that nothing has changed after a couple of buffer swaps
1398   application.Render(0);
1399   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1400   application.Render(0);
1401   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1402   END_TEST;
1403 }
1404
1405
1406 int UtcDaliAnimationSetSpeedFactorP4(void)
1407 {
1408   TestApplication application;
1409
1410   Actor actor = Actor::New();
1411   Stage::GetCurrent().Add(actor);
1412
1413   // Build the animation
1414   float durationSeconds(1.0f);
1415   Animation animation = Animation::New(durationSeconds);
1416
1417   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1418   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1419
1420   KeyFrames keyframes = KeyFrames::New();
1421   keyframes.Add( 0.0f, initialPosition);
1422   keyframes.Add( 1.0f, targetPosition );
1423   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1424
1425   bool signalReceived(false);
1426   AnimationFinishCheck finishCheck(signalReceived);
1427   animation.FinishedSignal().Connect(&application, finishCheck);
1428
1429   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1430
1431   tet_printf("Set speed to be half of normal speed\n");
1432   tet_printf("SetSpeedFactor(0.5f)\n");
1433   animation.SetSpeedFactor( 0.5f );
1434
1435   // Start the animation
1436   animation.Play();
1437
1438   application.SendNotification();
1439   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1440
1441   // We didn't expect the animation to finish yet
1442   application.SendNotification();
1443   finishCheck.CheckSignalNotReceived();
1444   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1445
1446   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1447
1448   // We didn't expect the animation to finish yet
1449   application.SendNotification();
1450   finishCheck.CheckSignalNotReceived();
1451   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1452
1453   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1454
1455   // We didn't expect the animation to finish yet
1456   application.SendNotification();
1457   finishCheck.CheckSignalNotReceived();
1458   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1459
1460   tet_printf("Reverse direction of animation whilst playing\n");
1461   tet_printf("SetSpeedFactor(-0.5f)\n");
1462   animation.SetSpeedFactor(-0.5f);
1463
1464   application.SendNotification();
1465   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1466
1467   // We didn't expect the animation to finish yet
1468   application.SendNotification();
1469   finishCheck.CheckSignalNotReceived();
1470   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1471
1472   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1473
1474   // We didn't expect the animation to finish yet
1475   application.SendNotification();
1476   finishCheck.CheckSignalNotReceived();
1477   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1478
1479   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1480
1481   // We did expect the animation to finish
1482   application.SendNotification();
1483   finishCheck.CheckSignalReceived();
1484   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1485
1486   // Check that nothing has changed after a couple of buffer swaps
1487   application.Render(0);
1488   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1489   application.Render(0);
1490   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1491   END_TEST;
1492 }
1493
1494 int UtcDaliAnimationSetSpeedFactorAndRange(void)
1495 {
1496   TestApplication application;
1497
1498   const unsigned int NUM_FRAMES(15);
1499
1500   struct TestData
1501   {
1502     float startTime;
1503     float endTime;
1504     float startX;
1505     float endX;
1506     float expected[NUM_FRAMES];
1507   };
1508
1509   TestData testData[] = {
1510     // ACTOR 0
1511     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1512     /*                       |----------PlayRange---------------|                 */
1513     /*                                            | reverse                       */
1514     { 0.0f,                                                                  1.0f, // TimePeriod
1515       0.0f,                                                                100.0f, // POS
1516       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1517        /**/                 30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1518        /**/                               50.0f,
1519        /**/                        40.0f,
1520        /**/                 30.0f,
1521        /**/                                             70.0f,
1522        /**/                                      60.0f,
1523        /**/                               50.0f,
1524        /**/
1525       }
1526     },
1527
1528     // ACTOR 1 - Across start of range
1529     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1530     /*                       |----------PlayRange---------------|                 */
1531     /*                                            | reverse                       */
1532     {                0.2f,                0.5f,                               // TimePeriod
1533                      20.0f,               50.0f,                // POS
1534       {/**/                 30.0f, 40.0f, 50.0f, 50.0f, 50.0f,  /* Loop */
1535        /**/                 30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1536        /**/                               50.0f,
1537        /**/                        40.0f,
1538        /**/                 30.0f,
1539        /**/                                             50.0f,
1540        /**/                                      50.0f,
1541        /**/                               50.0f
1542       }
1543     },
1544
1545     // ACTOR 2 - Across end of range
1546     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1547     /*                       |----------PlayRange---------------|                 */
1548     /*                                            | reverse                       */
1549     {/**/                                  0.5f,                      0.9f,   // TimePeriod
1550      /**/                                 50.0f,                      90.0f,  // POS
1551      { /**/                 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1552        /**/                 50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1553        /**/                               50.0f,
1554        /**/                        50.0f,
1555        /**/                 50.0f,                      70.0f,
1556        /**/                                      60.0f,
1557        /**/                               50.0f,
1558       }
1559     },
1560
1561     // ACTOR 3 - Before beginning of range
1562     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1563     /*                       |----------PlayRange---------------|                 */
1564     /*                                            | reverse                       */
1565     {/**/     0.1f,      0.25f, // TimePeriod
1566      /**/     10.0f,     25.0f, // POS
1567      { /**/
1568        /**/ 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f
1569        /**/
1570       }
1571     },
1572
1573     // ACTOR 4 - After end of range
1574     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1575     /*                       |----------PlayRange---------------|                 */
1576     /*                                            | reverse                       */
1577     {/**/                                                           0.85f,   1.0f, // TimePeriod
1578      /**/                                                           85.0f,  100.0f, // POS
1579      { /**/
1580        /**/ 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f
1581        /**/
1582      }
1583     },
1584     // Actor 5 - Middle of range
1585     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1586     /*                       |----------PlayRange---------------|                 */
1587     /*                                            | reverse                       */
1588     {/**/                          0.4f,            0.65f, // Time Period
1589      /**/                         40.0f,            65.0f, // Position
1590      { /**/                40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1591        /**/                40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1592        /**/                              50.0f,
1593        /**/                       40.0f,
1594        /**/                40.0f,
1595        /**/                                            65.0f,
1596        /**/                                      60.0f,
1597        /**/                              50.0f,
1598      }
1599     }
1600   };
1601
1602   const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1603
1604   // Build the animation
1605   float durationSeconds(1.0f);
1606   Animation animation = Animation::New(durationSeconds);
1607   bool signalReceived(false);
1608   AnimationFinishCheck finishCheck(signalReceived);
1609   animation.FinishedSignal().Connect(&application, finishCheck);
1610
1611   std::vector<Dali::Actor> actors;
1612
1613   for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1614   {
1615     Actor actor = Actor::New();
1616     actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1617     actors.push_back(actor);
1618     Stage::GetCurrent().Add(actor);
1619
1620     if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1621     {
1622       KeyFrames keyframes = KeyFrames::New();
1623       keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1624       keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1625       animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1626     }
1627     else
1628     {
1629       animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1630     }
1631   }
1632
1633   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1634   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1635   tet_printf("SetSpeedFactor(0.5f)\n");
1636   animation.SetSpeedFactor( 0.5f );
1637   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1638   animation.SetLooping(true);
1639
1640   // Start the animation
1641   animation.Play();
1642   application.SendNotification();
1643   application.Render(0);   // Frame 0 tests initial values
1644
1645   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1646   {
1647     unsigned int actorIndex = 0u;
1648     for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1649     {
1650       DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1651       if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) )
1652       {
1653         tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1654       }
1655     }
1656
1657     if( frame == 8 )
1658     {
1659       tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1660       tet_printf("SetSpeedFactor(-0.5f)\n");
1661       animation.SetSpeedFactor(-0.5f);
1662       application.SendNotification();
1663     }
1664     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1665
1666     // We didn't expect the animation to finish yet
1667     application.SendNotification();
1668     finishCheck.CheckSignalNotReceived();
1669   }
1670
1671   END_TEST;
1672 }
1673
1674 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount01(void)
1675 {
1676   TestApplication application;
1677
1678   const unsigned int NUM_FRAMES(15);
1679
1680   struct TestData
1681   {
1682     float startTime;
1683     float endTime;
1684     float startX;
1685     float endX;
1686     float expected[NUM_FRAMES];
1687   };
1688
1689   TestData testData =
1690     // ACTOR 0
1691     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1692     /*                       |----------PlayRange---------------|                 */
1693     { 0.0f,                                                                  1.0f, // TimePeriod
1694       0.0f,                                                                100.0f, // POS
1695       {/**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,  /* Loop */
1696        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1697        /**/                 30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1698        /**/
1699       }
1700     };
1701
1702
1703   // Build the animation
1704   float durationSeconds(1.0f);
1705   Animation animation = Animation::New(durationSeconds);
1706   bool signalReceived(false);
1707   AnimationFinishCheck finishCheck(signalReceived);
1708   animation.FinishedSignal().Connect(&application, finishCheck);
1709
1710   std::vector<Dali::Actor> actors;
1711
1712   Actor actor = Actor::New();
1713   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1714   actors.push_back(actor);
1715   Stage::GetCurrent().Add(actor);
1716
1717   KeyFrames keyframes = KeyFrames::New();
1718   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1719   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1720   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1721
1722   tet_printf("Test half speed factor. Animation will take twice the duration\n");
1723   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1724   tet_printf("SetSpeedFactor(0.5f)\n");
1725   tet_printf("SetLoopCount(3)\n");
1726   animation.SetSpeedFactor( 0.5f );
1727   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1728   animation.SetLoopCount(3);
1729
1730   // Start the animation
1731   animation.Play();
1732   application.SendNotification();
1733   application.Render(0);   // Frame 0 tests initial values
1734
1735   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1736   {
1737     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1738
1739     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1740
1741     if( frame < NUM_FRAMES-1 )
1742     {
1743       // We didn't expect the animation to finish yet
1744       application.SendNotification();
1745       finishCheck.CheckSignalNotReceived();
1746     }
1747   }
1748
1749   // We did expect the animation to finish
1750   application.SendNotification();
1751   finishCheck.CheckSignalReceived();
1752   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION );
1753
1754   END_TEST;
1755 }
1756
1757 int UtcDaliAnimationSetSpeedFactorRangeAndLoopCount02(void)
1758 {
1759   TestApplication application;
1760
1761   const unsigned int NUM_FRAMES(15);
1762
1763   struct TestData
1764   {
1765     float startTime;
1766     float endTime;
1767     float startX;
1768     float endX;
1769     float expected[NUM_FRAMES];
1770   };
1771
1772   TestData testData =
1773     // ACTOR 0
1774     /*0.0f,   0.1f   0.2f   0.3f   0.4f   0.5f   0.6f   0.7f   0.8f   0.9f   1.0f */
1775     /*                       |----------PlayRange---------------|                 */
1776     { 0.0f,                                                                  1.0f, // TimePeriod
1777       0.0f,                                                                100.0f, // POS
1778       {/**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1779        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1780        /**/                 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1781       }
1782     };
1783
1784
1785   // Build the animation
1786   float durationSeconds(1.0f);
1787   Animation animation = Animation::New(durationSeconds);
1788   bool signalReceived(false);
1789   AnimationFinishCheck finishCheck(signalReceived);
1790   animation.FinishedSignal().Connect(&application, finishCheck);
1791
1792   std::vector<Dali::Actor> actors;
1793
1794   Actor actor = Actor::New();
1795   actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1796   actors.push_back(actor);
1797   Stage::GetCurrent().Add(actor);
1798
1799   KeyFrames keyframes = KeyFrames::New();
1800   keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1801   keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1802   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
1803
1804   tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1805   tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1806   tet_printf("SetSpeedFactor(-0.5f)\n");
1807   tet_printf("SetLoopCount(3)\n");
1808   animation.SetSpeedFactor( -0.5f );
1809   animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1810   animation.SetLoopCount(3);
1811
1812   // Start the animation
1813   animation.Play();
1814   application.SendNotification();
1815   application.Render(0);   // Frame 0 tests initial values
1816
1817   for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1818   {
1819     DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1820
1821     application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1822
1823     if( frame < NUM_FRAMES-1 )
1824     {
1825       // We didn't expect the animation to finish yet
1826       application.SendNotification();
1827       finishCheck.CheckSignalNotReceived();
1828     }
1829   }
1830
1831   // We did expect the animation to finish
1832   application.SendNotification();
1833   finishCheck.CheckSignalReceived();
1834   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION );
1835
1836   END_TEST;
1837 }
1838
1839
1840 int UtcDaliAnimationGetSpeedFactorP(void)
1841 {
1842   TestApplication application;
1843
1844   Animation animation = Animation::New(1.0f);
1845   animation.SetSpeedFactor(0.5f);
1846   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1847
1848   animation.SetSpeedFactor(-2.5f);
1849   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1850   END_TEST;
1851 }
1852
1853 int UtcDaliAnimationSetPlayRangeP(void)
1854 {
1855   TestApplication application;
1856
1857   Actor actor = Actor::New();
1858   Stage::GetCurrent().Add( actor );
1859
1860   // Build the animation
1861   float durationSeconds( 1.0f );
1862   Animation animation = Animation::New( durationSeconds );
1863
1864   bool signalReceived( false );
1865   AnimationFinishCheck finishCheck( signalReceived );
1866   animation.FinishedSignal().Connect( &application, finishCheck );
1867   application.SendNotification();
1868
1869   // Set range between 0.4 and 0.8
1870   animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1871   application.SendNotification();
1872   DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1873
1874   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1875   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1876
1877   // Start the animation from 40% progress
1878   animation.Play();
1879
1880   application.SendNotification();
1881   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1882
1883   // We didn't expect the animation to finish yet
1884   application.SendNotification();
1885   finishCheck.CheckSignalNotReceived();
1886   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
1887
1888   application.SendNotification();
1889   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1890
1891   application.SendNotification();
1892   finishCheck.CheckSignalNotReceived();
1893   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
1894
1895   application.SendNotification();
1896   application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1897
1898   // We did expect the animation to finish
1899   application.SendNotification();
1900   finishCheck.CheckSignalReceived();
1901   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1902   END_TEST;
1903 }
1904
1905 int UtcDaliAnimationSetPlayRangeN(void)
1906 {
1907   TestApplication application;
1908
1909   Actor actor = Actor::New();
1910   Stage::GetCurrent().Add(actor);
1911
1912   // Build the animation
1913   Animation animation = Animation::New(0);
1914   application.SendNotification();
1915
1916   //PlayRange out of bounds
1917   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1918   application.SendNotification();
1919   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1920   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1921   application.SendNotification();
1922   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1923
1924   //If playRange is not in the correct order it has to be ordered
1925   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1926   application.SendNotification();
1927   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1928
1929   END_TEST;
1930 }
1931
1932 int UtcDaliAnimationGetPlayRangeP(void)
1933 {
1934   TestApplication application;
1935
1936   Actor actor = Actor::New();
1937   Stage::GetCurrent().Add( actor );
1938
1939   // Build the animation
1940   Animation animation = Animation::New( 1.0f );
1941   application.SendNotification();
1942
1943   //If PlayRange not specified it should be 0.0-1.0 by default
1944   DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1945
1946   // Set range between 0.4 and 0.8
1947   animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1948   application.SendNotification();
1949   DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
1950
1951   END_TEST;
1952 }
1953
1954 int UtcDaliAnimationPlayP(void)
1955 {
1956   TestApplication application;
1957
1958   Actor actor = Actor::New();
1959   Stage::GetCurrent().Add(actor);
1960
1961   // Build the animation
1962   float durationSeconds(1.0f);
1963   Animation animation = Animation::New(durationSeconds);
1964   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1965   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1966
1967   // Start the animation
1968   animation.Play();
1969
1970   bool signalReceived(false);
1971   AnimationFinishCheck finishCheck(signalReceived);
1972   animation.FinishedSignal().Connect(&application, finishCheck);
1973
1974   application.SendNotification();
1975   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1976
1977   // We didn't expect the animation to finish yet
1978   application.SendNotification();
1979   finishCheck.CheckSignalNotReceived();
1980   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1981
1982   animation.Play(); // Test that calling play has no effect, when animation is already playing
1983   application.SendNotification();
1984   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1985
1986   // We didn't expect the animation to finish yet
1987   application.SendNotification();
1988   finishCheck.CheckSignalNotReceived();
1989   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1990
1991   animation.Play(); // Test that calling play has no effect, when animation is already playing
1992   application.SendNotification();
1993   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1994
1995   // We didn't expect the animation to finish yet
1996   application.SendNotification();
1997   finishCheck.CheckSignalNotReceived();
1998   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1999
2000   animation.Play(); // Test that calling play has no effect, when animation is already playing
2001   application.SendNotification();
2002   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2003
2004   // We didn't expect the animation to finish yet
2005   application.SendNotification();
2006   finishCheck.CheckSignalNotReceived();
2007   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2008
2009   animation.Play(); // Test that calling play has no effect, when animation is already playing
2010   application.SendNotification();
2011   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2012
2013   // We did expect the animation to finish
2014   application.SendNotification();
2015   finishCheck.CheckSignalReceived();
2016   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2017
2018   // Check that nothing has changed after a couple of buffer swaps
2019   application.Render(0);
2020   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2021   application.Render(0);
2022   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2023   END_TEST;
2024 }
2025
2026 int UtcDaliAnimationPlayOffStageP(void)
2027 {
2028   // Test that an animation can be played, when the actor is off-stage.
2029   // When the actor is added to the stage, it should appear at the current position
2030   // i.e. where it would have been anyway, if on-stage from the beginning.
2031
2032   TestApplication application;
2033
2034   Actor actor = Actor::New();
2035   Vector3 basePosition(Vector3::ZERO);
2036   DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
2037   // Not added to the stage!
2038
2039   // Build the animation
2040   float durationSeconds(1.0f);
2041   Animation animation = Animation::New(durationSeconds);
2042   animation.SetDisconnectAction( Animation::Discard );
2043   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2044   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2045
2046   // Start the animation
2047   animation.Play();
2048
2049   bool signalReceived(false);
2050   AnimationFinishCheck finishCheck(signalReceived);
2051   animation.FinishedSignal().Connect(&application, finishCheck);
2052
2053   application.SendNotification();
2054   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2055
2056   // We didn't expect the animation to finish yet
2057   application.SendNotification();
2058   finishCheck.CheckSignalNotReceived();
2059   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
2060
2061   // Add to the stage
2062   Stage::GetCurrent().Add(actor);
2063
2064   application.SendNotification();
2065   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2066
2067   // We didn't expect the animation to finish yet
2068   application.SendNotification();
2069   finishCheck.CheckSignalNotReceived();
2070   Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
2071   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
2072
2073   // Remove from the stage
2074   Stage::GetCurrent().Remove(actor);
2075
2076   application.SendNotification();
2077   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2078
2079   // We didn't expect the animation to finish yet
2080   application.SendNotification();
2081   finishCheck.CheckSignalNotReceived();
2082   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
2083
2084   // Add to the stage
2085   Stage::GetCurrent().Add(actor);
2086
2087   application.SendNotification();
2088   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2089
2090   // We didn't expect the animation to finish yet
2091   application.SendNotification();
2092   finishCheck.CheckSignalNotReceived();
2093   expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
2094   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
2095
2096   application.SendNotification();
2097   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2098
2099   // We did expect the animation to finish
2100   application.SendNotification();
2101   finishCheck.CheckSignalReceived();
2102   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2103
2104   // Check that nothing has changed after a couple of buffer swaps
2105   application.Render(0);
2106   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2107   application.Render(0);
2108   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2109   END_TEST;
2110 }
2111
2112 int UtcDaliAnimationPlayDiscardHandleP(void)
2113 {
2114   TestApplication application;
2115
2116   Actor actor = Actor::New();
2117   Stage::GetCurrent().Add(actor);
2118
2119   // Build the animation
2120   float durationSeconds(1.0f);
2121   Animation animation = Animation::New(durationSeconds);
2122   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2123   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2124
2125   bool signalReceived(false);
2126   AnimationFinishCheck finishCheck(signalReceived);
2127   animation.FinishedSignal().Connect(&application, finishCheck);
2128
2129   // Start the animation
2130   animation.Play();
2131
2132   // This is a test of the "Fire and Forget" behaviour
2133   // Discard the animation handle!
2134   animation.Reset();
2135   DALI_TEST_CHECK( !animation );
2136
2137   application.SendNotification();
2138   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2139
2140   // We didn't expect the animation to finish yet
2141   application.SendNotification();
2142   finishCheck.CheckSignalNotReceived();
2143   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2144
2145   application.SendNotification();
2146   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2147
2148   // We didn't expect the animation to finish yet
2149   application.SendNotification();
2150   finishCheck.CheckSignalNotReceived();
2151   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2152
2153   application.SendNotification();
2154   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2155
2156   // We didn't expect the animation to finish yet
2157   application.SendNotification();
2158   finishCheck.CheckSignalNotReceived();
2159   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2160
2161   application.SendNotification();
2162   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2163
2164   // We didn't expect the animation to finish yet
2165   application.SendNotification();
2166   finishCheck.CheckSignalNotReceived();
2167   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2168
2169   application.SendNotification();
2170   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2171
2172   // We did expect the animation to finish
2173   application.SendNotification();
2174   finishCheck.CheckSignalReceived();
2175   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2176
2177   // Check that nothing has changed after a couple of buffer swaps
2178   application.Render(0);
2179   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2180   application.Render(0);
2181   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2182   END_TEST;
2183 }
2184
2185 int UtcDaliAnimationPlayStopDiscardHandleP(void)
2186 {
2187   TestApplication application;
2188
2189   Actor actor = Actor::New();
2190   Stage::GetCurrent().Add(actor);
2191
2192   // Build the animation
2193   float durationSeconds(1.0f);
2194   Animation animation = Animation::New(durationSeconds);
2195   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2196   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2197
2198   // Start the animation
2199   animation.Play();
2200
2201   bool signalReceived(false);
2202   AnimationFinishCheck finishCheck(signalReceived);
2203   animation.FinishedSignal().Connect(&application, finishCheck);
2204
2205   application.SendNotification();
2206   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2207
2208   // We didn't expect the animation to finish yet
2209   application.SendNotification();
2210   finishCheck.CheckSignalNotReceived();
2211   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2212
2213   // This is a test of the "Fire and Forget" behaviour
2214   // Stop the animation, and Discard the animation handle!
2215   animation.Stop();
2216   animation.Reset();
2217   DALI_TEST_CHECK( !animation );
2218
2219   application.SendNotification();
2220   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2221
2222   // We expect the animation to finish at 20% progress
2223   application.SendNotification();
2224   finishCheck.CheckSignalReceived();
2225   finishCheck.Reset();
2226   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2227
2228   application.SendNotification();
2229   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2230
2231   // Check that nothing has changed
2232   application.SendNotification();
2233   finishCheck.CheckSignalNotReceived();
2234   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2235
2236   application.SendNotification();
2237   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2238
2239   // Check that nothing has changed
2240   application.SendNotification();
2241   finishCheck.CheckSignalNotReceived();
2242   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2243
2244   application.SendNotification();
2245   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2246
2247   // Check that nothing has changed
2248   application.SendNotification();
2249   finishCheck.CheckSignalNotReceived();
2250   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2251   END_TEST;
2252 }
2253
2254 int UtcDaliAnimationPlayRangeP(void)
2255 {
2256   TestApplication application;
2257
2258   Actor actor = Actor::New();
2259   Stage::GetCurrent().Add(actor);
2260
2261   // Build the animation
2262   float durationSeconds(1.0f);
2263   Animation animation = Animation::New(durationSeconds);
2264   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2265   KeyFrames keyframes = KeyFrames::New();
2266   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2267   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2268
2269   animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2270
2271   // Set range between 0.4 and 0.8
2272   animation.SetPlayRange( Vector2(0.4f,0.8f) );
2273   animation.Play();
2274
2275   bool signalReceived(false);
2276   AnimationFinishCheck finishCheck(signalReceived);
2277   animation.FinishedSignal().Connect(&application, finishCheck);
2278
2279   //Test that setting progress outside the range doesn't work
2280   animation.SetCurrentProgress( 0.9f );
2281   application.SendNotification();
2282   application.Render(0);
2283   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2284   animation.SetCurrentProgress( 0.2f );
2285   application.SendNotification();
2286   application.Render(0);
2287   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2288
2289   application.SendNotification();
2290   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2291
2292   // We didn't expect the animation to finish yet
2293   application.SendNotification();
2294   finishCheck.CheckSignalNotReceived();
2295   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2296
2297   animation.Play(); // Test that calling play has no effect, when animation is already playing
2298   application.SendNotification();
2299   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2300
2301   // We did expect the animation to finish
2302   application.SendNotification();
2303   finishCheck.CheckSignalReceived();
2304   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2305
2306   // Check that nothing has changed after a couple of buffer swaps
2307   application.Render(0);
2308   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2309   application.Render(0);
2310   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2311
2312
2313   //Loop inside the range
2314   finishCheck.Reset();
2315   animation.SetLooping( true );
2316   animation.Play();
2317   application.SendNotification();
2318   float intervalSeconds = 0.1f;
2319   float progress = 0.4f;
2320   for (int iterations = 0; iterations < 10; ++iterations )
2321   {
2322     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2323
2324     progress += intervalSeconds;
2325     if (progress > 0.8f)
2326     {
2327       progress = progress - 0.4f;
2328     }
2329
2330     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2331   }
2332
2333   // We didn't expect the animation to finish yet
2334   application.SendNotification();
2335   finishCheck.CheckSignalNotReceived();
2336
2337
2338   //Test change range on the fly
2339   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2340   application.SendNotification();
2341
2342   for (int iterations = 0; iterations < 10; ++iterations )
2343   {
2344     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2345
2346     progress += intervalSeconds;
2347     if (progress > 0.9f)
2348     {
2349       progress = progress - 0.7f;
2350     }
2351
2352     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2353   }
2354
2355   END_TEST;
2356 }
2357
2358 int UtcDaliAnimationPlayFromP(void)
2359 {
2360   TestApplication application;
2361
2362   Actor actor = Actor::New();
2363   Stage::GetCurrent().Add(actor);
2364
2365   // Build the animation
2366   float durationSeconds(1.0f);
2367   Animation animation = Animation::New(durationSeconds);
2368   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2369   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2370
2371   // Start the animation from 40% progress
2372   animation.PlayFrom( 0.4f );
2373
2374   bool signalReceived(false);
2375   AnimationFinishCheck finishCheck(signalReceived);
2376   animation.FinishedSignal().Connect(&application, finishCheck);
2377
2378   application.SendNotification();
2379   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2380
2381   // We didn't expect the animation to finish yet
2382   application.SendNotification();
2383   finishCheck.CheckSignalNotReceived();
2384   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2385
2386   animation.Play(); // Test that calling play has no effect, when animation is already playing
2387   application.SendNotification();
2388   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2389
2390   // We didn't expect the animation to finish yet
2391   application.SendNotification();
2392   finishCheck.CheckSignalNotReceived();
2393   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2394
2395   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2396   // We did expect the animation to finish
2397   application.SendNotification();
2398   finishCheck.CheckSignalReceived();
2399   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2400
2401   // Check that nothing has changed after a couple of buffer swaps
2402   application.Render(0);
2403   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2404   application.Render(0);
2405   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2406   END_TEST;
2407 }
2408
2409 int UtcDaliAnimationPlayFromN(void)
2410 {
2411   TestApplication application;
2412
2413   Actor actor = Actor::New();
2414   Stage::GetCurrent().Add(actor);
2415
2416   // Build the animation
2417   float durationSeconds(1.0f);
2418   Animation animation = Animation::New(durationSeconds);
2419   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2420   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2421
2422   //PlayFrom with an argument outside the range [0..1] will be ignored
2423   animation.PlayFrom(-1.0f);
2424   application.SendNotification();
2425   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2426
2427   animation.PlayFrom(100.0f);
2428   application.SendNotification();
2429   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2430   END_TEST;
2431 }
2432
2433 int UtcDaliAnimationPauseP(void)
2434 {
2435   TestApplication application;
2436
2437   Actor actor = Actor::New();
2438   Stage::GetCurrent().Add(actor);
2439
2440   // Build the animation
2441   float durationSeconds(1.0f);
2442   Animation animation = Animation::New(durationSeconds);
2443   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2444   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2445
2446   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2447
2448   // Start the animation
2449   animation.Play();
2450
2451   bool signalReceived(false);
2452   AnimationFinishCheck finishCheck(signalReceived);
2453   animation.FinishedSignal().Connect(&application, finishCheck);
2454
2455   application.SendNotification();
2456   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2457
2458   // We didn't expect the animation to finish yet
2459   application.SendNotification();
2460   finishCheck.CheckSignalNotReceived();
2461   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2462
2463   // Pause the animation
2464   animation.Pause();
2465   application.SendNotification();
2466
2467   // Loop 5 times
2468   for (int i=0; i<5; ++i)
2469   {
2470     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2471
2472     // We didn't expect the animation to finish yet
2473     application.SendNotification();
2474     finishCheck.CheckSignalNotReceived();
2475     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2476   }
2477
2478   // Keep going
2479   animation.Play();
2480   application.SendNotification();
2481   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2482
2483   // We didn't expect the animation to finish yet
2484   application.SendNotification();
2485   finishCheck.CheckSignalNotReceived();
2486
2487   application.SendNotification();
2488   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2489
2490   // We did expect the animation to finish
2491   application.SendNotification();
2492   finishCheck.CheckSignalReceived();
2493   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2494
2495   // Check that nothing has changed after a couple of buffer swaps
2496   application.Render(0);
2497   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2498   application.Render(0);
2499   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2500   END_TEST;
2501 }
2502
2503
2504 int UtcDaliAnimationGetStateP(void)
2505 {
2506   TestApplication application;
2507
2508   Actor actor = Actor::New();
2509   Stage::GetCurrent().Add(actor);
2510
2511   // Build the animation
2512   float durationSeconds(1.0f);
2513   Animation animation = Animation::New(durationSeconds);
2514   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2515   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2516   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2517
2518   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2519
2520   // Start the animation
2521   animation.Play();
2522
2523   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2524
2525   bool signalReceived(false);
2526   AnimationFinishCheck finishCheck(signalReceived);
2527   animation.FinishedSignal().Connect(&application, finishCheck);
2528
2529   application.SendNotification();
2530   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2531
2532   // We didn't expect the animation to finish yet
2533   application.SendNotification();
2534   finishCheck.CheckSignalNotReceived();
2535   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2536   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2537
2538   // Pause the animation
2539   animation.Pause();
2540   DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2541   application.SendNotification();
2542   application.Render(0.f);
2543
2544   // Loop 5 times
2545   for (int i=0; i<5; ++i)
2546   {
2547     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2548
2549     // We didn't expect the animation to finish yet
2550     application.SendNotification();
2551     finishCheck.CheckSignalNotReceived();
2552     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2553     DALI_TEST_EQUALS( animation.GetState(), Animation::PAUSED, TEST_LOCATION );
2554   }
2555
2556   // Keep going
2557   finishCheck.Reset();
2558   animation.Play();
2559   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2560   application.SendNotification();
2561   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2562   // We didn't expect the animation to finish yet
2563   application.SendNotification();
2564   finishCheck.CheckSignalNotReceived();
2565   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2566
2567   application.SendNotification();
2568   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2569
2570   // We did expect the animation to finish
2571   application.SendNotification();
2572   finishCheck.CheckSignalReceived();
2573   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2574   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2575
2576   // Check that nothing has changed after a couple of buffer swaps
2577   application.Render(0);
2578   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2579   application.Render(0);
2580   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2581   DALI_TEST_EQUALS( animation.GetState(), Animation::STOPPED, TEST_LOCATION );
2582
2583   // re-play
2584   finishCheck.Reset();
2585   animation.Play();
2586   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2587   application.SendNotification();
2588   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2589   application.SendNotification();
2590   finishCheck.CheckSignalNotReceived();
2591   DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
2592
2593
2594   END_TEST;
2595 }
2596
2597 int UtcDaliAnimationStopP(void)
2598 {
2599   TestApplication application;
2600
2601   Actor actor = Actor::New();
2602   Stage::GetCurrent().Add(actor);
2603
2604   // Build the animation
2605   float durationSeconds(1.0f);
2606   Animation animation = Animation::New(durationSeconds);
2607   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2608   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2609
2610   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2611
2612   // Start the animation
2613   animation.Play();
2614
2615   bool signalReceived(false);
2616   AnimationFinishCheck finishCheck(signalReceived);
2617   animation.FinishedSignal().Connect(&application, finishCheck);
2618
2619   application.SendNotification();
2620   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2621
2622   // We didn't expect the animation to finish yet
2623   application.SendNotification();
2624   finishCheck.CheckSignalNotReceived();
2625   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2626
2627   // Stop the animation
2628   animation.Stop();
2629   application.SendNotification();
2630
2631   // Loop 5 times
2632   for (int i=0; i<5; ++i)
2633   {
2634     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2635
2636     // We did expect the animation to finish
2637     application.SendNotification();
2638     finishCheck.CheckSignalReceived();
2639     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2640   }
2641   END_TEST;
2642 }
2643
2644 int UtcDaliAnimationStopSetPositionP(void)
2645 {
2646   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2647   // i.e. to check that the animation does not interfere with the position set.
2648
2649   TestApplication application;
2650
2651   Actor actor = Actor::New();
2652   Stage::GetCurrent().Add(actor);
2653
2654   // Build the animation
2655   float durationSeconds(1.0f);
2656   Animation animation = Animation::New(durationSeconds);
2657   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2658   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2659
2660   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2661
2662   // Start the animation
2663   animation.Play();
2664
2665   bool signalReceived(false);
2666   AnimationFinishCheck finishCheck(signalReceived);
2667   animation.FinishedSignal().Connect(&application, finishCheck);
2668
2669   application.SendNotification();
2670   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2671
2672   // We didn't expect the animation to finish yet
2673   application.SendNotification();
2674   finishCheck.CheckSignalNotReceived();
2675   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2676
2677   // Stop the animation
2678   animation.Stop();
2679   Vector3 positionSet(2.0f, 3.0f, 4.0f);
2680   actor.SetPosition(positionSet);
2681   application.SendNotification();
2682
2683   // Loop 5 times
2684   for (int i=0; i<5; ++i)
2685   {
2686     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2687
2688     // We did expect the animation to finish
2689     application.SendNotification();
2690     finishCheck.CheckSignalReceived();
2691     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2692   }
2693   END_TEST;
2694 }
2695
2696 int UtcDaliAnimationClearP(void)
2697 {
2698   TestApplication application;
2699
2700   Actor actor = Actor::New();
2701   Stage::GetCurrent().Add(actor);
2702
2703   // Build the animation
2704   float durationSeconds(1.0f);
2705   Animation animation = Animation::New(durationSeconds);
2706   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2707   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2708
2709   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2710
2711   // Start the animation
2712   animation.Play();
2713
2714   bool signalReceived(false);
2715   AnimationFinishCheck finishCheck(signalReceived);
2716   animation.FinishedSignal().Connect(&application, finishCheck);
2717
2718   application.SendNotification();
2719   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2720
2721   // We didn't expect the animation to finish yet
2722   application.SendNotification();
2723   finishCheck.CheckSignalNotReceived();
2724   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2725
2726   // Clear the animation
2727   animation.Clear();
2728   application.SendNotification();
2729
2730   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2731
2732   // We don't expect the animation to finish now
2733   application.SendNotification();
2734   finishCheck.CheckSignalNotReceived();
2735   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2736
2737   // Restart as a scale animation; this should not move the actor's position
2738   finishCheck.Reset();
2739   actor.SetPosition(Vector3::ZERO);
2740   Vector3 targetScale(3.0f, 3.0f, 3.0f);
2741   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2742   animation.Play();
2743
2744   application.SendNotification();
2745   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2746
2747   // We didn't expect the animation to finish yet
2748   application.SendNotification();
2749   finishCheck.CheckSignalNotReceived();
2750   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2751   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2752
2753   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2754
2755   // We did expect the animation to finish
2756   application.SendNotification();
2757   finishCheck.CheckSignalReceived();
2758   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2759   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2760   END_TEST;
2761 }
2762
2763 int UtcDaliAnimationFinishedSignalP(void)
2764 {
2765   TestApplication application;
2766
2767   // Start the empty animation
2768   float durationSeconds(1.0f);
2769   Animation animation = Animation::New(durationSeconds);
2770   animation.Play();
2771
2772   bool signalReceived(false);
2773   AnimationFinishCheck finishCheck(signalReceived);
2774   animation.FinishedSignal().Connect(&application, finishCheck);
2775
2776   application.SendNotification();
2777   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2778
2779   // We did expect the animation to finish
2780   application.SendNotification();
2781   finishCheck.CheckSignalReceived();
2782   END_TEST;
2783 }
2784
2785 int UtcDaliAnimationAnimateByBooleanP(void)
2786 {
2787   TestApplication application;
2788
2789   Actor actor = Actor::New();
2790
2791   // Register a boolean property
2792   bool startValue(false);
2793   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2794   Stage::GetCurrent().Add(actor);
2795   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2796   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2797
2798   // Build the animation
2799   float durationSeconds(2.0f);
2800   Animation animation = Animation::New(durationSeconds);
2801   const bool relativeValue(true);
2802   const bool finalValue( false || relativeValue );
2803   animation.AnimateBy(Property(actor, index), relativeValue);
2804
2805   // Start the animation
2806   animation.Play();
2807
2808   bool signalReceived(false);
2809   AnimationFinishCheck finishCheck(signalReceived);
2810   animation.FinishedSignal().Connect(&application, finishCheck);
2811
2812   application.SendNotification();
2813   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2814
2815   // We didn't expect the animation to finish yet
2816   application.SendNotification();
2817   finishCheck.CheckSignalNotReceived();
2818   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2819
2820   application.SendNotification();
2821   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2822
2823   // We did expect the animation to finish
2824   application.SendNotification();
2825   finishCheck.CheckSignalReceived();
2826   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2827
2828   // Check that nothing has changed after a couple of buffer swaps
2829   application.Render(0);
2830   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2831   application.Render(0);
2832   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2833
2834   // Repeat with relative value "false" - this should be an NOOP
2835   animation = Animation::New(durationSeconds);
2836   bool noOpValue(false);
2837   animation.AnimateBy(Property(actor, index), noOpValue);
2838
2839   // Start the animation
2840   animation.Play();
2841
2842   finishCheck.Reset();
2843   animation.FinishedSignal().Connect(&application, finishCheck);
2844
2845   application.SendNotification();
2846   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2847
2848   // We didn't expect the animation to finish yet
2849   application.SendNotification();
2850   finishCheck.CheckSignalNotReceived();
2851   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2852
2853   application.SendNotification();
2854   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2855
2856   // We did expect the animation to finish
2857   application.SendNotification();
2858   finishCheck.CheckSignalReceived();
2859   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2860
2861   // Check that nothing has changed after a couple of buffer swaps
2862   application.Render(0);
2863   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2864   application.Render(0);
2865   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2866   END_TEST;
2867 }
2868
2869 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
2870 {
2871   TestApplication application;
2872
2873   Actor actor = Actor::New();
2874
2875   // Register a boolean property
2876   bool startValue(false);
2877   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2878   Stage::GetCurrent().Add(actor);
2879   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2880   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2881
2882   // Build the animation
2883   float durationSeconds(2.0f);
2884   Animation animation = Animation::New(durationSeconds);
2885   bool relativeValue(true);
2886   bool finalValue( false || relativeValue );
2887   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2888
2889   // Start the animation
2890   animation.Play();
2891
2892   bool signalReceived(false);
2893   AnimationFinishCheck finishCheck(signalReceived);
2894   animation.FinishedSignal().Connect(&application, finishCheck);
2895
2896   application.SendNotification();
2897   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2898
2899   // We didn't expect the animation to finish yet
2900   application.SendNotification();
2901   finishCheck.CheckSignalNotReceived();
2902   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2903
2904   application.SendNotification();
2905   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2906
2907   // We did expect the animation to finish
2908   application.SendNotification();
2909   finishCheck.CheckSignalReceived();
2910   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2911
2912   // Check that nothing has changed after a couple of buffer swaps
2913   application.Render(0);
2914   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2915   application.Render(0);
2916   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2917
2918   // Repeat with relative value "false" - this should be an NOOP
2919   animation = Animation::New(durationSeconds);
2920   bool noOpValue(false);
2921   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2922
2923   // Start the animation
2924   animation.Play();
2925
2926   finishCheck.Reset();
2927   animation.FinishedSignal().Connect(&application, finishCheck);
2928
2929   application.SendNotification();
2930   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2931
2932   // We didn't expect the animation to finish yet
2933   application.SendNotification();
2934   finishCheck.CheckSignalNotReceived();
2935   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2936
2937   application.SendNotification();
2938   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2939
2940   // We did expect the animation to finish
2941   application.SendNotification();
2942   finishCheck.CheckSignalReceived();
2943   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2944   END_TEST;
2945 }
2946
2947 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
2948 {
2949   TestApplication application;
2950
2951   Actor actor = Actor::New();
2952
2953   // Register a boolean property
2954   bool startValue(false);
2955   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2956   Stage::GetCurrent().Add(actor);
2957   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2958   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2959
2960   // Build the animation
2961   float durationSeconds(2.0f);
2962   Animation animation = Animation::New(durationSeconds);
2963   bool relativeValue(true);
2964   bool finalValue( false || relativeValue );
2965   float animatorDurationSeconds(durationSeconds * 0.5f);
2966   animation.AnimateBy( Property(actor, index),
2967                        relativeValue,
2968                        TimePeriod( animatorDurationSeconds ) );
2969
2970   // Start the animation
2971   animation.Play();
2972
2973   bool signalReceived(false);
2974   AnimationFinishCheck finishCheck(signalReceived);
2975   animation.FinishedSignal().Connect(&application, finishCheck);
2976
2977   application.SendNotification();
2978   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2979
2980   // We didn't expect the animation to finish yet
2981   application.SendNotification();
2982   finishCheck.CheckSignalNotReceived();
2983   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
2984
2985   application.SendNotification();
2986   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2987
2988   // We didn't expect the animation to finish yet...
2989   application.SendNotification();
2990   finishCheck.CheckSignalNotReceived();
2991
2992   // ...however we should have reached the final value
2993   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
2994
2995   application.SendNotification();
2996   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2997
2998   // We did expect the animation to finish
2999   application.SendNotification();
3000   finishCheck.CheckSignalReceived();
3001   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3002
3003   // Check that nothing has changed after a couple of buffer swaps
3004   application.Render(0);
3005   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3006   application.Render(0);
3007   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3008   END_TEST;
3009 }
3010
3011 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
3012 {
3013   TestApplication application;
3014
3015   Actor actor = Actor::New();
3016
3017   // Register a boolean property
3018   bool startValue(false);
3019   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3020   Stage::GetCurrent().Add(actor);
3021   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3022   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3023
3024   // Build the animation
3025   float durationSeconds(2.0f);
3026   Animation animation = Animation::New(durationSeconds);
3027   bool relativeValue(true);
3028   bool finalValue( false || relativeValue );
3029   float animatorDurationSeconds(durationSeconds * 0.5f);
3030   animation.AnimateBy( Property(actor, index),
3031                        relativeValue,
3032                        AlphaFunction::EASE_IN_OUT,
3033                        TimePeriod( animatorDurationSeconds ) );
3034
3035   // Start the animation
3036   animation.Play();
3037
3038   bool signalReceived(false);
3039   AnimationFinishCheck finishCheck(signalReceived);
3040   animation.FinishedSignal().Connect(&application, finishCheck);
3041
3042   application.SendNotification();
3043   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3044
3045   // We didn't expect the animation to finish yet
3046   application.SendNotification();
3047   finishCheck.CheckSignalNotReceived();
3048   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
3049
3050   application.SendNotification();
3051   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3052
3053   // We didn't expect the animation to finish yet...
3054   application.SendNotification();
3055   finishCheck.CheckSignalNotReceived();
3056
3057   // ...however we should have reached the final value
3058   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3059
3060   application.SendNotification();
3061   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3062
3063   // We did expect the animation to finish
3064   application.SendNotification();
3065   finishCheck.CheckSignalReceived();
3066   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3067
3068   // Check that nothing has changed after a couple of buffer swaps
3069   application.Render(0);
3070   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3071   application.Render(0);
3072   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
3073   END_TEST;
3074 }
3075
3076 int UtcDaliAnimationAnimateByFloatP(void)
3077 {
3078   TestApplication application;
3079
3080   Actor actor = Actor::New();
3081
3082   // Register a float property
3083   float startValue(10.0f);
3084   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3085   Stage::GetCurrent().Add(actor);
3086   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3087   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3088
3089   // Build the animation
3090   float durationSeconds(2.0f);
3091   Animation animation = Animation::New(durationSeconds);
3092   float targetValue(50.0f);
3093   float relativeValue(targetValue - startValue);
3094   animation.AnimateBy(Property(actor, index), relativeValue);
3095
3096   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3097
3098   // Start the animation
3099   animation.Play();
3100
3101   bool signalReceived(false);
3102   AnimationFinishCheck finishCheck(signalReceived);
3103   animation.FinishedSignal().Connect(&application, finishCheck);
3104
3105   application.SendNotification();
3106   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3107
3108   // We didn't expect the animation to finish yet
3109   application.SendNotification();
3110   finishCheck.CheckSignalNotReceived();
3111   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3112
3113   application.SendNotification();
3114   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3115
3116   // We did expect the animation to finish
3117   application.SendNotification();
3118   finishCheck.CheckSignalReceived();
3119   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3120
3121   // Check that nothing has changed after a couple of buffer swaps
3122   application.Render(0);
3123   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3124   application.Render(0);
3125   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3126   END_TEST;
3127 }
3128
3129 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
3130 {
3131   TestApplication application;
3132
3133   Actor actor = Actor::New();
3134
3135   // Register a float property
3136   float startValue(10.0f);
3137   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3138   Stage::GetCurrent().Add(actor);
3139   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3140   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3141
3142   // Build the animation
3143   float durationSeconds(1.0f);
3144   Animation animation = Animation::New(durationSeconds);
3145   float targetValue(90.0f);
3146   float relativeValue(targetValue - startValue);
3147   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3148
3149   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3150
3151   // Start the animation
3152   animation.Play();
3153
3154   bool signalReceived(false);
3155   AnimationFinishCheck finishCheck(signalReceived);
3156   animation.FinishedSignal().Connect(&application, finishCheck);
3157
3158   application.SendNotification();
3159   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3160
3161   // We didn't expect the animation to finish yet
3162   application.SendNotification();
3163   finishCheck.CheckSignalNotReceived();
3164
3165   // The position should have moved more, than with a linear alpha function
3166   float current( actor.GetCurrentProperty< float >( index ) );
3167   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3168
3169   application.SendNotification();
3170   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3171
3172   // We did expect the animation to finish
3173   application.SendNotification();
3174   finishCheck.CheckSignalReceived();
3175   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3176
3177   // Check that nothing has changed after a couple of buffer swaps
3178   application.Render(0);
3179   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3180   application.Render(0);
3181   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3182   END_TEST;
3183 }
3184
3185 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
3186 {
3187   TestApplication application;
3188
3189   Actor actor = Actor::New();
3190
3191   // Register a float property
3192   float startValue(10.0f);
3193   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3194   Stage::GetCurrent().Add(actor);
3195   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3196   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3197
3198   // Build the animation
3199   float durationSeconds(1.0f);
3200   Animation animation = Animation::New(durationSeconds);
3201   float targetValue(30.0f);
3202   float relativeValue(targetValue - startValue);
3203   float delay = 0.5f;
3204   animation.AnimateBy(Property(actor, index),
3205                       relativeValue,
3206                       TimePeriod(delay, durationSeconds - delay));
3207
3208   // Start the animation
3209   animation.Play();
3210
3211   bool signalReceived(false);
3212   AnimationFinishCheck finishCheck(signalReceived);
3213   animation.FinishedSignal().Connect(&application, finishCheck);
3214
3215   application.SendNotification();
3216   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3217
3218   // We didn't expect the animation to finish yet
3219   application.SendNotification();
3220   finishCheck.CheckSignalNotReceived();
3221   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3222
3223   application.SendNotification();
3224   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3225
3226   // We didn't expect the animation to finish yet
3227   application.SendNotification();
3228   finishCheck.CheckSignalNotReceived();
3229   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3230
3231   application.SendNotification();
3232   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3233
3234   // We did expect the animation to finish
3235   application.SendNotification();
3236   finishCheck.CheckSignalReceived();
3237   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3238
3239   // Check that nothing has changed after a couple of buffer swaps
3240   application.Render(0);
3241   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3242   application.Render(0);
3243   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3244   END_TEST;
3245 }
3246
3247 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
3248 {
3249   TestApplication application;
3250
3251   Actor actor = Actor::New();
3252
3253   // Register a float property
3254   float startValue(10.0f);
3255   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3256   Stage::GetCurrent().Add(actor);
3257   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3258   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3259
3260   // Build the animation
3261   float durationSeconds(1.0f);
3262   Animation animation = Animation::New(durationSeconds);
3263   float targetValue(30.0f);
3264   float relativeValue(targetValue - startValue);
3265   float delay = 0.5f;
3266   animation.AnimateBy(Property(actor, index),
3267                       relativeValue,
3268                       AlphaFunction::LINEAR,
3269                       TimePeriod(delay, durationSeconds - delay));
3270
3271   // Start the animation
3272   animation.Play();
3273
3274   bool signalReceived(false);
3275   AnimationFinishCheck finishCheck(signalReceived);
3276   animation.FinishedSignal().Connect(&application, finishCheck);
3277
3278   application.SendNotification();
3279   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3280
3281   // We didn't expect the animation to finish yet
3282   application.SendNotification();
3283   finishCheck.CheckSignalNotReceived();
3284   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
3285
3286   application.SendNotification();
3287   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3288
3289   // We didn't expect the animation to finish yet
3290   application.SendNotification();
3291   finishCheck.CheckSignalNotReceived();
3292   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3293
3294   application.SendNotification();
3295   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3296
3297   // We did expect the animation to finish
3298   application.SendNotification();
3299   finishCheck.CheckSignalReceived();
3300   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3301
3302   // Check that nothing has changed after a couple of buffer swaps
3303   application.Render(0);
3304   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3305   application.Render(0);
3306   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
3307   END_TEST;
3308 }
3309
3310 int UtcDaliAnimationAnimateByIntegerP(void)
3311 {
3312   TestApplication application;
3313
3314   Actor actor = Actor::New();
3315
3316   // Register an integer property
3317   int startValue(1);
3318   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3319   Stage::GetCurrent().Add(actor);
3320   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3321   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3322
3323   // Build the animation
3324   float durationSeconds(2.0f);
3325   Animation animation = Animation::New(durationSeconds);
3326   int targetValue(50);
3327   int relativeValue(targetValue - startValue);
3328   animation.AnimateBy(Property(actor, index), relativeValue);
3329
3330   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3331
3332   // Start the animation
3333   animation.Play();
3334
3335   bool signalReceived(false);
3336   AnimationFinishCheck finishCheck(signalReceived);
3337   animation.FinishedSignal().Connect(&application, finishCheck);
3338
3339   application.SendNotification();
3340   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3341
3342   // We didn't expect the animation to finish yet
3343   application.SendNotification();
3344   finishCheck.CheckSignalNotReceived();
3345   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3346
3347   application.SendNotification();
3348   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3349
3350   // We did expect the animation to finish
3351   application.SendNotification();
3352   finishCheck.CheckSignalReceived();
3353   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3354
3355   // Check that nothing has changed after a couple of buffer swaps
3356   application.Render(0);
3357   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3358   application.Render(0);
3359   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3360   END_TEST;
3361 }
3362
3363 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
3364 {
3365   TestApplication application;
3366
3367   Actor actor = Actor::New();
3368
3369   // Register an integer property
3370   int startValue(1);
3371   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3372   Stage::GetCurrent().Add(actor);
3373   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3374   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3375
3376   // Build the animation
3377   float durationSeconds(1.0f);
3378   Animation animation = Animation::New(durationSeconds);
3379   int targetValue(90);
3380   int relativeValue(targetValue - startValue);
3381   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3382
3383   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3384
3385   // Start the animation
3386   animation.Play();
3387
3388   bool signalReceived(false);
3389   AnimationFinishCheck finishCheck(signalReceived);
3390   animation.FinishedSignal().Connect(&application, finishCheck);
3391
3392   application.SendNotification();
3393   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3394
3395   // We didn't expect the animation to finish yet
3396   application.SendNotification();
3397   finishCheck.CheckSignalNotReceived();
3398
3399   // The position should have moved more, than with a linear alpha function
3400   int current( actor.GetCurrentProperty< int >( index ) );
3401   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3402
3403   application.SendNotification();
3404   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3405
3406   // We did expect the animation to finish
3407   application.SendNotification();
3408   finishCheck.CheckSignalReceived();
3409   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3410
3411   // Check that nothing has changed after a couple of buffer swaps
3412   application.Render(0);
3413   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3414   application.Render(0);
3415   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3416   END_TEST;
3417 }
3418
3419 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
3420 {
3421   TestApplication application;
3422
3423   Actor actor = Actor::New();
3424
3425   // Register an integer property
3426   int startValue(10);
3427   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3428   Stage::GetCurrent().Add(actor);
3429   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3430   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3431
3432   // Build the animation
3433   float durationSeconds(1.0f);
3434   Animation animation = Animation::New(durationSeconds);
3435   int targetValue(30);
3436   int relativeValue(targetValue - startValue);
3437   float delay = 0.5f;
3438   animation.AnimateBy(Property(actor, index),
3439                       relativeValue,
3440                       TimePeriod(delay, durationSeconds - delay));
3441
3442   // Start the animation
3443   animation.Play();
3444
3445   bool signalReceived(false);
3446   AnimationFinishCheck finishCheck(signalReceived);
3447   animation.FinishedSignal().Connect(&application, finishCheck);
3448
3449   application.SendNotification();
3450   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3451
3452   // We didn't expect the animation to finish yet
3453   application.SendNotification();
3454   finishCheck.CheckSignalNotReceived();
3455   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3456
3457   application.SendNotification();
3458   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3459
3460   // We didn't expect the animation to finish yet
3461   application.SendNotification();
3462   finishCheck.CheckSignalNotReceived();
3463   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3464
3465   application.SendNotification();
3466   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3467
3468   // We did expect the animation to finish
3469   application.SendNotification();
3470   finishCheck.CheckSignalReceived();
3471   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3472
3473   // Check that nothing has changed after a couple of buffer swaps
3474   application.Render(0);
3475   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3476   application.Render(0);
3477   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3478   END_TEST;
3479 }
3480
3481 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
3482 {
3483   TestApplication application;
3484
3485   Actor actor = Actor::New();
3486
3487   // Register an integer property
3488   int startValue(10);
3489   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3490   Stage::GetCurrent().Add(actor);
3491   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3492   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3493
3494   // Build the animation
3495   float durationSeconds(1.0f);
3496   Animation animation = Animation::New(durationSeconds);
3497   int targetValue(30);
3498   int relativeValue(targetValue - startValue);
3499   float delay = 0.5f;
3500   animation.AnimateBy(Property(actor, index),
3501                       relativeValue,
3502                       AlphaFunction::LINEAR,
3503                       TimePeriod(delay, durationSeconds - delay));
3504
3505   // Start the animation
3506   animation.Play();
3507
3508   bool signalReceived(false);
3509   AnimationFinishCheck finishCheck(signalReceived);
3510   animation.FinishedSignal().Connect(&application, finishCheck);
3511
3512   application.SendNotification();
3513   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3514
3515   // We didn't expect the animation to finish yet
3516   application.SendNotification();
3517   finishCheck.CheckSignalNotReceived();
3518   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
3519
3520   application.SendNotification();
3521   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3522
3523   // We didn't expect the animation to finish yet
3524   application.SendNotification();
3525   finishCheck.CheckSignalNotReceived();
3526   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3527
3528   application.SendNotification();
3529   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3530
3531   // We did expect the animation to finish
3532   application.SendNotification();
3533   finishCheck.CheckSignalReceived();
3534   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3535
3536   // Check that nothing has changed after a couple of buffer swaps
3537   application.Render(0);
3538   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3539   application.Render(0);
3540   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
3541   END_TEST;
3542 }
3543
3544 int UtcDaliAnimationAnimateByVector2P(void)
3545 {
3546   TestApplication application;
3547
3548   Actor actor = Actor::New();
3549
3550   // Register a Vector2 property
3551   Vector2 startValue(10.0f, 10.0f);
3552   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3553   Stage::GetCurrent().Add(actor);
3554   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3555   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3556
3557   // Build the animation
3558   float durationSeconds(2.0f);
3559   Animation animation = Animation::New(durationSeconds);
3560   Vector2 targetValue(60.0f, 60.0f);
3561   Vector2 relativeValue(targetValue - startValue);
3562   animation.AnimateBy(Property(actor, index), relativeValue);
3563
3564   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3565
3566   // Start the animation
3567   animation.Play();
3568
3569   bool signalReceived(false);
3570   AnimationFinishCheck finishCheck(signalReceived);
3571   animation.FinishedSignal().Connect(&application, finishCheck);
3572
3573   application.SendNotification();
3574   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3575
3576   // We didn't expect the animation to finish yet
3577   application.SendNotification();
3578   finishCheck.CheckSignalNotReceived();
3579   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3580
3581   application.SendNotification();
3582   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3583
3584   // We did expect the animation to finish
3585   application.SendNotification();
3586   finishCheck.CheckSignalReceived();
3587   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3588
3589   // Check that nothing has changed after a couple of buffer swaps
3590   application.Render(0);
3591   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3592   application.Render(0);
3593   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3594   END_TEST;
3595 }
3596
3597 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
3598 {
3599   TestApplication application;
3600
3601   Actor actor = Actor::New();
3602
3603   // Register a Vector2 property
3604   Vector2 startValue(100.0f, 100.0f);
3605   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3606   Stage::GetCurrent().Add(actor);
3607   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3608   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3609
3610   // Build the animation
3611   float durationSeconds(1.0f);
3612   Animation animation = Animation::New(durationSeconds);
3613   Vector2 targetValue(20.0f, 20.0f);
3614   Vector2 relativeValue(targetValue - startValue);
3615   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3616
3617   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3618
3619   // Start the animation
3620   animation.Play();
3621
3622   bool signalReceived(false);
3623   AnimationFinishCheck finishCheck(signalReceived);
3624   animation.FinishedSignal().Connect(&application, finishCheck);
3625
3626   application.SendNotification();
3627   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3628
3629   // We didn't expect the animation to finish yet
3630   application.SendNotification();
3631   finishCheck.CheckSignalNotReceived();
3632
3633   // The position should have moved more, than with a linear alpha function
3634   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
3635   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3636   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3637
3638   application.SendNotification();
3639   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3640
3641   // We did expect the animation to finish
3642   application.SendNotification();
3643   finishCheck.CheckSignalReceived();
3644   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3645
3646   // Check that nothing has changed after a couple of buffer swaps
3647   application.Render(0);
3648   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3649   application.Render(0);
3650   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3651   END_TEST;
3652 }
3653
3654 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
3655 {
3656   TestApplication application;
3657
3658   Actor actor = Actor::New();
3659
3660   // Register a Vector2 property
3661   Vector2 startValue(10.0f, 10.0f);
3662   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3663   Stage::GetCurrent().Add(actor);
3664   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3665   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3666
3667   // Build the animation
3668   float durationSeconds(1.0f);
3669   Animation animation = Animation::New(durationSeconds);
3670   Vector2 targetValue(30.0f, 30.0f);
3671   Vector2 relativeValue(targetValue - startValue);
3672   float delay = 0.5f;
3673   animation.AnimateBy(Property(actor, index),
3674                       relativeValue,
3675                       TimePeriod(delay, durationSeconds - delay));
3676
3677   // Start the animation
3678   animation.Play();
3679
3680   bool signalReceived(false);
3681   AnimationFinishCheck finishCheck(signalReceived);
3682   animation.FinishedSignal().Connect(&application, finishCheck);
3683
3684   application.SendNotification();
3685   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3686
3687   // We didn't expect the animation to finish yet
3688   application.SendNotification();
3689   finishCheck.CheckSignalNotReceived();
3690   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3691
3692   application.SendNotification();
3693   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3694
3695   // We didn't expect the animation to finish yet
3696   application.SendNotification();
3697   finishCheck.CheckSignalNotReceived();
3698   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3699
3700   application.SendNotification();
3701   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3702
3703   // We did expect the animation to finish
3704   application.SendNotification();
3705   finishCheck.CheckSignalReceived();
3706   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3707
3708   // Check that nothing has changed after a couple of buffer swaps
3709   application.Render(0);
3710   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3711   application.Render(0);
3712   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3713   END_TEST;
3714 }
3715
3716 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
3717 {
3718   TestApplication application;
3719
3720   Actor actor = Actor::New();
3721
3722   // Register a Vector2 property
3723   Vector2 startValue(5.0f, 5.0f);
3724   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3725   Stage::GetCurrent().Add(actor);
3726   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3727   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3728
3729   // Build the animation
3730   float durationSeconds(1.0f);
3731   Animation animation = Animation::New(durationSeconds);
3732   Vector2 targetValue(10.0f, 10.0f);
3733   Vector2 relativeValue(targetValue - startValue);
3734   float delay = 0.5f;
3735   animation.AnimateBy(Property(actor, index),
3736                       relativeValue,
3737                       AlphaFunction::LINEAR,
3738                       TimePeriod(delay, durationSeconds - delay));
3739
3740   // Start the animation
3741   animation.Play();
3742
3743   bool signalReceived(false);
3744   AnimationFinishCheck finishCheck(signalReceived);
3745   animation.FinishedSignal().Connect(&application, finishCheck);
3746
3747   application.SendNotification();
3748   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3749
3750   // We didn't expect the animation to finish yet
3751   application.SendNotification();
3752   finishCheck.CheckSignalNotReceived();
3753   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
3754
3755   application.SendNotification();
3756   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3757
3758   // We didn't expect the animation to finish yet
3759   application.SendNotification();
3760   finishCheck.CheckSignalNotReceived();
3761   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3762
3763   application.SendNotification();
3764   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3765
3766   // We did expect the animation to finish
3767   application.SendNotification();
3768   finishCheck.CheckSignalReceived();
3769   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3770
3771   // Check that nothing has changed after a couple of buffer swaps
3772   application.Render(0);
3773   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3774   application.Render(0);
3775   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
3776   END_TEST;
3777 }
3778
3779 int UtcDaliAnimationAnimateByVector3P(void)
3780 {
3781   TestApplication application;
3782
3783   Actor actor = Actor::New();
3784
3785   // Register a Vector3 property
3786   Vector3 startValue(10.0f, 10.0f, 10.0f);
3787   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3788   Stage::GetCurrent().Add(actor);
3789   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3790   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3791
3792   // Build the animation
3793   float durationSeconds(2.0f);
3794   Animation animation = Animation::New(durationSeconds);
3795   Vector3 targetValue(60.0f, 60.0f, 60.0f);
3796   Vector3 relativeValue(targetValue - startValue);
3797   animation.AnimateBy(Property(actor, index), relativeValue);
3798
3799   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3800
3801   // Start the animation
3802   animation.Play();
3803
3804   bool signalReceived(false);
3805   AnimationFinishCheck finishCheck(signalReceived);
3806   animation.FinishedSignal().Connect(&application, finishCheck);
3807
3808   application.SendNotification();
3809   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3810
3811   // We didn't expect the animation to finish yet
3812   application.SendNotification();
3813   finishCheck.CheckSignalNotReceived();
3814   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
3815
3816   application.SendNotification();
3817   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3818
3819   // We did expect the animation to finish
3820   application.SendNotification();
3821   finishCheck.CheckSignalReceived();
3822   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3823
3824   // Check that nothing has changed after a couple of buffer swaps
3825   application.Render(0);
3826   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3827   application.Render(0);
3828   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3829   END_TEST;
3830 }
3831
3832 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
3833 {
3834   TestApplication application;
3835
3836   Actor actor = Actor::New();
3837
3838   // Register a Vector3 property
3839   Vector3 startValue(100.0f, 100.0f, 100.0f);
3840   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3841   Stage::GetCurrent().Add(actor);
3842   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3843   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3844
3845   // Build the animation
3846   float durationSeconds(1.0f);
3847   Animation animation = Animation::New(durationSeconds);
3848   Vector3 targetValue(20.0f, 20.0f, 20.0f);
3849   Vector3 relativeValue(targetValue - startValue);
3850   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3851
3852   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3853
3854   // Start the animation
3855   animation.Play();
3856
3857   bool signalReceived(false);
3858   AnimationFinishCheck finishCheck(signalReceived);
3859   animation.FinishedSignal().Connect(&application, finishCheck);
3860
3861   application.SendNotification();
3862   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3863
3864   // We didn't expect the animation to finish yet
3865   application.SendNotification();
3866   finishCheck.CheckSignalNotReceived();
3867
3868   // The position should have moved more, than with a linear alpha function
3869   Vector3 current(actor.GetCurrentProperty< Vector3 >( index ));
3870   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3871   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3872   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3873
3874   application.SendNotification();
3875   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3876
3877   // We did expect the animation to finish
3878   application.SendNotification();
3879   finishCheck.CheckSignalReceived();
3880   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3881
3882   // Check that nothing has changed after a couple of buffer swaps
3883   application.Render(0);
3884   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3885   application.Render(0);
3886   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3887   END_TEST;
3888 }
3889
3890 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
3891 {
3892   TestApplication application;
3893
3894   Actor actor = Actor::New();
3895
3896   // Register a Vector3 property
3897   Vector3 startValue(10.0f, 10.0f, 10.0f);
3898   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3899   Stage::GetCurrent().Add(actor);
3900   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3901   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3902
3903   // Build the animation
3904   float durationSeconds(1.0f);
3905   Animation animation = Animation::New(durationSeconds);
3906   Vector3 targetValue(30.0f, 30.0f, 30.0f);
3907   Vector3 relativeValue(targetValue - startValue);
3908   float delay = 0.5f;
3909   animation.AnimateBy(Property(actor, index),
3910                       relativeValue,
3911                       TimePeriod(delay, durationSeconds - delay));
3912
3913   // Start the animation
3914   animation.Play();
3915
3916   bool signalReceived(false);
3917   AnimationFinishCheck finishCheck(signalReceived);
3918   animation.FinishedSignal().Connect(&application, finishCheck);
3919
3920   application.SendNotification();
3921   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3922
3923   // We didn't expect the animation to finish yet
3924   application.SendNotification();
3925   finishCheck.CheckSignalNotReceived();
3926   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3927
3928   application.SendNotification();
3929   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3930
3931   // We didn't expect the animation to finish yet
3932   application.SendNotification();
3933   finishCheck.CheckSignalNotReceived();
3934   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3935
3936   application.SendNotification();
3937   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3938
3939   // We did expect the animation to finish
3940   application.SendNotification();
3941   finishCheck.CheckSignalReceived();
3942   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3943
3944   // Check that nothing has changed after a couple of buffer swaps
3945   application.Render(0);
3946   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3947   application.Render(0);
3948   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
3949   END_TEST;
3950 }
3951
3952 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
3953 {
3954   TestApplication application;
3955
3956   Actor actor = Actor::New();
3957
3958   // Register a Vector3 property
3959   Vector3 startValue(5.0f, 5.0f, 5.0f);
3960   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3961   Stage::GetCurrent().Add(actor);
3962   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3963   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3964
3965   // Build the animation
3966   float durationSeconds(1.0f);
3967   Animation animation = Animation::New(durationSeconds);
3968   Vector3 targetValue(10.0f, 10.0f, 10.0f);
3969   Vector3 relativeValue(targetValue - startValue);
3970   float delay = 0.5f;
3971   animation.AnimateBy(Property(actor, index),
3972                       relativeValue,
3973                       AlphaFunction::LINEAR,
3974                       TimePeriod(delay, durationSeconds - delay));
3975
3976   // Start the animation
3977   animation.Play();
3978
3979   bool signalReceived(false);
3980   AnimationFinishCheck finishCheck(signalReceived);
3981   animation.FinishedSignal().Connect(&application, finishCheck);
3982
3983   application.SendNotification();
3984   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3985
3986   // We didn't expect the animation to finish yet
3987   application.SendNotification();
3988   finishCheck.CheckSignalNotReceived();
3989   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
3990
3991   application.SendNotification();
3992   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3993
3994   // We didn't expect the animation to finish yet
3995   application.SendNotification();
3996   finishCheck.CheckSignalNotReceived();
3997   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
3998
3999   application.SendNotification();
4000   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4001
4002   // We did expect the animation to finish
4003   application.SendNotification();
4004   finishCheck.CheckSignalReceived();
4005   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4006
4007   // Check that nothing has changed after a couple of buffer swaps
4008   application.Render(0);
4009   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4010   application.Render(0);
4011   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
4012   END_TEST;
4013 }
4014
4015 int UtcDaliAnimationAnimateByVector4P(void)
4016 {
4017   TestApplication application;
4018
4019   Actor actor = Actor::New();
4020
4021   // Register a Vector4 property
4022   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4023   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4024   Stage::GetCurrent().Add(actor);
4025   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4026   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4027
4028   // Build the animation
4029   float durationSeconds(2.0f);
4030   Animation animation = Animation::New(durationSeconds);
4031   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4032   Vector4 relativeValue(targetValue - startValue);
4033   animation.AnimateBy(Property(actor, index), relativeValue);
4034
4035   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4036
4037   // Start the animation
4038   animation.Play();
4039
4040   bool signalReceived(false);
4041   AnimationFinishCheck finishCheck(signalReceived);
4042   animation.FinishedSignal().Connect(&application, finishCheck);
4043
4044   application.SendNotification();
4045   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4046
4047   // We didn't expect the animation to finish yet
4048   application.SendNotification();
4049   finishCheck.CheckSignalNotReceived();
4050   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
4051
4052   application.SendNotification();
4053   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4054
4055   // We did expect the animation to finish
4056   application.SendNotification();
4057   finishCheck.CheckSignalReceived();
4058   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4059
4060   // Check that nothing has changed after a couple of buffer swaps
4061   application.Render(0);
4062   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4063   application.Render(0);
4064   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4065   END_TEST;
4066 }
4067
4068 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
4069 {
4070   TestApplication application;
4071
4072   Actor actor = Actor::New();
4073
4074   // Register a Vector4 property
4075   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4076   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4077   Stage::GetCurrent().Add(actor);
4078   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4079   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4080
4081   // Build the animation
4082   float durationSeconds(1.0f);
4083   Animation animation = Animation::New(durationSeconds);
4084   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4085   Vector4 relativeValue(targetValue - startValue);
4086   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4087
4088   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4089
4090   // Start the animation
4091   animation.Play();
4092
4093   bool signalReceived(false);
4094   AnimationFinishCheck finishCheck(signalReceived);
4095   animation.FinishedSignal().Connect(&application, finishCheck);
4096
4097   application.SendNotification();
4098   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4099
4100   // We didn't expect the animation to finish yet
4101   application.SendNotification();
4102   finishCheck.CheckSignalNotReceived();
4103
4104   // The position should have moved more, than with a linear alpha function
4105   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
4106   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4107   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4108   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4109   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4110
4111   application.SendNotification();
4112   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4113
4114   // We did expect the animation to finish
4115   application.SendNotification();
4116   finishCheck.CheckSignalReceived();
4117   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4118
4119   // Check that nothing has changed after a couple of buffer swaps
4120   application.Render(0);
4121   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4122   application.Render(0);
4123   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4124   END_TEST;
4125 }
4126
4127 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
4128 {
4129   TestApplication application;
4130
4131   Actor actor = Actor::New();
4132
4133   // Register a Vector4 property
4134   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4135   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4136   Stage::GetCurrent().Add(actor);
4137   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4138   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4139
4140   // Build the animation
4141   float durationSeconds(1.0f);
4142   Animation animation = Animation::New(durationSeconds);
4143   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4144   Vector4 relativeValue(targetValue - startValue);
4145   float delay = 0.5f;
4146   animation.AnimateBy(Property(actor, index),
4147                       relativeValue,
4148                       TimePeriod(delay, durationSeconds - delay));
4149
4150   // Start the animation
4151   animation.Play();
4152
4153   bool signalReceived(false);
4154   AnimationFinishCheck finishCheck(signalReceived);
4155   animation.FinishedSignal().Connect(&application, finishCheck);
4156
4157   application.SendNotification();
4158   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4159
4160   // We didn't expect the animation to finish yet
4161   application.SendNotification();
4162   finishCheck.CheckSignalNotReceived();
4163   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4164
4165   application.SendNotification();
4166   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4167
4168   // We didn't expect the animation to finish yet
4169   application.SendNotification();
4170   finishCheck.CheckSignalNotReceived();
4171   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4172
4173   application.SendNotification();
4174   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4175
4176   // We did expect the animation to finish
4177   application.SendNotification();
4178   finishCheck.CheckSignalReceived();
4179   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4180
4181   // Check that nothing has changed after a couple of buffer swaps
4182   application.Render(0);
4183   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4184   application.Render(0);
4185   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4186   END_TEST;
4187 }
4188
4189 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
4190 {
4191   TestApplication application;
4192
4193   Actor actor = Actor::New();
4194
4195   // Register a Vector4 property
4196   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4197   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4198   Stage::GetCurrent().Add(actor);
4199   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4200   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4201
4202   // Build the animation
4203   float durationSeconds(1.0f);
4204   Animation animation = Animation::New(durationSeconds);
4205   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4206   Vector4 relativeValue(targetValue - startValue);
4207   float delay = 0.5f;
4208   animation.AnimateBy(Property(actor, index),
4209                       relativeValue,
4210                       AlphaFunction::LINEAR,
4211                       TimePeriod(delay, durationSeconds - delay));
4212
4213   // Start the animation
4214   animation.Play();
4215
4216   bool signalReceived(false);
4217   AnimationFinishCheck finishCheck(signalReceived);
4218   animation.FinishedSignal().Connect(&application, finishCheck);
4219
4220   application.SendNotification();
4221   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4222
4223   // We didn't expect the animation to finish yet
4224   application.SendNotification();
4225   finishCheck.CheckSignalNotReceived();
4226   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
4227
4228   application.SendNotification();
4229   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4230
4231   // We didn't expect the animation to finish yet
4232   application.SendNotification();
4233   finishCheck.CheckSignalNotReceived();
4234   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
4235
4236   application.SendNotification();
4237   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4238
4239   // We did expect the animation to finish
4240   application.SendNotification();
4241   finishCheck.CheckSignalReceived();
4242   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4243
4244   // Check that nothing has changed after a couple of buffer swaps
4245   application.Render(0);
4246   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4247   application.Render(0);
4248   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
4249   END_TEST;
4250 }
4251
4252 int UtcDaliAnimationAnimateByActorPositionP(void)
4253 {
4254   TestApplication application;
4255
4256   Actor actor = Actor::New();
4257   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4258   actor.SetPosition(startPosition);
4259   Stage::GetCurrent().Add(actor);
4260   application.SendNotification();
4261   application.Render(0);
4262   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4263
4264   // Build the animation
4265   float durationSeconds(1.0f);
4266   Animation animation = Animation::New(durationSeconds);
4267   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4268   Vector3 relativePosition(targetPosition - startPosition);
4269   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4270
4271   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4272
4273   // Start the animation
4274   animation.Play();
4275
4276   bool signalReceived(false);
4277   AnimationFinishCheck finishCheck(signalReceived);
4278   animation.FinishedSignal().Connect(&application, finishCheck);
4279
4280   application.SendNotification();
4281   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4282
4283   // We didn't expect the animation to finish yet
4284   application.SendNotification();
4285   finishCheck.CheckSignalNotReceived();
4286   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4287
4288   application.SendNotification();
4289   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4290
4291   // We did expect the animation to finish
4292   application.SendNotification();
4293   finishCheck.CheckSignalReceived();
4294   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4295
4296   // Check that nothing has changed after a couple of buffer swaps
4297   application.Render(0);
4298   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4299   application.Render(0);
4300   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4301   END_TEST;
4302 }
4303
4304 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
4305 {
4306   TestApplication application;
4307
4308   Actor actor = Actor::New();
4309   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4310   actor.SetPosition(startPosition);
4311   Stage::GetCurrent().Add(actor);
4312   application.SendNotification();
4313   application.Render(0);
4314   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4315
4316   // Build the animation
4317   float durationSeconds(1.0f);
4318   Animation animation = Animation::New(durationSeconds);
4319   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4320   Vector3 relativePosition(targetPosition - startPosition);
4321   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4322
4323   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4324
4325   // Start the animation
4326   animation.Play();
4327
4328   bool signalReceived(false);
4329   AnimationFinishCheck finishCheck(signalReceived);
4330   animation.FinishedSignal().Connect(&application, finishCheck);
4331
4332   application.SendNotification();
4333   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4334
4335   // We didn't expect the animation to finish yet
4336   application.SendNotification();
4337   finishCheck.CheckSignalNotReceived();
4338
4339   // The position should have moved more, than with a linear alpha function
4340   Vector3 current(actor.GetCurrentPosition());
4341   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4342   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4343   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4344
4345   application.SendNotification();
4346   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4347
4348   // We did expect the animation to finish
4349   application.SendNotification();
4350   finishCheck.CheckSignalReceived();
4351   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4352
4353   // Check that nothing has changed after a couple of buffer swaps
4354   application.Render(0);
4355   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4356   application.Render(0);
4357   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4358   END_TEST;
4359 }
4360
4361 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
4362 {
4363   TestApplication application;
4364
4365   Actor actor = Actor::New();
4366   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4367   actor.SetPosition(startPosition);
4368   Stage::GetCurrent().Add(actor);
4369   application.SendNotification();
4370   application.Render(0);
4371   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4372
4373   // Build the animation
4374   float durationSeconds(1.0f);
4375   Animation animation = Animation::New(durationSeconds);
4376   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4377   Vector3 relativePosition(targetPosition - startPosition);
4378   float delay = 0.5f;
4379   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4380                       relativePosition,
4381                       TimePeriod(delay, durationSeconds - delay));
4382
4383   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4384
4385   // Start the animation
4386   animation.Play();
4387
4388   bool signalReceived(false);
4389   AnimationFinishCheck finishCheck(signalReceived);
4390   animation.FinishedSignal().Connect(&application, finishCheck);
4391
4392   application.SendNotification();
4393   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4394
4395   // We didn't expect the animation to finish yet
4396   application.SendNotification();
4397   finishCheck.CheckSignalNotReceived();
4398   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4399
4400   application.SendNotification();
4401   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4402
4403   // We did expect the animation to finish
4404   application.SendNotification();
4405   finishCheck.CheckSignalReceived();
4406   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4407
4408   // Check that nothing has changed after a couple of buffer swaps
4409   application.Render(0);
4410   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4411   application.Render(0);
4412   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4413   END_TEST;
4414 }
4415
4416 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
4417 {
4418   TestApplication application;
4419
4420   Actor actor = Actor::New();
4421   Vector3 startPosition(10.0f, 10.0f, 10.0f);
4422   actor.SetPosition(startPosition);
4423   Stage::GetCurrent().Add(actor);
4424   application.SendNotification();
4425   application.Render(0);
4426   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4427
4428   // Build the animation
4429   float durationSeconds(1.0f);
4430   Animation animation = Animation::New(durationSeconds);
4431   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4432   Vector3 relativePosition(targetPosition - startPosition);
4433   float delay = 0.5f;
4434   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4435                       relativePosition,
4436                       AlphaFunction::LINEAR,
4437                       TimePeriod(delay, durationSeconds - delay));
4438
4439   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4440
4441   // Start the animation
4442   animation.Play();
4443
4444   bool signalReceived(false);
4445   AnimationFinishCheck finishCheck(signalReceived);
4446   animation.FinishedSignal().Connect(&application, finishCheck);
4447
4448   application.SendNotification();
4449   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4450
4451   // We didn't expect the animation to finish yet
4452   application.SendNotification();
4453   finishCheck.CheckSignalNotReceived();
4454   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4455
4456   application.SendNotification();
4457   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4458
4459   // We did expect the animation to finish
4460   application.SendNotification();
4461   finishCheck.CheckSignalReceived();
4462   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4463
4464   // Check that nothing has changed after a couple of buffer swaps
4465   application.Render(0);
4466   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4467   application.Render(0);
4468   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4469   END_TEST;
4470 }
4471
4472 int UtcDaliAnimationAnimateByActorOrientationP1(void)
4473 {
4474   TestApplication application;
4475
4476   Actor actor = Actor::New();
4477   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4478   Stage::GetCurrent().Add(actor);
4479   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4480
4481   // Build the animation
4482   float durationSeconds(1.0f);
4483   Animation animation = Animation::New(durationSeconds);
4484   Degree relativeRotationDegrees(360.0f);
4485   Radian relativeRotationRadians(relativeRotationDegrees);
4486   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
4487
4488   // Start the animation
4489   animation.Play();
4490
4491   bool signalReceived(false);
4492   AnimationFinishCheck finishCheck(signalReceived);
4493   animation.FinishedSignal().Connect(&application, finishCheck);
4494
4495   application.SendNotification();
4496   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4497
4498   // We didn't expect the animation to finish yet
4499   application.SendNotification();
4500   finishCheck.CheckSignalNotReceived();
4501   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4502
4503   application.SendNotification();
4504   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4505
4506   // We didn't expect the animation to finish yet
4507   application.SendNotification();
4508   finishCheck.CheckSignalNotReceived();
4509   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4510
4511   application.SendNotification();
4512   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4513
4514   // We didn't expect the animation to finish yet
4515   application.SendNotification();
4516   finishCheck.CheckSignalNotReceived();
4517   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4518
4519   application.SendNotification();
4520   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4521
4522   // We did expect the animation to finish
4523   application.SendNotification();
4524   finishCheck.CheckSignalReceived();
4525   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4526   END_TEST;
4527 }
4528
4529 int UtcDaliAnimationAnimateByActorOrientationP2(void)
4530 {
4531   TestApplication application;
4532
4533   tet_printf("Testing that rotation angle > 360 performs full rotations\n");
4534
4535   Actor actor = Actor::New();
4536   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4537   Stage::GetCurrent().Add(actor);
4538   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4539
4540   // Build the animation
4541   float durationSeconds(1.0f);
4542   Animation animation = Animation::New(durationSeconds);
4543   Degree relativeRotationDegrees(710.0f);
4544   Radian relativeRotationRadians(relativeRotationDegrees);
4545
4546   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( relativeRotationRadians, Vector3::ZAXIS ) );
4547
4548   // Start the animation
4549   animation.Play();
4550
4551   bool signalReceived(false);
4552   AnimationFinishCheck finishCheck(signalReceived);
4553   animation.FinishedSignal().Connect(&application, finishCheck);
4554
4555   application.SendNotification();
4556   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4557
4558   // We didn't expect the animation to finish yet
4559   application.SendNotification();
4560   finishCheck.CheckSignalNotReceived();
4561   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4562
4563   application.SendNotification();
4564   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4565
4566   // We didn't expect the animation to finish yet
4567   application.SendNotification();
4568   finishCheck.CheckSignalNotReceived();
4569   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4570
4571   application.SendNotification();
4572   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4573
4574   // We didn't expect the animation to finish yet
4575   application.SendNotification();
4576   finishCheck.CheckSignalNotReceived();
4577   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4578
4579   application.SendNotification();
4580   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4581
4582   // We did expect the animation to finish
4583   application.SendNotification();
4584   finishCheck.CheckSignalReceived();
4585   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4586   END_TEST;
4587 }
4588
4589
4590 int UtcDaliAnimationAnimateByActorOrientationP3(void)
4591 {
4592   TestApplication application;
4593
4594   tet_printf("Testing that rotation angle > 360 performs partial rotations when cast to Quaternion\n");
4595
4596   Actor actor = Actor::New();
4597   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ) );
4598   Stage::GetCurrent().Add(actor);
4599   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4600
4601   // Build the animation
4602   float durationSeconds(1.0f);
4603   Animation animation = Animation::New(durationSeconds);
4604   Degree relativeRotationDegrees(730.0f);
4605   Radian relativeRotationRadians(relativeRotationDegrees);
4606
4607   Radian actualRotationRadians( Degree(10.0f) );
4608
4609   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::ZAXIS ) );
4610
4611   // Start the animation
4612   animation.Play();
4613
4614   bool signalReceived(false);
4615   AnimationFinishCheck finishCheck(signalReceived);
4616   animation.FinishedSignal().Connect(&application, finishCheck);
4617
4618   application.SendNotification();
4619   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4620
4621   // We didn't expect the animation to finish yet
4622   application.SendNotification();
4623   finishCheck.CheckSignalNotReceived();
4624   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.25f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4625
4626   application.SendNotification();
4627   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4628
4629   // We didn't expect the animation to finish yet
4630   application.SendNotification();
4631   finishCheck.CheckSignalNotReceived();
4632   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.5f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4633
4634   application.SendNotification();
4635   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4636
4637   // We didn't expect the animation to finish yet
4638   application.SendNotification();
4639   finishCheck.CheckSignalNotReceived();
4640   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians * 0.75f, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4641
4642   application.SendNotification();
4643   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4644
4645   // We did expect the animation to finish
4646   application.SendNotification();
4647   finishCheck.CheckSignalReceived();
4648   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(actualRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4649   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::ZAXIS), ROTATION_EPSILON, TEST_LOCATION );
4650   END_TEST;
4651 }
4652
4653
4654 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
4655 {
4656   TestApplication application;
4657
4658   Actor actor = Actor::New();
4659   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4660   Stage::GetCurrent().Add(actor);
4661   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4662
4663   // Build the animation
4664   float durationSeconds(1.0f);
4665   Animation animation = Animation::New(durationSeconds);
4666   Degree relativeRotationDegrees(360.0f);
4667   Radian relativeRotationRadians(relativeRotationDegrees);
4668   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
4669
4670   // Start the animation
4671   animation.Play();
4672
4673   bool signalReceived(false);
4674   AnimationFinishCheck finishCheck(signalReceived);
4675   animation.FinishedSignal().Connect(&application, finishCheck);
4676
4677   application.SendNotification();
4678   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4679
4680   // We didn't expect the animation to finish yet
4681   application.SendNotification();
4682   finishCheck.CheckSignalNotReceived();
4683   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4684
4685   application.SendNotification();
4686   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4687
4688   // We didn't expect the animation to finish yet
4689   application.SendNotification();
4690   finishCheck.CheckSignalNotReceived();
4691   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4692
4693   application.SendNotification();
4694   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4695
4696   // We didn't expect the animation to finish yet
4697   application.SendNotification();
4698   finishCheck.CheckSignalNotReceived();
4699   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4700
4701   application.SendNotification();
4702   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4703
4704   // We did expect the animation to finish
4705   application.SendNotification();
4706   finishCheck.CheckSignalReceived();
4707   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4708   END_TEST;
4709 }
4710
4711 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
4712 {
4713   TestApplication application;
4714
4715   Actor actor = Actor::New();
4716   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
4717   Stage::GetCurrent().Add(actor);
4718   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
4719
4720   // Build the animation
4721   float durationSeconds(1.0f);
4722   Animation animation = Animation::New(durationSeconds);
4723   Degree relativeRotationDegrees(360.0f);
4724   Radian relativeRotationRadians(relativeRotationDegrees);
4725   float delay = 0.3f;
4726   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
4727                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
4728
4729   // Start the animation
4730   animation.Play();
4731
4732   bool signalReceived(false);
4733   AnimationFinishCheck finishCheck(signalReceived);
4734   animation.FinishedSignal().Connect(&application, finishCheck);
4735
4736   application.SendNotification();
4737   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
4738
4739   // We didn't expect the animation to finish yet
4740   application.SendNotification();
4741   finishCheck.CheckSignalNotReceived();
4742   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
4743   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4744
4745   application.SendNotification();
4746   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
4747
4748   // We didn't expect the animation to finish yet
4749   application.SendNotification();
4750   finishCheck.CheckSignalNotReceived();
4751   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
4752   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4753
4754   application.SendNotification();
4755   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
4756
4757   // We didn't expect the animation to finish yet
4758   application.SendNotification();
4759   finishCheck.CheckSignalNotReceived();
4760   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
4761   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4762
4763   application.SendNotification();
4764   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4765
4766   // We did expect the animation to finish
4767   application.SendNotification();
4768   finishCheck.CheckSignalReceived();
4769   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
4770   END_TEST;
4771 }
4772
4773 int UtcDaliAnimationAnimateByActorScaleP(void)
4774 {
4775   TestApplication application;
4776
4777   Actor actor = Actor::New();
4778   Stage::GetCurrent().Add(actor);
4779   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4780
4781   // Build the animation
4782   float durationSeconds(1.0f);
4783   Animation animation = Animation::New(durationSeconds);
4784   Vector3 targetScale(2.0f, 2.0f, 2.0f);
4785   Vector3 relativeScale(targetScale - Vector3::ONE);
4786   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
4787
4788   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
4789
4790   // Start the animation
4791   animation.Play();
4792
4793   bool signalReceived(false);
4794   AnimationFinishCheck finishCheck(signalReceived);
4795   animation.FinishedSignal().Connect(&application, finishCheck);
4796
4797   application.SendNotification();
4798   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4799
4800   // We didn't expect the animation to finish yet
4801   application.SendNotification();
4802   finishCheck.CheckSignalNotReceived();
4803   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
4804
4805   application.SendNotification();
4806   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4807
4808   // We did expect the animation to finish
4809   application.SendNotification();
4810   finishCheck.CheckSignalReceived();
4811   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4812
4813   // Reset everything
4814   finishCheck.Reset();
4815   actor.SetScale(Vector3::ONE);
4816   application.SendNotification();
4817   application.Render(0);
4818   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4819
4820   // Repeat with a different (ease-in) alpha function
4821   animation = Animation::New(durationSeconds);
4822   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
4823   animation.FinishedSignal().Connect(&application, finishCheck);
4824   animation.Play();
4825
4826   application.SendNotification();
4827   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
4828
4829   // We didn't expect the animation to finish yet
4830   application.SendNotification();
4831   finishCheck.CheckSignalNotReceived();
4832
4833   // The scale should have grown less, than with a linear alpha function
4834   Vector3 current(actor.GetCurrentScale());
4835   DALI_TEST_CHECK( current.x > 1.0f );
4836   DALI_TEST_CHECK( current.y > 1.0f );
4837   DALI_TEST_CHECK( current.z > 1.0f );
4838   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
4839   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
4840   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
4841
4842   application.SendNotification();
4843   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
4844
4845   // We did expect the animation to finish
4846   application.SendNotification();
4847   finishCheck.CheckSignalReceived();
4848   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
4849
4850   // Reset everything
4851   finishCheck.Reset();
4852   actor.SetScale(Vector3::ONE);
4853   application.SendNotification();
4854   application.Render(0);
4855   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4856
4857   // Repeat with a delay
4858   float delay = 0.5f;
4859   animation = Animation::New(durationSeconds);
4860   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
4861   animation.FinishedSignal().Connect(&application, finishCheck);
4862   animation.Play();
4863
4864   application.SendNotification();
4865   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4866
4867   // We didn't expect the animation to finish yet
4868   application.SendNotification();
4869   finishCheck.CheckSignalNotReceived();
4870   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
4871
4872   application.SendNotification();
4873   application.Render(static_cast<unsigned int>(durationSeconds*500.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.GetCurrentScale(), targetScale, TEST_LOCATION );
4879   END_TEST;
4880 }
4881
4882 int UtcDaliAnimationAnimateToBooleanP(void)
4883 {
4884   TestApplication application;
4885
4886   Actor actor = Actor::New();
4887
4888   // Register a boolean property
4889   const bool startValue(false);
4890   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4891   Stage::GetCurrent().Add(actor);
4892   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4893   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
4894
4895   // Build the animation
4896   float durationSeconds(2.0f);
4897   Animation animation = Animation::New(durationSeconds);
4898   const bool targetValue( !startValue );
4899   animation.AnimateTo(Property(actor, index), targetValue);
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*950.0f)/* 95% progress */);
4910
4911   // We didn't expect the animation to finish yet
4912   application.SendNotification();
4913   finishCheck.CheckSignalNotReceived();
4914   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
4915
4916   application.SendNotification();
4917   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4918
4919   // We did expect the animation to finish
4920   application.SendNotification();
4921   finishCheck.CheckSignalReceived();
4922   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
4923
4924   // Check that nothing has changed after a couple of buffer swaps
4925   application.Render(0);
4926   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
4927   application.Render(0);
4928   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
4929
4930   // Repeat with target value "false"
4931   animation = Animation::New(durationSeconds);
4932   const bool finalValue( !targetValue );
4933   animation.AnimateTo(Property(actor, index), finalValue);
4934
4935   // Start the animation
4936   animation.Play();
4937
4938   finishCheck.Reset();
4939   animation.FinishedSignal().Connect(&application, finishCheck);
4940
4941   application.SendNotification();
4942   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4943
4944   // We didn't expect the animation to finish yet
4945   application.SendNotification();
4946   finishCheck.CheckSignalNotReceived();
4947   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
4948
4949   application.SendNotification();
4950   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4951
4952   // We did expect the animation to finish
4953   application.SendNotification();
4954   finishCheck.CheckSignalReceived();
4955   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
4956
4957   // Check that nothing has changed after a couple of buffer swaps
4958   application.Render(0);
4959   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
4960   application.Render(0);
4961   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
4962   END_TEST;
4963 }
4964
4965 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
4966 {
4967   TestApplication application;
4968
4969   Actor actor = Actor::New();
4970
4971   // Register a boolean property
4972   const bool startValue(false);
4973   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4974   Stage::GetCurrent().Add(actor);
4975   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4976   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
4977
4978   // Build the animation
4979   float durationSeconds(2.0f);
4980   Animation animation = Animation::New(durationSeconds);
4981   const bool targetValue( !startValue );
4982   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
4983
4984   // Start the animation
4985   animation.Play();
4986
4987   bool signalReceived(false);
4988   AnimationFinishCheck finishCheck(signalReceived);
4989   animation.FinishedSignal().Connect(&application, finishCheck);
4990
4991   application.SendNotification();
4992   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4993
4994   // We didn't expect the animation to finish yet
4995   application.SendNotification();
4996   finishCheck.CheckSignalNotReceived();
4997   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
4998
4999   application.SendNotification();
5000   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5001
5002   // We did expect the animation to finish
5003   application.SendNotification();
5004   finishCheck.CheckSignalReceived();
5005   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5006
5007   // Check that nothing has changed after a couple of buffer swaps
5008   application.Render(0);
5009   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5010   application.Render(0);
5011   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5012
5013   // Repeat with target value "false"
5014   animation = Animation::New(durationSeconds);
5015   const bool finalValue( !targetValue );
5016   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
5017
5018   // Start the animation
5019   animation.Play();
5020
5021   finishCheck.Reset();
5022   animation.FinishedSignal().Connect(&application, finishCheck);
5023
5024   application.SendNotification();
5025   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5026
5027   // We didn't expect the animation to finish yet
5028   application.SendNotification();
5029   finishCheck.CheckSignalNotReceived();
5030   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == targetValue );
5031
5032   application.SendNotification();
5033   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5034
5035   // We did expect the animation to finish
5036   application.SendNotification();
5037   finishCheck.CheckSignalReceived();
5038   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5039
5040   // Check that nothing has changed after a couple of buffer swaps
5041   application.Render(0);
5042   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5043   application.Render(0);
5044   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5045   END_TEST;
5046 }
5047
5048 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
5049 {
5050   TestApplication application;
5051
5052   Actor actor = Actor::New();
5053
5054   // Register a boolean property
5055   bool startValue(false);
5056   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5057   Stage::GetCurrent().Add(actor);
5058   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5059   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5060
5061   // Build the animation
5062   float durationSeconds(2.0f);
5063   Animation animation = Animation::New(durationSeconds);
5064   bool finalValue( !startValue );
5065   float animatorDurationSeconds(durationSeconds * 0.5f);
5066   animation.AnimateTo( Property(actor, index),
5067                        finalValue,
5068                        TimePeriod( animatorDurationSeconds ) );
5069
5070   // Start the animation
5071   animation.Play();
5072
5073   bool signalReceived(false);
5074   AnimationFinishCheck finishCheck(signalReceived);
5075   animation.FinishedSignal().Connect(&application, finishCheck);
5076
5077   application.SendNotification();
5078   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5079
5080   // We didn't expect the animation to finish yet
5081   application.SendNotification();
5082   finishCheck.CheckSignalNotReceived();
5083   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5084
5085   application.SendNotification();
5086   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5087
5088   // We didn't expect the animation to finish yet...
5089   application.SendNotification();
5090   finishCheck.CheckSignalNotReceived();
5091
5092   // ...however we should have reached the final value
5093   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5094
5095   application.SendNotification();
5096   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5097
5098   // We did expect the animation to finish
5099   application.SendNotification();
5100   finishCheck.CheckSignalReceived();
5101   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5102
5103   // Check that nothing has changed after a couple of buffer swaps
5104   application.Render(0);
5105   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5106   application.Render(0);
5107   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5108   END_TEST;
5109 }
5110
5111 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
5112 {
5113   TestApplication application;
5114
5115   Actor actor = Actor::New();
5116
5117   // Register a boolean property
5118   bool startValue(false);
5119   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5120   Stage::GetCurrent().Add(actor);
5121   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
5122   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5123
5124   // Build the animation
5125   float durationSeconds(2.0f);
5126   Animation animation = Animation::New(durationSeconds);
5127   bool finalValue( !startValue );
5128   float animatorDurationSeconds(durationSeconds * 0.5f);
5129   animation.AnimateTo( Property(actor, index),
5130                        finalValue,
5131                        AlphaFunction::LINEAR,
5132                        TimePeriod( animatorDurationSeconds ) );
5133
5134   // Start the animation
5135   animation.Play();
5136
5137   bool signalReceived(false);
5138   AnimationFinishCheck finishCheck(signalReceived);
5139   animation.FinishedSignal().Connect(&application, finishCheck);
5140
5141   application.SendNotification();
5142   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
5143
5144   // We didn't expect the animation to finish yet
5145   application.SendNotification();
5146   finishCheck.CheckSignalNotReceived();
5147   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == startValue );
5148
5149   application.SendNotification();
5150   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
5151
5152   // We didn't expect the animation to finish yet...
5153   application.SendNotification();
5154   finishCheck.CheckSignalNotReceived();
5155
5156   // ...however we should have reached the final value
5157   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5158
5159   application.SendNotification();
5160   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
5161
5162   // We did expect the animation to finish
5163   application.SendNotification();
5164   finishCheck.CheckSignalReceived();
5165   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5166
5167   // Check that nothing has changed after a couple of buffer swaps
5168   application.Render(0);
5169   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5170   application.Render(0);
5171   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( index ) == finalValue );
5172   END_TEST;
5173 }
5174
5175 int UtcDaliAnimationAnimateToFloatP(void)
5176 {
5177   TestApplication application;
5178
5179   Actor actor = Actor::New();
5180
5181   // Register a float property
5182   float startValue(10.0f);
5183   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5184   Stage::GetCurrent().Add(actor);
5185   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5186   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5187
5188   // Build the animation
5189   float durationSeconds(2.0f);
5190   Animation animation = Animation::New(durationSeconds);
5191   float targetValue(50.0f);
5192   float relativeValue(targetValue - startValue);
5193   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5194
5195   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5196
5197   // Start the animation
5198   animation.Play();
5199
5200   bool signalReceived(false);
5201   AnimationFinishCheck finishCheck(signalReceived);
5202   animation.FinishedSignal().Connect(&application, finishCheck);
5203
5204   application.SendNotification();
5205   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5206
5207   // We didn't expect the animation to finish yet
5208   application.SendNotification();
5209   finishCheck.CheckSignalNotReceived();
5210   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5211
5212   application.SendNotification();
5213   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5214
5215   // We did expect the animation to finish
5216   application.SendNotification();
5217   finishCheck.CheckSignalReceived();
5218   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5219   END_TEST;
5220 }
5221
5222 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
5223 {
5224   TestApplication application;
5225
5226   Actor actor = Actor::New();
5227
5228   // Register a float property
5229   float startValue(10.0f);
5230   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5231   Stage::GetCurrent().Add(actor);
5232   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5233   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5234
5235   // Build the animation
5236   float durationSeconds(1.0f);
5237   Animation animation = Animation::New(durationSeconds);
5238   float targetValue(90.0f);
5239   float relativeValue(targetValue - startValue);
5240   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5241
5242   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5243
5244   // Start the animation
5245   animation.Play();
5246
5247   bool signalReceived(false);
5248   AnimationFinishCheck finishCheck(signalReceived);
5249   animation.FinishedSignal().Connect(&application, finishCheck);
5250
5251   application.SendNotification();
5252   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5253
5254   // We didn't expect the animation to finish yet
5255   application.SendNotification();
5256   finishCheck.CheckSignalNotReceived();
5257
5258   // The position should have moved more, than with a linear alpha function
5259   float current( actor.GetCurrentProperty< float >( index ) );
5260   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5261
5262   application.SendNotification();
5263   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5264
5265   // We did expect the animation to finish
5266   application.SendNotification();
5267   finishCheck.CheckSignalReceived();
5268   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5269   END_TEST;
5270 }
5271
5272 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
5273 {
5274   TestApplication application;
5275
5276   Actor actor = Actor::New();
5277
5278   // Register a float property
5279   float startValue(10.0f);
5280   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5281   Stage::GetCurrent().Add(actor);
5282   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5283   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5284
5285   // Build the animation
5286   float durationSeconds(1.0f);
5287   Animation animation = Animation::New(durationSeconds);
5288   float targetValue(30.0f);
5289   float relativeValue(targetValue - startValue);
5290   float delay = 0.5f;
5291   animation.AnimateTo(Property(actor, index),
5292                       targetValue,
5293                       TimePeriod(delay, durationSeconds - delay));
5294
5295   // Start the animation
5296   animation.Play();
5297
5298   bool signalReceived(false);
5299   AnimationFinishCheck finishCheck(signalReceived);
5300   animation.FinishedSignal().Connect(&application, finishCheck);
5301
5302   application.SendNotification();
5303   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5304
5305   // We didn't expect the animation to finish yet
5306   application.SendNotification();
5307   finishCheck.CheckSignalNotReceived();
5308   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5309
5310   application.SendNotification();
5311   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5312
5313   // We didn't expect the animation to finish yet
5314   application.SendNotification();
5315   finishCheck.CheckSignalNotReceived();
5316   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5317
5318   application.SendNotification();
5319   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5320
5321   // We did expect the animation to finish
5322   application.SendNotification();
5323   finishCheck.CheckSignalReceived();
5324   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5325   END_TEST;
5326 }
5327
5328 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
5329 {
5330   TestApplication application;
5331
5332   Actor actor = Actor::New();
5333
5334   // Register a float property
5335   float startValue(10.0f);
5336   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5337   Stage::GetCurrent().Add(actor);
5338   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
5339   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5340
5341   // Build the animation
5342   float durationSeconds(1.0f);
5343   Animation animation = Animation::New(durationSeconds);
5344   float targetValue(30.0f);
5345   float relativeValue(targetValue - startValue);
5346   float delay = 0.5f;
5347   animation.AnimateTo(Property(actor, index),
5348                       targetValue,
5349                       AlphaFunction::LINEAR,
5350                       TimePeriod(delay, durationSeconds - delay));
5351
5352   // Start the animation
5353   animation.Play();
5354
5355   bool signalReceived(false);
5356   AnimationFinishCheck finishCheck(signalReceived);
5357   animation.FinishedSignal().Connect(&application, finishCheck);
5358
5359   application.SendNotification();
5360   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5361
5362   // We didn't expect the animation to finish yet
5363   application.SendNotification();
5364   finishCheck.CheckSignalNotReceived();
5365   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
5366
5367   application.SendNotification();
5368   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5369
5370   // We didn't expect the animation to finish yet
5371   application.SendNotification();
5372   finishCheck.CheckSignalNotReceived();
5373   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5374
5375   application.SendNotification();
5376   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5377
5378   // We did expect the animation to finish
5379   application.SendNotification();
5380   finishCheck.CheckSignalReceived();
5381   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
5382   END_TEST;
5383 }
5384
5385 int UtcDaliAnimationAnimateToIntegerP(void)
5386 {
5387   TestApplication application;
5388
5389   Actor actor = Actor::New();
5390
5391   // Register an integer property
5392   int startValue(10);
5393   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5394   Stage::GetCurrent().Add(actor);
5395   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5396   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5397
5398   // Build the animation
5399   float durationSeconds(2.0f);
5400   Animation animation = Animation::New(durationSeconds);
5401   int targetValue(50);
5402   int relativeValue(targetValue - startValue);
5403   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
5404
5405   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5406
5407   // Start the animation
5408   animation.Play();
5409
5410   bool signalReceived(false);
5411   AnimationFinishCheck finishCheck(signalReceived);
5412   animation.FinishedSignal().Connect(&application, finishCheck);
5413
5414   application.SendNotification();
5415   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5416
5417   // We didn't expect the animation to finish yet
5418   application.SendNotification();
5419   finishCheck.CheckSignalNotReceived();
5420   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5421
5422   application.SendNotification();
5423   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5424
5425   // We did expect the animation to finish
5426   application.SendNotification();
5427   finishCheck.CheckSignalReceived();
5428   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5429   END_TEST;
5430 }
5431
5432 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
5433 {
5434   TestApplication application;
5435
5436   Actor actor = Actor::New();
5437
5438   // Register an integer property
5439   int startValue(10);
5440   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5441   Stage::GetCurrent().Add(actor);
5442   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5443   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5444
5445   // Build the animation
5446   float durationSeconds(1.0f);
5447   Animation animation = Animation::New(durationSeconds);
5448   int targetValue(90);
5449   int relativeValue(targetValue - startValue);
5450   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5451
5452   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
5453
5454   // Start the animation
5455   animation.Play();
5456
5457   bool signalReceived(false);
5458   AnimationFinishCheck finishCheck(signalReceived);
5459   animation.FinishedSignal().Connect(&application, finishCheck);
5460
5461   application.SendNotification();
5462   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5463
5464   // We didn't expect the animation to finish yet
5465   application.SendNotification();
5466   finishCheck.CheckSignalNotReceived();
5467
5468   // The position should have moved more, than with a linear alpha function
5469   int current( actor.GetCurrentProperty< int >( index ) );
5470   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
5471
5472   application.SendNotification();
5473   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5474
5475   // We did expect the animation to finish
5476   application.SendNotification();
5477   finishCheck.CheckSignalReceived();
5478   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5479   END_TEST;
5480 }
5481
5482 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
5483 {
5484   TestApplication application;
5485
5486   Actor actor = Actor::New();
5487
5488   // Register an integer property
5489   int startValue(10);
5490   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5491   Stage::GetCurrent().Add(actor);
5492   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5493   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5494
5495   // Build the animation
5496   float durationSeconds(1.0f);
5497   Animation animation = Animation::New(durationSeconds);
5498   int targetValue(30);
5499   int relativeValue(targetValue - startValue);
5500   float delay = 0.5f;
5501   animation.AnimateTo(Property(actor, index),
5502                       targetValue,
5503                       TimePeriod(delay, durationSeconds - delay));
5504
5505   // Start the animation
5506   animation.Play();
5507
5508   bool signalReceived(false);
5509   AnimationFinishCheck finishCheck(signalReceived);
5510   animation.FinishedSignal().Connect(&application, finishCheck);
5511
5512   application.SendNotification();
5513   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5514
5515   // We didn't expect the animation to finish yet
5516   application.SendNotification();
5517   finishCheck.CheckSignalNotReceived();
5518   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5519
5520   application.SendNotification();
5521   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5522
5523   // We didn't expect the animation to finish yet
5524   application.SendNotification();
5525   finishCheck.CheckSignalNotReceived();
5526   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5527
5528   application.SendNotification();
5529   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5530
5531   // We did expect the animation to finish
5532   application.SendNotification();
5533   finishCheck.CheckSignalReceived();
5534   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5535   END_TEST;
5536 }
5537
5538 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
5539 {
5540   TestApplication application;
5541
5542   Actor actor = Actor::New();
5543
5544   // Register an integer property
5545   int startValue(10);
5546   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5547   Stage::GetCurrent().Add(actor);
5548   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
5549   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5550
5551   // Build the animation
5552   float durationSeconds(1.0f);
5553   Animation animation = Animation::New(durationSeconds);
5554   int targetValue(30);
5555   int relativeValue(targetValue - startValue);
5556   float delay = 0.5f;
5557   animation.AnimateTo(Property(actor, index),
5558                       targetValue,
5559                       AlphaFunction::LINEAR,
5560                       TimePeriod(delay, durationSeconds - delay));
5561
5562   // Start the animation
5563   animation.Play();
5564
5565   bool signalReceived(false);
5566   AnimationFinishCheck finishCheck(signalReceived);
5567   animation.FinishedSignal().Connect(&application, finishCheck);
5568
5569   application.SendNotification();
5570   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5571
5572   // We didn't expect the animation to finish yet
5573   application.SendNotification();
5574   finishCheck.CheckSignalNotReceived();
5575   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
5576
5577   application.SendNotification();
5578   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5579
5580   // We didn't expect the animation to finish yet
5581   application.SendNotification();
5582   finishCheck.CheckSignalNotReceived();
5583   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
5584
5585   application.SendNotification();
5586   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5587
5588   // We did expect the animation to finish
5589   application.SendNotification();
5590   finishCheck.CheckSignalReceived();
5591   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), targetValue, TEST_LOCATION );
5592   END_TEST;
5593 }
5594
5595 int UtcDaliAnimationAnimateToVector2P(void)
5596 {
5597   TestApplication application;
5598
5599   Actor actor = Actor::New();
5600
5601   // Register a Vector2 property
5602   Vector2 startValue(-50.0f, -50.0f);
5603   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5604   Stage::GetCurrent().Add(actor);
5605   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5606   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5607
5608   // Build the animation
5609   float durationSeconds(2.0f);
5610   Animation animation = Animation::New(durationSeconds);
5611   Vector2 targetValue(50.0f, 50.0f);
5612   Vector2 relativeValue(targetValue - startValue);
5613   animation.AnimateTo(Property(actor, index), targetValue);
5614
5615   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5616
5617   // Start the animation
5618   animation.Play();
5619
5620   bool signalReceived(false);
5621   AnimationFinishCheck finishCheck(signalReceived);
5622   animation.FinishedSignal().Connect(&application, finishCheck);
5623
5624   application.SendNotification();
5625   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5626
5627   // We didn't expect the animation to finish yet
5628   application.SendNotification();
5629   finishCheck.CheckSignalNotReceived();
5630   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5631
5632   application.SendNotification();
5633   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5634
5635   // We did expect the animation to finish
5636   application.SendNotification();
5637   finishCheck.CheckSignalReceived();
5638   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5639   END_TEST;
5640 }
5641
5642 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
5643 {
5644   TestApplication application;
5645
5646   Actor actor = Actor::New();
5647
5648   // Register a Vector2 property
5649   Vector2 startValue(1000.0f, 1000.0f);
5650   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5651   Stage::GetCurrent().Add(actor);
5652   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5653   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5654
5655   // Build the animation
5656   float durationSeconds(1.0f);
5657   Animation animation = Animation::New(durationSeconds);
5658   Vector2 targetValue(9000.0f, 9000.0f);
5659   Vector2 relativeValue(targetValue - startValue);
5660   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
5661
5662   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5663
5664   // Start the animation
5665   animation.Play();
5666
5667   bool signalReceived(false);
5668   AnimationFinishCheck finishCheck(signalReceived);
5669   animation.FinishedSignal().Connect(&application, finishCheck);
5670
5671   application.SendNotification();
5672   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5673
5674   // We didn't expect the animation to finish yet
5675   application.SendNotification();
5676   finishCheck.CheckSignalNotReceived();
5677
5678   // The position should have moved more, than with a linear alpha function
5679   Vector2 current( actor.GetCurrentProperty< Vector2 >( index ) );
5680   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
5681   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
5682
5683   application.SendNotification();
5684   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5685
5686   // We did expect the animation to finish
5687   application.SendNotification();
5688   finishCheck.CheckSignalReceived();
5689   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5690   END_TEST;
5691 }
5692
5693 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
5694 {
5695   TestApplication application;
5696
5697   Actor actor = Actor::New();
5698
5699   // Register a Vector2 property
5700   Vector2 startValue(10.0f, 10.0f);
5701   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5702   Stage::GetCurrent().Add(actor);
5703   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5704   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5705
5706   // Build the animation
5707   float durationSeconds(1.0f);
5708   Animation animation = Animation::New(durationSeconds);
5709   Vector2 targetValue(-10.0f, 20.0f);
5710   Vector2 relativeValue(targetValue - startValue);
5711   float delay = 0.5f;
5712   animation.AnimateTo(Property(actor, index),
5713                       targetValue,
5714                       TimePeriod(delay, durationSeconds - delay));
5715
5716   // Start the animation
5717   animation.Play();
5718
5719   bool signalReceived(false);
5720   AnimationFinishCheck finishCheck(signalReceived);
5721   animation.FinishedSignal().Connect(&application, finishCheck);
5722
5723   application.SendNotification();
5724   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5725
5726   // We didn't expect the animation to finish yet
5727   application.SendNotification();
5728   finishCheck.CheckSignalNotReceived();
5729   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5730
5731   application.SendNotification();
5732   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5733
5734   // We didn't expect the animation to finish yet
5735   application.SendNotification();
5736   finishCheck.CheckSignalNotReceived();
5737   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5738
5739   application.SendNotification();
5740   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5741
5742   // We did expect the animation to finish
5743   application.SendNotification();
5744   finishCheck.CheckSignalReceived();
5745   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5746   END_TEST;
5747 }
5748
5749 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
5750 {
5751   TestApplication application;
5752
5753   Actor actor = Actor::New();
5754
5755   // Register a Vector2 property
5756   Vector2 startValue(10.0f, 10.0f);
5757   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5758   Stage::GetCurrent().Add(actor);
5759   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5760   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue, TEST_LOCATION );
5761
5762   // Build the animation
5763   float durationSeconds(1.0f);
5764   Animation animation = Animation::New(durationSeconds);
5765   Vector2 targetValue(30.0f, 30.0f);
5766   Vector2 relativeValue(targetValue - startValue);
5767   float delay = 0.5f;
5768   animation.AnimateTo(Property(actor, index),
5769                       targetValue,
5770                       AlphaFunction::LINEAR,
5771                       TimePeriod(delay, durationSeconds - delay));
5772
5773   // Start the animation
5774   animation.Play();
5775
5776   bool signalReceived(false);
5777   AnimationFinishCheck finishCheck(signalReceived);
5778   animation.FinishedSignal().Connect(&application, finishCheck);
5779
5780   application.SendNotification();
5781   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5782
5783   // We didn't expect the animation to finish yet, but cached value should be the final one
5784   application.SendNotification();
5785   finishCheck.CheckSignalNotReceived();
5786   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5787   DALI_TEST_EQUALS( actor.GetCurrentProperty<Vector2>( index ), startValue, TEST_LOCATION );
5788
5789   application.SendNotification();
5790   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5791
5792   // We didn't expect the animation to finish yet
5793   application.SendNotification();
5794   finishCheck.CheckSignalNotReceived();
5795   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5796
5797   application.SendNotification();
5798   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5799
5800   // We did expect the animation to finish
5801   application.SendNotification();
5802   finishCheck.CheckSignalReceived();
5803   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5804   DALI_TEST_EQUALS( actor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
5805   END_TEST;
5806 }
5807
5808 int UtcDaliAnimationAnimateToVector3P(void)
5809 {
5810   TestApplication application;
5811
5812   Actor actor = Actor::New();
5813
5814   // Register a Vector3 property
5815   Vector3 startValue(-50.0f, -50.0f, -50.0f);
5816   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5817   Stage::GetCurrent().Add(actor);
5818   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( index ), startValue, TEST_LOCATION );
5819   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
5820
5821   // Build the animation
5822   float durationSeconds(2.0f);
5823   Animation animation = Animation::New(durationSeconds);
5824   Vector3 targetValue(50.0f, 50.0f, 50.0f);
5825   Vector3 relativeValue(targetValue - startValue);
5826   animation.AnimateTo(Property(actor, index), targetValue);
5827
5828   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5829
5830   // Start the animation
5831   animation.Play();
5832
5833   bool signalReceived(false);
5834   AnimationFinishCheck finishCheck(signalReceived);
5835   animation.FinishedSignal().Connect(&application, finishCheck);
5836
5837   application.SendNotification();
5838   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5839
5840   // We didn't expect the animation to finish yet
5841   application.SendNotification();
5842   finishCheck.CheckSignalNotReceived();
5843   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
5844
5845   application.SendNotification();
5846   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5847
5848   // We did expect the animation to finish
5849   application.SendNotification();
5850   finishCheck.CheckSignalReceived();
5851   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
5852   END_TEST;
5853 }
5854
5855 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
5856 {
5857   TestApplication application;
5858
5859   Actor actor = Actor::New();
5860
5861   // Register a Vector3 property
5862   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
5863   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5864   Stage::GetCurrent().Add(actor);
5865   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5866   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
5867
5868   // Build the animation
5869   float durationSeconds(1.0f);
5870   Animation animation = Animation::New(durationSeconds);
5871   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
5872   Vector3 relativeValue(targetValue - startValue);
5873   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
5874
5875   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
5876
5877   // Start the animation
5878   animation.Play();
5879
5880   bool signalReceived(false);
5881   AnimationFinishCheck finishCheck(signalReceived);
5882   animation.FinishedSignal().Connect(&application, finishCheck);
5883
5884   application.SendNotification();
5885   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
5886
5887   // We didn't expect the animation to finish yet
5888   application.SendNotification();
5889   finishCheck.CheckSignalNotReceived();
5890
5891   // The position should have moved more, than with a linear alpha function
5892   Vector3 current( actor.GetCurrentProperty< Vector3 >( index ) );
5893   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
5894   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
5895   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
5896
5897   application.SendNotification();
5898   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5899
5900   // We did expect the animation to finish
5901   application.SendNotification();
5902   finishCheck.CheckSignalReceived();
5903   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
5904   END_TEST;
5905 }
5906
5907 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
5908 {
5909   TestApplication application;
5910
5911   Actor actor = Actor::New();
5912
5913   // Register a Vector3 property
5914   Vector3 startValue(10.0f, 10.0f, 10.0f);
5915   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5916   Stage::GetCurrent().Add(actor);
5917   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5918   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
5919
5920   // Build the animation
5921   float durationSeconds(1.0f);
5922   Animation animation = Animation::New(durationSeconds);
5923   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
5924   Vector3 relativeValue(targetValue - startValue);
5925   float delay = 0.5f;
5926   animation.AnimateTo(Property(actor, index),
5927                       targetValue,
5928                       TimePeriod(delay, durationSeconds - delay));
5929
5930   // Start the animation
5931   animation.Play();
5932
5933   bool signalReceived(false);
5934   AnimationFinishCheck finishCheck(signalReceived);
5935   animation.FinishedSignal().Connect(&application, finishCheck);
5936
5937   application.SendNotification();
5938   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5939
5940   // We didn't expect the animation to finish yet
5941   application.SendNotification();
5942   finishCheck.CheckSignalNotReceived();
5943   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
5944
5945   application.SendNotification();
5946   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5947
5948   // We didn't expect the animation to finish yet
5949   application.SendNotification();
5950   finishCheck.CheckSignalNotReceived();
5951   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
5952
5953   application.SendNotification();
5954   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5955
5956   // We did expect the animation to finish
5957   application.SendNotification();
5958   finishCheck.CheckSignalReceived();
5959   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
5960   END_TEST;
5961 }
5962
5963 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
5964 {
5965   TestApplication application;
5966
5967   Actor actor = Actor::New();
5968
5969   // Register a Vector3 property
5970   Vector3 startValue(10.0f, 10.0f, 10.0f);
5971   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5972   Stage::GetCurrent().Add(actor);
5973   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
5974   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
5975
5976   // Build the animation
5977   float durationSeconds(1.0f);
5978   Animation animation = Animation::New(durationSeconds);
5979   Vector3 targetValue(30.0f, 30.0f, 30.0f);
5980   Vector3 relativeValue(targetValue - startValue);
5981   float delay = 0.5f;
5982   animation.AnimateTo(Property(actor, "testProperty"),
5983                       targetValue,
5984                       AlphaFunction::LINEAR,
5985                       TimePeriod(delay, durationSeconds - delay));
5986
5987   // Start the animation
5988   animation.Play();
5989
5990   bool signalReceived(false);
5991   AnimationFinishCheck finishCheck(signalReceived);
5992   animation.FinishedSignal().Connect(&application, finishCheck);
5993
5994   application.SendNotification();
5995   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5996
5997   // We didn't expect the animation to finish yet
5998   application.SendNotification();
5999   finishCheck.CheckSignalNotReceived();
6000   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6001
6002   application.SendNotification();
6003   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6004
6005   // We didn't expect the animation to finish yet
6006   application.SendNotification();
6007   finishCheck.CheckSignalNotReceived();
6008   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6009
6010   application.SendNotification();
6011   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6012
6013   // We did expect the animation to finish
6014   application.SendNotification();
6015   finishCheck.CheckSignalReceived();
6016   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6017   END_TEST;
6018 }
6019
6020 int UtcDaliAnimationAnimateToVector3ComponentP(void)
6021 {
6022   TestApplication application;
6023
6024   Actor actor = Actor::New();
6025
6026   // Register a Vector3 property
6027   Vector3 startValue(10.0f, 10.0f, 10.0f);
6028   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6029   Stage::GetCurrent().Add(actor);
6030   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
6031   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6032
6033   // Build the animation
6034   float durationSeconds(1.0f);
6035   Animation animation = Animation::New(durationSeconds);
6036   Vector3 targetValue(30.0f, 30.0f, 10.0f);
6037   Vector3 relativeValue(targetValue - startValue);
6038   float delay = 0.5f;
6039   animation.AnimateTo(Property(actor, "testProperty",  0),
6040                       30.0f,
6041                       AlphaFunction::LINEAR,
6042                       TimePeriod(delay, durationSeconds - delay));
6043   animation.AnimateTo(Property(actor, index, 1),
6044                       30.0f,
6045                       AlphaFunction::LINEAR,
6046                       TimePeriod(delay, durationSeconds - delay));
6047
6048   // Start the animation
6049   animation.Play();
6050
6051   bool signalReceived(false);
6052   AnimationFinishCheck finishCheck(signalReceived);
6053   animation.FinishedSignal().Connect(&application, finishCheck);
6054
6055   application.SendNotification();
6056   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6057
6058   // We didn't expect the animation to finish yet
6059   application.SendNotification();
6060   finishCheck.CheckSignalNotReceived();
6061   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue, TEST_LOCATION );
6062
6063   application.SendNotification();
6064   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6065
6066   // We didn't expect the animation to finish yet
6067   application.SendNotification();
6068   finishCheck.CheckSignalNotReceived();
6069   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6070
6071   application.SendNotification();
6072   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6073
6074   // We did expect the animation to finish
6075   application.SendNotification();
6076   finishCheck.CheckSignalReceived();
6077   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
6078   END_TEST;
6079 }
6080
6081 int UtcDaliAnimationAnimateToVector4P(void)
6082 {
6083   TestApplication application;
6084
6085   Actor actor = Actor::New();
6086
6087   // Register a Vector4 property
6088   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
6089   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6090   Stage::GetCurrent().Add(actor);
6091   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6092   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6093
6094   // Build the animation
6095   float durationSeconds(2.0f);
6096   Animation animation = Animation::New(durationSeconds);
6097   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
6098   Vector4 relativeValue(targetValue - startValue);
6099   animation.AnimateTo(Property(actor, index), targetValue);
6100
6101   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6102
6103   // Start the animation
6104   animation.Play();
6105
6106   bool signalReceived(false);
6107   AnimationFinishCheck finishCheck(signalReceived);
6108   animation.FinishedSignal().Connect(&application, finishCheck);
6109
6110   application.SendNotification();
6111   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6112
6113   // We didn't expect the animation to finish yet
6114   application.SendNotification();
6115   finishCheck.CheckSignalNotReceived();
6116   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), ninetyFivePercentProgress, TEST_LOCATION );
6117
6118   application.SendNotification();
6119   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6120
6121   // We did expect the animation to finish
6122   application.SendNotification();
6123   finishCheck.CheckSignalReceived();
6124   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6125   END_TEST;
6126 }
6127
6128 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
6129 {
6130   TestApplication application;
6131
6132   Actor actor = Actor::New();
6133
6134   // Register a Vector4 property
6135   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
6136   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6137   Stage::GetCurrent().Add(actor);
6138   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6139   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6140
6141   // Build the animation
6142   float durationSeconds(1.0f);
6143   Animation animation = Animation::New(durationSeconds);
6144   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
6145   Vector4 relativeValue(targetValue - startValue);
6146   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
6147
6148   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
6149
6150   // Start the animation
6151   animation.Play();
6152
6153   bool signalReceived(false);
6154   AnimationFinishCheck finishCheck(signalReceived);
6155   animation.FinishedSignal().Connect(&application, finishCheck);
6156
6157   application.SendNotification();
6158   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
6159
6160   // We didn't expect the animation to finish yet
6161   application.SendNotification();
6162   finishCheck.CheckSignalNotReceived();
6163
6164   // The position should have moved more, than with a linear alpha function
6165   Vector4 current( actor.GetCurrentProperty< Vector4 >( index ) );
6166   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
6167   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
6168   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
6169   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
6170
6171   application.SendNotification();
6172   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
6173
6174   // We did expect the animation to finish
6175   application.SendNotification();
6176   finishCheck.CheckSignalReceived();
6177   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6178   END_TEST;
6179 }
6180
6181 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
6182 {
6183   TestApplication application;
6184
6185   Actor actor = Actor::New();
6186
6187   // Register a Vector4 property
6188   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6189   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6190   Stage::GetCurrent().Add(actor);
6191   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6192   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6193
6194   // Build the animation
6195   float durationSeconds(1.0f);
6196   Animation animation = Animation::New(durationSeconds);
6197   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
6198   Vector4 relativeValue(targetValue - startValue);
6199   float delay = 0.5f;
6200   animation.AnimateTo(Property(actor, index),
6201                       targetValue,
6202                       TimePeriod(delay, durationSeconds - delay));
6203
6204   // Start the animation
6205   animation.Play();
6206
6207   bool signalReceived(false);
6208   AnimationFinishCheck finishCheck(signalReceived);
6209   animation.FinishedSignal().Connect(&application, finishCheck);
6210
6211   application.SendNotification();
6212   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6213
6214   // We didn't expect the animation to finish yet
6215   application.SendNotification();
6216   finishCheck.CheckSignalNotReceived();
6217   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, VECTOR4_EPSILON, TEST_LOCATION );
6218
6219   application.SendNotification();
6220   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6221
6222   // We didn't expect the animation to finish yet
6223   application.SendNotification();
6224   finishCheck.CheckSignalNotReceived();
6225   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
6226
6227   application.SendNotification();
6228   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6229
6230   // We did expect the animation to finish
6231   application.SendNotification();
6232   finishCheck.CheckSignalReceived();
6233   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
6234   END_TEST;
6235 }
6236
6237 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
6238 {
6239   TestApplication application;
6240
6241   Actor actor = Actor::New();
6242
6243   // Register a Vector4 property
6244   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
6245   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
6246   Stage::GetCurrent().Add(actor);
6247   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
6248   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6249
6250   // Build the animation
6251   float durationSeconds(1.0f);
6252   Animation animation = Animation::New(durationSeconds);
6253   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
6254   Vector4 relativeValue(targetValue - startValue);
6255   float delay = 0.5f;
6256   animation.AnimateTo(Property(actor, index),
6257                       targetValue,
6258                       AlphaFunction::LINEAR,
6259                       TimePeriod(delay, durationSeconds - delay));
6260
6261   // Start the animation
6262   animation.Play();
6263
6264   bool signalReceived(false);
6265   AnimationFinishCheck finishCheck(signalReceived);
6266   animation.FinishedSignal().Connect(&application, finishCheck);
6267
6268   application.SendNotification();
6269   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6270
6271   // We didn't expect the animation to finish yet
6272   application.SendNotification();
6273   finishCheck.CheckSignalNotReceived();
6274   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue, TEST_LOCATION );
6275
6276   application.SendNotification();
6277   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
6278
6279   // We didn't expect the animation to finish yet
6280   application.SendNotification();
6281   finishCheck.CheckSignalNotReceived();
6282   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
6283
6284   application.SendNotification();
6285   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6286
6287   // We did expect the animation to finish
6288   application.SendNotification();
6289   finishCheck.CheckSignalReceived();
6290   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
6291   END_TEST;
6292 }
6293
6294 int UtcDaliAnimationAnimateToActorParentOriginP(void)
6295 {
6296   TestApplication application;
6297
6298   Actor actor = Actor::New();
6299   Stage::GetCurrent().Add(actor);
6300   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
6301
6302   // Build the animation
6303   float durationSeconds(1.0f);
6304   Animation animation = Animation::New(durationSeconds);
6305   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
6306
6307   try
6308   {
6309     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
6310   }
6311   catch (Dali::DaliException& e)
6312   {
6313     DALI_TEST_PRINT_ASSERT( e );
6314     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6315   }
6316   END_TEST;
6317 }
6318
6319 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
6320 {
6321   TestApplication application;
6322
6323   Actor actor = Actor::New();
6324   Stage::GetCurrent().Add(actor);
6325   float startValue(0.0f);
6326   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
6327   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
6328
6329   // Build the animation
6330   float durationSeconds(1.0f);
6331   Animation animation = Animation::New(durationSeconds);
6332   float targetX(1.0f);
6333
6334   try
6335   {
6336     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
6337   }
6338   catch (Dali::DaliException& e)
6339   {
6340     DALI_TEST_PRINT_ASSERT( e );
6341     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6342   }
6343   END_TEST;
6344 }
6345
6346 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
6347 {
6348   TestApplication application;
6349
6350   Actor actor = Actor::New();
6351   Stage::GetCurrent().Add(actor);
6352   float startValue(0.0f);
6353   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
6354   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
6355
6356   // Build the animation
6357   float durationSeconds(1.0f);
6358   Animation animation = Animation::New(durationSeconds);
6359   float targetY(1.0f);
6360
6361   try
6362   {
6363     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
6364   }
6365   catch (Dali::DaliException& e)
6366   {
6367     DALI_TEST_PRINT_ASSERT( e );
6368     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6369   }
6370   END_TEST;
6371 }
6372
6373 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
6374 {
6375   TestApplication application;
6376
6377   Actor actor = Actor::New();
6378   Stage::GetCurrent().Add(actor);
6379   float startValue(0.5f);
6380   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
6381   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
6382
6383   // Build the animation
6384   float durationSeconds(1.0f);
6385   Animation animation = Animation::New(durationSeconds);
6386   float targetZ(1.0f);
6387
6388   try
6389   {
6390     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
6391   }
6392   catch (Dali::DaliException& e)
6393   {
6394     DALI_TEST_PRINT_ASSERT( e );
6395     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6396   }
6397   END_TEST;
6398 }
6399
6400 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
6401 {
6402   TestApplication application;
6403
6404   Actor actor = Actor::New();
6405   Stage::GetCurrent().Add(actor);
6406   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
6407
6408   // Build the animation
6409   float durationSeconds(1.0f);
6410   Animation animation = Animation::New(durationSeconds);
6411   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
6412
6413   try
6414   {
6415     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
6416   }
6417   catch (Dali::DaliException& e)
6418   {
6419     DALI_TEST_PRINT_ASSERT( e );
6420     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6421   }
6422   END_TEST;
6423 }
6424
6425 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
6426 {
6427   TestApplication application;
6428
6429   Actor actor = Actor::New();
6430   Stage::GetCurrent().Add(actor);
6431   float startValue(0.5f);
6432   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
6433   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
6434
6435   // Build the animation
6436   float durationSeconds(1.0f);
6437   Animation animation = Animation::New(durationSeconds);
6438   float targetX(1.0f);
6439
6440   try
6441   {
6442     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
6443   }
6444   catch (Dali::DaliException& e)
6445   {
6446     DALI_TEST_PRINT_ASSERT( e );
6447     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6448   }
6449   END_TEST;
6450 }
6451
6452 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
6453 {
6454   TestApplication application;
6455
6456   Actor actor = Actor::New();
6457   Stage::GetCurrent().Add(actor);
6458   float startValue(0.5f);
6459   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
6460   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
6461
6462   // Build the animation
6463   float durationSeconds(1.0f);
6464   Animation animation = Animation::New(durationSeconds);
6465   float targetY(0.0f);
6466
6467   try
6468   {
6469     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
6470   }
6471   catch (Dali::DaliException& e)
6472   {
6473     DALI_TEST_PRINT_ASSERT( e );
6474     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6475   }
6476   END_TEST;
6477 }
6478
6479 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
6480 {
6481   TestApplication application;
6482
6483   Actor actor = Actor::New();
6484   Stage::GetCurrent().Add(actor);
6485   float startValue(0.5f);
6486   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
6487   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
6488
6489   // Build the animation
6490   float durationSeconds(1.0f);
6491   Animation animation = Animation::New(durationSeconds);
6492   float targetZ(100.0f);
6493
6494   try
6495   {
6496     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
6497   }
6498   catch (Dali::DaliException& e)
6499   {
6500     DALI_TEST_PRINT_ASSERT( e );
6501     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
6502   }
6503   END_TEST;
6504 }
6505
6506 int UtcDaliAnimationAnimateToActorSizeP(void)
6507 {
6508   TestApplication application;
6509
6510   Actor actor = Actor::New();
6511   Stage::GetCurrent().Add(actor);
6512   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6513
6514   // Build the animation
6515   float durationSeconds(1.0f);
6516   Animation animation = Animation::New(durationSeconds);
6517   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6518   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
6519
6520   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6521
6522   // Should return the initial properties before play
6523   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6524   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), 0.0f, TEST_LOCATION );
6525   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), 0.0f, TEST_LOCATION );
6526   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), 0.0f, TEST_LOCATION );
6527
6528   // Start the animation
6529   animation.Play();
6530
6531   // Should return the target property after play
6532   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), targetSize, TEST_LOCATION );
6533   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetSize.width, TEST_LOCATION );
6534   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetSize.height, TEST_LOCATION );
6535   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetSize.depth, TEST_LOCATION );
6536
6537   bool signalReceived(false);
6538   AnimationFinishCheck finishCheck(signalReceived);
6539   animation.FinishedSignal().Connect(&application, finishCheck);
6540
6541   application.SendNotification();
6542   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6543
6544   // We didn't expect the animation to finish yet
6545   application.SendNotification();
6546   finishCheck.CheckSignalNotReceived();
6547   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6548
6549   application.SendNotification();
6550   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6551
6552   // We did expect the animation to finish
6553   application.SendNotification();
6554   finishCheck.CheckSignalReceived();
6555   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6556
6557   // Reset everything
6558   finishCheck.Reset();
6559   actor.SetSize(Vector3::ZERO);
6560   application.SendNotification();
6561   application.Render(0);
6562   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6563
6564   // Repeat with a different (ease-in) alpha function
6565   animation = Animation::New(durationSeconds);
6566   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
6567   animation.FinishedSignal().Connect(&application, finishCheck);
6568   animation.Play();
6569
6570   application.SendNotification();
6571   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6572
6573   // We didn't expect the animation to finish yet
6574   application.SendNotification();
6575   finishCheck.CheckSignalNotReceived();
6576
6577   // The size should have travelled less, than with a linear alpha function
6578   Vector3 current(actor.GetCurrentSize());
6579   DALI_TEST_CHECK( current.x > 0.0f );
6580   DALI_TEST_CHECK( current.y > 0.0f );
6581   DALI_TEST_CHECK( current.z > 0.0f );
6582   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6583   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6584   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6585
6586   application.SendNotification();
6587   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6588
6589   // We did expect the animation to finish
6590   application.SendNotification();
6591   finishCheck.CheckSignalReceived();
6592   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6593
6594   // Reset everything
6595   finishCheck.Reset();
6596   actor.SetSize(Vector3::ZERO);
6597   application.SendNotification();
6598   application.Render(0);
6599   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6600
6601   // Repeat with a delay
6602   float delay = 0.5f;
6603   animation = Animation::New(durationSeconds);
6604   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6605   animation.FinishedSignal().Connect(&application, finishCheck);
6606   animation.Play();
6607
6608   application.SendNotification();
6609   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6610
6611   // We didn't expect the animation to finish yet
6612   application.SendNotification();
6613   finishCheck.CheckSignalNotReceived();
6614   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6615
6616   application.SendNotification();
6617   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6618
6619   // We did expect the animation to finish
6620   application.SendNotification();
6621   finishCheck.CheckSignalReceived();
6622   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6623   END_TEST;
6624 }
6625
6626 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
6627 {
6628   TestApplication application;
6629
6630   Actor actor = Actor::New();
6631   Stage::GetCurrent().Add(actor);
6632   float startValue(0.0f);
6633   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
6634   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
6635
6636   // Build the animation
6637   float durationSeconds(1.0f);
6638   Animation animation = Animation::New(durationSeconds);
6639   float targetWidth(10.0f);
6640   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
6641
6642   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
6643
6644   // Should return the initial properties before play
6645   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6646   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), startValue, TEST_LOCATION );
6647
6648   // Start the animation
6649   animation.Play();
6650
6651   // Should return the target property after play
6652   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( targetWidth, 0.0f, 0.0f ), TEST_LOCATION );
6653   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), targetWidth, TEST_LOCATION );
6654
6655   bool signalReceived(false);
6656   AnimationFinishCheck finishCheck(signalReceived);
6657   animation.FinishedSignal().Connect(&application, finishCheck);
6658
6659   application.SendNotification();
6660   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6661
6662   // We didn't expect the animation to finish yet
6663   application.SendNotification();
6664   finishCheck.CheckSignalNotReceived();
6665   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
6666
6667   application.SendNotification();
6668   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6669
6670   // We did expect the animation to finish
6671   application.SendNotification();
6672   finishCheck.CheckSignalReceived();
6673   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
6674   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
6675   END_TEST;
6676 }
6677
6678 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
6679 {
6680   TestApplication application;
6681
6682   Actor actor = Actor::New();
6683   Stage::GetCurrent().Add(actor);
6684   float startValue(0.0f);
6685   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
6686   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
6687
6688   // Build the animation
6689   float durationSeconds(1.0f);
6690   Animation animation = Animation::New(durationSeconds);
6691   float targetHeight(-10.0f);
6692   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
6693
6694   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
6695
6696   // Should return the initial properties before play
6697   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6698   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), startValue, TEST_LOCATION );
6699
6700   // Start the animation
6701   animation.Play();
6702
6703   // Should return the target property after play
6704   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, targetHeight, 0.0f ), TEST_LOCATION );
6705   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), targetHeight, TEST_LOCATION );
6706
6707   bool signalReceived(false);
6708   AnimationFinishCheck finishCheck(signalReceived);
6709   animation.FinishedSignal().Connect(&application, finishCheck);
6710
6711   application.SendNotification();
6712   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6713
6714   // We didn't expect the animation to finish yet
6715   application.SendNotification();
6716   finishCheck.CheckSignalNotReceived();
6717   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
6718
6719   application.SendNotification();
6720   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6721
6722   // We did expect the animation to finish
6723   application.SendNotification();
6724   finishCheck.CheckSignalReceived();
6725   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
6726   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
6727   END_TEST;
6728 }
6729
6730 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
6731 {
6732   TestApplication application;
6733
6734   Actor actor = Actor::New();
6735   Stage::GetCurrent().Add(actor);
6736   float startValue(0.0f);
6737   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
6738   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
6739
6740   // Build the animation
6741   float durationSeconds(1.0f);
6742   Animation animation = Animation::New(durationSeconds);
6743   float targetDepth(-10.0f);
6744   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
6745
6746   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
6747
6748   // Should return the initial properties before play
6749   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ZERO, TEST_LOCATION );
6750   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), startValue, TEST_LOCATION );
6751
6752   // Start the animation
6753   animation.Play();
6754
6755   // Should return the target property after play
6756   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, targetDepth ), TEST_LOCATION );
6757   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), targetDepth, TEST_LOCATION );
6758
6759   bool signalReceived(false);
6760   AnimationFinishCheck finishCheck(signalReceived);
6761   animation.FinishedSignal().Connect(&application, finishCheck);
6762
6763   application.SendNotification();
6764   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6765
6766   // We didn't expect the animation to finish yet
6767   application.SendNotification();
6768   finishCheck.CheckSignalNotReceived();
6769   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
6770
6771   application.SendNotification();
6772   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6773
6774   // We did expect the animation to finish
6775   application.SendNotification();
6776   finishCheck.CheckSignalReceived();
6777   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
6778   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
6779   END_TEST;
6780 }
6781
6782 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
6783 {
6784   TestApplication application;
6785
6786   Actor actor = Actor::New();
6787   Stage::GetCurrent().Add(actor);
6788   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6789
6790   // Build the animation
6791   float durationSeconds(1.0f);
6792   Animation animation = Animation::New(durationSeconds);
6793   Vector3 targetSize(100.0f, 100.0f, 100.0f);
6794   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
6795
6796   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
6797
6798   // Start the animation
6799   animation.Play();
6800
6801   bool signalReceived(false);
6802   AnimationFinishCheck finishCheck(signalReceived);
6803   animation.FinishedSignal().Connect(&application, finishCheck);
6804
6805   application.SendNotification();
6806   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6807
6808   // We didn't expect the animation to finish yet
6809   application.SendNotification();
6810   finishCheck.CheckSignalNotReceived();
6811   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
6812
6813   application.SendNotification();
6814   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6815
6816   // We did expect the animation to finish
6817   application.SendNotification();
6818   finishCheck.CheckSignalReceived();
6819   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
6820
6821   // Reset everything
6822   finishCheck.Reset();
6823   actor.SetSize(Vector3::ZERO);
6824   application.SendNotification();
6825   application.Render(0);
6826   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6827
6828   // Repeat with a different (ease-in) alpha function
6829   animation = Animation::New(durationSeconds);
6830   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
6831   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
6832   animation.FinishedSignal().Connect(&application, finishCheck);
6833   animation.Play();
6834
6835   application.SendNotification();
6836   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6837
6838   // We didn't expect the animation to finish yet
6839   application.SendNotification();
6840   finishCheck.CheckSignalNotReceived();
6841
6842   // The size should have travelled less, than with a linear alpha function
6843   Vector3 current(actor.GetCurrentSize());
6844   DALI_TEST_CHECK( current.x > 0.0f );
6845   DALI_TEST_CHECK( current.y > 0.0f );
6846   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6847   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6848
6849   application.SendNotification();
6850   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6851
6852   // We did expect the animation to finish
6853   application.SendNotification();
6854   finishCheck.CheckSignalReceived();
6855   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
6856   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
6857
6858   // Reset everything
6859   finishCheck.Reset();
6860   actor.SetSize(Vector3::ZERO);
6861   application.SendNotification();
6862   application.Render(0);
6863   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6864
6865   // Repeat with a delay
6866   float delay = 0.5f;
6867   animation = Animation::New(durationSeconds);
6868   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
6869   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
6870   animation.FinishedSignal().Connect(&application, finishCheck);
6871   animation.Play();
6872
6873   application.SendNotification();
6874   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6875
6876   // We didn't expect the animation to finish yet
6877   application.SendNotification();
6878   finishCheck.CheckSignalNotReceived();
6879   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
6880
6881   application.SendNotification();
6882   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6883
6884   // We did expect the animation to finish
6885   application.SendNotification();
6886   finishCheck.CheckSignalReceived();
6887   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
6888   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
6889   END_TEST;
6890 }
6891
6892 int UtcDaliAnimationAnimateToActorPositionP(void)
6893 {
6894   TestApplication application;
6895
6896   Actor actor = Actor::New();
6897   Stage::GetCurrent().Add(actor);
6898   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6899
6900   // Build the animation
6901   float durationSeconds(1.0f);
6902   Animation animation = Animation::New(durationSeconds);
6903   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
6904   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
6905
6906   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6907
6908   // Should return the initial properties before play
6909   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
6910   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
6911   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), 0.0f, TEST_LOCATION );
6912   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), 0.0f, TEST_LOCATION );
6913
6914   // Start the animation
6915   animation.Play();
6916
6917   // Should return the target property after play
6918   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
6919   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetPosition.x, TEST_LOCATION );
6920   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetPosition.y, TEST_LOCATION );
6921   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetPosition.z, TEST_LOCATION );
6922
6923   bool signalReceived(false);
6924   AnimationFinishCheck finishCheck(signalReceived);
6925   animation.FinishedSignal().Connect(&application, finishCheck);
6926
6927   application.SendNotification();
6928   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
6929
6930   // We didn't expect the animation to finish yet
6931   application.SendNotification();
6932   finishCheck.CheckSignalNotReceived();
6933   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6934
6935   application.SendNotification();
6936   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6937
6938   // We did expect the animation to finish
6939   application.SendNotification();
6940   finishCheck.CheckSignalReceived();
6941   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6942   END_TEST;
6943 }
6944
6945 int UtcDaliAnimationAnimateToActorPositionXP(void)
6946 {
6947   TestApplication application;
6948
6949   Actor actor = Actor::New();
6950   Stage::GetCurrent().Add(actor);
6951   float startValue(0.0f);
6952   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
6953   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
6954   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6955   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6956
6957   // Build the animation
6958   float durationSeconds(1.0f);
6959   Animation animation = Animation::New(durationSeconds);
6960   float targetX(1.0f);
6961   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
6962
6963   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
6964
6965   // Should return the initial properties before play
6966   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
6967   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), startValue, TEST_LOCATION );
6968
6969   // Start the animation
6970   animation.Play();
6971
6972   // Should return the target property after play
6973   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( targetX, 0.0f, 0.0f ), TEST_LOCATION );
6974   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), targetX, TEST_LOCATION );
6975
6976   bool signalReceived(false);
6977   AnimationFinishCheck finishCheck(signalReceived);
6978   animation.FinishedSignal().Connect(&application, finishCheck);
6979
6980   application.SendNotification();
6981   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6982
6983   // We didn't expect the animation to finish yet
6984   application.SendNotification();
6985   finishCheck.CheckSignalNotReceived();
6986   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
6987
6988   application.SendNotification();
6989   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6990
6991   // We did expect the animation to finish
6992   application.SendNotification();
6993   finishCheck.CheckSignalReceived();
6994   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
6995   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
6996   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
6997   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
6998   END_TEST;
6999 }
7000
7001 int UtcDaliAnimationAnimateToActorPositionYP(void)
7002 {
7003   TestApplication application;
7004
7005   Actor actor = Actor::New();
7006   Stage::GetCurrent().Add(actor);
7007   float startValue(0.0f);
7008   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
7009   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7010   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7011   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7012
7013   // Build the animation
7014   float durationSeconds(1.0f);
7015   Animation animation = Animation::New(durationSeconds);
7016   float targetY(10.0f);
7017   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
7018
7019   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7020
7021   // Should return the initial properties before play
7022   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7023   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), startValue, TEST_LOCATION );
7024
7025   // Start the animation
7026   animation.Play();
7027
7028   // Should return the target property after play
7029   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, targetY, 0.0f ), TEST_LOCATION );
7030   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Y ), targetY, TEST_LOCATION );
7031
7032   bool signalReceived(false);
7033   AnimationFinishCheck finishCheck(signalReceived);
7034   animation.FinishedSignal().Connect(&application, finishCheck);
7035
7036   application.SendNotification();
7037   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7038
7039   // We didn't expect the animation to finish yet
7040   application.SendNotification();
7041   finishCheck.CheckSignalNotReceived();
7042   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
7043
7044   application.SendNotification();
7045   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7046
7047   // We did expect the animation to finish
7048   application.SendNotification();
7049   finishCheck.CheckSignalReceived();
7050   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
7051   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7052   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
7053   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7054   END_TEST;
7055 }
7056
7057 int UtcDaliAnimationAnimateToActorPositionZP(void)
7058 {
7059   TestApplication application;
7060
7061   Actor actor = Actor::New();
7062   Stage::GetCurrent().Add(actor);
7063   float startValue(0.0f);
7064   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
7065   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7066   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7067   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
7068
7069   // Build the animation
7070   float durationSeconds(1.0f);
7071   Animation animation = Animation::New(durationSeconds);
7072   float targetZ(-5.0f);
7073   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
7074
7075   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7076
7077   // Should return the initial properties before play
7078   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
7079   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), startValue, TEST_LOCATION );
7080
7081   // Start the animation
7082   animation.Play();
7083
7084   // Should return the target property after play
7085   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, targetZ ), TEST_LOCATION );
7086   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_Z ), targetZ, TEST_LOCATION );
7087
7088   bool signalReceived(false);
7089   AnimationFinishCheck finishCheck(signalReceived);
7090   animation.FinishedSignal().Connect(&application, finishCheck);
7091
7092   application.SendNotification();
7093   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7094
7095   // We didn't expect the animation to finish yet
7096   application.SendNotification();
7097   finishCheck.CheckSignalNotReceived();
7098   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
7099
7100   application.SendNotification();
7101   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7102
7103   // We did expect the animation to finish
7104   application.SendNotification();
7105   finishCheck.CheckSignalReceived();
7106   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
7107   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
7108   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
7109   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
7110   END_TEST;
7111 }
7112
7113 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
7114 {
7115   TestApplication application;
7116
7117   Actor actor = Actor::New();
7118   Stage::GetCurrent().Add(actor);
7119   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7120
7121   // Build the animation
7122   float durationSeconds(1.0f);
7123   Animation animation = Animation::New(durationSeconds);
7124   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7125   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
7126
7127   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7128
7129   // Start the animation
7130   animation.Play();
7131
7132   bool signalReceived(false);
7133   AnimationFinishCheck finishCheck(signalReceived);
7134   animation.FinishedSignal().Connect(&application, finishCheck);
7135
7136   application.SendNotification();
7137   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
7138
7139   // We didn't expect the animation to finish yet
7140   application.SendNotification();
7141   finishCheck.CheckSignalNotReceived();
7142
7143   // The position should have moved less, than with a linear alpha function
7144   Vector3 current(actor.GetCurrentPosition());
7145   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
7146   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
7147   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
7148   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
7149   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
7150   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
7151
7152   application.SendNotification();
7153   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7154
7155   // We did expect the animation to finish
7156   application.SendNotification();
7157   finishCheck.CheckSignalReceived();
7158   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7159   END_TEST;
7160 }
7161
7162 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
7163 {
7164   TestApplication application;
7165
7166   Actor actor = Actor::New();
7167   Stage::GetCurrent().Add(actor);
7168   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7169
7170   // Build the animation
7171   float durationSeconds(1.0f);
7172   Animation animation = Animation::New(durationSeconds);
7173   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7174   float delay = 0.5f;
7175   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7176                        targetPosition,
7177                        TimePeriod( delay, durationSeconds - delay ) );
7178
7179   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7180
7181   // Start the animation
7182   animation.Play();
7183
7184   bool signalReceived(false);
7185   AnimationFinishCheck finishCheck(signalReceived);
7186   animation.FinishedSignal().Connect(&application, finishCheck);
7187
7188   application.SendNotification();
7189   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7190
7191   // We didn't expect the animation to finish yet
7192   application.SendNotification();
7193   finishCheck.CheckSignalNotReceived();
7194   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7195
7196   application.SendNotification();
7197   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7198
7199   // We didn't expect the animation to finish yet
7200   application.SendNotification();
7201   finishCheck.CheckSignalNotReceived();
7202   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7203
7204   application.SendNotification();
7205   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7206
7207   // We did expect the animation to finish
7208   application.SendNotification();
7209   finishCheck.CheckSignalReceived();
7210   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7211   END_TEST;
7212 }
7213
7214 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
7215 {
7216   TestApplication application;
7217
7218   Actor actor = Actor::New();
7219   Stage::GetCurrent().Add(actor);
7220   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7221
7222   // Build the animation
7223   float durationSeconds(1.0f);
7224   Animation animation = Animation::New(durationSeconds);
7225   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
7226   float delay = 0.5f;
7227   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
7228                        targetPosition,
7229                        AlphaFunction::LINEAR,
7230                        TimePeriod( delay, durationSeconds - delay ) );
7231
7232   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
7233
7234   // Start the animation
7235   animation.Play();
7236
7237   bool signalReceived(false);
7238   AnimationFinishCheck finishCheck(signalReceived);
7239   animation.FinishedSignal().Connect(&application, finishCheck);
7240
7241   application.SendNotification();
7242   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7243
7244   // We didn't expect the animation to finish yet
7245   application.SendNotification();
7246   finishCheck.CheckSignalNotReceived();
7247   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
7248
7249   application.SendNotification();
7250   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
7251
7252   // We didn't expect the animation to finish yet
7253   application.SendNotification();
7254   finishCheck.CheckSignalNotReceived();
7255   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
7256
7257   application.SendNotification();
7258   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
7259
7260   // We did expect the animation to finish
7261   application.SendNotification();
7262   finishCheck.CheckSignalReceived();
7263   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
7264   END_TEST;
7265 }
7266
7267 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
7268 {
7269   TestApplication application;
7270
7271   Actor actor = Actor::New();
7272   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7273   Stage::GetCurrent().Add(actor);
7274   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7275
7276   // Build the animation
7277   float durationSeconds(1.0f);
7278   Animation animation = Animation::New(durationSeconds);
7279   Degree targetRotationDegrees(90.0f);
7280   Radian targetRotationRadians(targetRotationDegrees);
7281   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
7282
7283   // Start the animation
7284   animation.Play();
7285
7286   // Target value should be retrievable straight away
7287   DALI_TEST_EQUALS( actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7288
7289   bool signalReceived(false);
7290   AnimationFinishCheck finishCheck(signalReceived);
7291   animation.FinishedSignal().Connect(&application, finishCheck);
7292
7293   application.SendNotification();
7294   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7295
7296   // We didn't expect the animation to finish yet
7297   application.SendNotification();
7298   finishCheck.CheckSignalNotReceived();
7299   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7300
7301   application.SendNotification();
7302   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7303
7304   // We didn't expect the animation to finish yet
7305   application.SendNotification();
7306   finishCheck.CheckSignalNotReceived();
7307   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7308
7309   application.SendNotification();
7310   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7311
7312   // We didn't expect the animation to finish yet
7313   application.SendNotification();
7314   finishCheck.CheckSignalNotReceived();
7315   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7316
7317   application.SendNotification();
7318   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7319
7320   // We did expect the animation to finish
7321   application.SendNotification();
7322   finishCheck.CheckSignalReceived();
7323   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7324   END_TEST;
7325 }
7326
7327 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
7328 {
7329   TestApplication application;
7330
7331   Actor actor = Actor::New();
7332   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7333   Stage::GetCurrent().Add(actor);
7334   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7335
7336   // Build the animation
7337   float durationSeconds(1.0f);
7338   Animation animation = Animation::New(durationSeconds);
7339   Degree targetRotationDegrees(90.0f);
7340   Radian targetRotationRadians(targetRotationDegrees);
7341   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
7342   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
7343
7344   // Start the animation
7345   animation.Play();
7346
7347   bool signalReceived(false);
7348   AnimationFinishCheck finishCheck(signalReceived);
7349   animation.FinishedSignal().Connect(&application, finishCheck);
7350
7351   application.SendNotification();
7352   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7353
7354   // We didn't expect the animation to finish yet
7355   application.SendNotification();
7356   finishCheck.CheckSignalNotReceived();
7357   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7358
7359   application.SendNotification();
7360   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7361
7362   // We didn't expect the animation to finish yet
7363   application.SendNotification();
7364   finishCheck.CheckSignalNotReceived();
7365   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7366
7367   application.SendNotification();
7368   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7369
7370   // We didn't expect the animation to finish yet
7371   application.SendNotification();
7372   finishCheck.CheckSignalNotReceived();
7373   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7374
7375   application.SendNotification();
7376   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7377
7378   // We did expect the animation to finish
7379   application.SendNotification();
7380   finishCheck.CheckSignalReceived();
7381   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7382   END_TEST;
7383 }
7384
7385 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
7386 {
7387   TestApplication application;
7388
7389   Actor actor = Actor::New();
7390   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7391   Stage::GetCurrent().Add(actor);
7392   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7393
7394   // Build the animation
7395   float durationSeconds(1.0f);
7396   Animation animation = Animation::New(durationSeconds);
7397   Degree targetRotationDegrees(90.0f);
7398   Radian targetRotationRadians(targetRotationDegrees);
7399   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
7400
7401   // Start the animation
7402   animation.Play();
7403
7404   bool signalReceived(false);
7405   AnimationFinishCheck finishCheck(signalReceived);
7406   animation.FinishedSignal().Connect(&application, finishCheck);
7407
7408   application.SendNotification();
7409   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7410
7411   // We didn't expect the animation to finish yet
7412   application.SendNotification();
7413   finishCheck.CheckSignalNotReceived();
7414   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7415
7416   application.SendNotification();
7417   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7418
7419   // We didn't expect the animation to finish yet
7420   application.SendNotification();
7421   finishCheck.CheckSignalNotReceived();
7422   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7423
7424   application.SendNotification();
7425   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7426
7427   // We didn't expect the animation to finish yet
7428   application.SendNotification();
7429   finishCheck.CheckSignalNotReceived();
7430   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7431
7432   application.SendNotification();
7433   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7434
7435   // We did expect the animation to finish
7436   application.SendNotification();
7437   finishCheck.CheckSignalReceived();
7438   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7439   END_TEST;
7440 }
7441
7442 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
7443 {
7444   TestApplication application;
7445
7446   Actor actor = Actor::New();
7447   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7448   Stage::GetCurrent().Add(actor);
7449   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7450
7451   // Build the animation
7452   float durationSeconds(1.0f);
7453   Animation animation = Animation::New(durationSeconds);
7454   Degree targetRotationDegrees(90.0f);
7455   Radian targetRotationRadians(targetRotationDegrees);
7456   float delay(0.1f);
7457   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
7458
7459   // Start the animation
7460   animation.Play();
7461
7462   bool signalReceived(false);
7463   AnimationFinishCheck finishCheck(signalReceived);
7464   animation.FinishedSignal().Connect(&application, finishCheck);
7465
7466   application.SendNotification();
7467   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7468
7469   // We didn't expect the animation to finish yet
7470   application.SendNotification();
7471   finishCheck.CheckSignalNotReceived();
7472   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7473   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7474
7475   application.SendNotification();
7476   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7477
7478   // We didn't expect the animation to finish yet
7479   application.SendNotification();
7480   finishCheck.CheckSignalNotReceived();
7481   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7482   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7483
7484   application.SendNotification();
7485   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7486
7487   // We didn't expect the animation to finish yet
7488   application.SendNotification();
7489   finishCheck.CheckSignalNotReceived();
7490   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7491   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7492
7493   application.SendNotification();
7494   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7495
7496   // We did expect the animation to finish
7497   application.SendNotification();
7498   finishCheck.CheckSignalReceived();
7499   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7500   END_TEST;
7501 }
7502
7503 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
7504 {
7505   TestApplication application;
7506
7507   Actor actor = Actor::New();
7508   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
7509   Stage::GetCurrent().Add(actor);
7510   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
7511
7512   // Build the animation
7513   float durationSeconds(1.0f);
7514   Animation animation = Animation::New(durationSeconds);
7515   Degree targetRotationDegrees(90.0f);
7516   Radian targetRotationRadians(targetRotationDegrees);
7517   float delay(0.1f);
7518   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
7519
7520   // Start the animation
7521   animation.Play();
7522
7523   bool signalReceived(false);
7524   AnimationFinishCheck finishCheck(signalReceived);
7525   animation.FinishedSignal().Connect(&application, finishCheck);
7526
7527   application.SendNotification();
7528   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7529
7530   // We didn't expect the animation to finish yet
7531   application.SendNotification();
7532   finishCheck.CheckSignalNotReceived();
7533   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
7534   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7535
7536   application.SendNotification();
7537   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7538
7539   // We didn't expect the animation to finish yet
7540   application.SendNotification();
7541   finishCheck.CheckSignalNotReceived();
7542   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
7543   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7544
7545   application.SendNotification();
7546   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7547
7548   // We didn't expect the animation to finish yet
7549   application.SendNotification();
7550   finishCheck.CheckSignalNotReceived();
7551   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
7552   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7553
7554   application.SendNotification();
7555   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
7556
7557   // We did expect the animation to finish
7558   application.SendNotification();
7559   finishCheck.CheckSignalReceived();
7560   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
7561   END_TEST;
7562 }
7563
7564 int UtcDaliAnimationAnimateToActorScaleP(void)
7565 {
7566   TestApplication application;
7567
7568   Actor actor = Actor::New();
7569   Stage::GetCurrent().Add(actor);
7570   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7571
7572   // Build the animation
7573   float durationSeconds(1.0f);
7574   Animation animation = Animation::New(durationSeconds);
7575   Vector3 targetScale(2.0f, 2.0f, 2.0f);
7576   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
7577
7578   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
7579
7580   // Start the animation
7581   animation.Play();
7582
7583   // Target value should be retrievable straight away
7584   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), targetScale, TEST_LOCATION );
7585   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetScale.x, TEST_LOCATION );
7586   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetScale.y, TEST_LOCATION );
7587   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetScale.z, 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*990.0f)/* 99% progress */);
7595
7596   // We didn't expect the animation to finish yet
7597   application.SendNotification();
7598   finishCheck.CheckSignalNotReceived();
7599   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
7600
7601   application.SendNotification();
7602   application.Render(static_cast<unsigned int>(durationSeconds*10.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.GetCurrentScale(), targetScale, TEST_LOCATION );
7608
7609   // Reset everything
7610   finishCheck.Reset();
7611   actor.SetScale(Vector3::ONE);
7612   application.SendNotification();
7613   application.Render(0);
7614   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7615
7616   // Repeat with a different (ease-in) alpha function
7617   animation = Animation::New(durationSeconds);
7618   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
7619   animation.FinishedSignal().Connect(&application, finishCheck);
7620   animation.Play();
7621
7622   application.SendNotification();
7623   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
7624
7625   // We didn't expect the animation to finish yet
7626   application.SendNotification();
7627   finishCheck.CheckSignalNotReceived();
7628
7629   // The scale should have grown less, than with a linear alpha function
7630   Vector3 current(actor.GetCurrentScale());
7631   DALI_TEST_CHECK( current.x > 1.0f );
7632   DALI_TEST_CHECK( current.y > 1.0f );
7633   DALI_TEST_CHECK( current.z > 1.0f );
7634   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
7635   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
7636   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
7637
7638   application.SendNotification();
7639   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
7640
7641   // We did expect the animation to finish
7642   application.SendNotification();
7643   finishCheck.CheckSignalReceived();
7644   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7645
7646   // Reset everything
7647   finishCheck.Reset();
7648   actor.SetScale(Vector3::ONE);
7649   application.SendNotification();
7650   application.Render(0);
7651   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7652
7653   // Repeat with a delay
7654   float delay = 0.5f;
7655   animation = Animation::New(durationSeconds);
7656   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
7657   animation.FinishedSignal().Connect(&application, finishCheck);
7658   animation.Play();
7659
7660   application.SendNotification();
7661   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
7662
7663   // We didn't expect the animation to finish yet
7664   application.SendNotification();
7665   finishCheck.CheckSignalNotReceived();
7666   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
7667
7668   application.SendNotification();
7669   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7670
7671   // We did expect the animation to finish
7672   application.SendNotification();
7673   finishCheck.CheckSignalReceived();
7674   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
7675   END_TEST;
7676 }
7677
7678 int UtcDaliAnimationAnimateToActorScaleXP(void)
7679 {
7680   TestApplication application;
7681
7682   Actor actor = Actor::New();
7683   Stage::GetCurrent().Add(actor);
7684   float startValue(1.0f);
7685   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
7686   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7687   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7688   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7689   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7690   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7691   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7692
7693   // Build the animation
7694   float durationSeconds(1.0f);
7695   Animation animation = Animation::New(durationSeconds);
7696   float targetX(10.0f);
7697   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
7698
7699   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
7700
7701   // Start the animation
7702   animation.Play();
7703
7704   // Target value should be retrievable straight away
7705   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( targetX, startValue, startValue ), TEST_LOCATION );
7706   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
7707
7708   bool signalReceived(false);
7709   AnimationFinishCheck finishCheck(signalReceived);
7710   animation.FinishedSignal().Connect(&application, finishCheck);
7711
7712   application.SendNotification();
7713   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7714
7715   // We didn't expect the animation to finish yet
7716   application.SendNotification();
7717   finishCheck.CheckSignalNotReceived();
7718   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
7719   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), fiftyPercentProgress, TEST_LOCATION );
7720   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7721   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7722
7723   application.SendNotification();
7724   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7725
7726   // We did expect the animation to finish
7727   application.SendNotification();
7728   finishCheck.CheckSignalReceived();
7729   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
7730   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), targetX, TEST_LOCATION );
7731   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7732   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7733   END_TEST;
7734 }
7735
7736 int UtcDaliAnimationAnimateToActorScaleYP(void)
7737 {
7738   TestApplication application;
7739
7740   Actor actor = Actor::New();
7741   Stage::GetCurrent().Add(actor);
7742   float startValue(1.0f);
7743   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
7744   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7745   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7746   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7747   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7748   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7749   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7750
7751   // Build the animation
7752   float durationSeconds(1.0f);
7753   Animation animation = Animation::New(durationSeconds);
7754   float targetY(1000.0f);
7755   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
7756
7757   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
7758
7759   // Start the animation
7760   animation.Play();
7761
7762   // Target value should be retrievable straight away
7763   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, targetY, startValue ), TEST_LOCATION );
7764   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
7765
7766   bool signalReceived(false);
7767   AnimationFinishCheck finishCheck(signalReceived);
7768   animation.FinishedSignal().Connect(&application, finishCheck);
7769
7770   application.SendNotification();
7771   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7772
7773   // We didn't expect the animation to finish yet
7774   application.SendNotification();
7775   finishCheck.CheckSignalNotReceived();
7776   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
7777   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7778   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), fiftyPercentProgress, TEST_LOCATION );
7779   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7780
7781   application.SendNotification();
7782   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7783
7784   // We did expect the animation to finish
7785   application.SendNotification();
7786   finishCheck.CheckSignalReceived();
7787   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
7788   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7789   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), targetY, TEST_LOCATION );
7790   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7791   END_TEST;
7792 }
7793
7794 int UtcDaliAnimationAnimateToActorScaleZP(void)
7795 {
7796   TestApplication application;
7797
7798   Actor actor = Actor::New();
7799   Stage::GetCurrent().Add(actor);
7800   float startValue(1.0f);
7801   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
7802   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
7803   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
7804   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
7805   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7806   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7807   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), startValue, TEST_LOCATION );
7808
7809   // Build the animation
7810   float durationSeconds(1.0f);
7811   Animation animation = Animation::New(durationSeconds);
7812   float targetZ(-1000.0f);
7813   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
7814
7815   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
7816
7817   // Start the animation
7818   animation.Play();
7819
7820   // Target value should be retrievable straight away
7821   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SCALE ), Vector3( startValue, startValue, targetZ ), TEST_LOCATION );
7822   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
7823
7824   bool signalReceived(false);
7825   AnimationFinishCheck finishCheck(signalReceived);
7826   animation.FinishedSignal().Connect(&application, finishCheck);
7827
7828   application.SendNotification();
7829   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
7830
7831   // We didn't expect the animation to finish yet
7832   application.SendNotification();
7833   finishCheck.CheckSignalNotReceived();
7834   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
7835   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7836   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7837   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), fiftyPercentProgress, TEST_LOCATION );
7838
7839   application.SendNotification();
7840   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7841
7842   // We did expect the animation to finish
7843   application.SendNotification();
7844   finishCheck.CheckSignalReceived();
7845   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
7846   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), startValue, TEST_LOCATION );
7847   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), startValue, TEST_LOCATION );
7848   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), targetZ, TEST_LOCATION );
7849   END_TEST;
7850 }
7851
7852 int UtcDaliAnimationAnimateToActorColorP(void)
7853 {
7854   TestApplication application;
7855
7856   Actor actor = Actor::New();
7857   Stage::GetCurrent().Add(actor);
7858   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7859
7860   // Build the animation
7861   float durationSeconds(1.0f);
7862   Animation animation = Animation::New(durationSeconds);
7863   Vector4 targetColor(Color::RED);
7864   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
7865
7866   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
7867   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
7868
7869   // Start the animation
7870   animation.Play();
7871
7872   // Target value should be retrievable straight away
7873   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), targetColor, TEST_LOCATION );
7874   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetColor.r, TEST_LOCATION );
7875   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetColor.g, TEST_LOCATION );
7876   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetColor.b, TEST_LOCATION );
7877   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetColor.a, TEST_LOCATION );
7878   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetColor.a, TEST_LOCATION );
7879
7880   bool signalReceived(false);
7881   AnimationFinishCheck finishCheck(signalReceived);
7882   animation.FinishedSignal().Connect(&application, finishCheck);
7883
7884   application.SendNotification();
7885   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7886
7887   // We didn't expect the animation to finish yet
7888   application.SendNotification();
7889   finishCheck.CheckSignalNotReceived();
7890   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
7891
7892   application.SendNotification();
7893   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7894
7895   // We did expect the animation to finish
7896   application.SendNotification();
7897   finishCheck.CheckSignalReceived();
7898   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7899
7900   // Reset everything
7901   finishCheck.Reset();
7902   actor.SetColor(Color::WHITE);
7903   application.SendNotification();
7904   application.Render(0);
7905   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7906
7907   // Repeat with a different (ease-in) alpha function
7908   animation = Animation::New(durationSeconds);
7909   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
7910   animation.FinishedSignal().Connect(&application, finishCheck);
7911   animation.Play();
7912
7913   application.SendNotification();
7914   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7915
7916   // We didn't expect the animation to finish yet
7917   application.SendNotification();
7918   finishCheck.CheckSignalNotReceived();
7919
7920   // The color should have changed less, than with a linear alpha function
7921   Vector4 current(actor.GetCurrentColor());
7922   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
7923   DALI_TEST_CHECK( current.y < 1.0f );
7924   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
7925   DALI_TEST_CHECK( current.z  < 1.0f );
7926   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
7927   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
7928
7929   application.SendNotification();
7930   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
7931
7932   // We did expect the animation to finish
7933   application.SendNotification();
7934   finishCheck.CheckSignalReceived();
7935   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7936
7937   // Reset everything
7938   finishCheck.Reset();
7939   actor.SetColor(Color::WHITE);
7940   application.SendNotification();
7941   application.Render(0);
7942   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
7943
7944   // Repeat with a shorter animator duration
7945   float animatorDuration = 0.5f;
7946   animation = Animation::New(durationSeconds);
7947   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
7948   animation.FinishedSignal().Connect(&application, finishCheck);
7949   animation.Play();
7950
7951   application.SendNotification();
7952   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
7953
7954   // We didn't expect the animation to finish yet
7955   application.SendNotification();
7956   finishCheck.CheckSignalNotReceived();
7957   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
7958
7959   application.SendNotification();
7960   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
7961
7962   // We didn't expect the animation to finish yet
7963   application.SendNotification();
7964   finishCheck.CheckSignalNotReceived();
7965   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7966
7967   application.SendNotification();
7968   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
7969
7970   // We did expect the animation to finish
7971   application.SendNotification();
7972   finishCheck.CheckSignalReceived();
7973   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
7974   END_TEST;
7975 }
7976
7977 int UtcDaliAnimationAnimateToActorColorRedP(void)
7978 {
7979   TestApplication application;
7980
7981   Actor actor = Actor::New();
7982   Stage::GetCurrent().Add(actor);
7983   float startValue(1.0f);
7984   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
7985   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7986   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7987   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7988   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7989   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
7990   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
7991   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
7992   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
7993
7994   // Build the animation
7995   float durationSeconds(1.0f);
7996   Animation animation = Animation::New(durationSeconds);
7997   float targetRed(0.5f);
7998   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
7999
8000   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
8001
8002   // Start the animation
8003   animation.Play();
8004
8005   // Target value should be retrievable straight away
8006   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( targetRed, startValue, startValue, startValue ), TEST_LOCATION );
8007   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_RED ), targetRed, TEST_LOCATION );
8008
8009   bool signalReceived(false);
8010   AnimationFinishCheck finishCheck(signalReceived);
8011   animation.FinishedSignal().Connect(&application, finishCheck);
8012
8013   application.SendNotification();
8014   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8015
8016   // We didn't expect the animation to finish yet
8017   application.SendNotification();
8018   finishCheck.CheckSignalNotReceived();
8019   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
8020   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
8021   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
8022   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8023   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8024
8025   application.SendNotification();
8026   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8027
8028   // We did expect the animation to finish
8029   application.SendNotification();
8030   finishCheck.CheckSignalReceived();
8031   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
8032   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
8033   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8034   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8035   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8036   END_TEST;
8037 }
8038
8039 int UtcDaliAnimationAnimateToActorColorGreenP(void)
8040 {
8041   TestApplication application;
8042
8043   Actor actor = Actor::New();
8044   Stage::GetCurrent().Add(actor);
8045   float startValue(1.0f);
8046   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
8047   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8048   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8049   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8050   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8051   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8052   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8053   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8054   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8055
8056   // Build the animation
8057   float durationSeconds(1.0f);
8058   Animation animation = Animation::New(durationSeconds);
8059   float targetGreen(0.5f);
8060   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
8061
8062   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
8063
8064   // Start the animation
8065   animation.Play();
8066
8067   // Target value should be retrievable straight away
8068   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, targetGreen, startValue, startValue ), TEST_LOCATION );
8069   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), targetGreen, TEST_LOCATION );
8070
8071   bool signalReceived(false);
8072   AnimationFinishCheck finishCheck(signalReceived);
8073   animation.FinishedSignal().Connect(&application, finishCheck);
8074
8075   application.SendNotification();
8076   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8077
8078   // We didn't expect the animation to finish yet
8079   application.SendNotification();
8080   finishCheck.CheckSignalNotReceived();
8081   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
8082   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
8083   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
8084   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
8085   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
8086
8087   application.SendNotification();
8088   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8089
8090   // We did expect the animation to finish
8091   application.SendNotification();
8092   finishCheck.CheckSignalReceived();
8093   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
8094   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
8095   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
8096   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
8097   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
8098   END_TEST;
8099 }
8100
8101 int UtcDaliAnimationAnimateToActorColorBlueP(void)
8102 {
8103   TestApplication application;
8104
8105   Actor actor = Actor::New();
8106   Stage::GetCurrent().Add(actor);
8107   float startValue(1.0f);
8108   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
8109   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8110   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8111   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8112   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8113   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8114   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8115   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8116   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8117
8118   // Build the animation
8119   float durationSeconds(1.0f);
8120   Animation animation = Animation::New(durationSeconds);
8121   float targetBlue(0.5f);
8122   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
8123
8124   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
8125
8126   // Start the animation
8127   animation.Play();
8128
8129   // Target value should be retrievable straight away
8130   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, targetBlue, startValue ), TEST_LOCATION );
8131   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), targetBlue, TEST_LOCATION );
8132
8133   bool signalReceived(false);
8134   AnimationFinishCheck finishCheck(signalReceived);
8135   animation.FinishedSignal().Connect(&application, finishCheck);
8136
8137   application.SendNotification();
8138   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8139
8140   // We didn't expect the animation to finish yet
8141   application.SendNotification();
8142   finishCheck.CheckSignalNotReceived();
8143   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
8144   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8145   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8146   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  fiftyPercentProgress, TEST_LOCATION );
8147   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue,           TEST_LOCATION );
8148
8149   application.SendNotification();
8150   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8151
8152   // We did expect the animation to finish
8153   application.SendNotification();
8154   finishCheck.CheckSignalReceived();
8155   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
8156   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8157   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8158   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  targetBlue, TEST_LOCATION );
8159   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8160   END_TEST;
8161 }
8162
8163 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
8164 {
8165   TestApplication application;
8166
8167   Actor actor = Actor::New();
8168   Stage::GetCurrent().Add(actor);
8169   float startValue(1.0f);
8170   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8171   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8172   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8173   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8174   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8175   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8176   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8177   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8178   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8179
8180   // Build the animation
8181   float durationSeconds(1.0f);
8182   Animation animation = Animation::New(durationSeconds);
8183   float targetAlpha(0.5f);
8184   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
8185
8186   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
8187
8188   // Start the animation
8189   animation.Play();
8190
8191   // Target value should be retrievable straight away
8192   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( Actor::Property::COLOR ), Vector4( startValue, startValue, startValue, targetAlpha ), TEST_LOCATION );
8193   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8194   DALI_TEST_EQUALS( actor.GetProperty< float >( DevelActor::Property::OPACITY ), targetAlpha, TEST_LOCATION );
8195
8196   bool signalReceived(false);
8197   AnimationFinishCheck finishCheck(signalReceived);
8198   animation.FinishedSignal().Connect(&application, finishCheck);
8199
8200   application.SendNotification();
8201   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8202
8203   // We didn't expect the animation to finish yet
8204   application.SendNotification();
8205   finishCheck.CheckSignalNotReceived();
8206   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
8207   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,           TEST_LOCATION );
8208   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,           TEST_LOCATION );
8209   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,           TEST_LOCATION );
8210   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), fiftyPercentProgress, TEST_LOCATION );
8211
8212   application.SendNotification();
8213   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8214
8215   // We did expect the animation to finish
8216   application.SendNotification();
8217   finishCheck.CheckSignalReceived();
8218   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
8219   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue,  TEST_LOCATION );
8220   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue,  TEST_LOCATION );
8221   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue,  TEST_LOCATION );
8222   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), targetAlpha, TEST_LOCATION );
8223   END_TEST;
8224 }
8225
8226 int UtcDaliAnimationKeyFrames01P(void)
8227 {
8228   TestApplication application;
8229
8230   KeyFrames keyFrames = KeyFrames::New();
8231   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8232
8233   keyFrames.Add(0.0f, 0.1f);
8234
8235   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8236
8237   KeyFrames keyFrames2( keyFrames);
8238   DALI_TEST_CHECK( keyFrames2 );
8239   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
8240
8241   KeyFrames keyFrames3 = KeyFrames::New();
8242   keyFrames3.Add(0.6f, true);
8243   DALI_TEST_CHECK( keyFrames3 );
8244   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
8245
8246   keyFrames3 = keyFrames;
8247   DALI_TEST_CHECK( keyFrames3 );
8248   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
8249
8250   END_TEST;
8251 }
8252
8253 int UtcDaliAnimationKeyFrames02P(void)
8254 {
8255   TestApplication application;
8256
8257   KeyFrames keyFrames = KeyFrames::New();
8258   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8259
8260   keyFrames.Add(0.0f, 0.1f);
8261   keyFrames.Add(0.2f, 0.5f);
8262   keyFrames.Add(0.4f, 0.0f);
8263   keyFrames.Add(0.6f, 1.0f);
8264   keyFrames.Add(0.8f, 0.7f);
8265   keyFrames.Add(1.0f, 0.9f);
8266
8267   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
8268
8269   try
8270   {
8271     keyFrames.Add(1.9f, false);
8272   }
8273   catch (Dali::DaliException& e)
8274   {
8275     DALI_TEST_PRINT_ASSERT( e );
8276     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8277   }
8278   END_TEST;
8279 }
8280
8281 int UtcDaliAnimationKeyFrames03P(void)
8282 {
8283   TestApplication application;
8284
8285   KeyFrames keyFrames = KeyFrames::New();
8286   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8287
8288   keyFrames.Add(0.0f, true);
8289   keyFrames.Add(0.2f, false);
8290   keyFrames.Add(0.4f, false);
8291   keyFrames.Add(0.6f, true);
8292   keyFrames.Add(0.8f, true);
8293   keyFrames.Add(1.0f, false);
8294
8295   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
8296
8297   try
8298   {
8299     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8300   }
8301   catch (Dali::DaliException& e)
8302   {
8303     DALI_TEST_PRINT_ASSERT( e );
8304     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8305   }
8306   END_TEST;
8307 }
8308
8309 int UtcDaliAnimationKeyFrames04P(void)
8310 {
8311   TestApplication application;
8312
8313   KeyFrames keyFrames = KeyFrames::New();
8314   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8315
8316   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
8317   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
8318   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
8319   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
8320   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
8321   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
8322
8323   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
8324
8325   try
8326   {
8327     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
8328   }
8329   catch (Dali::DaliException& e)
8330   {
8331     DALI_TEST_PRINT_ASSERT( e );
8332     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8333   }
8334   END_TEST;
8335 }
8336
8337 int UtcDaliAnimationKeyFrames05P(void)
8338 {
8339   TestApplication application;
8340
8341   KeyFrames keyFrames = KeyFrames::New();
8342   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8343
8344   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
8345   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
8346   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
8347   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
8348   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
8349   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
8350
8351   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
8352
8353   try
8354   {
8355     keyFrames.Add(0.7f, 1.0f);
8356   }
8357   catch (Dali::DaliException& e)
8358   {
8359     DALI_TEST_PRINT_ASSERT( e );
8360     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8361   }
8362   END_TEST;
8363 }
8364
8365 int UtcDaliAnimationKeyFrames06P(void)
8366 {
8367   TestApplication application;
8368
8369   KeyFrames keyFrames = KeyFrames::New();
8370   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8371
8372   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
8373   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8374   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
8375   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
8376   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
8377   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
8378
8379   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
8380
8381   try
8382   {
8383     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8384   }
8385   catch (Dali::DaliException& e)
8386   {
8387     DALI_TEST_PRINT_ASSERT( e );
8388     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8389   }
8390   END_TEST;
8391 }
8392
8393 int UtcDaliAnimationKeyFrames07P(void)
8394 {
8395   TestApplication application;
8396
8397   KeyFrames keyFrames = KeyFrames::New();
8398   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
8399
8400   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
8401   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
8402   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
8403   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
8404   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
8405   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
8406
8407   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
8408
8409   try
8410   {
8411     keyFrames.Add(0.7f, 1.1f);
8412   }
8413   catch (Dali::DaliException& e)
8414   {
8415     DALI_TEST_PRINT_ASSERT( e );
8416     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
8417   }
8418   END_TEST;
8419 }
8420
8421 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
8422 {
8423   TestApplication application;
8424
8425   float startValue(1.0f);
8426   Actor actor = Actor::New();
8427   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8428   Stage::GetCurrent().Add(actor);
8429
8430   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8431   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8432   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8433   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8434   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8435   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8436   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8437   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8438   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8439
8440   // Build the animation
8441   float durationSeconds(1.0f);
8442   Animation animation = Animation::New(durationSeconds);
8443
8444   KeyFrames keyFrames = KeyFrames::New();
8445   keyFrames.Add(0.0f, 0.1f);
8446   keyFrames.Add(0.2f, 0.5f);
8447   keyFrames.Add(0.4f, 0.0f);
8448   keyFrames.Add(0.6f, 1.0f);
8449   keyFrames.Add(0.8f, 0.7f);
8450   keyFrames.Add(1.0f, 0.9f);
8451
8452   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
8453
8454   // Start the animation
8455   animation.Play();
8456
8457   bool signalReceived(false);
8458   AnimationFinishCheck finishCheck(signalReceived);
8459   animation.FinishedSignal().Connect(&application, finishCheck);
8460   application.SendNotification();
8461   application.Render(0);
8462   application.SendNotification();
8463   finishCheck.CheckSignalNotReceived();
8464   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8465
8466   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8467   application.SendNotification();
8468   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8469   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8470   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8471   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
8472   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
8473
8474   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8475   application.SendNotification();
8476   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8477   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8478   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
8480   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
8481
8482   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8483   application.SendNotification();
8484   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8485   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8486   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8487   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
8488   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8489
8490   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8491   application.SendNotification();
8492   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8493   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8494   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8495   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
8496   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8497
8498   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8499   application.SendNotification();
8500   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8502   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8503   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
8504   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
8505
8506   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8507   application.SendNotification();
8508   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8509   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8510   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8511   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
8512   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8513
8514   // We did expect the animation to finish
8515
8516   finishCheck.CheckSignalReceived();
8517   END_TEST;
8518 }
8519
8520 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
8521 {
8522   TestApplication application;
8523
8524   float startValue(1.0f);
8525   Actor actor = Actor::New();
8526   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8527   Stage::GetCurrent().Add(actor);
8528
8529   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8530   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8531   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8532   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8533   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8534   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8535   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8536   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8537   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8538
8539   // Build the animation
8540   float durationSeconds(1.0f);
8541   Animation animation = Animation::New(durationSeconds);
8542
8543   KeyFrames keyFrames = KeyFrames::New();
8544   keyFrames.Add(0.0f, 0.1f);
8545   keyFrames.Add(0.2f, 0.5f);
8546   keyFrames.Add(0.4f, 0.0f);
8547   keyFrames.Add(0.6f, 1.0f);
8548   keyFrames.Add(0.8f, 0.7f);
8549   keyFrames.Add(1.0f, 0.9f);
8550
8551   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
8552
8553   // Start the animation
8554   animation.Play();
8555
8556   bool signalReceived(false);
8557   AnimationFinishCheck finishCheck(signalReceived);
8558   animation.FinishedSignal().Connect(&application, finishCheck);
8559   application.SendNotification();
8560   application.Render(0);
8561   application.SendNotification();
8562   finishCheck.CheckSignalNotReceived();
8563   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
8564
8565   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
8566   application.SendNotification();
8567   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8568   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8569   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8570   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.36f, 0.01f, TEST_LOCATION );
8571   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
8572
8573   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
8574   application.SendNotification();
8575   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8576   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8577   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8578   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.21f, 0.01f, TEST_LOCATION );
8579   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
8580
8581   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
8582   application.SendNotification();
8583   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8584   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8585   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8586   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.0f, 0.01f, TEST_LOCATION );
8587   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
8588
8589   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
8590   application.SendNotification();
8591   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8592   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8593   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8594   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7f, 0.01f, TEST_LOCATION );
8595   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
8596
8597   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
8598   application.SendNotification();
8599   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8600   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8601   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8602   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.76f, 0.01f, TEST_LOCATION );
8603   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
8604
8605   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
8606   application.SendNotification();
8607   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8608   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8609   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8610   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.9f, 0.01f, TEST_LOCATION );
8611   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
8612
8613   // We did expect the animation to finish
8614
8615   finishCheck.CheckSignalReceived();
8616   END_TEST;
8617 }
8618
8619 int UtcDaliAnimationAnimateBetweenActorColorP(void)
8620 {
8621   TestApplication application;
8622
8623   float startValue(1.0f);
8624   Actor actor = Actor::New();
8625   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8626   Stage::GetCurrent().Add(actor);
8627
8628   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8629   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8630   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8631   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8632   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8633   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8634   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8635   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8636   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8637
8638   // Build the animation
8639   float durationSeconds(1.0f);
8640   Animation animation = Animation::New(durationSeconds);
8641
8642   KeyFrames keyFrames = KeyFrames::New();
8643   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8644   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8645   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8646
8647   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
8648
8649   // Start the animation
8650   animation.Play();
8651
8652   bool signalReceived(false);
8653   AnimationFinishCheck finishCheck(signalReceived);
8654   animation.FinishedSignal().Connect(&application, finishCheck);
8655   application.SendNotification();
8656   application.Render(0);
8657   application.SendNotification();
8658   finishCheck.CheckSignalNotReceived();
8659   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
8660   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
8661   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
8662   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
8663
8664   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8665   application.SendNotification();
8666   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
8667   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
8668   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
8669   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
8670
8671   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8672   application.SendNotification();
8673   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
8674   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
8675   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
8676   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
8677
8678   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8679   application.SendNotification();
8680   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
8681   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
8682   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
8683   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
8684
8685   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8686   application.SendNotification();
8687   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
8688   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
8689   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
8690   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
8691
8692   // We did expect the animation to finish
8693
8694   finishCheck.CheckSignalReceived();
8695   END_TEST;
8696 }
8697
8698 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
8699 {
8700   TestApplication application;
8701
8702   float startValue(1.0f);
8703   Actor actor = Actor::New();
8704   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8705   Stage::GetCurrent().Add(actor);
8706
8707   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8708   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8709   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8710   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8711   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8712   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
8713   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
8714   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
8715   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
8716
8717   // Build the animation
8718   float durationSeconds(1.0f);
8719   Animation animation = Animation::New(durationSeconds);
8720
8721   KeyFrames keyFrames = KeyFrames::New();
8722   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8723   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8724   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8725
8726   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
8727
8728   // Start the animation
8729   animation.Play();
8730
8731   bool signalReceived(false);
8732   AnimationFinishCheck finishCheck(signalReceived);
8733   animation.FinishedSignal().Connect(&application, finishCheck);
8734   application.SendNotification();
8735   application.Render(0);
8736   application.SendNotification();
8737   finishCheck.CheckSignalNotReceived();
8738   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
8739   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
8740   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
8741   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
8742
8743   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8744   application.SendNotification();
8745   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
8746   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
8747   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
8748   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
8749
8750   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8751   application.SendNotification();
8752   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
8753   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
8754   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
8755   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
8756
8757   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8758   application.SendNotification();
8759   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
8760   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
8761   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
8762   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
8763
8764   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8765   application.SendNotification();
8766   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
8767   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
8768   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
8769   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
8770
8771   // We did expect the animation to finish
8772
8773   finishCheck.CheckSignalReceived();
8774   END_TEST;
8775 }
8776
8777 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
8778 {
8779   TestApplication application;
8780
8781   Actor actor = Actor::New();
8782   AngleAxis aa(Degree(90), Vector3::XAXIS);
8783   actor.SetOrientation(aa.angle, aa.axis);
8784   Stage::GetCurrent().Add(actor);
8785
8786   application.SendNotification();
8787   application.Render(0);
8788
8789   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8790
8791   // Build the animation
8792   float durationSeconds(1.0f);
8793   Animation animation = Animation::New(durationSeconds);
8794
8795   KeyFrames keyFrames = KeyFrames::New();
8796   keyFrames.Add(0.0f, false);
8797   keyFrames.Add(0.2f, true);
8798   keyFrames.Add(0.4f, true);
8799   keyFrames.Add(0.8f, false);
8800   keyFrames.Add(1.0f, true);
8801
8802   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
8803
8804   // Start the animation
8805   animation.Play();
8806
8807   bool signalReceived(false);
8808   AnimationFinishCheck finishCheck(signalReceived);
8809   animation.FinishedSignal().Connect(&application, finishCheck);
8810   application.SendNotification();
8811   application.SendNotification();
8812   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8813   application.SendNotification();
8814   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8815   application.SendNotification();
8816
8817   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
8818   finishCheck.CheckSignalReceived();
8819   END_TEST;
8820 }
8821
8822 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
8823 {
8824   TestApplication application;
8825
8826   Actor actor = Actor::New();
8827   AngleAxis aa(Degree(90), Vector3::XAXIS);
8828   actor.SetOrientation(aa.angle, aa.axis);
8829   Stage::GetCurrent().Add(actor);
8830
8831   application.SendNotification();
8832   application.Render(0);
8833
8834   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
8835
8836   // Build the animation
8837   float durationSeconds(1.0f);
8838   Animation animation = Animation::New(durationSeconds);
8839
8840   KeyFrames keyFrames = KeyFrames::New();
8841   keyFrames.Add(0.0f, false);
8842   keyFrames.Add(0.2f, true);
8843   keyFrames.Add(0.4f, true);
8844   keyFrames.Add(0.8f, false);
8845   keyFrames.Add(1.0f, true);
8846
8847   //Cubic interpolation for boolean values should be ignored
8848   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
8849
8850   // Start the animation
8851   animation.Play();
8852
8853   bool signalReceived(false);
8854   AnimationFinishCheck finishCheck(signalReceived);
8855   animation.FinishedSignal().Connect(&application, finishCheck);
8856   application.SendNotification();
8857   application.SendNotification();
8858   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8859   application.SendNotification();
8860   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8861   application.SendNotification();
8862
8863   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
8864   finishCheck.CheckSignalReceived();
8865   END_TEST;
8866 }
8867
8868 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
8869 {
8870   TestApplication application;
8871
8872   Actor actor = Actor::New();
8873   AngleAxis aa(Degree(90), Vector3::XAXIS);
8874   actor.SetOrientation(aa.angle, aa.axis);
8875   Stage::GetCurrent().Add(actor);
8876
8877   application.SendNotification();
8878   application.Render(0);
8879   Quaternion start(Radian(aa.angle), aa.axis);
8880   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8881
8882   // Build the animation
8883   float durationSeconds(1.0f);
8884   Animation animation = Animation::New(durationSeconds);
8885
8886   KeyFrames keyFrames = KeyFrames::New();
8887   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
8888
8889   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
8890
8891   // Start the animation
8892   animation.Play();
8893
8894   bool signalReceived(false);
8895   AnimationFinishCheck finishCheck(signalReceived);
8896   animation.FinishedSignal().Connect(&application, finishCheck);
8897   application.SendNotification();
8898   application.SendNotification();
8899   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
8900   application.SendNotification();
8901   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
8902   application.SendNotification();
8903
8904   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
8905
8906   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8907   finishCheck.CheckSignalReceived();
8908   END_TEST;
8909 }
8910
8911 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
8912 {
8913   TestApplication application;
8914
8915   Actor actor = Actor::New();
8916   AngleAxis aa(Degree(90), Vector3::XAXIS);
8917   actor.SetOrientation(aa.angle, aa.axis);
8918   application.SendNotification();
8919   application.Render(0);
8920   Stage::GetCurrent().Add(actor);
8921
8922   Quaternion start(Radian(aa.angle), aa.axis);
8923   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8924
8925   // Build the animation
8926   float durationSeconds(1.0f);
8927   Animation animation = Animation::New(durationSeconds);
8928
8929   KeyFrames keyFrames = KeyFrames::New();
8930   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
8931   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
8932   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
8933
8934   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
8935
8936   // Start the animation
8937   animation.Play();
8938
8939   bool signalReceived(false);
8940   AnimationFinishCheck finishCheck(signalReceived);
8941   animation.FinishedSignal().Connect(&application, finishCheck);
8942   application.SendNotification();
8943   application.Render(0);
8944   application.SendNotification();
8945   finishCheck.CheckSignalNotReceived();
8946
8947   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
8948   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8949
8950   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8951   application.SendNotification();
8952   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
8953   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8954
8955   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8956   application.SendNotification();
8957   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
8958   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8959
8960   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8961   application.SendNotification();
8962   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
8963   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8964
8965   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8966   application.SendNotification();
8967   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
8968   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
8969
8970   // We did expect the animation to finish
8971
8972   finishCheck.CheckSignalReceived();
8973   END_TEST;
8974 }
8975
8976 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
8977 {
8978   TestApplication application;
8979
8980   Actor actor = Actor::New();
8981   AngleAxis aa(Degree(90), Vector3::XAXIS);
8982   actor.SetOrientation(aa.angle, aa.axis);
8983   Stage::GetCurrent().Add(actor);
8984
8985   application.SendNotification();
8986   application.Render(0);
8987   Quaternion start(Radian(aa.angle), aa.axis);
8988   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
8989
8990   // Build the animation
8991   float durationSeconds(1.0f);
8992   Animation animation = Animation::New(durationSeconds);
8993
8994   KeyFrames keyFrames = KeyFrames::New();
8995   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
8996
8997   //Cubic interpolation should be ignored for quaternions
8998   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
8999
9000   // Start the animation
9001   animation.Play();
9002
9003   bool signalReceived(false);
9004   AnimationFinishCheck finishCheck(signalReceived);
9005   animation.FinishedSignal().Connect(&application, finishCheck);
9006   application.SendNotification();
9007   application.SendNotification();
9008   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
9009   application.SendNotification();
9010   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
9011   application.SendNotification();
9012
9013   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
9014
9015   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9016   finishCheck.CheckSignalReceived();
9017   END_TEST;
9018 }
9019
9020 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
9021 {
9022   TestApplication application;
9023
9024   Actor actor = Actor::New();
9025   AngleAxis aa(Degree(90), Vector3::XAXIS);
9026   actor.SetOrientation(aa.angle, aa.axis);
9027   application.SendNotification();
9028   application.Render(0);
9029   Stage::GetCurrent().Add(actor);
9030
9031   Quaternion start(Radian(aa.angle), aa.axis);
9032   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
9033
9034   // Build the animation
9035   float durationSeconds(1.0f);
9036   Animation animation = Animation::New(durationSeconds);
9037
9038   KeyFrames keyFrames = KeyFrames::New();
9039   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
9040   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
9041   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
9042
9043   //Cubic interpolation should be ignored for quaternions
9044   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
9045
9046   // Start the animation
9047   animation.Play();
9048
9049   bool signalReceived(false);
9050   AnimationFinishCheck finishCheck(signalReceived);
9051   animation.FinishedSignal().Connect(&application, finishCheck);
9052   application.SendNotification();
9053   application.Render(0);
9054   application.SendNotification();
9055   finishCheck.CheckSignalNotReceived();
9056
9057   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
9058   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9059
9060   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9061   application.SendNotification();
9062   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
9063   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9064
9065   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9066   application.SendNotification();
9067   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
9068   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9069
9070   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9071   application.SendNotification();
9072   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
9073   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9074
9075   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9076   application.SendNotification();
9077   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
9078   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
9079
9080   // We did expect the animation to finish
9081
9082   finishCheck.CheckSignalReceived();
9083   END_TEST;
9084 }
9085
9086 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
9087 {
9088   TestApplication application;
9089
9090   float startValue(1.0f);
9091   Actor actor = Actor::New();
9092   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9093   Stage::GetCurrent().Add(actor);
9094
9095   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9096   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9097   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9099   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9100   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9101   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9102   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9103   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9104
9105   // Build the animation
9106   float durationSeconds(1.0f);
9107   Animation animation = Animation::New(durationSeconds);
9108
9109   KeyFrames keyFrames = KeyFrames::New();
9110   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9111   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9112   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9113
9114   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
9115
9116   // Start the animation
9117   animation.Play();
9118
9119   bool signalReceived(false);
9120   AnimationFinishCheck finishCheck(signalReceived);
9121   animation.FinishedSignal().Connect(&application, finishCheck);
9122   application.SendNotification();
9123   application.Render(0);
9124   application.SendNotification();
9125   finishCheck.CheckSignalNotReceived();
9126   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9127   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9128   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9129   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9130
9131   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9132   application.SendNotification();
9133   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9134   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9135   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9136   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9137
9138   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9139   application.SendNotification();
9140   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9141   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9142   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9143   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9144
9145   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9146   application.SendNotification();
9147   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9148   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9149   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9150   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9151
9152   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9153   application.SendNotification();
9154   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9155   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9156   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9157   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9158
9159   // We did expect the animation to finish
9160
9161   finishCheck.CheckSignalReceived();
9162   END_TEST;
9163 }
9164
9165 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
9166 {
9167   TestApplication application;
9168
9169   float startValue(1.0f);
9170   Actor actor = Actor::New();
9171   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9172   Stage::GetCurrent().Add(actor);
9173
9174   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9175   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9176   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9177   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9178   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9179   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9180   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9181   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9182   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9183
9184   // Build the animation
9185   float durationSeconds(1.0f);
9186   Animation animation = Animation::New(durationSeconds);
9187
9188   KeyFrames keyFrames = KeyFrames::New();
9189   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9190   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9191   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9192
9193   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
9194
9195   // Start the animation
9196   animation.Play();
9197
9198   bool signalReceived(false);
9199   AnimationFinishCheck finishCheck(signalReceived);
9200   animation.FinishedSignal().Connect(&application, finishCheck);
9201   application.SendNotification();
9202   application.Render(0);
9203   application.SendNotification();
9204   finishCheck.CheckSignalNotReceived();
9205   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9206   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9207   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9208   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9209
9210   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9211   application.SendNotification();
9212   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9213   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9214   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9215   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9216
9217   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9218   application.SendNotification();
9219   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9220   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9221   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9222   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9223
9224   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9225   application.SendNotification();
9226   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9227   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9228   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9229   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9230
9231   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9232   application.SendNotification();
9233   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9234   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9235   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9236   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9237
9238   // We did expect the animation to finish
9239
9240   finishCheck.CheckSignalReceived();
9241   END_TEST;
9242 }
9243
9244 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
9245 {
9246   TestApplication application;
9247
9248   float startValue(1.0f);
9249   Actor actor = Actor::New();
9250   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9251   Stage::GetCurrent().Add(actor);
9252
9253   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9254   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9255   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9256   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9257   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9258   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9259   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9260   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9261   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9262
9263   // Build the animation
9264   float durationSeconds(1.0f);
9265   float delay = 0.5f;
9266   Animation animation = Animation::New(durationSeconds);
9267
9268   KeyFrames keyFrames = KeyFrames::New();
9269   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9270   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9271   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9272
9273   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
9274
9275   // Start the animation
9276   animation.Play();
9277
9278   bool signalReceived(false);
9279   AnimationFinishCheck finishCheck(signalReceived);
9280   animation.FinishedSignal().Connect(&application, finishCheck);
9281   application.SendNotification();
9282
9283   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9284   application.SendNotification();
9285   finishCheck.CheckSignalNotReceived();
9286   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9287   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9288   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9289   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9290
9291   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9292   application.SendNotification();
9293   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9294   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9295   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9296   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9297
9298   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9299   application.SendNotification();
9300   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9301   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9302   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9303   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9304
9305   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9306   application.SendNotification();
9307   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9308   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9309   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9310   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9311
9312   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9313   application.SendNotification();
9314   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9315   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9316   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9317   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9318
9319   // We did expect the animation to finish
9320
9321   finishCheck.CheckSignalReceived();
9322   END_TEST;
9323 }
9324
9325 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
9326 {
9327   TestApplication application;
9328
9329   float startValue(1.0f);
9330   Actor actor = Actor::New();
9331   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9332   Stage::GetCurrent().Add(actor);
9333
9334   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9335   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9336   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9337   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9338   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9339   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9340   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9341   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9342   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9343
9344   // Build the animation
9345   float durationSeconds(1.0f);
9346   float delay = 0.5f;
9347   Animation animation = Animation::New(durationSeconds);
9348
9349   KeyFrames keyFrames = KeyFrames::New();
9350   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9351   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9352   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9353
9354   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9355
9356   // Start the animation
9357   animation.Play();
9358
9359   bool signalReceived(false);
9360   AnimationFinishCheck finishCheck(signalReceived);
9361   animation.FinishedSignal().Connect(&application, finishCheck);
9362   application.SendNotification();
9363
9364   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9365   application.SendNotification();
9366   finishCheck.CheckSignalNotReceived();
9367   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9368   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9369   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9370   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9371
9372   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9373   application.SendNotification();
9374   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9375   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9376   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9377   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9378
9379   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9380   application.SendNotification();
9381   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9382   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
9383   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9384   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9385
9386   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9387   application.SendNotification();
9388   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9389   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9390   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9391   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9392
9393   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9394   application.SendNotification();
9395   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9396   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9397   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9398   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9399
9400   // We did expect the animation to finish
9401
9402   finishCheck.CheckSignalReceived();
9403   END_TEST;
9404 }
9405
9406 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
9407 {
9408   TestApplication application;
9409
9410   float startValue(1.0f);
9411   float delay = 0.5f;
9412   Actor actor = Actor::New();
9413   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9414   Stage::GetCurrent().Add(actor);
9415
9416   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9417   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9418   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9419   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9420   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9421   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9422   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9423   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9424   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9425
9426   // Build the animation
9427   float durationSeconds(1.0f);
9428   Animation animation = Animation::New(durationSeconds);
9429
9430   KeyFrames keyFrames = KeyFrames::New();
9431   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9432   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9433   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9434
9435   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
9436
9437   // Start the animation
9438   animation.Play();
9439
9440   bool signalReceived(false);
9441   AnimationFinishCheck finishCheck(signalReceived);
9442   animation.FinishedSignal().Connect(&application, finishCheck);
9443   application.SendNotification();
9444
9445   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9446   application.SendNotification();
9447   finishCheck.CheckSignalNotReceived();
9448   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9449   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9450   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9451   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9452
9453   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9454   application.SendNotification();
9455   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.5f, 0.01f, TEST_LOCATION );
9456   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.5f, 0.01f, TEST_LOCATION );
9457   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.5f, 0.01f, TEST_LOCATION );
9458   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.5f, 0.01f, TEST_LOCATION );
9459
9460   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9461   application.SendNotification();
9462   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9463   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9464   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9465   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9466
9467   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9468   application.SendNotification();
9469   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.95f, 0.01f, TEST_LOCATION );
9470   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.90f, 0.01f, TEST_LOCATION );
9471   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85f, 0.01f, TEST_LOCATION );
9472   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.80f, 0.01f, TEST_LOCATION );
9473
9474   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9475   application.SendNotification();
9476   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9477   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9478   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9479   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9480
9481   // We did expect the animation to finish
9482
9483   finishCheck.CheckSignalReceived();
9484   END_TEST;
9485 }
9486
9487 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
9488 {
9489   TestApplication application;
9490
9491   float startValue(1.0f);
9492   Actor actor = Actor::New();
9493   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
9494   Stage::GetCurrent().Add(actor);
9495
9496   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
9497   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
9498   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
9499   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
9500   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
9501   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   startValue, TEST_LOCATION );
9502   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), startValue, TEST_LOCATION );
9503   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  startValue, TEST_LOCATION );
9504   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), startValue, TEST_LOCATION );
9505
9506
9507   // Build the animation
9508   float durationSeconds(1.0f);
9509   float delay = 0.5f;
9510   Animation animation = Animation::New(durationSeconds);
9511
9512   KeyFrames keyFrames = KeyFrames::New();
9513   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
9514   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
9515   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
9516
9517   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
9518
9519   // Start the animation
9520   animation.Play();
9521
9522   bool signalReceived(false);
9523   AnimationFinishCheck finishCheck(signalReceived);
9524   animation.FinishedSignal().Connect(&application, finishCheck);
9525   application.SendNotification();
9526
9527   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
9528   application.SendNotification();
9529   finishCheck.CheckSignalNotReceived();
9530   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.1f, 0.01f, TEST_LOCATION );
9531   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.2f, 0.01f, TEST_LOCATION );
9532   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.3f, 0.01f, TEST_LOCATION );
9533   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4f, 0.01f, TEST_LOCATION );
9534
9535   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
9536   application.SendNotification();
9537   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.55f, 0.01f, TEST_LOCATION );
9538   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.525f, 0.01f, TEST_LOCATION );
9539   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.506f, 0.01f, TEST_LOCATION );
9540   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.4875f, 0.01f, TEST_LOCATION );
9541
9542   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
9543   application.SendNotification();
9544   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.9f, 0.01f, TEST_LOCATION );
9545   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.8f, 0.01f, TEST_LOCATION );
9546   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.7f, 0.01f, TEST_LOCATION );
9547   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.6f, 0.01f, TEST_LOCATION );
9548
9549   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
9550   application.SendNotification();
9551   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   0.99375f, 0.01f, TEST_LOCATION );
9552   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 0.925f, 0.01f, TEST_LOCATION );
9553   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  0.85625f, 0.01f, TEST_LOCATION );
9554   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 0.7875f, 0.01f, TEST_LOCATION );
9555
9556   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
9557   application.SendNotification();
9558   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ),   1.0f, 0.01f, TEST_LOCATION );
9559   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), 1.0f, 0.01f, TEST_LOCATION );
9560   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ),  1.0f, 0.01f, TEST_LOCATION );
9561   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), 1.0f, 0.01f, TEST_LOCATION );
9562
9563   // We did expect the animation to finish
9564
9565   finishCheck.CheckSignalReceived();
9566   END_TEST;
9567 }
9568
9569 int UtcDaliAnimationAnimateP(void)
9570 {
9571   TestApplication application;
9572
9573   Actor actor = Actor::New();
9574   Stage::GetCurrent().Add(actor);
9575
9576   //Build the path
9577   Vector3 position0( 30.0,  80.0,  0.0);
9578   Vector3 position1( 70.0,  120.0, 0.0);
9579   Vector3 position2( 100.0, 100.0, 0.0);
9580
9581   Dali::Path path = Dali::Path::New();
9582   path.AddPoint(position0);
9583   path.AddPoint(position1);
9584   path.AddPoint(position2);
9585
9586   //Control points for first segment
9587   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9588   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9589
9590   //Control points for second segment
9591   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9592   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9593
9594   // Build the animation
9595   float durationSeconds( 1.0f );
9596   Animation animation = Animation::New(durationSeconds);
9597   animation.Animate(actor, path, Vector3::XAXIS);
9598
9599   // Start the animation
9600   animation.Play();
9601
9602   bool signalReceived(false);
9603   AnimationFinishCheck finishCheck(signalReceived);
9604   animation.FinishedSignal().Connect(&application, finishCheck);
9605   application.SendNotification();
9606   application.Render(0);
9607   application.SendNotification();
9608   finishCheck.CheckSignalNotReceived();
9609   Vector3 position, tangent;
9610   Quaternion rotation;
9611   path.Sample( 0.0f, position, tangent );
9612   rotation = Quaternion( Vector3::XAXIS, tangent );
9613   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9614   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9615
9616   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9617   application.SendNotification();
9618   path.Sample( 0.25f, position, tangent );
9619   rotation = Quaternion( Vector3::XAXIS, tangent );
9620   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9621   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9622
9623   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9624   application.SendNotification();
9625   path.Sample( 0.5f, position, tangent );
9626   rotation = Quaternion( Vector3::XAXIS, tangent );
9627   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9628   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9629
9630   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9631   application.SendNotification();
9632   path.Sample( 0.75f, position, tangent );
9633   rotation = Quaternion( Vector3::XAXIS, tangent );
9634   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9635   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9636
9637   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9638   application.SendNotification();
9639   path.Sample( 1.0f, position, tangent );
9640   rotation = Quaternion( Vector3::XAXIS, tangent );
9641   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9642   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9643
9644   finishCheck.CheckSignalReceived();
9645   END_TEST;
9646 }
9647
9648 int UtcDaliAnimationAnimateAlphaFunctionP(void)
9649 {
9650   TestApplication application;
9651
9652   Actor actor = Actor::New();
9653   Stage::GetCurrent().Add(actor);
9654
9655   //Build the path
9656   Vector3 position0( 30.0,  80.0,  0.0);
9657   Vector3 position1( 70.0,  120.0, 0.0);
9658   Vector3 position2( 100.0, 100.0, 0.0);
9659
9660   Dali::Path path = Dali::Path::New();
9661   path.AddPoint(position0);
9662   path.AddPoint(position1);
9663   path.AddPoint(position2);
9664
9665   //Control points for first segment
9666   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9667   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9668
9669   //Control points for second segment
9670   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9671   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9672
9673   // Build the animation
9674   float durationSeconds( 1.0f );
9675   Animation animation = Animation::New(durationSeconds);
9676   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
9677
9678   // Start the animation
9679   animation.Play();
9680
9681   bool signalReceived(false);
9682   AnimationFinishCheck finishCheck(signalReceived);
9683   animation.FinishedSignal().Connect(&application, finishCheck);
9684   application.SendNotification();
9685   application.Render(0);
9686   application.SendNotification();
9687   finishCheck.CheckSignalNotReceived();
9688   Vector3 position, tangent;
9689   Quaternion rotation;
9690   path.Sample( 0.0f, position, tangent );
9691   rotation = Quaternion( Vector3::XAXIS, tangent );
9692   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9693   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9694
9695   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9696   application.SendNotification();
9697   path.Sample( 0.25f, position, tangent );
9698   rotation = Quaternion( Vector3::XAXIS, tangent );
9699   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9700   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9701
9702   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9703   application.SendNotification();
9704   path.Sample( 0.5f, position, tangent );
9705   rotation = Quaternion( Vector3::XAXIS, tangent );
9706   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9707   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9708
9709   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9710   application.SendNotification();
9711   path.Sample( 0.75f, position, tangent );
9712   rotation = Quaternion( Vector3::XAXIS, tangent );
9713   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9714   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9715
9716   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9717   application.SendNotification();
9718   path.Sample( 1.0f, position, tangent );
9719   rotation = Quaternion( Vector3::XAXIS, tangent );
9720   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9721   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9722
9723   finishCheck.CheckSignalReceived();
9724   END_TEST;
9725 }
9726
9727 int UtcDaliAnimationAnimateTimePeriodP(void)
9728 {
9729   TestApplication application;
9730
9731   Actor actor = Actor::New();
9732   Stage::GetCurrent().Add(actor);
9733
9734   //Build the path
9735   Vector3 position0( 30.0,  80.0,  0.0);
9736   Vector3 position1( 70.0,  120.0, 0.0);
9737   Vector3 position2( 100.0, 100.0, 0.0);
9738
9739   Dali::Path path = Dali::Path::New();
9740   path.AddPoint(position0);
9741   path.AddPoint(position1);
9742   path.AddPoint(position2);
9743
9744   //Control points for first segment
9745   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9746   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9747
9748   //Control points for second segment
9749   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9750   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9751
9752   // Build the animation
9753   float durationSeconds( 1.0f );
9754   Animation animation = Animation::New(durationSeconds);
9755   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
9756
9757   // Start the animation
9758   animation.Play();
9759
9760   bool signalReceived(false);
9761   AnimationFinishCheck finishCheck(signalReceived);
9762   animation.FinishedSignal().Connect(&application, finishCheck);
9763   application.SendNotification();
9764   application.Render(0);
9765   application.SendNotification();
9766   finishCheck.CheckSignalNotReceived();
9767   Vector3 position, tangent;
9768   Quaternion rotation;
9769   path.Sample( 0.0f, position, tangent );
9770   rotation = Quaternion( Vector3::XAXIS, tangent );
9771   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9772   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9773
9774   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9775   application.SendNotification();
9776   path.Sample( 0.25f, position, tangent );
9777   rotation = Quaternion( Vector3::XAXIS, tangent );
9778   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9779   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9780
9781   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9782   application.SendNotification();
9783   path.Sample( 0.5f, position, tangent );
9784   rotation = Quaternion( Vector3::XAXIS, tangent );
9785   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9786   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9787
9788   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9789   application.SendNotification();
9790   path.Sample( 0.75f, position, tangent );
9791   rotation = Quaternion( Vector3::XAXIS, tangent );
9792   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9793   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9794
9795   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9796   application.SendNotification();
9797   path.Sample( 1.0f, position, tangent );
9798   rotation = Quaternion( Vector3::XAXIS, tangent );
9799   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9800   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9801
9802   finishCheck.CheckSignalReceived();
9803   END_TEST;
9804 }
9805
9806 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
9807 {
9808   TestApplication application;
9809
9810   Actor actor = Actor::New();
9811   Stage::GetCurrent().Add(actor);
9812
9813   //Build the path
9814   Vector3 position0( 30.0,  80.0,  0.0);
9815   Vector3 position1( 70.0,  120.0, 0.0);
9816   Vector3 position2( 100.0, 100.0, 0.0);
9817
9818   Dali::Path path = Dali::Path::New();
9819   path.AddPoint(position0);
9820   path.AddPoint(position1);
9821   path.AddPoint(position2);
9822
9823   //Control points for first segment
9824   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
9825   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
9826
9827   //Control points for second segment
9828   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
9829   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
9830
9831   // Build the animation
9832   float durationSeconds( 1.0f );
9833   Animation animation = Animation::New(durationSeconds);
9834   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
9835
9836   // Start the animation
9837   animation.Play();
9838
9839   bool signalReceived(false);
9840   AnimationFinishCheck finishCheck(signalReceived);
9841   animation.FinishedSignal().Connect(&application, finishCheck);
9842   application.SendNotification();
9843   application.Render(0);
9844   application.SendNotification();
9845   finishCheck.CheckSignalNotReceived();
9846   Vector3 position, tangent;
9847   Quaternion rotation;
9848   path.Sample( 0.0f, position, tangent );
9849   rotation = Quaternion( Vector3::XAXIS, tangent );
9850   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9851   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9852
9853   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
9854   application.SendNotification();
9855   path.Sample( 0.25f, position, tangent );
9856   rotation = Quaternion( Vector3::XAXIS, tangent );
9857   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9858   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9859
9860   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
9861   application.SendNotification();
9862   path.Sample( 0.5f, position, tangent );
9863   rotation = Quaternion( Vector3::XAXIS, tangent );
9864   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9865   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9866
9867   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
9868   application.SendNotification();
9869   path.Sample( 0.75f, position, tangent );
9870   rotation = Quaternion( Vector3::XAXIS, tangent );
9871   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9872   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9873
9874   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
9875   application.SendNotification();
9876   path.Sample( 1.0f, position, tangent );
9877   rotation = Quaternion( Vector3::XAXIS, tangent );
9878   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
9879   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
9880
9881   finishCheck.CheckSignalReceived();
9882   END_TEST;
9883 }
9884
9885 int UtcDaliAnimationShowP(void)
9886 {
9887   TestApplication application;
9888
9889   Actor actor = Actor::New();
9890   actor.SetVisible(false);
9891   application.SendNotification();
9892   application.Render(0);
9893   DALI_TEST_CHECK( !actor.IsVisible() );
9894   Stage::GetCurrent().Add(actor);
9895
9896   // Start the animation
9897   float durationSeconds(10.0f);
9898   Animation animation = Animation::New(durationSeconds);
9899   animation.Show(actor, durationSeconds*0.5f);
9900   animation.Play();
9901
9902   bool signalReceived(false);
9903   AnimationFinishCheck finishCheck(signalReceived);
9904   animation.FinishedSignal().Connect(&application, finishCheck);
9905
9906   application.SendNotification();
9907   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
9908
9909   // We didn't expect the animation to finish yet
9910   application.SendNotification();
9911   finishCheck.CheckSignalNotReceived();
9912   DALI_TEST_CHECK( !actor.IsVisible() );
9913
9914   application.SendNotification();
9915   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
9916
9917   // We didn't expect the animation to finish yet
9918   application.SendNotification();
9919   finishCheck.CheckSignalNotReceived();
9920   DALI_TEST_CHECK( actor.IsVisible() );
9921
9922   application.SendNotification();
9923   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9924
9925   // We did expect the animation to finish
9926   application.SendNotification();
9927   finishCheck.CheckSignalReceived();
9928   DALI_TEST_CHECK( actor.IsVisible() );
9929   END_TEST;
9930 }
9931
9932 int UtcDaliAnimationHideP(void)
9933 {
9934   TestApplication application;
9935
9936   Actor actor = Actor::New();
9937   DALI_TEST_CHECK( actor.IsVisible() );
9938   Stage::GetCurrent().Add(actor);
9939
9940   // Start the animation
9941   float durationSeconds(10.0f);
9942   Animation animation = Animation::New(durationSeconds);
9943   animation.Hide(actor, durationSeconds*0.5f);
9944   animation.Play();
9945
9946   bool signalReceived(false);
9947   AnimationFinishCheck finishCheck(signalReceived);
9948   animation.FinishedSignal().Connect(&application, finishCheck);
9949
9950   application.SendNotification();
9951   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
9952
9953   // We didn't expect the animation to finish yet
9954   application.SendNotification();
9955   finishCheck.CheckSignalNotReceived();
9956   DALI_TEST_CHECK( actor.IsVisible() );
9957
9958   application.SendNotification();
9959   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
9960
9961   // We didn't expect the animation to finish yet
9962   application.SendNotification();
9963   finishCheck.CheckSignalNotReceived();
9964   DALI_TEST_CHECK( !actor.IsVisible() );
9965
9966   application.SendNotification();
9967   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
9968
9969   // We did expect the animation to finish
9970   application.SendNotification();
9971   finishCheck.CheckSignalReceived();
9972   DALI_TEST_CHECK( !actor.IsVisible() );
9973   END_TEST;
9974 }
9975
9976 int UtcDaliAnimationShowHideAtEndP(void)
9977 {
9978   // Test that show/hide delay can be the same as animation duration
9979   // i.e. to show/hide at the end of the animation
9980
9981   TestApplication application;
9982
9983   Actor actor = Actor::New();
9984   DALI_TEST_CHECK( actor.IsVisible() );
9985   Stage::GetCurrent().Add(actor);
9986
9987   // Start Hide animation
9988   float durationSeconds(10.0f);
9989   Animation animation = Animation::New(durationSeconds);
9990   animation.Hide(actor, durationSeconds/*Hide at end*/);
9991   animation.Play();
9992
9993   bool signalReceived(false);
9994   AnimationFinishCheck finishCheck(signalReceived);
9995   animation.FinishedSignal().Connect(&application, finishCheck);
9996
9997   application.SendNotification();
9998   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
9999
10000   // We did expect the animation to finish
10001   application.SendNotification();
10002   finishCheck.CheckSignalReceived();
10003   DALI_TEST_CHECK( !actor.IsVisible() );
10004
10005   // Start Show animation
10006   animation = Animation::New(durationSeconds);
10007   animation.Show(actor, durationSeconds/*Show at end*/);
10008   animation.FinishedSignal().Connect(&application, finishCheck);
10009   animation.Play();
10010
10011   application.SendNotification();
10012   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
10013
10014   // We did expect the animation to finish
10015   application.SendNotification();
10016   finishCheck.CheckSignalReceived();
10017   DALI_TEST_CHECK( actor.IsVisible() );
10018   END_TEST;
10019 }
10020
10021 int UtcDaliKeyFramesCreateDestroyP(void)
10022 {
10023   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
10024
10025   KeyFrames* keyFrames = new KeyFrames;
10026   delete keyFrames;
10027   DALI_TEST_CHECK( true );
10028   END_TEST;
10029 }
10030
10031 int UtcDaliKeyFramesDownCastP(void)
10032 {
10033   TestApplication application;
10034   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
10035
10036   KeyFrames keyFrames = KeyFrames::New();
10037   BaseHandle object(keyFrames);
10038
10039   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
10040   DALI_TEST_CHECK(keyFrames2);
10041
10042   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
10043   DALI_TEST_CHECK(keyFrames3);
10044
10045   BaseHandle unInitializedObject;
10046   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
10047   DALI_TEST_CHECK(!keyFrames4);
10048
10049   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
10050   DALI_TEST_CHECK(!keyFrames5);
10051   END_TEST;
10052 }
10053
10054 int UtcDaliAnimationCreateDestroyP(void)
10055 {
10056   TestApplication application;
10057   Animation* animation = new Animation;
10058   DALI_TEST_CHECK( animation );
10059   delete animation;
10060   END_TEST;
10061 }
10062
10063 struct UpdateManagerTestConstraint
10064 {
10065   UpdateManagerTestConstraint(TestApplication& application)
10066   : mApplication(application)
10067   {
10068   }
10069
10070   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
10071   {
10072     mApplication.SendNotification();  // Process events
10073   }
10074
10075   TestApplication& mApplication;
10076 };
10077
10078 int UtcDaliAnimationUpdateManagerP(void)
10079 {
10080   TestApplication application;
10081
10082   Actor actor = Actor::New();
10083   Stage::GetCurrent().Add( actor );
10084
10085   // Build the animation
10086   Animation animation = Animation::New( 0.0f );
10087
10088   bool signalReceived = false;
10089   AnimationFinishCheck finishCheck( signalReceived );
10090   animation.FinishedSignal().Connect( &application, finishCheck );
10091
10092   Vector3 startValue(1.0f, 1.0f, 1.0f);
10093   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10094   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
10095   constraint.Apply();
10096
10097   // Apply animation to actor
10098   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
10099   animation.AnimateTo( Property(actor, DevelActor::Property::OPACITY), 0.3f, AlphaFunction::LINEAR );
10100
10101   animation.Play();
10102
10103   application.SendNotification();
10104   application.UpdateOnly( 16 );
10105
10106   finishCheck.CheckSignalNotReceived();
10107
10108   application.SendNotification();   // Process events
10109
10110   finishCheck.CheckSignalReceived();
10111
10112   END_TEST;
10113 }
10114
10115 int UtcDaliAnimationSignalOrderP(void)
10116 {
10117   TestApplication application;
10118
10119   Actor actor = Actor::New();
10120   Stage::GetCurrent().Add( actor );
10121
10122   // Build the animations
10123   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
10124   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
10125
10126   bool signal1Received = false;
10127   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
10128
10129   bool signal2Received = false;
10130   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
10131
10132   // Apply animations to actor
10133   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
10134   animation1.Play();
10135   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
10136   animation2.Play();
10137
10138   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10139   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10140
10141   application.SendNotification();
10142   application.UpdateOnly( 10 ); // 10ms progress
10143
10144   // no notifications yet
10145   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10146   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10147
10148   application.SendNotification();
10149
10150   // first completed
10151   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
10152   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
10153   signal1Received = false;
10154
10155   // 1st animation is complete now, do another update with no ProcessEvents in between
10156   application.UpdateOnly( 20 ); // 20ms progress
10157
10158   // ProcessEvents
10159   application.SendNotification();
10160
10161   // 2nd should complete now
10162   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
10163   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
10164
10165   END_TEST;
10166 }
10167
10168 int UtcDaliAnimationExtendDurationP(void)
10169 {
10170   TestApplication application;
10171
10172   Actor actor = Actor::New();
10173
10174   // Register a float property
10175   float startValue(10.0f);
10176   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10177   Stage::GetCurrent().Add(actor);
10178   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
10179   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10180
10181   // Build the animation
10182   float initialDurationSeconds(1.0f);
10183   float animatorDelay = 5.0f;
10184   float animatorDurationSeconds(5.0f);
10185   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
10186   Animation animation = Animation::New(initialDurationSeconds);
10187   float targetValue(30.0f);
10188   float relativeValue(targetValue - startValue);
10189
10190   animation.AnimateTo(Property(actor, index),
10191                       targetValue,
10192                       TimePeriod(animatorDelay, animatorDurationSeconds));
10193
10194   // The duration should have been extended
10195   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
10196
10197   // Start the animation
10198   animation.Play();
10199
10200   bool signalReceived(false);
10201   AnimationFinishCheck finishCheck(signalReceived);
10202   animation.FinishedSignal().Connect(&application, finishCheck);
10203
10204   application.SendNotification();
10205   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
10206
10207   // We didn't expect the animation to finish yet, but cached value should be the final one
10208   application.SendNotification();
10209   finishCheck.CheckSignalNotReceived();
10210   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10211   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
10212
10213   application.SendNotification();
10214   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
10215
10216   // We didn't expect the animation to finish yet
10217   application.SendNotification();
10218   finishCheck.CheckSignalNotReceived();
10219   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue+(relativeValue*0.5f), TEST_LOCATION );
10220
10221   application.SendNotification();
10222   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
10223
10224   // We did expect the animation to finish
10225   application.SendNotification();
10226   finishCheck.CheckSignalReceived();
10227   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), targetValue, TEST_LOCATION );
10228   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), targetValue, TEST_LOCATION );
10229   END_TEST;
10230 }
10231
10232 int UtcDaliAnimationCustomIntProperty(void)
10233 {
10234   TestApplication application;
10235
10236   Actor actor = Actor::New();
10237   Stage::GetCurrent().Add(actor);
10238   int startValue(0u);
10239
10240   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
10241   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), startValue, TEST_LOCATION );
10242   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), startValue, TEST_LOCATION );
10243
10244   // Build the animation
10245   float durationSeconds(1.0f);
10246   Animation animation = Animation::New(durationSeconds);
10247   animation.AnimateTo( Property(actor, index), 20 );
10248
10249   // Start the animation
10250   animation.Play();
10251
10252   // Target value should be retrievable straight away
10253   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10254
10255   bool signalReceived(false);
10256   AnimationFinishCheck finishCheck(signalReceived);
10257   animation.FinishedSignal().Connect(&application, finishCheck);
10258
10259   application.SendNotification();
10260   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
10261
10262   // We didn't expect the animation to finish yet
10263   application.SendNotification();
10264   finishCheck.CheckSignalNotReceived();
10265   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 10, TEST_LOCATION );
10266
10267   application.SendNotification();
10268   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
10269
10270   // We did expect the animation to finish
10271   application.SendNotification();
10272   finishCheck.CheckSignalReceived();
10273   DALI_TEST_EQUALS( actor.GetCurrentProperty< int >( index ), 20, TEST_LOCATION );
10274   DALI_TEST_EQUALS( actor.GetProperty< int >( index ), 20, TEST_LOCATION );
10275   END_TEST;
10276 }
10277
10278 int UtcDaliAnimationDuration(void)
10279 {
10280   TestApplication application;
10281
10282   Actor actor = Actor::New();
10283   Stage::GetCurrent().Add(actor);
10284
10285   Animation animation = Animation::New( 0.0f );
10286   DALI_TEST_EQUALS( 0.0f, animation.GetDuration(), TEST_LOCATION );
10287
10288   // The animation duration should automatically increase depending on the animator time period
10289
10290   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 0.0f, 1.0f ) );
10291   DALI_TEST_EQUALS( 1.0f, animation.GetDuration(), TEST_LOCATION );
10292
10293   animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), 200.0f, TimePeriod( 10.0f, 1.0f ) );
10294   DALI_TEST_EQUALS( 11.0f, animation.GetDuration(), TEST_LOCATION );
10295
10296   END_TEST;
10297 }
10298
10299 int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
10300 {
10301   TestApplication application;
10302
10303   Actor actor = Actor::New();
10304
10305   // Register an integer property
10306   int startValue(1);
10307   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10308   Stage::GetCurrent().Add(actor);
10309   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10310
10311   try
10312   {
10313     // Build the animation
10314     Animation animation = Animation::New( 2.0f );
10315     std::string relativeValue = "relative string";
10316     animation.AnimateBy( Property(actor, index), relativeValue );
10317     tet_result(TET_FAIL);
10318   }
10319   catch ( Dali::DaliException& e )
10320   {
10321     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10322   }
10323
10324
10325   END_TEST;
10326 }
10327
10328
10329 int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
10330 {
10331   TestApplication application;
10332
10333   Actor actor = Actor::New();
10334
10335   // Register an integer property
10336   int startValue(1);
10337   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10338   Stage::GetCurrent().Add(actor);
10339   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10340
10341   try
10342   {
10343     // Build the animation
10344     Animation animation = Animation::New( 2.0f );
10345     std::string relativeValue = "relative string";
10346     animation.AnimateTo( Property(actor, index), relativeValue );
10347
10348     tet_result(TET_FAIL);
10349   }
10350   catch ( Dali::DaliException& e )
10351   {
10352    DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
10353   }
10354
10355   END_TEST;
10356 }
10357
10358 int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
10359 {
10360   TestApplication application;
10361
10362   Actor actor = Actor::New();
10363
10364   // Register an integer property
10365   int startValue(1);
10366   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
10367   Stage::GetCurrent().Add(actor);
10368   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
10369
10370   try
10371   {
10372     // Build the animation
10373     KeyFrames keyFrames = KeyFrames::New();
10374     keyFrames.Add( 0.0f, std::string("relative string1") );
10375     keyFrames.Add( 1.0f, std::string("relative string2") );
10376     // no need to really create the animation as keyframes do the check
10377
10378     tet_result(TET_FAIL);
10379   }
10380   catch ( Dali::DaliException& e )
10381   {
10382     DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
10383   }
10384
10385   END_TEST;
10386 }
10387
10388 int UtcDaliAnimationSetAndGetTargetBeforePlayP(void)
10389 {
10390   tet_infoline("Setting up an animation should not effect it's position property until the animation plays");
10391
10392   TestApplication application;
10393
10394   tet_infoline("Set initial position and set up animation to re-position actor");
10395
10396   Actor actor = Actor::New();
10397   Stage::GetCurrent().Add(actor);
10398   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10399   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10400
10401   // Build the animation
10402   Animation animation = Animation::New(2.0f);
10403
10404   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10405   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10406   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10407
10408   tet_infoline("Set target position in animation without intiating play");
10409
10410   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
10411   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
10412
10413   application.SendNotification();
10414   application.Render();
10415
10416   tet_infoline("Ensure position of actor is still at intial value");
10417
10418   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10419   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10420   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10421
10422   tet_infoline("Play animation and ensure actor position is now target");
10423
10424   animation.Play();
10425   application.SendNotification();
10426   application.Render(1000u);
10427
10428   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10429
10430   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10431   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10432   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10433
10434   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10435
10436   application.Render(2000u);
10437
10438   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10439
10440   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPosition.x, TEST_LOCATION );
10441   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPosition.y, TEST_LOCATION );
10442   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPosition.z, TEST_LOCATION );
10443
10444   END_TEST;
10445 }
10446
10447 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsPositionP(void)
10448 {
10449   tet_infoline("Setting up an animation should not effect it's position property until the animation plays even with mulitple animators");
10450
10451   TestApplication application;
10452
10453   std::vector<Vector3> targetPositions;
10454
10455   targetPositions.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10456   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10457   targetPositions.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10458
10459   tet_infoline("Set initial position and set up animation to re-position actor");
10460
10461   Actor actor = Actor::New();
10462   Stage::GetCurrent().Add(actor);
10463   Vector3 initialPosition(0.0f, 0.0f, 0.0f);
10464   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10465
10466   // Build the animation
10467   Animation animation = Animation::New(2.0f);
10468
10469   //Test GetCurrentProgress return 0.0 as the duration is 0.0
10470   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
10471   DALI_TEST_EQUALS( Vector3( 0.0f, 0.0f, 0.0f ), actor.GetCurrentPosition(), TEST_LOCATION );
10472
10473   tet_infoline("Set target position in animation without intiating play");
10474
10475   for ( unsigned int i = 0; i < targetPositions.size(); i++ )
10476   {
10477     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[i], AlphaFunction::LINEAR);
10478   }
10479
10480   application.SendNotification();
10481   application.Render();
10482
10483   tet_infoline("Ensure position of actor is still at intial value");
10484
10485   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), initialPosition.x, TEST_LOCATION );
10486   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), initialPosition.y, TEST_LOCATION );
10487   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), initialPosition.z, TEST_LOCATION );
10488
10489   tet_infoline("Play animation and ensure actor position is now target");
10490
10491   animation.Play();
10492   application.SendNotification();
10493   application.Render(1000u);
10494
10495   tet_infoline("Ensure position of actor is at target value when aninmation half way");
10496
10497   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10498   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10499   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10500
10501   tet_printf( "x position at half way point(%f)\n", actor.GetCurrentPosition().x );
10502
10503   application.Render(2000u);
10504
10505   tet_infoline("Ensure position of actor is still at target value when aninmation complete");
10506
10507   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[2].x, TEST_LOCATION );
10508   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[2].y, TEST_LOCATION );
10509   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[2].z, TEST_LOCATION );
10510
10511   END_TEST;
10512 }
10513
10514 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionP(void)
10515 {
10516   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");
10517
10518   TestApplication application;
10519
10520   std::vector<Vector3> targetSizes;
10521   std::vector<Vector3> targetPositions;
10522
10523   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10524   targetSizes.push_back( Vector3( 50.0f, 10.0f, 100.0f ) );
10525
10526   targetPositions.push_back( Vector3( 200.0f, 1.0f, 100.0f ) );
10527
10528   tet_infoline("Set initial position and set up animation to re-position actor");
10529
10530   Actor actor = Actor::New();
10531   Stage::GetCurrent().Add(actor);
10532   Vector3 initialSize( 10.0f, 10.0f, 10.0f);
10533   Vector3 initialPosition(10.0f, 10.0f, 10.0f);
10534
10535   actor.SetProperty( Actor::Property::SIZE, initialSize );
10536   actor.SetProperty( Actor::Property::POSITION, initialPosition );
10537
10538   // Build the animation
10539   Animation animation = Animation::New(2.0f);
10540
10541   tet_infoline("Set target size in animation without intiating play");
10542   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10543   tet_infoline("Set target position in animation without intiating play");
10544   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPositions[0], AlphaFunction::LINEAR);
10545   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10546
10547   application.SendNotification();
10548   application.Render();
10549
10550   tet_infoline("Ensure position of actor is still at intial size and position");
10551
10552   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10553   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10554   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10555
10556   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialPosition.x, TEST_LOCATION );
10557   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialPosition.y, TEST_LOCATION );
10558   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialPosition.z, TEST_LOCATION );
10559
10560   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10561
10562   animation.Play();
10563   application.SendNotification();
10564   application.Render(2000u);
10565
10566   tet_infoline("Ensure position and size of actor is at target value when aninmation playing");
10567
10568   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10569   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10570   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10571
10572   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetPositions[0].x, TEST_LOCATION );
10573   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetPositions[0].y, TEST_LOCATION );
10574   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetPositions[0].z, TEST_LOCATION );
10575
10576   END_TEST;
10577 }
10578
10579 int UtcDaliAnimationSetAndGetTargetBeforePlayMulitpleAnimatorsSizeAndPositionColourP(void)
10580 {
10581   tet_infoline("Setting up an animation should not effect it's size property until the animation plays even if other Properties animated");
10582
10583   TestApplication application;
10584
10585   std::vector<Vector3> targetSizes;
10586   std::vector<float> targetColors;
10587
10588   targetSizes.push_back( Vector3( 100.0f, 100.0f, 100.0f ) );
10589   targetSizes.push_back( Vector3( 50.0f, 10.0f, 150.0f ) );
10590
10591   targetColors.push_back( 1.0f );
10592
10593   tet_infoline("Set initial position and set up animation to re-position actor");
10594
10595   Actor actor = Actor::New();
10596   Stage::GetCurrent().Add(actor);
10597   Vector3 initialSize( 10.0f, 5.0f, 10.0f);
10598
10599   actor.SetProperty( Actor::Property::SIZE, initialSize );
10600
10601   // Build the animation
10602   Animation animation = Animation::New(2.0f);
10603
10604   tet_infoline("Set target size in animation without initiating play");
10605   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[0], AlphaFunction::LINEAR);
10606   tet_infoline("Set target position in animation without intiating play");
10607   animation.AnimateTo(Property(actor, Actor::Property::COLOR_RED), targetColors[0], AlphaFunction::LINEAR);
10608   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetSizes[1], AlphaFunction::LINEAR);
10609
10610   application.SendNotification();
10611   application.Render();
10612
10613   tet_infoline("Ensure position of actor is still at initial size and position");
10614
10615   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), initialSize.x, TEST_LOCATION );
10616   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), initialSize.y, TEST_LOCATION );
10617   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), initialSize.z, TEST_LOCATION );
10618
10619   tet_infoline("Play animation and ensure actor position and size is now matches targets");
10620
10621   animation.Play();
10622   application.SendNotification();
10623   application.Render(2000u);
10624
10625   tet_infoline("Ensure position and size of actor is at target value when animation playing");
10626
10627   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetSizes[1].x, TEST_LOCATION );
10628   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetSizes[1].y, TEST_LOCATION );
10629   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetSizes[1].z, TEST_LOCATION );
10630
10631   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED), targetColors[0], TEST_LOCATION );
10632
10633   END_TEST;
10634 }
10635
10636 int UtcDaliAnimationTimePeriodOrder(void)
10637 {
10638   tet_infoline("Animate the same property with different time periods and ensure it runs correctly and ends up in the right place" );
10639
10640   TestApplication application;
10641
10642   Actor actor = Actor::New();
10643   Stage::GetCurrent().Add( actor );
10644
10645   application.SendNotification();
10646   application.Render();
10647
10648   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10649   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10650   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10651   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10652   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10653
10654   //////////////////////////////////////////////////////////////////////////////////
10655
10656   tet_infoline( "With two AnimateTo calls" );
10657
10658   Animation animation = Animation::New( 0.0f );
10659   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
10660   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
10661   animation.Play();
10662
10663   tet_infoline( "The target position should change instantly" );
10664   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10665   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10666
10667   application.SendNotification();
10668   application.Render(5000); // After the animation is complete
10669
10670   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10671   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10672   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10673
10674   //////////////////////////////////////////////////////////////////////////////////
10675
10676   tet_infoline( "Same animation again but in a different order - should yield the same result" );
10677
10678   actor.SetX( 0.0f );
10679   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10680   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10681
10682   application.SendNotification();
10683   application.Render();
10684
10685   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10686   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10687   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10688
10689   animation = Animation::New( 0.0f );
10690   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 1.0f, 1.0f ) );
10691   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f, TimePeriod( 3.0f, 1.0f ) );
10692   animation.Play();
10693
10694   tet_infoline( "The target position should change instantly" );
10695   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10696   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10697
10698   application.SendNotification();
10699   application.Render(5000); // After the animation is complete
10700
10701   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10702   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), TEST_LOCATION );
10703   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 100.0f, TEST_LOCATION );
10704
10705   END_TEST;
10706 }
10707
10708 int UtcDaliAnimationTimePeriodOrderSeveralAnimateToCalls(void)
10709 {
10710   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" );
10711
10712   TestApplication application;
10713
10714   Actor actor = Actor::New();
10715   Stage::GetCurrent().Add( actor );
10716
10717   application.SendNotification();
10718   application.Render();
10719
10720   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10721   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10722   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10723   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10724   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10725
10726   //////////////////////////////////////////////////////////////////////////////////
10727
10728   tet_infoline( "" );
10729
10730   Animation animation = Animation::New( 0.0f );
10731   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
10732   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
10733   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
10734   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
10735   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
10736   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
10737   animation.Play();
10738
10739   tet_infoline( "The target position should change instantly" );
10740   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10741   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
10742
10743   application.SendNotification();
10744   application.Render(14000); // After the animation is complete
10745
10746   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10747   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10748   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
10749
10750   //////////////////////////////////////////////////////////////////////////////////
10751
10752   tet_infoline( "Same animation again but in a different order - should end up at the same point" );
10753
10754   actor.SetX( 0.0f );
10755
10756   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10757   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10758
10759   application.SendNotification();
10760   application.Render();
10761
10762   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
10763   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::ZERO, TEST_LOCATION );
10764   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 0.0f, TEST_LOCATION );
10765
10766   animation = Animation::New( 0.0f );
10767   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 200.0f, TimePeriod( 2.0f, 5.0f ) );
10768   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 10.0f, TimePeriod( 10.0f, 2.0f ) );
10769   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 145.0f, TimePeriod( 3.0f, 10.0f ) );
10770   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1000.0f, TimePeriod( 4.0f, 2.0f ) );
10771   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 1.0f, TimePeriod( 3.0f, 4.0f ) );
10772   animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 109.0f, TimePeriod( 1.0f, 1.0f ) );
10773   animation.Play();
10774
10775   tet_infoline( "The target position should change instantly" );
10776   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10777   DALI_TEST_EQUALS( actor.GetProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
10778
10779   application.SendNotification();
10780   application.Render(14000); // After the animation is complete
10781
10782   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10783   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3( 145.0f, 0.0f, 0.0f ), TEST_LOCATION );
10784   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), 145.0f, TEST_LOCATION );
10785
10786   END_TEST;
10787 }