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