[dali_1.1.16] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Animation.cpp
1 /*
2  * Copyright (c) 2014 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-test-suite-utils.h>
24
25 using std::max;
26 using namespace Dali;
27
28 void utc_dali_animation_startuP(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void utc_dali_animation_cleanuP(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40
41 static const float ROTATION_EPSILON = 0.0001f;
42 static const float VECTOR4_EPSILON = 0.0001f;
43
44 // Functor to test whether a Finish signal is emitted
45 struct AnimationFinishCheck
46 {
47   AnimationFinishCheck(bool& signalReceived)
48   : mSignalReceived(signalReceived)
49   {
50   }
51
52   void operator()(Animation& animation)
53   {
54     mSignalReceived = true;
55   }
56
57   void Reset()
58   {
59     mSignalReceived = false;
60   }
61
62   void CheckSignalReceived()
63   {
64     if (!mSignalReceived)
65     {
66       tet_printf("Expected Finish signal was not received\n");
67       tet_result(TET_FAIL);
68     }
69     else
70     {
71       tet_result(TET_PASS);
72     }
73   }
74
75   void CheckSignalNotReceived()
76   {
77     if (mSignalReceived)
78     {
79       tet_printf("Unexpected Finish signal was received\n");
80       tet_result(TET_FAIL);
81     }
82     else
83     {
84       tet_result(TET_PASS);
85     }
86   }
87
88   bool& mSignalReceived; // owned by individual tests
89 };
90
91 } // anon namespace
92
93 int UtcDaliAnimationConstructorP(void)
94 {
95   TestApplication application;
96
97   Animation animation;
98
99   DALI_TEST_CHECK( !animation );
100   END_TEST;
101 }
102
103 int UtcDaliAnimationNewP(void)
104 {
105   TestApplication application;
106
107   Animation animation = Animation::New( 1.0f );
108
109   DALI_TEST_CHECK(animation);
110   END_TEST;
111 }
112
113 int UtcDaliAnimationNewN(void)
114 {
115   TestApplication application;
116
117   Animation animation = Animation::New( -1.0f );
118
119   DALI_TEST_CHECK(animation);
120   DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
121   END_TEST;
122 }
123
124 int UtcDaliAnimationDownCastP(void)
125 {
126   TestApplication application;
127
128   tet_infoline("Testing Dali::Animation::DownCast()");
129
130   float durationSeconds(1.0f);
131   Animation animation = Animation::New(durationSeconds);
132
133   BaseHandle object(animation);
134
135   Animation animation2 = Animation::DownCast(object);
136   DALI_TEST_CHECK(animation2);
137
138   Animation animation3 = DownCast< Animation >(object);
139   DALI_TEST_CHECK(animation3);
140   END_TEST;
141 }
142
143 int UtcDaliAnimationDownCastN(void)
144 {
145   TestApplication application;
146
147   BaseHandle unInitializedObject;
148
149   Animation animation1 = Animation::DownCast( unInitializedObject );
150   DALI_TEST_CHECK( !animation1 );
151
152   Animation animation2 = DownCast< Animation >( unInitializedObject );
153   DALI_TEST_CHECK( !animation2 );
154   END_TEST;
155 }
156
157 int UtcDaliAnimationCopyConstructorP(void)
158 {
159   TestApplication application;
160
161   // Initialize an object, ref count == 1
162   Animation animation = Animation::New( 1.0f );
163
164   Animation copy( animation );
165   DALI_TEST_CHECK( copy );
166
167   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
168   END_TEST;
169 }
170
171 int UtcDaliAnimationAssignmentOperatorP(void)
172 {
173   TestApplication application;
174
175   Animation animation = Animation::New( 1.0f );
176
177   Animation copy = animation;
178   DALI_TEST_CHECK( copy );
179
180   DALI_TEST_CHECK( animation == copy );
181
182   DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
183   END_TEST;
184 }
185
186 int UtcDaliAnimationSetDurationP(void)
187 {
188   TestApplication application;
189
190   Actor actor = Actor::New();
191   Stage::GetCurrent().Add(actor);
192
193   // Build the animation
194   float durationSeconds(1.0f);
195   Animation animation = Animation::New(durationSeconds);
196   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
197
198   // Start the animation
199   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
200   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
201   animation.Play();
202
203   bool signalReceived(false);
204   AnimationFinishCheck finishCheck(signalReceived);
205   animation.FinishedSignal().Connect(&application, finishCheck);
206
207   application.SendNotification();
208   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
209
210   // We didn't expect the animation to finish yet
211   application.SendNotification();
212   finishCheck.CheckSignalNotReceived();
213
214   application.Render(2u/*just beyond the animation duration*/);
215
216   // We did expect the animation to finish
217   application.SendNotification();
218   finishCheck.CheckSignalReceived();
219   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
220
221   // Restart the animation, with a different duration
222   finishCheck.Reset();
223   actor.SetPosition(Vector3::ZERO);
224   durationSeconds = 3.5f;
225   animation.SetDuration(durationSeconds);
226   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
227   animation.Play();
228
229   application.SendNotification();
230   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
231
232   // We didn't expect the animation to finish yet
233   application.SendNotification();
234   finishCheck.CheckSignalNotReceived();
235
236   application.Render(2u/*just beyond the animation duration*/);
237
238   // We did expect the animation to finish
239   application.SendNotification();
240   finishCheck.CheckSignalReceived();
241   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
242
243   // Check that nothing has changed after a couple of buffer swaps
244   application.Render(0);
245   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
246   application.Render(0);
247   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
248   END_TEST;
249 }
250
251 int UtcDaliAnimationSetDurationN(void)
252 {
253   TestApplication application;
254
255   Animation animation = Animation::New( 1.0f );
256   DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
257
258   animation.SetDuration( -1.0f );
259   DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
260   END_TEST;
261 }
262
263 int UtcDaliAnimationGetDurationP(void)
264 {
265   TestApplication application;
266
267   Animation animation = Animation::New(1.0f);
268   DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
269
270   animation.SetDuration(2.0f);
271   DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
272   END_TEST;
273 }
274
275 int UtcDaliAnimationSetLoopingP(void)
276 {
277   TestApplication application;
278
279   Actor actor = Actor::New();
280   Stage::GetCurrent().Add(actor);
281
282   // Build the animation
283   float durationSeconds(1.0f);
284   Animation animation = Animation::New(durationSeconds);
285   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
286   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
287
288   // Start the animation
289   animation.SetLooping(true);
290   DALI_TEST_CHECK(animation.IsLooping());
291   animation.Play();
292
293   bool signalReceived(false);
294   AnimationFinishCheck finishCheck(signalReceived);
295   animation.FinishedSignal().Connect(&application, finishCheck);
296
297   application.SendNotification();
298
299   // Loop 5 times
300   float intervalSeconds = 0.25f;
301   float progress = 0.0f;
302   for (int iterations = 0; iterations < 5;)
303   {
304     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
305
306     progress += intervalSeconds;
307     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
308
309     if (progress >= 1.0f)
310     {
311       progress = progress - 1.0f;
312       ++iterations;
313     }
314   }
315
316   // We didn't expect the animation to finish yet
317   application.SendNotification();
318   finishCheck.CheckSignalNotReceived();
319
320   animation.SetLooping(false);
321   DALI_TEST_CHECK(!animation.IsLooping());
322
323   application.SendNotification();
324   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
325
326   // We did expect the animation to finish
327   application.SendNotification();
328   finishCheck.CheckSignalReceived();
329   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
330
331   // Check that nothing has changed after a couple of buffer swaps
332   application.Render(0);
333   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
334   application.Render(0);
335   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
336   END_TEST;
337 }
338
339 int UtcDaliAnimationIsLoopingP(void)
340 {
341   TestApplication application;
342
343   Animation animation = Animation::New(1.0f);
344   DALI_TEST_CHECK(!animation.IsLooping());
345
346   animation.SetLooping(true);
347   DALI_TEST_CHECK(animation.IsLooping());
348   END_TEST;
349 }
350
351 int UtcDaliAnimationSetEndActioN(void)
352 {
353   TestApplication application;
354
355   Actor actor = Actor::New();
356   Stage::GetCurrent().Add(actor);
357
358   // Build the animation
359   float durationSeconds(1.0f);
360   Animation animation = Animation::New(durationSeconds);
361   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
362
363   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
364   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
365
366   // Start the animation
367   animation.Play();
368
369   bool signalReceived(false);
370   AnimationFinishCheck finishCheck(signalReceived);
371   animation.FinishedSignal().Connect(&application, finishCheck);
372
373   application.SendNotification();
374   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
375
376   // We did expect the animation to finish
377   application.SendNotification();
378   finishCheck.CheckSignalReceived();
379   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
380
381   // Go back to the start
382   actor.SetPosition(Vector3::ZERO);
383   application.SendNotification();
384   application.Render(0);
385   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
386
387   // Test BakeFinal, animate again, for half the duration
388   finishCheck.Reset();
389   animation.SetEndAction(Animation::BakeFinal);
390   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
391   animation.Play();
392
393   application.SendNotification();
394   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
395
396   // Stop the animation early
397   animation.Stop();
398
399   // We did NOT expect the animation to finish
400   application.SendNotification();
401   finishCheck.CheckSignalNotReceived();
402   DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
403
404   // The position should be same with target position in the next frame
405   application.Render(0);
406   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
407
408   // Go back to the start
409   actor.SetPosition(Vector3::ZERO);
410   application.SendNotification();
411   application.Render(0);
412   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
413
414   // Test EndAction::Discard, animate again, but don't bake this time
415   finishCheck.Reset();
416   animation.SetEndAction(Animation::Discard);
417   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
418   animation.Play();
419
420   application.SendNotification();
421   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
422
423   // We did expect the animation to finish
424   application.SendNotification();
425   finishCheck.CheckSignalReceived();
426   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
427
428   // The position should be discarded in the next frame
429   application.Render(0);
430   DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION );
431
432   // Check that nothing has changed after a couple of buffer swaps
433   application.Render(0);
434   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
435   application.Render(0);
436   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION );
437   END_TEST;
438 }
439
440 int UtcDaliAnimationGetEndActionP(void)
441 {
442   TestApplication application;
443
444   Animation animation = Animation::New(1.0f);
445   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake);
446
447   animation.SetEndAction(Animation::Discard);
448   DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard);
449
450   animation.SetEndAction(Animation::BakeFinal);
451   DALI_TEST_CHECK(animation.GetEndAction() == Animation::BakeFinal);
452
453   END_TEST;
454 }
455
456 int UtcDaliAnimationSetDisconnectActionP(void)
457 {
458   TestApplication application;
459   Stage stage( Stage::GetCurrent() );
460
461   // Default: BakeFinal
462   {
463     Actor actor = Actor::New();
464     stage.Add(actor);
465
466     // Build the animation
467     float durationSeconds(1.0f);
468     Animation animation = Animation::New(durationSeconds);
469     DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal);
470
471     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
472     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
473
474     // Start the animation
475     animation.Play();
476
477     application.SendNotification();
478     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
479
480     actor.Unparent();
481
482     application.SendNotification();
483     application.Render();
484
485     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
486   }
487
488   // Bake
489   {
490     Actor actor = Actor::New();
491     stage.Add(actor);
492
493     // Build the animation
494     float durationSeconds(1.0f);
495     Animation animation = Animation::New(durationSeconds);
496     animation.SetDisconnectAction( Animation::Bake );
497
498     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
499     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
500
501     // Start the animation
502     animation.Play();
503
504     application.SendNotification();
505     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
506
507     actor.Unparent();
508
509     application.SendNotification();
510     application.Render();
511
512     DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
513   }
514
515   // Discard
516   {
517     Actor actor = Actor::New();
518     stage.Add(actor);
519
520     // Build the animation
521     float durationSeconds(1.0f);
522     Animation animation = Animation::New(durationSeconds);
523     animation.SetDisconnectAction( Animation::Discard );
524
525     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
526     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
527
528     // Start the animation
529     animation.Play();
530
531     application.SendNotification();
532     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
533
534     actor.Unparent();
535
536     application.SendNotification();
537     application.Render();
538
539     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
540   }
541
542   // Don't play the animation: disconnect action should not be applied
543   {
544     Actor actor = Actor::New();
545     stage.Add(actor);
546
547     // Build the animation
548     float durationSeconds(1.0f);
549     Animation animation = Animation::New(durationSeconds);
550
551     Vector3 targetPosition(10.0f, 10.0f, 10.0f);
552     animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
553
554     application.SendNotification();
555     application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
556
557     actor.Unparent();
558
559     application.SendNotification();
560     application.Render();
561
562     DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
563   }
564
565   END_TEST;
566 }
567
568 int UtcDaliAnimationGetDisconnectActionP(void)
569 {
570   TestApplication application;
571   Animation animation = Animation::New(1.0f);
572   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
573
574   animation.SetDisconnectAction(Animation::Discard);
575   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Discard);
576
577   animation.SetDisconnectAction(Animation::Bake);
578   DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::Bake);
579
580   END_TEST;
581 }
582
583 int UtcDaliAnimationSetDefaultAlphaFunctionP(void)
584 {
585   TestApplication application;
586
587   Animation animation = Animation::New(1.0f);
588   AlphaFunction func = animation.GetDefaultAlphaFunction();
589   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
590
591   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
592   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
593   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
594   END_TEST;
595 }
596
597 int UtcDaliAnimationGetDefaultAlphaFunctionP(void)
598 {
599   TestApplication application;
600
601   Animation animation = Animation::New(1.0f);
602   AlphaFunction func = animation.GetDefaultAlphaFunction();
603
604   // Test that the default is linear
605   DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
606
607   animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN);
608   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
609   DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
610
611   END_TEST;
612 }
613
614 int UtcDaliAnimationSetCurrentProgressP(void)
615 {
616   TestApplication application;
617
618   Actor actor = Actor::New();
619   Stage::GetCurrent().Add(actor);
620
621   // Build the animation
622   Animation animation = Animation::New(0.0f);
623
624   //Set duration
625   float durationSeconds(1.0f);
626   animation.SetDuration(durationSeconds);
627
628   bool signalReceived(false);
629   AnimationFinishCheck finishCheck(signalReceived);
630   animation.FinishedSignal().Connect(&application, finishCheck);
631   application.SendNotification();
632
633   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
634   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
635
636   // Start the animation from 40% progress
637   animation.SetCurrentProgress( 0.4f );
638   animation.Play();
639
640   application.SendNotification();
641   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
642
643   // We didn't expect the animation to finish yet
644   application.SendNotification();
645   finishCheck.CheckSignalNotReceived();
646   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
647   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
648
649   animation.Play(); // Test that calling play has no effect, when animation is already playing
650   application.SendNotification();
651
652   //Set the progress to 70%
653   animation.SetCurrentProgress( 0.7f );
654   application.SendNotification();
655   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
656   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
657
658   application.SendNotification();
659   finishCheck.CheckSignalNotReceived();
660   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
661   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
662
663   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
664   // We did expect the animation to finish
665   application.SendNotification();
666   finishCheck.CheckSignalReceived();
667   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
668
669   // Check that nothing has changed after a couple of buffer swaps
670   application.Render(0);
671   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
672   application.Render(0);
673   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
674   END_TEST;
675 }
676
677 int UtcDaliAnimationSetCurrentProgressN(void)
678 {
679   TestApplication application;
680
681   Actor actor = Actor::New();
682   Stage::GetCurrent().Add(actor);
683
684   // Build the animation
685   Animation animation = Animation::New(0.0f);
686
687   //Set duration
688   float durationSeconds(1.0f);
689   animation.SetDuration(durationSeconds);
690
691   bool signalReceived(false);
692   AnimationFinishCheck finishCheck(signalReceived);
693   animation.FinishedSignal().Connect(&application, finishCheck);
694   application.SendNotification();
695
696   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
697   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
698
699   //Trying to set the current cursor outside the range [0..1] is ignored
700   animation.SetCurrentProgress( -1.0f);
701   application.SendNotification();
702   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
703
704   animation.SetCurrentProgress( 100.0f);
705   application.SendNotification();
706   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
707   END_TEST;
708 }
709
710 int UtcDaliAnimationGetCurrentProgressP(void)
711 {
712   TestApplication application;
713
714   Actor actor = Actor::New();
715   Stage::GetCurrent().Add(actor);
716
717   // Build the animation
718   Animation animation = Animation::New(0.0f);
719   animation.Play();
720
721   //Test GetCurrentProgress return 0.0 as the duration is 0.0
722   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
723
724   animation.SetCurrentProgress( 0.5f );
725   application.SendNotification();
726   application.Render(static_cast<unsigned int>(100.0f));
727
728   //Progress should still be 0.0
729   DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
730
731   //Set duration
732   float durationSeconds(1.0f);
733   animation.SetDuration(durationSeconds);
734   application.SendNotification();
735
736   bool signalReceived(false);
737   AnimationFinishCheck finishCheck(signalReceived);
738   animation.FinishedSignal().Connect(&application, finishCheck);
739   application.SendNotification();
740
741   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
742   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
743
744   // Start the animation from 40% progress
745   animation.SetCurrentProgress( 0.4f );
746   animation.Play();
747
748   application.SendNotification();
749   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
750
751   // We didn't expect the animation to finish yet
752   application.SendNotification();
753   finishCheck.CheckSignalNotReceived();
754   DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
755
756   animation.Play(); // Test that calling play has no effect, when animation is already playing
757   application.SendNotification();
758
759   //Set the progress to 70%
760   animation.SetCurrentProgress( 0.7f );
761   application.SendNotification();
762   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
763   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
764
765   application.SendNotification();
766   finishCheck.CheckSignalNotReceived();
767   DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
768
769   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
770   // We did expect the animation to finish
771   application.SendNotification();
772   finishCheck.CheckSignalReceived();
773   END_TEST;
774 }
775
776 int UtcDaliAnimationSetSpeedFactorP(void)
777 {
778   TestApplication application;
779
780   Actor actor = Actor::New();
781   Stage::GetCurrent().Add(actor);
782
783   // Build the animation
784   float durationSeconds(1.0f);
785   Animation animation = Animation::New(durationSeconds);
786
787   const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
788   const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
789
790   KeyFrames keyframes = KeyFrames::New();
791   keyframes.Add( 0.0f, initialPosition);
792   keyframes.Add( 1.0f, targetPosition );
793   animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR);
794
795   //Set speed to be x2
796   animation.SetSpeedFactor(2.0f);
797
798   // Start the animation
799   animation.Play();
800
801   bool signalReceived(false);
802   AnimationFinishCheck finishCheck(signalReceived);
803   animation.FinishedSignal().Connect(&application, finishCheck);
804
805   application.SendNotification();
806   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
807
808   // We didn't expect the animation to finish yet
809   application.SendNotification();
810   finishCheck.CheckSignalNotReceived();
811   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
812
813   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
814
815   // We didn't expect the animation to finish yet
816   application.SendNotification();
817   finishCheck.CheckSignalNotReceived();
818   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
819
820   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
821
822   // We did expect the animation to finish
823   application.SendNotification();
824   finishCheck.CheckSignalReceived();
825   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
826
827   // Check that nothing has changed after a couple of buffer swaps
828   application.Render(0);
829   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
830   application.Render(0);
831   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
832
833   finishCheck.Reset();
834
835   //Test -1 speed factor. Animation will play in reverse at normal speed
836   animation.SetSpeedFactor( -1.0f );
837
838   // Start the animation
839   animation.Play();
840
841   application.SendNotification();
842   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
843
844   // We didn't expect the animation to finish yet
845   application.SendNotification();
846   finishCheck.CheckSignalNotReceived();
847   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
848
849   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
850
851   // We didn't expect the animation to finish yet
852   application.SendNotification();
853   finishCheck.CheckSignalNotReceived();
854   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
855
856   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
857
858   // We didn't expect the animation to finish yet
859   application.SendNotification();
860   finishCheck.CheckSignalNotReceived();
861   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
862
863   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
864
865   // We didn't expect the animation to finish yet
866   application.SendNotification();
867   finishCheck.CheckSignalNotReceived();
868   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
869
870   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
871
872   // We did expect the animation to finish
873   application.SendNotification();
874   finishCheck.CheckSignalReceived();
875   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
876
877   // Check that nothing has changed after a couple of buffer swaps
878   application.Render(0);
879   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
880   application.Render(0);
881   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
882
883   //Test change speed factor on the fly
884   finishCheck.Reset();
885
886   //Set speed to be half of normal speed
887   animation.SetSpeedFactor( 0.5f );
888
889   // Start the animation
890   animation.Play();
891
892   application.SendNotification();
893   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
894
895   // We didn't expect the animation to finish yet
896   application.SendNotification();
897   finishCheck.CheckSignalNotReceived();
898   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
899
900   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
901
902   // We didn't expect the animation to finish yet
903   application.SendNotification();
904   finishCheck.CheckSignalNotReceived();
905   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
906
907   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
908
909   // We didn't expect the animation to finish yet
910   application.SendNotification();
911   finishCheck.CheckSignalNotReceived();
912   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
913
914   //Change speed factor while animation still playing.
915   animation.SetSpeedFactor(-1.0f);
916   application.SendNotification();
917   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
918
919   // We didn't expect the animation to finish yet
920   application.SendNotification();
921   finishCheck.CheckSignalNotReceived();
922   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
923
924   application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond the animation duration*/);
925
926   // We did expect the animation to finish
927   application.SendNotification();
928   finishCheck.CheckSignalReceived();
929   DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
930
931   // Check that nothing has changed after a couple of buffer swaps
932   application.Render(0);
933   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
934   application.Render(0);
935   DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
936   END_TEST;
937 }
938
939 int UtcDaliAnimationGetSpeedFactorP(void)
940 {
941   TestApplication application;
942
943   Animation animation = Animation::New(1.0f);
944   animation.SetSpeedFactor(0.5f);
945   DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
946
947   animation.SetSpeedFactor(-2.5f);
948   DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
949   END_TEST;
950 }
951
952 int UtcDaliAnimationSetPlayRangeP(void)
953 {
954   TestApplication application;
955
956   Actor actor = Actor::New();
957   Stage::GetCurrent().Add( actor );
958
959   // Build the animation
960   float durationSeconds( 1.0f );
961   Animation animation = Animation::New( durationSeconds );
962
963   bool signalReceived( false );
964   AnimationFinishCheck finishCheck( signalReceived );
965   animation.FinishedSignal().Connect( &application, finishCheck );
966   application.SendNotification();
967
968   // Set range between 0.4 and 0.8
969   animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
970   application.SendNotification();
971   DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
972
973   Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
974   animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
975
976   // Start the animation from 40% progress
977   animation.Play();
978
979   application.SendNotification();
980   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
981
982   // We didn't expect the animation to finish yet
983   application.SendNotification();
984   finishCheck.CheckSignalNotReceived();
985   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
986
987   application.SendNotification();
988   application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
989
990   application.SendNotification();
991   finishCheck.CheckSignalNotReceived();
992   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
993
994   application.SendNotification();
995   application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
996
997   // We did expect the animation to finish
998   application.SendNotification();
999   finishCheck.CheckSignalReceived();
1000   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1001   END_TEST;
1002 }
1003
1004 int UtcDaliAnimationSetPlayRangeN(void)
1005 {
1006   TestApplication application;
1007
1008   Actor actor = Actor::New();
1009   Stage::GetCurrent().Add(actor);
1010
1011   // Build the animation
1012   Animation animation = Animation::New(0);
1013   application.SendNotification();
1014
1015   //PlayRange out of bounds
1016   animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1017   application.SendNotification();
1018   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1019   animation.SetPlayRange( Vector2(0.0f,2.0f) );
1020   application.SendNotification();
1021   DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1022
1023   //If playRange is not in the correct order it has to be ordered
1024   animation.SetPlayRange( Vector2(0.8f,0.2f) );
1025   application.SendNotification();
1026   DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1027
1028   END_TEST;
1029 }
1030
1031 int UtcDaliAnimationGetPlayRangeP(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( 1.0f );
1040   application.SendNotification();
1041
1042   //If PlayRange not specified it should be 0.0-1.0 by default
1043   DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1044
1045   // Set range between 0.4 and 0.8
1046   animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1047   application.SendNotification();
1048   DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
1049
1050   END_TEST;
1051 }
1052
1053 int UtcDaliAnimationPlayP(void)
1054 {
1055   TestApplication application;
1056
1057   Actor actor = Actor::New();
1058   Stage::GetCurrent().Add(actor);
1059
1060   // Build the animation
1061   float durationSeconds(1.0f);
1062   Animation animation = Animation::New(durationSeconds);
1063   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1064   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1065
1066   // Start the animation
1067   animation.Play();
1068
1069   bool signalReceived(false);
1070   AnimationFinishCheck finishCheck(signalReceived);
1071   animation.FinishedSignal().Connect(&application, finishCheck);
1072
1073   application.SendNotification();
1074   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1075
1076   // We didn't expect the animation to finish yet
1077   application.SendNotification();
1078   finishCheck.CheckSignalNotReceived();
1079   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1080
1081   animation.Play(); // Test that calling play has no effect, when animation is already playing
1082   application.SendNotification();
1083   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1084
1085   // We didn't expect the animation to finish yet
1086   application.SendNotification();
1087   finishCheck.CheckSignalNotReceived();
1088   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1089
1090   animation.Play(); // Test that calling play has no effect, when animation is already playing
1091   application.SendNotification();
1092   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1093
1094   // We didn't expect the animation to finish yet
1095   application.SendNotification();
1096   finishCheck.CheckSignalNotReceived();
1097   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1098
1099   animation.Play(); // Test that calling play has no effect, when animation is already playing
1100   application.SendNotification();
1101   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1102
1103   // We didn't expect the animation to finish yet
1104   application.SendNotification();
1105   finishCheck.CheckSignalNotReceived();
1106   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1107
1108   animation.Play(); // Test that calling play has no effect, when animation is already playing
1109   application.SendNotification();
1110   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1111
1112   // We did expect the animation to finish
1113   application.SendNotification();
1114   finishCheck.CheckSignalReceived();
1115   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1116
1117   // Check that nothing has changed after a couple of buffer swaps
1118   application.Render(0);
1119   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1120   application.Render(0);
1121   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1122   END_TEST;
1123 }
1124
1125 int UtcDaliAnimationPlayOffStageP(void)
1126 {
1127   // Test that an animation can be played, when the actor is off-stage.
1128   // When the actor is added to the stage, it should appear at the current position
1129   // i.e. where it would have been anyway, if on-stage from the beginning.
1130
1131   TestApplication application;
1132
1133   Actor actor = Actor::New();
1134   Vector3 basePosition(Vector3::ZERO);
1135   DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
1136   // Not added to the stage!
1137
1138   // Build the animation
1139   float durationSeconds(1.0f);
1140   Animation animation = Animation::New(durationSeconds);
1141   animation.SetDisconnectAction( Animation::Discard );
1142   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1143   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1144
1145   // Start the animation
1146   animation.Play();
1147
1148   bool signalReceived(false);
1149   AnimationFinishCheck finishCheck(signalReceived);
1150   animation.FinishedSignal().Connect(&application, finishCheck);
1151
1152   application.SendNotification();
1153   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1154
1155   // We didn't expect the animation to finish yet
1156   application.SendNotification();
1157   finishCheck.CheckSignalNotReceived();
1158   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
1159
1160   // Add to the stage
1161   Stage::GetCurrent().Add(actor);
1162
1163   application.SendNotification();
1164   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1165
1166   // We didn't expect the animation to finish yet
1167   application.SendNotification();
1168   finishCheck.CheckSignalNotReceived();
1169   Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
1170   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
1171
1172   // Remove from the stage
1173   Stage::GetCurrent().Remove(actor);
1174
1175   application.SendNotification();
1176   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1177
1178   // We didn't expect the animation to finish yet
1179   application.SendNotification();
1180   finishCheck.CheckSignalNotReceived();
1181   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
1182
1183   // Add to the stage
1184   Stage::GetCurrent().Add(actor);
1185
1186   application.SendNotification();
1187   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1188
1189   // We didn't expect the animation to finish yet
1190   application.SendNotification();
1191   finishCheck.CheckSignalNotReceived();
1192   expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
1193   DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
1194
1195   application.SendNotification();
1196   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1197
1198   // We did expect the animation to finish
1199   application.SendNotification();
1200   finishCheck.CheckSignalReceived();
1201   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1202
1203   // Check that nothing has changed after a couple of buffer swaps
1204   application.Render(0);
1205   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1206   application.Render(0);
1207   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1208   END_TEST;
1209 }
1210
1211 int UtcDaliAnimationPlayDiscardHandleP(void)
1212 {
1213   TestApplication application;
1214
1215   Actor actor = Actor::New();
1216   Stage::GetCurrent().Add(actor);
1217
1218   // Build the animation
1219   float durationSeconds(1.0f);
1220   Animation animation = Animation::New(durationSeconds);
1221   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1222   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1223
1224   bool signalReceived(false);
1225   AnimationFinishCheck finishCheck(signalReceived);
1226   animation.FinishedSignal().Connect(&application, finishCheck);
1227
1228   // Start the animation
1229   animation.Play();
1230
1231   // This is a test of the "Fire and Forget" behaviour
1232   // Discard the animation handle!
1233   animation.Reset();
1234   DALI_TEST_CHECK( !animation );
1235
1236   application.SendNotification();
1237   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1238
1239   // We didn't expect the animation to finish yet
1240   application.SendNotification();
1241   finishCheck.CheckSignalNotReceived();
1242   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1243
1244   application.SendNotification();
1245   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1246
1247   // We didn't expect the animation to finish yet
1248   application.SendNotification();
1249   finishCheck.CheckSignalNotReceived();
1250   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1251
1252   application.SendNotification();
1253   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1254
1255   // We didn't expect the animation to finish yet
1256   application.SendNotification();
1257   finishCheck.CheckSignalNotReceived();
1258   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1259
1260   application.SendNotification();
1261   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1262
1263   // We didn't expect the animation to finish yet
1264   application.SendNotification();
1265   finishCheck.CheckSignalNotReceived();
1266   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1267
1268   application.SendNotification();
1269   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1270
1271   // We did expect the animation to finish
1272   application.SendNotification();
1273   finishCheck.CheckSignalReceived();
1274   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1275
1276   // Check that nothing has changed after a couple of buffer swaps
1277   application.Render(0);
1278   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1279   application.Render(0);
1280   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1281   END_TEST;
1282 }
1283
1284 int UtcDaliAnimationPlayStopDiscardHandleP(void)
1285 {
1286   TestApplication application;
1287
1288   Actor actor = Actor::New();
1289   Stage::GetCurrent().Add(actor);
1290
1291   // Build the animation
1292   float durationSeconds(1.0f);
1293   Animation animation = Animation::New(durationSeconds);
1294   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1295   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1296
1297   // Start the animation
1298   animation.Play();
1299
1300   bool signalReceived(false);
1301   AnimationFinishCheck finishCheck(signalReceived);
1302   animation.FinishedSignal().Connect(&application, finishCheck);
1303
1304   application.SendNotification();
1305   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1306
1307   // We didn't expect the animation to finish yet
1308   application.SendNotification();
1309   finishCheck.CheckSignalNotReceived();
1310   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1311
1312   // This is a test of the "Fire and Forget" behaviour
1313   // Stop the animation, and Discard the animation handle!
1314   animation.Stop();
1315   animation.Reset();
1316   DALI_TEST_CHECK( !animation );
1317
1318   application.SendNotification();
1319   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1320
1321   // We expect the animation to finish at 20% progress
1322   application.SendNotification();
1323   finishCheck.CheckSignalReceived();
1324   finishCheck.Reset();
1325   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1326
1327   application.SendNotification();
1328   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1329
1330   // Check that nothing has changed
1331   application.SendNotification();
1332   finishCheck.CheckSignalNotReceived();
1333   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1334
1335   application.SendNotification();
1336   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1337
1338   // Check that nothing has changed
1339   application.SendNotification();
1340   finishCheck.CheckSignalNotReceived();
1341   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1342
1343   application.SendNotification();
1344   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
1345
1346   // Check that nothing has changed
1347   application.SendNotification();
1348   finishCheck.CheckSignalNotReceived();
1349   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1350   END_TEST;
1351 }
1352
1353 int UtcDaliAnimationPlayRangeP(void)
1354 {
1355   TestApplication application;
1356
1357   Actor actor = Actor::New();
1358   Stage::GetCurrent().Add(actor);
1359
1360   // Build the animation
1361   float durationSeconds(1.0f);
1362   Animation animation = Animation::New(durationSeconds);
1363   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1364   KeyFrames keyframes = KeyFrames::New();
1365   keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
1366   keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
1367
1368   animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
1369
1370   // Set range between 0.4 and 0.8
1371   animation.SetPlayRange( Vector2(0.4f,0.8f) );
1372   animation.Play();
1373
1374   bool signalReceived(false);
1375   AnimationFinishCheck finishCheck(signalReceived);
1376   animation.FinishedSignal().Connect(&application, finishCheck);
1377
1378   //Test that setting progress outside the range doesn't work
1379   animation.SetCurrentProgress( 0.9f );
1380   application.SendNotification();
1381   application.Render(0);
1382   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1383   animation.SetCurrentProgress( 0.2f );
1384   application.SendNotification();
1385   application.Render(0);
1386   DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
1387
1388   application.SendNotification();
1389   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1390
1391   // We didn't expect the animation to finish yet
1392   application.SendNotification();
1393   finishCheck.CheckSignalNotReceived();
1394   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1395
1396   animation.Play(); // Test that calling play has no effect, when animation is already playing
1397   application.SendNotification();
1398   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
1399
1400   // We did expect the animation to finish
1401   application.SendNotification();
1402   finishCheck.CheckSignalReceived();
1403   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1404
1405   // Check that nothing has changed after a couple of buffer swaps
1406   application.Render(0);
1407   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1408   application.Render(0);
1409   DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
1410
1411
1412   //Loop inside the range
1413   finishCheck.Reset();
1414   animation.SetLooping( true );
1415   animation.Play();
1416   application.SendNotification();
1417   float intervalSeconds = 0.1f;
1418   float progress = 0.4f;
1419   for (int iterations = 0; iterations < 10; ++iterations )
1420   {
1421     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1422
1423     progress += intervalSeconds;
1424     if (progress > 0.8f)
1425     {
1426       progress = progress - 0.4f;
1427     }
1428
1429     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1430   }
1431
1432   // We didn't expect the animation to finish yet
1433   application.SendNotification();
1434   finishCheck.CheckSignalNotReceived();
1435
1436
1437   //Test change range on the fly
1438   animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
1439   application.SendNotification();
1440
1441   for (int iterations = 0; iterations < 10; ++iterations )
1442   {
1443     application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
1444
1445     progress += intervalSeconds;
1446     if (progress > 0.9f)
1447     {
1448       progress = progress - 0.7f;
1449     }
1450
1451     DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
1452   }
1453
1454   END_TEST;
1455 }
1456
1457 int UtcDaliAnimationPlayFromP(void)
1458 {
1459   TestApplication application;
1460
1461   Actor actor = Actor::New();
1462   Stage::GetCurrent().Add(actor);
1463
1464   // Build the animation
1465   float durationSeconds(1.0f);
1466   Animation animation = Animation::New(durationSeconds);
1467   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1468   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1469
1470   // Start the animation from 40% progress
1471   animation.PlayFrom( 0.4f );
1472
1473   bool signalReceived(false);
1474   AnimationFinishCheck finishCheck(signalReceived);
1475   animation.FinishedSignal().Connect(&application, finishCheck);
1476
1477   application.SendNotification();
1478   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1479
1480   // We didn't expect the animation to finish yet
1481   application.SendNotification();
1482   finishCheck.CheckSignalNotReceived();
1483   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1484
1485   animation.Play(); // Test that calling play has no effect, when animation is already playing
1486   application.SendNotification();
1487   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1488
1489   // We didn't expect the animation to finish yet
1490   application.SendNotification();
1491   finishCheck.CheckSignalNotReceived();
1492   DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1493
1494   application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1495   // We did expect the animation to finish
1496   application.SendNotification();
1497   finishCheck.CheckSignalReceived();
1498   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1499
1500   // Check that nothing has changed after a couple of buffer swaps
1501   application.Render(0);
1502   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1503   application.Render(0);
1504   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1505   END_TEST;
1506 }
1507
1508 int UtcDaliAnimationPlayFromN(void)
1509 {
1510   TestApplication application;
1511
1512   Actor actor = Actor::New();
1513   Stage::GetCurrent().Add(actor);
1514
1515   // Build the animation
1516   float durationSeconds(1.0f);
1517   Animation animation = Animation::New(durationSeconds);
1518   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1519   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1520
1521   //PlayFrom with an argument outside the range [0..1] will be ignored
1522   animation.PlayFrom(-1.0f);
1523   application.SendNotification();
1524   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1525
1526   animation.PlayFrom(100.0f);
1527   application.SendNotification();
1528   DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1529   END_TEST;
1530 }
1531
1532 int UtcDaliAnimationPauseP(void)
1533 {
1534   TestApplication application;
1535
1536   Actor actor = Actor::New();
1537   Stage::GetCurrent().Add(actor);
1538
1539   // Build the animation
1540   float durationSeconds(1.0f);
1541   Animation animation = Animation::New(durationSeconds);
1542   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1543   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1544
1545   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1546
1547   // Start the animation
1548   animation.Play();
1549
1550   bool signalReceived(false);
1551   AnimationFinishCheck finishCheck(signalReceived);
1552   animation.FinishedSignal().Connect(&application, finishCheck);
1553
1554   application.SendNotification();
1555   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1556
1557   // We didn't expect the animation to finish yet
1558   application.SendNotification();
1559   finishCheck.CheckSignalNotReceived();
1560   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1561
1562   // Pause the animation
1563   animation.Pause();
1564   application.SendNotification();
1565
1566   // Loop 5 times
1567   for (int i=0; i<5; ++i)
1568   {
1569     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1570
1571     // We didn't expect the animation to finish yet
1572     application.SendNotification();
1573     finishCheck.CheckSignalNotReceived();
1574     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
1575   }
1576
1577   // Keep going
1578   animation.Play();
1579   application.SendNotification();
1580   application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
1581
1582   // We didn't expect the animation to finish yet
1583   application.SendNotification();
1584   finishCheck.CheckSignalNotReceived();
1585
1586   application.SendNotification();
1587   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
1588
1589   // We did expect the animation to finish
1590   application.SendNotification();
1591   finishCheck.CheckSignalReceived();
1592   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1593
1594   // Check that nothing has changed after a couple of buffer swaps
1595   application.Render(0);
1596   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1597   application.Render(0);
1598   DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1599   END_TEST;
1600 }
1601
1602 int UtcDaliAnimationStoP(void)
1603 {
1604   TestApplication application;
1605
1606   Actor actor = Actor::New();
1607   Stage::GetCurrent().Add(actor);
1608
1609   // Build the animation
1610   float durationSeconds(1.0f);
1611   Animation animation = Animation::New(durationSeconds);
1612   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1613   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1614
1615   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1616
1617   // Start the animation
1618   animation.Play();
1619
1620   bool signalReceived(false);
1621   AnimationFinishCheck finishCheck(signalReceived);
1622   animation.FinishedSignal().Connect(&application, finishCheck);
1623
1624   application.SendNotification();
1625   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1626
1627   // We didn't expect the animation to finish yet
1628   application.SendNotification();
1629   finishCheck.CheckSignalNotReceived();
1630   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1631
1632   // Stop the animation
1633   animation.Stop();
1634   application.SendNotification();
1635
1636   // Loop 5 times
1637   for (int i=0; i<5; ++i)
1638   {
1639     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1640
1641     // We did expect the animation to finish
1642     application.SendNotification();
1643     finishCheck.CheckSignalReceived();
1644     DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
1645   }
1646   END_TEST;
1647 }
1648
1649 int UtcDaliAnimationStopSetPositionP(void)
1650 {
1651   // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
1652   // i.e. to check that the animation does not interfere with the position set.
1653
1654   TestApplication application;
1655
1656   Actor actor = Actor::New();
1657   Stage::GetCurrent().Add(actor);
1658
1659   // Build the animation
1660   float durationSeconds(1.0f);
1661   Animation animation = Animation::New(durationSeconds);
1662   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1663   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1664
1665   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1666
1667   // Start the animation
1668   animation.Play();
1669
1670   bool signalReceived(false);
1671   AnimationFinishCheck finishCheck(signalReceived);
1672   animation.FinishedSignal().Connect(&application, finishCheck);
1673
1674   application.SendNotification();
1675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1676
1677   // We didn't expect the animation to finish yet
1678   application.SendNotification();
1679   finishCheck.CheckSignalNotReceived();
1680   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1681
1682   // Stop the animation
1683   animation.Stop();
1684   Vector3 positionSet(2.0f, 3.0f, 4.0f);
1685   actor.SetPosition(positionSet);
1686   application.SendNotification();
1687
1688   // Loop 5 times
1689   for (int i=0; i<5; ++i)
1690   {
1691     application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
1692
1693     // We did expect the animation to finish
1694     application.SendNotification();
1695     finishCheck.CheckSignalReceived();
1696     DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
1697   }
1698   END_TEST;
1699 }
1700
1701 int UtcDaliAnimationClearP(void)
1702 {
1703   TestApplication application;
1704
1705   Actor actor = Actor::New();
1706   Stage::GetCurrent().Add(actor);
1707
1708   // Build the animation
1709   float durationSeconds(1.0f);
1710   Animation animation = Animation::New(durationSeconds);
1711   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1712   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1713
1714   Vector3 fiftyPercentProgress(targetPosition * 0.5f);
1715
1716   // Start the animation
1717   animation.Play();
1718
1719   bool signalReceived(false);
1720   AnimationFinishCheck finishCheck(signalReceived);
1721   animation.FinishedSignal().Connect(&application, finishCheck);
1722
1723   application.SendNotification();
1724   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1725
1726   // We didn't expect the animation to finish yet
1727   application.SendNotification();
1728   finishCheck.CheckSignalNotReceived();
1729   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
1730
1731   // Clear the animation
1732   animation.Clear();
1733   application.SendNotification();
1734
1735   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1736
1737   // We don't expect the animation to finish now
1738   application.SendNotification();
1739   finishCheck.CheckSignalNotReceived();
1740   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
1741
1742   // Restart as a scale animation; this should not move the actor's position
1743   finishCheck.Reset();
1744   actor.SetPosition(Vector3::ZERO);
1745   Vector3 targetScale(3.0f, 3.0f, 3.0f);
1746   animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
1747   animation.Play();
1748
1749   application.SendNotification();
1750   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
1751
1752   // We didn't expect the animation to finish yet
1753   application.SendNotification();
1754   finishCheck.CheckSignalNotReceived();
1755   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1756   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
1757
1758   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
1759
1760   // We did expect the animation to finish
1761   application.SendNotification();
1762   finishCheck.CheckSignalReceived();
1763   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
1764   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
1765   END_TEST;
1766 }
1767
1768 int UtcDaliAnimationFinishedSignalP(void)
1769 {
1770   TestApplication application;
1771
1772   // Start the empty animation
1773   float durationSeconds(1.0f);
1774   Animation animation = Animation::New(durationSeconds);
1775   animation.Play();
1776
1777   bool signalReceived(false);
1778   AnimationFinishCheck finishCheck(signalReceived);
1779   animation.FinishedSignal().Connect(&application, finishCheck);
1780
1781   application.SendNotification();
1782   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
1783
1784   // We did expect the animation to finish
1785   application.SendNotification();
1786   finishCheck.CheckSignalReceived();
1787   END_TEST;
1788 }
1789
1790 int UtcDaliAnimationAnimateByBooleanP(void)
1791 {
1792   TestApplication application;
1793
1794   Actor actor = Actor::New();
1795
1796   // Register a boolean property
1797   bool startValue(false);
1798   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
1799   Stage::GetCurrent().Add(actor);
1800   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1801
1802   // Build the animation
1803   float durationSeconds(2.0f);
1804   Animation animation = Animation::New(durationSeconds);
1805   const bool relativeValue(true);
1806   const bool finalValue( false || relativeValue );
1807   animation.AnimateBy(Property(actor, index), relativeValue);
1808
1809   // Start the animation
1810   animation.Play();
1811
1812   bool signalReceived(false);
1813   AnimationFinishCheck finishCheck(signalReceived);
1814   animation.FinishedSignal().Connect(&application, finishCheck);
1815
1816   application.SendNotification();
1817   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1818
1819   // We didn't expect the animation to finish yet
1820   application.SendNotification();
1821   finishCheck.CheckSignalNotReceived();
1822   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1823
1824   application.SendNotification();
1825   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1826
1827   // We did expect the animation to finish
1828   application.SendNotification();
1829   finishCheck.CheckSignalReceived();
1830   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1831
1832   // Check that nothing has changed after a couple of buffer swaps
1833   application.Render(0);
1834   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1835   application.Render(0);
1836   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1837
1838   // Repeat with relative value "false" - this should be an NOOP
1839   animation = Animation::New(durationSeconds);
1840   bool noOpValue(false);
1841   animation.AnimateBy(Property(actor, index), noOpValue);
1842
1843   // Start the animation
1844   animation.Play();
1845
1846   finishCheck.Reset();
1847   animation.FinishedSignal().Connect(&application, finishCheck);
1848
1849   application.SendNotification();
1850   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1851
1852   // We didn't expect the animation to finish yet
1853   application.SendNotification();
1854   finishCheck.CheckSignalNotReceived();
1855   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1856
1857   application.SendNotification();
1858   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1859
1860   // We did expect the animation to finish
1861   application.SendNotification();
1862   finishCheck.CheckSignalReceived();
1863   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1864
1865   // Check that nothing has changed after a couple of buffer swaps
1866   application.Render(0);
1867   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1868   application.Render(0);
1869   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1870   END_TEST;
1871 }
1872
1873 int UtcDaliAnimationAnimateByBooleanAlphaFunctionP(void)
1874 {
1875   TestApplication application;
1876
1877   Actor actor = Actor::New();
1878
1879   // Register a boolean property
1880   bool startValue(false);
1881   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
1882   Stage::GetCurrent().Add(actor);
1883   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1884
1885   // Build the animation
1886   float durationSeconds(2.0f);
1887   Animation animation = Animation::New(durationSeconds);
1888   bool relativeValue(true);
1889   bool finalValue( false || relativeValue );
1890   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
1891
1892   // Start the animation
1893   animation.Play();
1894
1895   bool signalReceived(false);
1896   AnimationFinishCheck finishCheck(signalReceived);
1897   animation.FinishedSignal().Connect(&application, finishCheck);
1898
1899   application.SendNotification();
1900   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1901
1902   // We didn't expect the animation to finish yet
1903   application.SendNotification();
1904   finishCheck.CheckSignalNotReceived();
1905   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1906
1907   application.SendNotification();
1908   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1909
1910   // We did expect the animation to finish
1911   application.SendNotification();
1912   finishCheck.CheckSignalReceived();
1913   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1914
1915   // Check that nothing has changed after a couple of buffer swaps
1916   application.Render(0);
1917   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1918   application.Render(0);
1919   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1920
1921   // Repeat with relative value "false" - this should be an NOOP
1922   animation = Animation::New(durationSeconds);
1923   bool noOpValue(false);
1924   animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
1925
1926   // Start the animation
1927   animation.Play();
1928
1929   finishCheck.Reset();
1930   animation.FinishedSignal().Connect(&application, finishCheck);
1931
1932   application.SendNotification();
1933   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
1934
1935   // We didn't expect the animation to finish yet
1936   application.SendNotification();
1937   finishCheck.CheckSignalNotReceived();
1938   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1939
1940   application.SendNotification();
1941   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
1942
1943   // We did expect the animation to finish
1944   application.SendNotification();
1945   finishCheck.CheckSignalReceived();
1946   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1947   END_TEST;
1948 }
1949
1950 int UtcDaliAnimationAnimateByBooleanTimePeriodP(void)
1951 {
1952   TestApplication application;
1953
1954   Actor actor = Actor::New();
1955
1956   // Register a boolean property
1957   bool startValue(false);
1958   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
1959   Stage::GetCurrent().Add(actor);
1960   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1961
1962   // Build the animation
1963   float durationSeconds(2.0f);
1964   Animation animation = Animation::New(durationSeconds);
1965   bool relativeValue(true);
1966   bool finalValue( false || relativeValue );
1967   float animatorDurationSeconds(durationSeconds * 0.5f);
1968   animation.AnimateBy( Property(actor, index),
1969                        relativeValue,
1970                        TimePeriod( animatorDurationSeconds ) );
1971
1972   // Start the animation
1973   animation.Play();
1974
1975   bool signalReceived(false);
1976   AnimationFinishCheck finishCheck(signalReceived);
1977   animation.FinishedSignal().Connect(&application, finishCheck);
1978
1979   application.SendNotification();
1980   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
1981
1982   // We didn't expect the animation to finish yet
1983   application.SendNotification();
1984   finishCheck.CheckSignalNotReceived();
1985   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1986
1987   application.SendNotification();
1988   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
1989
1990   // We didn't expect the animation to finish yet...
1991   application.SendNotification();
1992   finishCheck.CheckSignalNotReceived();
1993
1994   // ...however we should have reached the final value
1995   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
1996
1997   application.SendNotification();
1998   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
1999
2000   // We did expect the animation to finish
2001   application.SendNotification();
2002   finishCheck.CheckSignalReceived();
2003   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2004
2005   // Check that nothing has changed after a couple of buffer swaps
2006   application.Render(0);
2007   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2008   application.Render(0);
2009   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2010   END_TEST;
2011 }
2012
2013 int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void)
2014 {
2015   TestApplication application;
2016
2017   Actor actor = Actor::New();
2018
2019   // Register a boolean property
2020   bool startValue(false);
2021   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2022   Stage::GetCurrent().Add(actor);
2023   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2024
2025   // Build the animation
2026   float durationSeconds(2.0f);
2027   Animation animation = Animation::New(durationSeconds);
2028   bool relativeValue(true);
2029   bool finalValue( false || relativeValue );
2030   float animatorDurationSeconds(durationSeconds * 0.5f);
2031   animation.AnimateBy( Property(actor, index),
2032                        relativeValue,
2033                        AlphaFunction::EASE_IN_OUT,
2034                        TimePeriod( animatorDurationSeconds ) );
2035
2036   // Start the animation
2037   animation.Play();
2038
2039   bool signalReceived(false);
2040   AnimationFinishCheck finishCheck(signalReceived);
2041   animation.FinishedSignal().Connect(&application, finishCheck);
2042
2043   application.SendNotification();
2044   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2045
2046   // We didn't expect the animation to finish yet
2047   application.SendNotification();
2048   finishCheck.CheckSignalNotReceived();
2049   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2050
2051   application.SendNotification();
2052   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2053
2054   // We didn't expect the animation to finish yet...
2055   application.SendNotification();
2056   finishCheck.CheckSignalNotReceived();
2057
2058   // ...however we should have reached the final value
2059   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2060
2061   application.SendNotification();
2062   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2063
2064   // We did expect the animation to finish
2065   application.SendNotification();
2066   finishCheck.CheckSignalReceived();
2067   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2068
2069   // Check that nothing has changed after a couple of buffer swaps
2070   application.Render(0);
2071   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2072   application.Render(0);
2073   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2074   END_TEST;
2075 }
2076
2077 int UtcDaliAnimationAnimateByFloatP(void)
2078 {
2079   TestApplication application;
2080
2081   Actor actor = Actor::New();
2082
2083   // Register a float property
2084   float startValue(10.0f);
2085   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2086   Stage::GetCurrent().Add(actor);
2087   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2088
2089   // Build the animation
2090   float durationSeconds(2.0f);
2091   Animation animation = Animation::New(durationSeconds);
2092   float targetValue(50.0f);
2093   float relativeValue(targetValue - startValue);
2094   animation.AnimateBy(Property(actor, index), relativeValue);
2095
2096   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2097
2098   // Start the animation
2099   animation.Play();
2100
2101   bool signalReceived(false);
2102   AnimationFinishCheck finishCheck(signalReceived);
2103   animation.FinishedSignal().Connect(&application, finishCheck);
2104
2105   application.SendNotification();
2106   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2107
2108   // We didn't expect the animation to finish yet
2109   application.SendNotification();
2110   finishCheck.CheckSignalNotReceived();
2111   DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
2112
2113   application.SendNotification();
2114   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2115
2116   // We did expect the animation to finish
2117   application.SendNotification();
2118   finishCheck.CheckSignalReceived();
2119   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2120
2121   // Check that nothing has changed after a couple of buffer swaps
2122   application.Render(0);
2123   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2124   application.Render(0);
2125   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2126   END_TEST;
2127 }
2128
2129 int UtcDaliAnimationAnimateByFloatAlphaFunctionP(void)
2130 {
2131   TestApplication application;
2132
2133   Actor actor = Actor::New();
2134
2135   // Register a float property
2136   float startValue(10.0f);
2137   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2138   Stage::GetCurrent().Add(actor);
2139   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2140
2141   // Build the animation
2142   float durationSeconds(1.0f);
2143   Animation animation = Animation::New(durationSeconds);
2144   float targetValue(90.0f);
2145   float relativeValue(targetValue - startValue);
2146   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
2147
2148   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2149
2150   // Start the animation
2151   animation.Play();
2152
2153   bool signalReceived(false);
2154   AnimationFinishCheck finishCheck(signalReceived);
2155   animation.FinishedSignal().Connect(&application, finishCheck);
2156
2157   application.SendNotification();
2158   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2159
2160   // We didn't expect the animation to finish yet
2161   application.SendNotification();
2162   finishCheck.CheckSignalNotReceived();
2163
2164   // The position should have moved more, than with a linear alpha function
2165   float current(actor.GetProperty<float>(index));
2166   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2167
2168   application.SendNotification();
2169   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2170
2171   // We did expect the animation to finish
2172   application.SendNotification();
2173   finishCheck.CheckSignalReceived();
2174   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2175
2176   // Check that nothing has changed after a couple of buffer swaps
2177   application.Render(0);
2178   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2179   application.Render(0);
2180   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2181   END_TEST;
2182 }
2183
2184 int UtcDaliAnimationAnimateByFloatTimePeriodP(void)
2185 {
2186   TestApplication application;
2187
2188   Actor actor = Actor::New();
2189
2190   // Register a float property
2191   float startValue(10.0f);
2192   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2193   Stage::GetCurrent().Add(actor);
2194   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2195
2196   // Build the animation
2197   float durationSeconds(1.0f);
2198   Animation animation = Animation::New(durationSeconds);
2199   float targetValue(30.0f);
2200   float relativeValue(targetValue - startValue);
2201   float delay = 0.5f;
2202   animation.AnimateBy(Property(actor, index),
2203                       relativeValue,
2204                       TimePeriod(delay, durationSeconds - delay));
2205
2206   // Start the animation
2207   animation.Play();
2208
2209   bool signalReceived(false);
2210   AnimationFinishCheck finishCheck(signalReceived);
2211   animation.FinishedSignal().Connect(&application, finishCheck);
2212
2213   application.SendNotification();
2214   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2215
2216   // We didn't expect the animation to finish yet
2217   application.SendNotification();
2218   finishCheck.CheckSignalNotReceived();
2219   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2220
2221   application.SendNotification();
2222   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2223
2224   // We didn't expect the animation to finish yet
2225   application.SendNotification();
2226   finishCheck.CheckSignalNotReceived();
2227   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2228
2229   application.SendNotification();
2230   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2231
2232   // We did expect the animation to finish
2233   application.SendNotification();
2234   finishCheck.CheckSignalReceived();
2235   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2236
2237   // Check that nothing has changed after a couple of buffer swaps
2238   application.Render(0);
2239   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2240   application.Render(0);
2241   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2242   END_TEST;
2243 }
2244
2245 int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void)
2246 {
2247   TestApplication application;
2248
2249   Actor actor = Actor::New();
2250
2251   // Register a float property
2252   float startValue(10.0f);
2253   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2254   Stage::GetCurrent().Add(actor);
2255   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2256
2257   // Build the animation
2258   float durationSeconds(1.0f);
2259   Animation animation = Animation::New(durationSeconds);
2260   float targetValue(30.0f);
2261   float relativeValue(targetValue - startValue);
2262   float delay = 0.5f;
2263   animation.AnimateBy(Property(actor, index),
2264                       relativeValue,
2265                       AlphaFunction::LINEAR,
2266                       TimePeriod(delay, durationSeconds - delay));
2267
2268   // Start the animation
2269   animation.Play();
2270
2271   bool signalReceived(false);
2272   AnimationFinishCheck finishCheck(signalReceived);
2273   animation.FinishedSignal().Connect(&application, finishCheck);
2274
2275   application.SendNotification();
2276   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2277
2278   // We didn't expect the animation to finish yet
2279   application.SendNotification();
2280   finishCheck.CheckSignalNotReceived();
2281   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
2282
2283   application.SendNotification();
2284   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2285
2286   // We didn't expect the animation to finish yet
2287   application.SendNotification();
2288   finishCheck.CheckSignalNotReceived();
2289   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2290
2291   application.SendNotification();
2292   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2293
2294   // We did expect the animation to finish
2295   application.SendNotification();
2296   finishCheck.CheckSignalReceived();
2297   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2298
2299   // Check that nothing has changed after a couple of buffer swaps
2300   application.Render(0);
2301   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2302   application.Render(0);
2303   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
2304   END_TEST;
2305 }
2306
2307 int UtcDaliAnimationAnimateByIntegerP(void)
2308 {
2309   TestApplication application;
2310
2311   Actor actor = Actor::New();
2312
2313   // Register an integer property
2314   int startValue(1);
2315   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2316   Stage::GetCurrent().Add(actor);
2317   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2318
2319   // Build the animation
2320   float durationSeconds(2.0f);
2321   Animation animation = Animation::New(durationSeconds);
2322   int targetValue(50);
2323   int relativeValue(targetValue - startValue);
2324   animation.AnimateBy(Property(actor, index), relativeValue);
2325
2326   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2327
2328   // Start the animation
2329   animation.Play();
2330
2331   bool signalReceived(false);
2332   AnimationFinishCheck finishCheck(signalReceived);
2333   animation.FinishedSignal().Connect(&application, finishCheck);
2334
2335   application.SendNotification();
2336   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2337
2338   // We didn't expect the animation to finish yet
2339   application.SendNotification();
2340   finishCheck.CheckSignalNotReceived();
2341   DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
2342
2343   application.SendNotification();
2344   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2345
2346   // We did expect the animation to finish
2347   application.SendNotification();
2348   finishCheck.CheckSignalReceived();
2349   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2350
2351   // Check that nothing has changed after a couple of buffer swaps
2352   application.Render(0);
2353   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2354   application.Render(0);
2355   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2356   END_TEST;
2357 }
2358
2359 int UtcDaliAnimationAnimateByIntegerAlphaFunctionP(void)
2360 {
2361   TestApplication application;
2362
2363   Actor actor = Actor::New();
2364
2365   // Register an integer property
2366   int startValue(1);
2367   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2368   Stage::GetCurrent().Add(actor);
2369   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2370
2371   // Build the animation
2372   float durationSeconds(1.0f);
2373   Animation animation = Animation::New(durationSeconds);
2374   int targetValue(90);
2375   int relativeValue(targetValue - startValue);
2376   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
2377
2378   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
2379
2380   // Start the animation
2381   animation.Play();
2382
2383   bool signalReceived(false);
2384   AnimationFinishCheck finishCheck(signalReceived);
2385   animation.FinishedSignal().Connect(&application, finishCheck);
2386
2387   application.SendNotification();
2388   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2389
2390   // We didn't expect the animation to finish yet
2391   application.SendNotification();
2392   finishCheck.CheckSignalNotReceived();
2393
2394   // The position should have moved more, than with a linear alpha function
2395   int current(actor.GetProperty<int>(index));
2396   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
2397
2398   application.SendNotification();
2399   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2400
2401   // We did expect the animation to finish
2402   application.SendNotification();
2403   finishCheck.CheckSignalReceived();
2404   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2405
2406   // Check that nothing has changed after a couple of buffer swaps
2407   application.Render(0);
2408   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2409   application.Render(0);
2410   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2411   END_TEST;
2412 }
2413
2414 int UtcDaliAnimationAnimateByIntegerTimePeriodP(void)
2415 {
2416   TestApplication application;
2417
2418   Actor actor = Actor::New();
2419
2420   // Register an integer property
2421   int startValue(10);
2422   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2423   Stage::GetCurrent().Add(actor);
2424   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2425
2426   // Build the animation
2427   float durationSeconds(1.0f);
2428   Animation animation = Animation::New(durationSeconds);
2429   int targetValue(30);
2430   int relativeValue(targetValue - startValue);
2431   float delay = 0.5f;
2432   animation.AnimateBy(Property(actor, index),
2433                       relativeValue,
2434                       TimePeriod(delay, durationSeconds - delay));
2435
2436   // Start the animation
2437   animation.Play();
2438
2439   bool signalReceived(false);
2440   AnimationFinishCheck finishCheck(signalReceived);
2441   animation.FinishedSignal().Connect(&application, finishCheck);
2442
2443   application.SendNotification();
2444   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2445
2446   // We didn't expect the animation to finish yet
2447   application.SendNotification();
2448   finishCheck.CheckSignalNotReceived();
2449   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2450
2451   application.SendNotification();
2452   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2453
2454   // We didn't expect the animation to finish yet
2455   application.SendNotification();
2456   finishCheck.CheckSignalNotReceived();
2457   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2458
2459   application.SendNotification();
2460   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2461
2462   // We did expect the animation to finish
2463   application.SendNotification();
2464   finishCheck.CheckSignalReceived();
2465   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2466
2467   // Check that nothing has changed after a couple of buffer swaps
2468   application.Render(0);
2469   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2470   application.Render(0);
2471   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2472   END_TEST;
2473 }
2474
2475 int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void)
2476 {
2477   TestApplication application;
2478
2479   Actor actor = Actor::New();
2480
2481   // Register an integer property
2482   int startValue(10);
2483   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2484   Stage::GetCurrent().Add(actor);
2485   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2486
2487   // Build the animation
2488   float durationSeconds(1.0f);
2489   Animation animation = Animation::New(durationSeconds);
2490   int targetValue(30);
2491   int relativeValue(targetValue - startValue);
2492   float delay = 0.5f;
2493   animation.AnimateBy(Property(actor, index),
2494                       relativeValue,
2495                       AlphaFunction::LINEAR,
2496                       TimePeriod(delay, durationSeconds - delay));
2497
2498   // Start the animation
2499   animation.Play();
2500
2501   bool signalReceived(false);
2502   AnimationFinishCheck finishCheck(signalReceived);
2503   animation.FinishedSignal().Connect(&application, finishCheck);
2504
2505   application.SendNotification();
2506   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2507
2508   // We didn't expect the animation to finish yet
2509   application.SendNotification();
2510   finishCheck.CheckSignalNotReceived();
2511   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
2512
2513   application.SendNotification();
2514   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2515
2516   // We didn't expect the animation to finish yet
2517   application.SendNotification();
2518   finishCheck.CheckSignalNotReceived();
2519   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
2520
2521   application.SendNotification();
2522   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2523
2524   // We did expect the animation to finish
2525   application.SendNotification();
2526   finishCheck.CheckSignalReceived();
2527   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2528
2529   // Check that nothing has changed after a couple of buffer swaps
2530   application.Render(0);
2531   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2532   application.Render(0);
2533   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
2534   END_TEST;
2535 }
2536
2537 int UtcDaliAnimationAnimateByVector2P(void)
2538 {
2539   TestApplication application;
2540
2541   Actor actor = Actor::New();
2542
2543   // Register a Vector2 property
2544   Vector2 startValue(10.0f, 10.0f);
2545   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2546   Stage::GetCurrent().Add(actor);
2547   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2548
2549   // Build the animation
2550   float durationSeconds(2.0f);
2551   Animation animation = Animation::New(durationSeconds);
2552   Vector2 targetValue(60.0f, 60.0f);
2553   Vector2 relativeValue(targetValue - startValue);
2554   animation.AnimateBy(Property(actor, index), relativeValue);
2555
2556   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2557
2558   // Start the animation
2559   animation.Play();
2560
2561   bool signalReceived(false);
2562   AnimationFinishCheck finishCheck(signalReceived);
2563   animation.FinishedSignal().Connect(&application, finishCheck);
2564
2565   application.SendNotification();
2566   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2567
2568   // We didn't expect the animation to finish yet
2569   application.SendNotification();
2570   finishCheck.CheckSignalNotReceived();
2571   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
2572
2573   application.SendNotification();
2574   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2575
2576   // We did expect the animation to finish
2577   application.SendNotification();
2578   finishCheck.CheckSignalReceived();
2579   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2580
2581   // Check that nothing has changed after a couple of buffer swaps
2582   application.Render(0);
2583   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2584   application.Render(0);
2585   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2586   END_TEST;
2587 }
2588
2589 int UtcDaliAnimationAnimateByVector2AlphaFunctionP(void)
2590 {
2591   TestApplication application;
2592
2593   Actor actor = Actor::New();
2594
2595   // Register a Vector2 property
2596   Vector2 startValue(100.0f, 100.0f);
2597   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2598   Stage::GetCurrent().Add(actor);
2599   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2600
2601   // Build the animation
2602   float durationSeconds(1.0f);
2603   Animation animation = Animation::New(durationSeconds);
2604   Vector2 targetValue(20.0f, 20.0f);
2605   Vector2 relativeValue(targetValue - startValue);
2606   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
2607
2608   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2609
2610   // Start the animation
2611   animation.Play();
2612
2613   bool signalReceived(false);
2614   AnimationFinishCheck finishCheck(signalReceived);
2615   animation.FinishedSignal().Connect(&application, finishCheck);
2616
2617   application.SendNotification();
2618   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2619
2620   // We didn't expect the animation to finish yet
2621   application.SendNotification();
2622   finishCheck.CheckSignalNotReceived();
2623
2624   // The position should have moved more, than with a linear alpha function
2625   Vector2 current(actor.GetProperty<Vector2>(index));
2626   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2627   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2628
2629   application.SendNotification();
2630   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2631
2632   // We did expect the animation to finish
2633   application.SendNotification();
2634   finishCheck.CheckSignalReceived();
2635   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2636
2637   // Check that nothing has changed after a couple of buffer swaps
2638   application.Render(0);
2639   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2640   application.Render(0);
2641   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2642   END_TEST;
2643 }
2644
2645 int UtcDaliAnimationAnimateByVector2TimePeriodP(void)
2646 {
2647   TestApplication application;
2648
2649   Actor actor = Actor::New();
2650
2651   // Register a Vector2 property
2652   Vector2 startValue(10.0f, 10.0f);
2653   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2654   Stage::GetCurrent().Add(actor);
2655   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2656
2657   // Build the animation
2658   float durationSeconds(1.0f);
2659   Animation animation = Animation::New(durationSeconds);
2660   Vector2 targetValue(30.0f, 30.0f);
2661   Vector2 relativeValue(targetValue - startValue);
2662   float delay = 0.5f;
2663   animation.AnimateBy(Property(actor, index),
2664                       relativeValue,
2665                       TimePeriod(delay, durationSeconds - delay));
2666
2667   // Start the animation
2668   animation.Play();
2669
2670   bool signalReceived(false);
2671   AnimationFinishCheck finishCheck(signalReceived);
2672   animation.FinishedSignal().Connect(&application, finishCheck);
2673
2674   application.SendNotification();
2675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2676
2677   // We didn't expect the animation to finish yet
2678   application.SendNotification();
2679   finishCheck.CheckSignalNotReceived();
2680   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2681
2682   application.SendNotification();
2683   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2684
2685   // We didn't expect the animation to finish yet
2686   application.SendNotification();
2687   finishCheck.CheckSignalNotReceived();
2688   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2689
2690   application.SendNotification();
2691   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2692
2693   // We did expect the animation to finish
2694   application.SendNotification();
2695   finishCheck.CheckSignalReceived();
2696   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2697
2698   // Check that nothing has changed after a couple of buffer swaps
2699   application.Render(0);
2700   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2701   application.Render(0);
2702   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2703   END_TEST;
2704 }
2705
2706 int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void)
2707 {
2708   TestApplication application;
2709
2710   Actor actor = Actor::New();
2711
2712   // Register a Vector2 property
2713   Vector2 startValue(5.0f, 5.0f);
2714   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2715   Stage::GetCurrent().Add(actor);
2716   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2717
2718   // Build the animation
2719   float durationSeconds(1.0f);
2720   Animation animation = Animation::New(durationSeconds);
2721   Vector2 targetValue(10.0f, 10.0f);
2722   Vector2 relativeValue(targetValue - startValue);
2723   float delay = 0.5f;
2724   animation.AnimateBy(Property(actor, index),
2725                       relativeValue,
2726                       AlphaFunction::LINEAR,
2727                       TimePeriod(delay, durationSeconds - delay));
2728
2729   // Start the animation
2730   animation.Play();
2731
2732   bool signalReceived(false);
2733   AnimationFinishCheck finishCheck(signalReceived);
2734   animation.FinishedSignal().Connect(&application, finishCheck);
2735
2736   application.SendNotification();
2737   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2738
2739   // We didn't expect the animation to finish yet
2740   application.SendNotification();
2741   finishCheck.CheckSignalNotReceived();
2742   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
2743
2744   application.SendNotification();
2745   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2746
2747   // We didn't expect the animation to finish yet
2748   application.SendNotification();
2749   finishCheck.CheckSignalNotReceived();
2750   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2751
2752   application.SendNotification();
2753   application.Render(static_cast<unsigned int>(durationSeconds*250.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.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2759
2760   // Check that nothing has changed after a couple of buffer swaps
2761   application.Render(0);
2762   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2763   application.Render(0);
2764   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
2765   END_TEST;
2766 }
2767
2768 int UtcDaliAnimationAnimateByVector3P(void)
2769 {
2770   TestApplication application;
2771
2772   Actor actor = Actor::New();
2773
2774   // Register a Vector3 property
2775   Vector3 startValue(10.0f, 10.0f, 10.0f);
2776   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2777   Stage::GetCurrent().Add(actor);
2778   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2779
2780   // Build the animation
2781   float durationSeconds(2.0f);
2782   Animation animation = Animation::New(durationSeconds);
2783   Vector3 targetValue(60.0f, 60.0f, 60.0f);
2784   Vector3 relativeValue(targetValue - startValue);
2785   animation.AnimateBy(Property(actor, index), relativeValue);
2786
2787   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2788
2789   // Start the animation
2790   animation.Play();
2791
2792   bool signalReceived(false);
2793   AnimationFinishCheck finishCheck(signalReceived);
2794   animation.FinishedSignal().Connect(&application, finishCheck);
2795
2796   application.SendNotification();
2797   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2798
2799   // We didn't expect the animation to finish yet
2800   application.SendNotification();
2801   finishCheck.CheckSignalNotReceived();
2802   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
2803
2804   application.SendNotification();
2805   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2806
2807   // We did expect the animation to finish
2808   application.SendNotification();
2809   finishCheck.CheckSignalReceived();
2810   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2811
2812   // Check that nothing has changed after a couple of buffer swaps
2813   application.Render(0);
2814   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2815   application.Render(0);
2816   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2817   END_TEST;
2818 }
2819
2820 int UtcDaliAnimationAnimateByVector3AlphaFunctionP(void)
2821 {
2822   TestApplication application;
2823
2824   Actor actor = Actor::New();
2825
2826   // Register a Vector3 property
2827   Vector3 startValue(100.0f, 100.0f, 100.0f);
2828   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2829   Stage::GetCurrent().Add(actor);
2830   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2831
2832   // Build the animation
2833   float durationSeconds(1.0f);
2834   Animation animation = Animation::New(durationSeconds);
2835   Vector3 targetValue(20.0f, 20.0f, 20.0f);
2836   Vector3 relativeValue(targetValue - startValue);
2837   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
2838
2839   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
2840
2841   // Start the animation
2842   animation.Play();
2843
2844   bool signalReceived(false);
2845   AnimationFinishCheck finishCheck(signalReceived);
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
2855   // The position should have moved more, than with a linear alpha function
2856   Vector3 current(actor.GetProperty<Vector3>(index));
2857   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
2858   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
2859   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
2860
2861   application.SendNotification();
2862   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2863
2864   // We did expect the animation to finish
2865   application.SendNotification();
2866   finishCheck.CheckSignalReceived();
2867   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2868
2869   // Check that nothing has changed after a couple of buffer swaps
2870   application.Render(0);
2871   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2872   application.Render(0);
2873   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2874   END_TEST;
2875 }
2876
2877 int UtcDaliAnimationAnimateByVector3TimePeriodP(void)
2878 {
2879   TestApplication application;
2880
2881   Actor actor = Actor::New();
2882
2883   // Register a Vector3 property
2884   Vector3 startValue(10.0f, 10.0f, 10.0f);
2885   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2886   Stage::GetCurrent().Add(actor);
2887   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2888
2889   // Build the animation
2890   float durationSeconds(1.0f);
2891   Animation animation = Animation::New(durationSeconds);
2892   Vector3 targetValue(30.0f, 30.0f, 30.0f);
2893   Vector3 relativeValue(targetValue - startValue);
2894   float delay = 0.5f;
2895   animation.AnimateBy(Property(actor, index),
2896                       relativeValue,
2897                       TimePeriod(delay, durationSeconds - delay));
2898
2899   // Start the animation
2900   animation.Play();
2901
2902   bool signalReceived(false);
2903   AnimationFinishCheck finishCheck(signalReceived);
2904   animation.FinishedSignal().Connect(&application, finishCheck);
2905
2906   application.SendNotification();
2907   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2908
2909   // We didn't expect the animation to finish yet
2910   application.SendNotification();
2911   finishCheck.CheckSignalNotReceived();
2912   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2913
2914   application.SendNotification();
2915   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2916
2917   // We didn't expect the animation to finish yet
2918   application.SendNotification();
2919   finishCheck.CheckSignalNotReceived();
2920   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2921
2922   application.SendNotification();
2923   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2924
2925   // We did expect the animation to finish
2926   application.SendNotification();
2927   finishCheck.CheckSignalReceived();
2928   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2929
2930   // Check that nothing has changed after a couple of buffer swaps
2931   application.Render(0);
2932   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2933   application.Render(0);
2934   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2935   END_TEST;
2936 }
2937
2938 int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void)
2939 {
2940   TestApplication application;
2941
2942   Actor actor = Actor::New();
2943
2944   // Register a Vector3 property
2945   Vector3 startValue(5.0f, 5.0f, 5.0f);
2946   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
2947   Stage::GetCurrent().Add(actor);
2948   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2949
2950   // Build the animation
2951   float durationSeconds(1.0f);
2952   Animation animation = Animation::New(durationSeconds);
2953   Vector3 targetValue(10.0f, 10.0f, 10.0f);
2954   Vector3 relativeValue(targetValue - startValue);
2955   float delay = 0.5f;
2956   animation.AnimateBy(Property(actor, index),
2957                       relativeValue,
2958                       AlphaFunction::LINEAR,
2959                       TimePeriod(delay, durationSeconds - delay));
2960
2961   // Start the animation
2962   animation.Play();
2963
2964   bool signalReceived(false);
2965   AnimationFinishCheck finishCheck(signalReceived);
2966   animation.FinishedSignal().Connect(&application, finishCheck);
2967
2968   application.SendNotification();
2969   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
2970
2971   // We didn't expect the animation to finish yet
2972   application.SendNotification();
2973   finishCheck.CheckSignalNotReceived();
2974   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
2975
2976   application.SendNotification();
2977   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
2978
2979   // We didn't expect the animation to finish yet
2980   application.SendNotification();
2981   finishCheck.CheckSignalNotReceived();
2982   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
2983
2984   application.SendNotification();
2985   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
2986
2987   // We did expect the animation to finish
2988   application.SendNotification();
2989   finishCheck.CheckSignalReceived();
2990   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2991
2992   // Check that nothing has changed after a couple of buffer swaps
2993   application.Render(0);
2994   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2995   application.Render(0);
2996   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
2997   END_TEST;
2998 }
2999
3000 int UtcDaliAnimationAnimateByVector4P(void)
3001 {
3002   TestApplication application;
3003
3004   Actor actor = Actor::New();
3005
3006   // Register a Vector4 property
3007   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3008   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3009   Stage::GetCurrent().Add(actor);
3010   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3011
3012   // Build the animation
3013   float durationSeconds(2.0f);
3014   Animation animation = Animation::New(durationSeconds);
3015   Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
3016   Vector4 relativeValue(targetValue - startValue);
3017   animation.AnimateBy(Property(actor, index), relativeValue);
3018
3019   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3020
3021   // Start the animation
3022   animation.Play();
3023
3024   bool signalReceived(false);
3025   AnimationFinishCheck finishCheck(signalReceived);
3026   animation.FinishedSignal().Connect(&application, finishCheck);
3027
3028   application.SendNotification();
3029   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3030
3031   // We didn't expect the animation to finish yet
3032   application.SendNotification();
3033   finishCheck.CheckSignalNotReceived();
3034   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
3035
3036   application.SendNotification();
3037   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3038
3039   // We did expect the animation to finish
3040   application.SendNotification();
3041   finishCheck.CheckSignalReceived();
3042   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3043
3044   // Check that nothing has changed after a couple of buffer swaps
3045   application.Render(0);
3046   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3047   application.Render(0);
3048   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3049   END_TEST;
3050 }
3051
3052 int UtcDaliAnimationAnimateByVector4AlphaFunctionP(void)
3053 {
3054   TestApplication application;
3055
3056   Actor actor = Actor::New();
3057
3058   // Register a Vector4 property
3059   Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
3060   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3061   Stage::GetCurrent().Add(actor);
3062   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3063
3064   // Build the animation
3065   float durationSeconds(1.0f);
3066   Animation animation = Animation::New(durationSeconds);
3067   Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
3068   Vector4 relativeValue(targetValue - startValue);
3069   animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3070
3071   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3072
3073   // Start the animation
3074   animation.Play();
3075
3076   bool signalReceived(false);
3077   AnimationFinishCheck finishCheck(signalReceived);
3078   animation.FinishedSignal().Connect(&application, finishCheck);
3079
3080   application.SendNotification();
3081   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3082
3083   // We didn't expect the animation to finish yet
3084   application.SendNotification();
3085   finishCheck.CheckSignalNotReceived();
3086
3087   // The position should have moved more, than with a linear alpha function
3088   Vector4 current(actor.GetProperty<Vector4>(index));
3089   DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3090   DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3091   DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3092   DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
3093
3094   application.SendNotification();
3095   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3096
3097   // We did expect the animation to finish
3098   application.SendNotification();
3099   finishCheck.CheckSignalReceived();
3100   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3101
3102   // Check that nothing has changed after a couple of buffer swaps
3103   application.Render(0);
3104   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3105   application.Render(0);
3106   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3107   END_TEST;
3108 }
3109
3110 int UtcDaliAnimationAnimateByVector4TimePeriodP(void)
3111 {
3112   TestApplication application;
3113
3114   Actor actor = Actor::New();
3115
3116   // Register a Vector4 property
3117   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
3118   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3119   Stage::GetCurrent().Add(actor);
3120   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3121
3122   // Build the animation
3123   float durationSeconds(1.0f);
3124   Animation animation = Animation::New(durationSeconds);
3125   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
3126   Vector4 relativeValue(targetValue - startValue);
3127   float delay = 0.5f;
3128   animation.AnimateBy(Property(actor, index),
3129                       relativeValue,
3130                       TimePeriod(delay, durationSeconds - delay));
3131
3132   // Start the animation
3133   animation.Play();
3134
3135   bool signalReceived(false);
3136   AnimationFinishCheck finishCheck(signalReceived);
3137   animation.FinishedSignal().Connect(&application, finishCheck);
3138
3139   application.SendNotification();
3140   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3141
3142   // We didn't expect the animation to finish yet
3143   application.SendNotification();
3144   finishCheck.CheckSignalNotReceived();
3145   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3146
3147   application.SendNotification();
3148   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3149
3150   // We didn't expect the animation to finish yet
3151   application.SendNotification();
3152   finishCheck.CheckSignalNotReceived();
3153   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3154
3155   application.SendNotification();
3156   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3157
3158   // We did expect the animation to finish
3159   application.SendNotification();
3160   finishCheck.CheckSignalReceived();
3161   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3162
3163   // Check that nothing has changed after a couple of buffer swaps
3164   application.Render(0);
3165   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3166   application.Render(0);
3167   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3168   END_TEST;
3169 }
3170
3171 int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void)
3172 {
3173   TestApplication application;
3174
3175   Actor actor = Actor::New();
3176
3177   // Register a Vector4 property
3178   Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
3179   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3180   Stage::GetCurrent().Add(actor);
3181   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3182
3183   // Build the animation
3184   float durationSeconds(1.0f);
3185   Animation animation = Animation::New(durationSeconds);
3186   Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
3187   Vector4 relativeValue(targetValue - startValue);
3188   float delay = 0.5f;
3189   animation.AnimateBy(Property(actor, index),
3190                       relativeValue,
3191                       AlphaFunction::LINEAR,
3192                       TimePeriod(delay, durationSeconds - delay));
3193
3194   // Start the animation
3195   animation.Play();
3196
3197   bool signalReceived(false);
3198   AnimationFinishCheck finishCheck(signalReceived);
3199   animation.FinishedSignal().Connect(&application, finishCheck);
3200
3201   application.SendNotification();
3202   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3203
3204   // We didn't expect the animation to finish yet
3205   application.SendNotification();
3206   finishCheck.CheckSignalNotReceived();
3207   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
3208
3209   application.SendNotification();
3210   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3211
3212   // We didn't expect the animation to finish yet
3213   application.SendNotification();
3214   finishCheck.CheckSignalNotReceived();
3215   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3216
3217   application.SendNotification();
3218   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3219
3220   // We did expect the animation to finish
3221   application.SendNotification();
3222   finishCheck.CheckSignalReceived();
3223   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3224
3225   // Check that nothing has changed after a couple of buffer swaps
3226   application.Render(0);
3227   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3228   application.Render(0);
3229   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
3230   END_TEST;
3231 }
3232
3233 int UtcDaliAnimationAnimateByActorPositionP(void)
3234 {
3235   TestApplication application;
3236
3237   Actor actor = Actor::New();
3238   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3239   actor.SetPosition(startPosition);
3240   Stage::GetCurrent().Add(actor);
3241   application.SendNotification();
3242   application.Render(0);
3243   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3244
3245   // Build the animation
3246   float durationSeconds(1.0f);
3247   Animation animation = Animation::New(durationSeconds);
3248   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3249   Vector3 relativePosition(targetPosition - startPosition);
3250   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
3251
3252   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3253
3254   // Start the animation
3255   animation.Play();
3256
3257   bool signalReceived(false);
3258   AnimationFinishCheck finishCheck(signalReceived);
3259   animation.FinishedSignal().Connect(&application, finishCheck);
3260
3261   application.SendNotification();
3262   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3263
3264   // We didn't expect the animation to finish yet
3265   application.SendNotification();
3266   finishCheck.CheckSignalNotReceived();
3267   DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
3268
3269   application.SendNotification();
3270   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3271
3272   // We did expect the animation to finish
3273   application.SendNotification();
3274   finishCheck.CheckSignalReceived();
3275   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3276
3277   // Check that nothing has changed after a couple of buffer swaps
3278   application.Render(0);
3279   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3280   application.Render(0);
3281   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3282   END_TEST;
3283 }
3284
3285 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionP(void)
3286 {
3287   TestApplication application;
3288
3289   Actor actor = Actor::New();
3290   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3291   actor.SetPosition(startPosition);
3292   Stage::GetCurrent().Add(actor);
3293   application.SendNotification();
3294   application.Render(0);
3295   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3296
3297   // Build the animation
3298   float durationSeconds(1.0f);
3299   Animation animation = Animation::New(durationSeconds);
3300   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3301   Vector3 relativePosition(targetPosition - startPosition);
3302   animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
3303
3304   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3305
3306   // Start the animation
3307   animation.Play();
3308
3309   bool signalReceived(false);
3310   AnimationFinishCheck finishCheck(signalReceived);
3311   animation.FinishedSignal().Connect(&application, finishCheck);
3312
3313   application.SendNotification();
3314   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3315
3316   // We didn't expect the animation to finish yet
3317   application.SendNotification();
3318   finishCheck.CheckSignalNotReceived();
3319
3320   // The position should have moved more, than with a linear alpha function
3321   Vector3 current(actor.GetCurrentPosition());
3322   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
3323   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
3324   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
3325
3326   application.SendNotification();
3327   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3328
3329   // We did expect the animation to finish
3330   application.SendNotification();
3331   finishCheck.CheckSignalReceived();
3332   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3333
3334   // Check that nothing has changed after a couple of buffer swaps
3335   application.Render(0);
3336   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3337   application.Render(0);
3338   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3339   END_TEST;
3340 }
3341
3342 int UtcDaliAnimationAnimateByActorPositionTimePeriodP(void)
3343 {
3344   TestApplication application;
3345
3346   Actor actor = Actor::New();
3347   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3348   actor.SetPosition(startPosition);
3349   Stage::GetCurrent().Add(actor);
3350   application.SendNotification();
3351   application.Render(0);
3352   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3353
3354   // Build the animation
3355   float durationSeconds(1.0f);
3356   Animation animation = Animation::New(durationSeconds);
3357   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3358   Vector3 relativePosition(targetPosition - startPosition);
3359   float delay = 0.5f;
3360   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
3361                       relativePosition,
3362                       TimePeriod(delay, durationSeconds - delay));
3363
3364   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3365
3366   // Start the animation
3367   animation.Play();
3368
3369   bool signalReceived(false);
3370   AnimationFinishCheck finishCheck(signalReceived);
3371   animation.FinishedSignal().Connect(&application, finishCheck);
3372
3373   application.SendNotification();
3374   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3375
3376   // We didn't expect the animation to finish yet
3377   application.SendNotification();
3378   finishCheck.CheckSignalNotReceived();
3379   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3380
3381   application.SendNotification();
3382   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3383
3384   // We did expect the animation to finish
3385   application.SendNotification();
3386   finishCheck.CheckSignalReceived();
3387   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3388
3389   // Check that nothing has changed after a couple of buffer swaps
3390   application.Render(0);
3391   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3392   application.Render(0);
3393   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3394   END_TEST;
3395 }
3396
3397 int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void)
3398 {
3399   TestApplication application;
3400
3401   Actor actor = Actor::New();
3402   Vector3 startPosition(10.0f, 10.0f, 10.0f);
3403   actor.SetPosition(startPosition);
3404   Stage::GetCurrent().Add(actor);
3405   application.SendNotification();
3406   application.Render(0);
3407   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3408
3409   // Build the animation
3410   float durationSeconds(1.0f);
3411   Animation animation = Animation::New(durationSeconds);
3412   Vector3 targetPosition(20.0f, 20.0f, 20.0f);
3413   Vector3 relativePosition(targetPosition - startPosition);
3414   float delay = 0.5f;
3415   animation.AnimateBy(Property(actor, Actor::Property::POSITION),
3416                       relativePosition,
3417                       AlphaFunction::LINEAR,
3418                       TimePeriod(delay, durationSeconds - delay));
3419
3420   Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
3421
3422   // Start the animation
3423   animation.Play();
3424
3425   bool signalReceived(false);
3426   AnimationFinishCheck finishCheck(signalReceived);
3427   animation.FinishedSignal().Connect(&application, finishCheck);
3428
3429   application.SendNotification();
3430   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3431
3432   // We didn't expect the animation to finish yet
3433   application.SendNotification();
3434   finishCheck.CheckSignalNotReceived();
3435   DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
3436
3437   application.SendNotification();
3438   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3439
3440   // We did expect the animation to finish
3441   application.SendNotification();
3442   finishCheck.CheckSignalReceived();
3443   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3444
3445   // Check that nothing has changed after a couple of buffer swaps
3446   application.Render(0);
3447   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3448   application.Render(0);
3449   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
3450   END_TEST;
3451 }
3452
3453 int UtcDaliAnimationAnimateByActorOrientationP(void)
3454 {
3455   TestApplication application;
3456
3457   Actor actor = Actor::New();
3458   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
3459   Stage::GetCurrent().Add(actor);
3460   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
3461
3462   // Build the animation
3463   float durationSeconds(1.0f);
3464   Animation animation = Animation::New(durationSeconds);
3465   Degree relativeRotationDegrees(360.0f);
3466   Radian relativeRotationRadians(relativeRotationDegrees);
3467   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ) );
3468
3469   // Start the animation
3470   animation.Play();
3471
3472   bool signalReceived(false);
3473   AnimationFinishCheck finishCheck(signalReceived);
3474   animation.FinishedSignal().Connect(&application, finishCheck);
3475
3476   application.SendNotification();
3477   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
3478
3479   // We didn't expect the animation to finish yet
3480   application.SendNotification();
3481   finishCheck.CheckSignalNotReceived();
3482   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3483
3484   application.SendNotification();
3485   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
3486
3487   // We didn't expect the animation to finish yet
3488   application.SendNotification();
3489   finishCheck.CheckSignalNotReceived();
3490   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3491
3492   application.SendNotification();
3493   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
3494
3495   // We didn't expect the animation to finish yet
3496   application.SendNotification();
3497   finishCheck.CheckSignalNotReceived();
3498   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3499
3500   application.SendNotification();
3501   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3502
3503   // We did expect the animation to finish
3504   application.SendNotification();
3505   finishCheck.CheckSignalReceived();
3506   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3507   END_TEST;
3508 }
3509
3510 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionP(void)
3511 {
3512   TestApplication application;
3513
3514   Actor actor = Actor::New();
3515   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
3516   Stage::GetCurrent().Add(actor);
3517   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
3518
3519   // Build the animation
3520   float durationSeconds(1.0f);
3521   Animation animation = Animation::New(durationSeconds);
3522   Degree relativeRotationDegrees(360.0f);
3523   Radian relativeRotationRadians(relativeRotationDegrees);
3524   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN );
3525
3526   // Start the animation
3527   animation.Play();
3528
3529   bool signalReceived(false);
3530   AnimationFinishCheck finishCheck(signalReceived);
3531   animation.FinishedSignal().Connect(&application, finishCheck);
3532
3533   application.SendNotification();
3534   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
3535
3536   // We didn't expect the animation to finish yet
3537   application.SendNotification();
3538   finishCheck.CheckSignalNotReceived();
3539   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3540
3541   application.SendNotification();
3542   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
3543
3544   // We didn't expect the animation to finish yet
3545   application.SendNotification();
3546   finishCheck.CheckSignalNotReceived();
3547   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3548
3549   application.SendNotification();
3550   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
3551
3552   // We didn't expect the animation to finish yet
3553   application.SendNotification();
3554   finishCheck.CheckSignalNotReceived();
3555   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3556
3557   application.SendNotification();
3558   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3559
3560   // We did expect the animation to finish
3561   application.SendNotification();
3562   finishCheck.CheckSignalReceived();
3563   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3564   END_TEST;
3565 }
3566
3567 int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void)
3568 {
3569   TestApplication application;
3570
3571   Actor actor = Actor::New();
3572   actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
3573   Stage::GetCurrent().Add(actor);
3574   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
3575
3576   // Build the animation
3577   float durationSeconds(1.0f);
3578   Animation animation = Animation::New(durationSeconds);
3579   Degree relativeRotationDegrees(360.0f);
3580   Radian relativeRotationRadians(relativeRotationDegrees);
3581   float delay = 0.3f;
3582   animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ),
3583                        AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) );
3584
3585   // Start the animation
3586   animation.Play();
3587
3588   bool signalReceived(false);
3589   AnimationFinishCheck finishCheck(signalReceived);
3590   animation.FinishedSignal().Connect(&application, finishCheck);
3591
3592   application.SendNotification();
3593   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
3594
3595   // We didn't expect the animation to finish yet
3596   application.SendNotification();
3597   finishCheck.CheckSignalNotReceived();
3598   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
3599   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3600
3601   application.SendNotification();
3602   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
3603
3604   // We didn't expect the animation to finish yet
3605   application.SendNotification();
3606   finishCheck.CheckSignalNotReceived();
3607   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
3608   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3609
3610   application.SendNotification();
3611   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
3612
3613   // We didn't expect the animation to finish yet
3614   application.SendNotification();
3615   finishCheck.CheckSignalNotReceived();
3616   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
3617   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3618
3619   application.SendNotification();
3620   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3621
3622   // We did expect the animation to finish
3623   application.SendNotification();
3624   finishCheck.CheckSignalReceived();
3625   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
3626   END_TEST;
3627 }
3628
3629 int UtcDaliAnimationAnimateByActorScaleP(void)
3630 {
3631   TestApplication application;
3632
3633   Actor actor = Actor::New();
3634   Stage::GetCurrent().Add(actor);
3635   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3636
3637   // Build the animation
3638   float durationSeconds(1.0f);
3639   Animation animation = Animation::New(durationSeconds);
3640   Vector3 targetScale(2.0f, 2.0f, 2.0f);
3641   Vector3 relativeScale(targetScale - Vector3::ONE);
3642   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), Vector3( relativeScale.x, relativeScale.y, relativeScale.z ) );
3643
3644   Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f);
3645
3646   // Start the animation
3647   animation.Play();
3648
3649   bool signalReceived(false);
3650   AnimationFinishCheck finishCheck(signalReceived);
3651   animation.FinishedSignal().Connect(&application, finishCheck);
3652
3653   application.SendNotification();
3654   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
3655
3656   // We didn't expect the animation to finish yet
3657   application.SendNotification();
3658   finishCheck.CheckSignalNotReceived();
3659   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
3660
3661   application.SendNotification();
3662   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
3663
3664   // We did expect the animation to finish
3665   application.SendNotification();
3666   finishCheck.CheckSignalReceived();
3667   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
3668
3669   // Reset everything
3670   finishCheck.Reset();
3671   actor.SetScale(Vector3::ONE);
3672   application.SendNotification();
3673   application.Render(0);
3674   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3675
3676   // Repeat with a different (ease-in) alpha function
3677   animation = Animation::New(durationSeconds);
3678   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN );
3679   animation.FinishedSignal().Connect(&application, finishCheck);
3680   animation.Play();
3681
3682   application.SendNotification();
3683   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
3684
3685   // We didn't expect the animation to finish yet
3686   application.SendNotification();
3687   finishCheck.CheckSignalNotReceived();
3688
3689   // The scale should have grown less, than with a linear alpha function
3690   Vector3 current(actor.GetCurrentScale());
3691   DALI_TEST_CHECK( current.x > 1.0f );
3692   DALI_TEST_CHECK( current.y > 1.0f );
3693   DALI_TEST_CHECK( current.z > 1.0f );
3694   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
3695   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
3696   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
3697
3698   application.SendNotification();
3699   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
3700
3701   // We did expect the animation to finish
3702   application.SendNotification();
3703   finishCheck.CheckSignalReceived();
3704   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
3705
3706   // Reset everything
3707   finishCheck.Reset();
3708   actor.SetScale(Vector3::ONE);
3709   application.SendNotification();
3710   application.Render(0);
3711   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3712
3713   // Repeat with a delay
3714   float delay = 0.5f;
3715   animation = Animation::New(durationSeconds);
3716   animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
3717   animation.FinishedSignal().Connect(&application, finishCheck);
3718   animation.Play();
3719
3720   application.SendNotification();
3721   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3722
3723   // We didn't expect the animation to finish yet
3724   application.SendNotification();
3725   finishCheck.CheckSignalNotReceived();
3726   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3727
3728   application.SendNotification();
3729   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
3730
3731   // We did expect the animation to finish
3732   application.SendNotification();
3733   finishCheck.CheckSignalReceived();
3734   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
3735   END_TEST;
3736 }
3737
3738 int UtcDaliAnimationAnimateToBooleanP(void)
3739 {
3740   TestApplication application;
3741
3742   Actor actor = Actor::New();
3743
3744   // Register a boolean property
3745   const bool startValue(false);
3746   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3747   Stage::GetCurrent().Add(actor);
3748   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3749
3750   // Build the animation
3751   float durationSeconds(2.0f);
3752   Animation animation = Animation::New(durationSeconds);
3753   const bool targetValue( !startValue );
3754   animation.AnimateTo(Property(actor, index), targetValue);
3755
3756   // Start the animation
3757   animation.Play();
3758
3759   bool signalReceived(false);
3760   AnimationFinishCheck finishCheck(signalReceived);
3761   animation.FinishedSignal().Connect(&application, finishCheck);
3762
3763   application.SendNotification();
3764   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3765
3766   // We didn't expect the animation to finish yet
3767   application.SendNotification();
3768   finishCheck.CheckSignalNotReceived();
3769   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3770
3771   application.SendNotification();
3772   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3773
3774   // We did expect the animation to finish
3775   application.SendNotification();
3776   finishCheck.CheckSignalReceived();
3777   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3778
3779   // Check that nothing has changed after a couple of buffer swaps
3780   application.Render(0);
3781   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3782   application.Render(0);
3783   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3784
3785   // Repeat with target value "false"
3786   animation = Animation::New(durationSeconds);
3787   const bool finalValue( !targetValue );
3788   animation.AnimateTo(Property(actor, index), finalValue);
3789
3790   // Start the animation
3791   animation.Play();
3792
3793   finishCheck.Reset();
3794   animation.FinishedSignal().Connect(&application, finishCheck);
3795
3796   application.SendNotification();
3797   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3798
3799   // We didn't expect the animation to finish yet
3800   application.SendNotification();
3801   finishCheck.CheckSignalNotReceived();
3802   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3803
3804   application.SendNotification();
3805   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3806
3807   // We did expect the animation to finish
3808   application.SendNotification();
3809   finishCheck.CheckSignalReceived();
3810   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3811
3812   // Check that nothing has changed after a couple of buffer swaps
3813   application.Render(0);
3814   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3815   application.Render(0);
3816   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3817   END_TEST;
3818 }
3819
3820 int UtcDaliAnimationAnimateToBooleanAlphaFunctionP(void)
3821 {
3822   TestApplication application;
3823
3824   Actor actor = Actor::New();
3825
3826   // Register a boolean property
3827   const bool startValue(false);
3828   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3829   Stage::GetCurrent().Add(actor);
3830   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3831
3832   // Build the animation
3833   float durationSeconds(2.0f);
3834   Animation animation = Animation::New(durationSeconds);
3835   const bool targetValue( !startValue );
3836   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
3837
3838   // Start the animation
3839   animation.Play();
3840
3841   bool signalReceived(false);
3842   AnimationFinishCheck finishCheck(signalReceived);
3843   animation.FinishedSignal().Connect(&application, finishCheck);
3844
3845   application.SendNotification();
3846   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3847
3848   // We didn't expect the animation to finish yet
3849   application.SendNotification();
3850   finishCheck.CheckSignalNotReceived();
3851   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3852
3853   application.SendNotification();
3854   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3855
3856   // We did expect the animation to finish
3857   application.SendNotification();
3858   finishCheck.CheckSignalReceived();
3859   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3860
3861   // Check that nothing has changed after a couple of buffer swaps
3862   application.Render(0);
3863   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3864   application.Render(0);
3865   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3866
3867   // Repeat with target value "false"
3868   animation = Animation::New(durationSeconds);
3869   const bool finalValue( !targetValue );
3870   animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT);
3871
3872   // Start the animation
3873   animation.Play();
3874
3875   finishCheck.Reset();
3876   animation.FinishedSignal().Connect(&application, finishCheck);
3877
3878   application.SendNotification();
3879   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3880
3881   // We didn't expect the animation to finish yet
3882   application.SendNotification();
3883   finishCheck.CheckSignalNotReceived();
3884   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == targetValue );
3885
3886   application.SendNotification();
3887   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3888
3889   // We did expect the animation to finish
3890   application.SendNotification();
3891   finishCheck.CheckSignalReceived();
3892   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3893
3894   // Check that nothing has changed after a couple of buffer swaps
3895   application.Render(0);
3896   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3897   application.Render(0);
3898   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3899   END_TEST;
3900 }
3901
3902 int UtcDaliAnimationAnimateToBooleanTimePeriodP(void)
3903 {
3904   TestApplication application;
3905
3906   Actor actor = Actor::New();
3907
3908   // Register a boolean property
3909   bool startValue(false);
3910   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3911   Stage::GetCurrent().Add(actor);
3912   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3913
3914   // Build the animation
3915   float durationSeconds(2.0f);
3916   Animation animation = Animation::New(durationSeconds);
3917   bool finalValue( !startValue );
3918   float animatorDurationSeconds(durationSeconds * 0.5f);
3919   animation.AnimateTo( Property(actor, index),
3920                        finalValue,
3921                        TimePeriod( animatorDurationSeconds ) );
3922
3923   // Start the animation
3924   animation.Play();
3925
3926   bool signalReceived(false);
3927   AnimationFinishCheck finishCheck(signalReceived);
3928   animation.FinishedSignal().Connect(&application, finishCheck);
3929
3930   application.SendNotification();
3931   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3932
3933   // We didn't expect the animation to finish yet
3934   application.SendNotification();
3935   finishCheck.CheckSignalNotReceived();
3936   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3937
3938   application.SendNotification();
3939   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3940
3941   // We didn't expect the animation to finish yet...
3942   application.SendNotification();
3943   finishCheck.CheckSignalNotReceived();
3944
3945   // ...however we should have reached the final value
3946   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3947
3948   application.SendNotification();
3949   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3950
3951   // We did expect the animation to finish
3952   application.SendNotification();
3953   finishCheck.CheckSignalReceived();
3954   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3955
3956   // Check that nothing has changed after a couple of buffer swaps
3957   application.Render(0);
3958   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3959   application.Render(0);
3960   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3961   END_TEST;
3962 }
3963
3964 int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void)
3965 {
3966   TestApplication application;
3967
3968   Actor actor = Actor::New();
3969
3970   // Register a boolean property
3971   bool startValue(false);
3972   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
3973   Stage::GetCurrent().Add(actor);
3974   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3975
3976   // Build the animation
3977   float durationSeconds(2.0f);
3978   Animation animation = Animation::New(durationSeconds);
3979   bool finalValue( !startValue );
3980   float animatorDurationSeconds(durationSeconds * 0.5f);
3981   animation.AnimateTo( Property(actor, index),
3982                        finalValue,
3983                        AlphaFunction::LINEAR,
3984                        TimePeriod( animatorDurationSeconds ) );
3985
3986   // Start the animation
3987   animation.Play();
3988
3989   bool signalReceived(false);
3990   AnimationFinishCheck finishCheck(signalReceived);
3991   animation.FinishedSignal().Connect(&application, finishCheck);
3992
3993   application.SendNotification();
3994   application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3995
3996   // We didn't expect the animation to finish yet
3997   application.SendNotification();
3998   finishCheck.CheckSignalNotReceived();
3999   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
4000
4001   application.SendNotification();
4002   application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
4003
4004   // We didn't expect the animation to finish yet...
4005   application.SendNotification();
4006   finishCheck.CheckSignalNotReceived();
4007
4008   // ...however we should have reached the final value
4009   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4010
4011   application.SendNotification();
4012   application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
4013
4014   // We did expect the animation to finish
4015   application.SendNotification();
4016   finishCheck.CheckSignalReceived();
4017   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4018
4019   // Check that nothing has changed after a couple of buffer swaps
4020   application.Render(0);
4021   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4022   application.Render(0);
4023   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
4024   END_TEST;
4025 }
4026
4027 int UtcDaliAnimationAnimateToFloatP(void)
4028 {
4029   TestApplication application;
4030
4031   Actor actor = Actor::New();
4032
4033   // Register a float property
4034   float startValue(10.0f);
4035   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4036   Stage::GetCurrent().Add(actor);
4037   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4038
4039   // Build the animation
4040   float durationSeconds(2.0f);
4041   Animation animation = Animation::New(durationSeconds);
4042   float targetValue(50.0f);
4043   float relativeValue(targetValue - startValue);
4044   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
4045
4046   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4047
4048   // Start the animation
4049   animation.Play();
4050
4051   bool signalReceived(false);
4052   AnimationFinishCheck finishCheck(signalReceived);
4053   animation.FinishedSignal().Connect(&application, finishCheck);
4054
4055   application.SendNotification();
4056   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4057
4058   // We didn't expect the animation to finish yet
4059   application.SendNotification();
4060   finishCheck.CheckSignalNotReceived();
4061   DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
4062
4063   application.SendNotification();
4064   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4065
4066   // We did expect the animation to finish
4067   application.SendNotification();
4068   finishCheck.CheckSignalReceived();
4069   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
4070   END_TEST;
4071 }
4072
4073 int UtcDaliAnimationAnimateToFloatAlphaFunctionP(void)
4074 {
4075   TestApplication application;
4076
4077   Actor actor = Actor::New();
4078
4079   // Register a float property
4080   float startValue(10.0f);
4081   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4082   Stage::GetCurrent().Add(actor);
4083   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4084
4085   // Build the animation
4086   float durationSeconds(1.0f);
4087   Animation animation = Animation::New(durationSeconds);
4088   float targetValue(90.0f);
4089   float relativeValue(targetValue - startValue);
4090   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
4091
4092   float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4093
4094   // Start the animation
4095   animation.Play();
4096
4097   bool signalReceived(false);
4098   AnimationFinishCheck finishCheck(signalReceived);
4099   animation.FinishedSignal().Connect(&application, finishCheck);
4100
4101   application.SendNotification();
4102   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4103
4104   // We didn't expect the animation to finish yet
4105   application.SendNotification();
4106   finishCheck.CheckSignalNotReceived();
4107
4108   // The position should have moved more, than with a linear alpha function
4109   float current(actor.GetProperty<float>(index));
4110   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
4111
4112   application.SendNotification();
4113   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4114
4115   // We did expect the animation to finish
4116   application.SendNotification();
4117   finishCheck.CheckSignalReceived();
4118   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
4119   END_TEST;
4120 }
4121
4122 int UtcDaliAnimationAnimateToFloatTimePeriodP(void)
4123 {
4124   TestApplication application;
4125
4126   Actor actor = Actor::New();
4127
4128   // Register a float property
4129   float startValue(10.0f);
4130   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4131   Stage::GetCurrent().Add(actor);
4132   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4133
4134   // Build the animation
4135   float durationSeconds(1.0f);
4136   Animation animation = Animation::New(durationSeconds);
4137   float targetValue(30.0f);
4138   float relativeValue(targetValue - startValue);
4139   float delay = 0.5f;
4140   animation.AnimateTo(Property(actor, index),
4141                       targetValue,
4142                       TimePeriod(delay, durationSeconds - delay));
4143
4144   // Start the animation
4145   animation.Play();
4146
4147   bool signalReceived(false);
4148   AnimationFinishCheck finishCheck(signalReceived);
4149   animation.FinishedSignal().Connect(&application, finishCheck);
4150
4151   application.SendNotification();
4152   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4153
4154   // We didn't expect the animation to finish yet
4155   application.SendNotification();
4156   finishCheck.CheckSignalNotReceived();
4157   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4158
4159   application.SendNotification();
4160   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4161
4162   // We didn't expect the animation to finish yet
4163   application.SendNotification();
4164   finishCheck.CheckSignalNotReceived();
4165   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4166
4167   application.SendNotification();
4168   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4169
4170   // We did expect the animation to finish
4171   application.SendNotification();
4172   finishCheck.CheckSignalReceived();
4173   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
4174   END_TEST;
4175 }
4176
4177 int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void)
4178 {
4179   TestApplication application;
4180
4181   Actor actor = Actor::New();
4182
4183   // Register a float property
4184   float startValue(10.0f);
4185   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4186   Stage::GetCurrent().Add(actor);
4187   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4188
4189   // Build the animation
4190   float durationSeconds(1.0f);
4191   Animation animation = Animation::New(durationSeconds);
4192   float targetValue(30.0f);
4193   float relativeValue(targetValue - startValue);
4194   float delay = 0.5f;
4195   animation.AnimateTo(Property(actor, index),
4196                       targetValue,
4197                       AlphaFunction::LINEAR,
4198                       TimePeriod(delay, durationSeconds - delay));
4199
4200   // Start the animation
4201   animation.Play();
4202
4203   bool signalReceived(false);
4204   AnimationFinishCheck finishCheck(signalReceived);
4205   animation.FinishedSignal().Connect(&application, finishCheck);
4206
4207   application.SendNotification();
4208   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4209
4210   // We didn't expect the animation to finish yet
4211   application.SendNotification();
4212   finishCheck.CheckSignalNotReceived();
4213   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
4214
4215   application.SendNotification();
4216   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4217
4218   // We didn't expect the animation to finish yet
4219   application.SendNotification();
4220   finishCheck.CheckSignalNotReceived();
4221   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4222
4223   application.SendNotification();
4224   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4225
4226   // We did expect the animation to finish
4227   application.SendNotification();
4228   finishCheck.CheckSignalReceived();
4229   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
4230   END_TEST;
4231 }
4232
4233 int UtcDaliAnimationAnimateToIntegerP(void)
4234 {
4235   TestApplication application;
4236
4237   Actor actor = Actor::New();
4238
4239   // Register an integer property
4240   int startValue(10);
4241   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4242   Stage::GetCurrent().Add(actor);
4243   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4244
4245   // Build the animation
4246   float durationSeconds(2.0f);
4247   Animation animation = Animation::New(durationSeconds);
4248   int targetValue(50);
4249   int relativeValue(targetValue - startValue);
4250   animation.AnimateTo(Property(actor, "testProperty"), targetValue);
4251
4252   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
4253
4254   // Start the animation
4255   animation.Play();
4256
4257   bool signalReceived(false);
4258   AnimationFinishCheck finishCheck(signalReceived);
4259   animation.FinishedSignal().Connect(&application, finishCheck);
4260
4261   application.SendNotification();
4262   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4263
4264   // We didn't expect the animation to finish yet
4265   application.SendNotification();
4266   finishCheck.CheckSignalNotReceived();
4267   DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
4268
4269   application.SendNotification();
4270   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4271
4272   // We did expect the animation to finish
4273   application.SendNotification();
4274   finishCheck.CheckSignalReceived();
4275   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4276   END_TEST;
4277 }
4278
4279 int UtcDaliAnimationAnimateToIntegerAlphaFunctionP(void)
4280 {
4281   TestApplication application;
4282
4283   Actor actor = Actor::New();
4284
4285   // Register an integer property
4286   int startValue(10);
4287   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4288   Stage::GetCurrent().Add(actor);
4289   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4290
4291   // Build the animation
4292   float durationSeconds(1.0f);
4293   Animation animation = Animation::New(durationSeconds);
4294   int targetValue(90);
4295   int relativeValue(targetValue - startValue);
4296   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
4297
4298   int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
4299
4300   // Start the animation
4301   animation.Play();
4302
4303   bool signalReceived(false);
4304   AnimationFinishCheck finishCheck(signalReceived);
4305   animation.FinishedSignal().Connect(&application, finishCheck);
4306
4307   application.SendNotification();
4308   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4309
4310   // We didn't expect the animation to finish yet
4311   application.SendNotification();
4312   finishCheck.CheckSignalNotReceived();
4313
4314   // The position should have moved more, than with a linear alpha function
4315   int current(actor.GetProperty<int>(index));
4316   DALI_TEST_CHECK( current > ninetyFivePercentProgress );
4317
4318   application.SendNotification();
4319   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4320
4321   // We did expect the animation to finish
4322   application.SendNotification();
4323   finishCheck.CheckSignalReceived();
4324   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4325   END_TEST;
4326 }
4327
4328 int UtcDaliAnimationAnimateToIntegerTimePeriodP(void)
4329 {
4330   TestApplication application;
4331
4332   Actor actor = Actor::New();
4333
4334   // Register an integer property
4335   int startValue(10);
4336   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4337   Stage::GetCurrent().Add(actor);
4338   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4339
4340   // Build the animation
4341   float durationSeconds(1.0f);
4342   Animation animation = Animation::New(durationSeconds);
4343   int targetValue(30);
4344   int relativeValue(targetValue - startValue);
4345   float delay = 0.5f;
4346   animation.AnimateTo(Property(actor, index),
4347                       targetValue,
4348                       TimePeriod(delay, durationSeconds - delay));
4349
4350   // Start the animation
4351   animation.Play();
4352
4353   bool signalReceived(false);
4354   AnimationFinishCheck finishCheck(signalReceived);
4355   animation.FinishedSignal().Connect(&application, finishCheck);
4356
4357   application.SendNotification();
4358   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4359
4360   // We didn't expect the animation to finish yet
4361   application.SendNotification();
4362   finishCheck.CheckSignalNotReceived();
4363   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4364
4365   application.SendNotification();
4366   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4367
4368   // We didn't expect the animation to finish yet
4369   application.SendNotification();
4370   finishCheck.CheckSignalNotReceived();
4371   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4372
4373   application.SendNotification();
4374   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4375
4376   // We did expect the animation to finish
4377   application.SendNotification();
4378   finishCheck.CheckSignalReceived();
4379   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4380   END_TEST;
4381 }
4382
4383 int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void)
4384 {
4385   TestApplication application;
4386
4387   Actor actor = Actor::New();
4388
4389   // Register an integer property
4390   int startValue(10);
4391   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4392   Stage::GetCurrent().Add(actor);
4393   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
4394
4395   // Build the animation
4396   float durationSeconds(1.0f);
4397   Animation animation = Animation::New(durationSeconds);
4398   int targetValue(30);
4399   int relativeValue(targetValue - startValue);
4400   float delay = 0.5f;
4401   animation.AnimateTo(Property(actor, index),
4402                       targetValue,
4403                       AlphaFunction::LINEAR,
4404                       TimePeriod(delay, durationSeconds - delay));
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.GetProperty<int>(index), startValue, TEST_LOCATION );
4420
4421   application.SendNotification();
4422   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4423
4424   // We didn't expect the animation to finish yet
4425   application.SendNotification();
4426   finishCheck.CheckSignalNotReceived();
4427   DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
4428
4429   application.SendNotification();
4430   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4431
4432   // We did expect the animation to finish
4433   application.SendNotification();
4434   finishCheck.CheckSignalReceived();
4435   DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
4436   END_TEST;
4437 }
4438
4439 int UtcDaliAnimationAnimateToVector2P(void)
4440 {
4441   TestApplication application;
4442
4443   Actor actor = Actor::New();
4444
4445   // Register a Vector2 property
4446   Vector2 startValue(-50.0f, -50.0f);
4447   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4448   Stage::GetCurrent().Add(actor);
4449   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4450
4451   // Build the animation
4452   float durationSeconds(2.0f);
4453   Animation animation = Animation::New(durationSeconds);
4454   Vector2 targetValue(50.0f, 50.0f);
4455   Vector2 relativeValue(targetValue - startValue);
4456   animation.AnimateTo(Property(actor, index), targetValue);
4457
4458   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4459
4460   // Start the animation
4461   animation.Play();
4462
4463   bool signalReceived(false);
4464   AnimationFinishCheck finishCheck(signalReceived);
4465   animation.FinishedSignal().Connect(&application, finishCheck);
4466
4467   application.SendNotification();
4468   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4469
4470   // We didn't expect the animation to finish yet
4471   application.SendNotification();
4472   finishCheck.CheckSignalNotReceived();
4473   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
4474
4475   application.SendNotification();
4476   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4477
4478   // We did expect the animation to finish
4479   application.SendNotification();
4480   finishCheck.CheckSignalReceived();
4481   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4482   END_TEST;
4483 }
4484
4485 int UtcDaliAnimationAnimateToVector2AlphaFunctionP(void)
4486 {
4487   TestApplication application;
4488
4489   Actor actor = Actor::New();
4490
4491   // Register a Vector2 property
4492   Vector2 startValue(1000.0f, 1000.0f);
4493   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4494   Stage::GetCurrent().Add(actor);
4495   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4496
4497   // Build the animation
4498   float durationSeconds(1.0f);
4499   Animation animation = Animation::New(durationSeconds);
4500   Vector2 targetValue(9000.0f, 9000.0f);
4501   Vector2 relativeValue(targetValue - startValue);
4502   animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction::EASE_OUT);
4503
4504   Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4505
4506   // Start the animation
4507   animation.Play();
4508
4509   bool signalReceived(false);
4510   AnimationFinishCheck finishCheck(signalReceived);
4511   animation.FinishedSignal().Connect(&application, finishCheck);
4512
4513   application.SendNotification();
4514   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4515
4516   // We didn't expect the animation to finish yet
4517   application.SendNotification();
4518   finishCheck.CheckSignalNotReceived();
4519
4520   // The position should have moved more, than with a linear alpha function
4521   Vector2 current(actor.GetProperty<Vector2>(index));
4522   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4523   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4524
4525   application.SendNotification();
4526   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4527
4528   // We did expect the animation to finish
4529   application.SendNotification();
4530   finishCheck.CheckSignalReceived();
4531   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4532   END_TEST;
4533 }
4534
4535 int UtcDaliAnimationAnimateToVector2TimePeriodP(void)
4536 {
4537   TestApplication application;
4538
4539   Actor actor = Actor::New();
4540
4541   // Register a Vector2 property
4542   Vector2 startValue(10.0f, 10.0f);
4543   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4544   Stage::GetCurrent().Add(actor);
4545   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4546
4547   // Build the animation
4548   float durationSeconds(1.0f);
4549   Animation animation = Animation::New(durationSeconds);
4550   Vector2 targetValue(-10.0f, 20.0f);
4551   Vector2 relativeValue(targetValue - startValue);
4552   float delay = 0.5f;
4553   animation.AnimateTo(Property(actor, index),
4554                       targetValue,
4555                       TimePeriod(delay, durationSeconds - delay));
4556
4557   // Start the animation
4558   animation.Play();
4559
4560   bool signalReceived(false);
4561   AnimationFinishCheck finishCheck(signalReceived);
4562   animation.FinishedSignal().Connect(&application, finishCheck);
4563
4564   application.SendNotification();
4565   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4566
4567   // We didn't expect the animation to finish yet
4568   application.SendNotification();
4569   finishCheck.CheckSignalNotReceived();
4570   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4571
4572   application.SendNotification();
4573   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4574
4575   // We didn't expect the animation to finish yet
4576   application.SendNotification();
4577   finishCheck.CheckSignalNotReceived();
4578   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4579
4580   application.SendNotification();
4581   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4582
4583   // We did expect the animation to finish
4584   application.SendNotification();
4585   finishCheck.CheckSignalReceived();
4586   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4587   END_TEST;
4588 }
4589
4590 int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void)
4591 {
4592   TestApplication application;
4593
4594   Actor actor = Actor::New();
4595
4596   // Register a Vector2 property
4597   Vector2 startValue(10.0f, 10.0f);
4598   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4599   Stage::GetCurrent().Add(actor);
4600   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4601
4602   // Build the animation
4603   float durationSeconds(1.0f);
4604   Animation animation = Animation::New(durationSeconds);
4605   Vector2 targetValue(30.0f, 30.0f);
4606   Vector2 relativeValue(targetValue - startValue);
4607   float delay = 0.5f;
4608   animation.AnimateTo(Property(actor, index),
4609                       targetValue,
4610                       AlphaFunction::LINEAR,
4611                       TimePeriod(delay, durationSeconds - delay));
4612
4613   // Start the animation
4614   animation.Play();
4615
4616   bool signalReceived(false);
4617   AnimationFinishCheck finishCheck(signalReceived);
4618   animation.FinishedSignal().Connect(&application, finishCheck);
4619
4620   application.SendNotification();
4621   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4622
4623   // We didn't expect the animation to finish yet
4624   application.SendNotification();
4625   finishCheck.CheckSignalNotReceived();
4626   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
4627
4628   application.SendNotification();
4629   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4630
4631   // We didn't expect the animation to finish yet
4632   application.SendNotification();
4633   finishCheck.CheckSignalNotReceived();
4634   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4635
4636   application.SendNotification();
4637   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4638
4639   // We did expect the animation to finish
4640   application.SendNotification();
4641   finishCheck.CheckSignalReceived();
4642   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
4643   END_TEST;
4644 }
4645
4646 int UtcDaliAnimationAnimateToVector3P(void)
4647 {
4648   TestApplication application;
4649
4650   Actor actor = Actor::New();
4651
4652   // Register a Vector3 property
4653   Vector3 startValue(-50.0f, -50.0f, -50.0f);
4654   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4655   Stage::GetCurrent().Add(actor);
4656   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4657
4658   // Build the animation
4659   float durationSeconds(2.0f);
4660   Animation animation = Animation::New(durationSeconds);
4661   Vector3 targetValue(50.0f, 50.0f, 50.0f);
4662   Vector3 relativeValue(targetValue - startValue);
4663   animation.AnimateTo(Property(actor, index), targetValue);
4664
4665   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4666
4667   // Start the animation
4668   animation.Play();
4669
4670   bool signalReceived(false);
4671   AnimationFinishCheck finishCheck(signalReceived);
4672   animation.FinishedSignal().Connect(&application, finishCheck);
4673
4674   application.SendNotification();
4675   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4676
4677   // We didn't expect the animation to finish yet
4678   application.SendNotification();
4679   finishCheck.CheckSignalNotReceived();
4680   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
4681
4682   application.SendNotification();
4683   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4684
4685   // We did expect the animation to finish
4686   application.SendNotification();
4687   finishCheck.CheckSignalReceived();
4688   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4689   END_TEST;
4690 }
4691
4692 int UtcDaliAnimationAnimateToVector3AlphaFunctionP(void)
4693 {
4694   TestApplication application;
4695
4696   Actor actor = Actor::New();
4697
4698   // Register a Vector3 property
4699   Vector3 startValue(1000.0f, 1000.0f, 1000.0f);
4700   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4701   Stage::GetCurrent().Add(actor);
4702   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4703
4704   // Build the animation
4705   float durationSeconds(1.0f);
4706   Animation animation = Animation::New(durationSeconds);
4707   Vector3 targetValue(9000.0f, 9000.0f, 9000.0f);
4708   Vector3 relativeValue(targetValue - startValue);
4709   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
4710
4711   Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4712
4713   // Start the animation
4714   animation.Play();
4715
4716   bool signalReceived(false);
4717   AnimationFinishCheck finishCheck(signalReceived);
4718   animation.FinishedSignal().Connect(&application, finishCheck);
4719
4720   application.SendNotification();
4721   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4722
4723   // We didn't expect the animation to finish yet
4724   application.SendNotification();
4725   finishCheck.CheckSignalNotReceived();
4726
4727   // The position should have moved more, than with a linear alpha function
4728   Vector3 current(actor.GetProperty<Vector3>(index));
4729   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4730   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4731   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4732
4733   application.SendNotification();
4734   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4735
4736   // We did expect the animation to finish
4737   application.SendNotification();
4738   finishCheck.CheckSignalReceived();
4739   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4740   END_TEST;
4741 }
4742
4743 int UtcDaliAnimationAnimateToVector3TimePeriodP(void)
4744 {
4745   TestApplication application;
4746
4747   Actor actor = Actor::New();
4748
4749   // Register a Vector3 property
4750   Vector3 startValue(10.0f, 10.0f, 10.0f);
4751   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4752   Stage::GetCurrent().Add(actor);
4753   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4754
4755   // Build the animation
4756   float durationSeconds(1.0f);
4757   Animation animation = Animation::New(durationSeconds);
4758   Vector3 targetValue(-10.0f, 20.0f, 100.0f);
4759   Vector3 relativeValue(targetValue - startValue);
4760   float delay = 0.5f;
4761   animation.AnimateTo(Property(actor, index),
4762                       targetValue,
4763                       TimePeriod(delay, durationSeconds - delay));
4764
4765   // Start the animation
4766   animation.Play();
4767
4768   bool signalReceived(false);
4769   AnimationFinishCheck finishCheck(signalReceived);
4770   animation.FinishedSignal().Connect(&application, finishCheck);
4771
4772   application.SendNotification();
4773   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4774
4775   // We didn't expect the animation to finish yet
4776   application.SendNotification();
4777   finishCheck.CheckSignalNotReceived();
4778   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4779
4780   application.SendNotification();
4781   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4782
4783   // We didn't expect the animation to finish yet
4784   application.SendNotification();
4785   finishCheck.CheckSignalNotReceived();
4786   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4787
4788   application.SendNotification();
4789   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4790
4791   // We did expect the animation to finish
4792   application.SendNotification();
4793   finishCheck.CheckSignalReceived();
4794   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4795   END_TEST;
4796 }
4797
4798 int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void)
4799 {
4800   TestApplication application;
4801
4802   Actor actor = Actor::New();
4803
4804   // Register a Vector3 property
4805   Vector3 startValue(10.0f, 10.0f, 10.0f);
4806   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4807   Stage::GetCurrent().Add(actor);
4808   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4809
4810   // Build the animation
4811   float durationSeconds(1.0f);
4812   Animation animation = Animation::New(durationSeconds);
4813   Vector3 targetValue(30.0f, 30.0f, 30.0f);
4814   Vector3 relativeValue(targetValue - startValue);
4815   float delay = 0.5f;
4816   animation.AnimateTo(Property(actor, "testProperty"),
4817                       targetValue,
4818                       AlphaFunction::LINEAR,
4819                       TimePeriod(delay, durationSeconds - delay));
4820
4821   // Start the animation
4822   animation.Play();
4823
4824   bool signalReceived(false);
4825   AnimationFinishCheck finishCheck(signalReceived);
4826   animation.FinishedSignal().Connect(&application, finishCheck);
4827
4828   application.SendNotification();
4829   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4830
4831   // We didn't expect the animation to finish yet
4832   application.SendNotification();
4833   finishCheck.CheckSignalNotReceived();
4834   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4835
4836   application.SendNotification();
4837   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4838
4839   // We didn't expect the animation to finish yet
4840   application.SendNotification();
4841   finishCheck.CheckSignalNotReceived();
4842   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4843
4844   application.SendNotification();
4845   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4846
4847   // We did expect the animation to finish
4848   application.SendNotification();
4849   finishCheck.CheckSignalReceived();
4850   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4851   END_TEST;
4852 }
4853
4854 int UtcDaliAnimationAnimateToVector3ComponentP(void)
4855 {
4856   TestApplication application;
4857
4858   Actor actor = Actor::New();
4859
4860   // Register a Vector3 property
4861   Vector3 startValue(10.0f, 10.0f, 10.0f);
4862   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4863   Stage::GetCurrent().Add(actor);
4864   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4865
4866   // Build the animation
4867   float durationSeconds(1.0f);
4868   Animation animation = Animation::New(durationSeconds);
4869   Vector3 targetValue(30.0f, 30.0f, 10.0f);
4870   Vector3 relativeValue(targetValue - startValue);
4871   float delay = 0.5f;
4872   animation.AnimateTo(Property(actor, "testProperty",  0),
4873                       30.0f,
4874                       AlphaFunction::LINEAR,
4875                       TimePeriod(delay, durationSeconds - delay));
4876   animation.AnimateTo(Property(actor, index, 1),
4877                       30.0f,
4878                       AlphaFunction::LINEAR,
4879                       TimePeriod(delay, durationSeconds - delay));
4880
4881   // Start the animation
4882   animation.Play();
4883
4884   bool signalReceived(false);
4885   AnimationFinishCheck finishCheck(signalReceived);
4886   animation.FinishedSignal().Connect(&application, finishCheck);
4887
4888   application.SendNotification();
4889   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4890
4891   // We didn't expect the animation to finish yet
4892   application.SendNotification();
4893   finishCheck.CheckSignalNotReceived();
4894   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
4895
4896   application.SendNotification();
4897   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4898
4899   // We didn't expect the animation to finish yet
4900   application.SendNotification();
4901   finishCheck.CheckSignalNotReceived();
4902   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4903
4904   application.SendNotification();
4905   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4906
4907   // We did expect the animation to finish
4908   application.SendNotification();
4909   finishCheck.CheckSignalReceived();
4910   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
4911   END_TEST;
4912 }
4913
4914 int UtcDaliAnimationAnimateToVector4P(void)
4915 {
4916   TestApplication application;
4917
4918   Actor actor = Actor::New();
4919
4920   // Register a Vector4 property
4921   Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f);
4922   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4923   Stage::GetCurrent().Add(actor);
4924   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4925
4926   // Build the animation
4927   float durationSeconds(2.0f);
4928   Animation animation = Animation::New(durationSeconds);
4929   Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f);
4930   Vector4 relativeValue(targetValue - startValue);
4931   animation.AnimateTo(Property(actor, index), targetValue);
4932
4933   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4934
4935   // Start the animation
4936   animation.Play();
4937
4938   bool signalReceived(false);
4939   AnimationFinishCheck finishCheck(signalReceived);
4940   animation.FinishedSignal().Connect(&application, finishCheck);
4941
4942   application.SendNotification();
4943   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4944
4945   // We didn't expect the animation to finish yet
4946   application.SendNotification();
4947   finishCheck.CheckSignalNotReceived();
4948   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4949
4950   application.SendNotification();
4951   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4952
4953   // We did expect the animation to finish
4954   application.SendNotification();
4955   finishCheck.CheckSignalReceived();
4956   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4957   END_TEST;
4958 }
4959
4960 int UtcDaliAnimationAnimateToVector4AlphaFunctionP(void)
4961 {
4962   TestApplication application;
4963
4964   Actor actor = Actor::New();
4965
4966   // Register a Vector4 property
4967   Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f);
4968   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
4969   Stage::GetCurrent().Add(actor);
4970   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4971
4972   // Build the animation
4973   float durationSeconds(1.0f);
4974   Animation animation = Animation::New(durationSeconds);
4975   Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f);
4976   Vector4 relativeValue(targetValue - startValue);
4977   animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT);
4978
4979   Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4980
4981   // Start the animation
4982   animation.Play();
4983
4984   bool signalReceived(false);
4985   AnimationFinishCheck finishCheck(signalReceived);
4986   animation.FinishedSignal().Connect(&application, finishCheck);
4987
4988   application.SendNotification();
4989   application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4990
4991   // We didn't expect the animation to finish yet
4992   application.SendNotification();
4993   finishCheck.CheckSignalNotReceived();
4994
4995   // The position should have moved more, than with a linear alpha function
4996   Vector4 current(actor.GetProperty<Vector4>(index));
4997   DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4998   DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4999   DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
5000   DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w );
5001
5002   application.SendNotification();
5003   application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
5004
5005   // We did expect the animation to finish
5006   application.SendNotification();
5007   finishCheck.CheckSignalReceived();
5008   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
5009   END_TEST;
5010 }
5011
5012 int UtcDaliAnimationAnimateToVector4TimePeriodP(void)
5013 {
5014   TestApplication application;
5015
5016   Actor actor = Actor::New();
5017
5018   // Register a Vector4 property
5019   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
5020   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5021   Stage::GetCurrent().Add(actor);
5022   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
5023
5024   // Build the animation
5025   float durationSeconds(1.0f);
5026   Animation animation = Animation::New(durationSeconds);
5027   Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f);
5028   Vector4 relativeValue(targetValue - startValue);
5029   float delay = 0.5f;
5030   animation.AnimateTo(Property(actor, index),
5031                       targetValue,
5032                       TimePeriod(delay, durationSeconds - delay));
5033
5034   // Start the animation
5035   animation.Play();
5036
5037   bool signalReceived(false);
5038   AnimationFinishCheck finishCheck(signalReceived);
5039   animation.FinishedSignal().Connect(&application, finishCheck);
5040
5041   application.SendNotification();
5042   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5043
5044   // We didn't expect the animation to finish yet
5045   application.SendNotification();
5046   finishCheck.CheckSignalNotReceived();
5047   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, VECTOR4_EPSILON, TEST_LOCATION );
5048
5049   application.SendNotification();
5050   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5051
5052   // We didn't expect the animation to finish yet
5053   application.SendNotification();
5054   finishCheck.CheckSignalNotReceived();
5055   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION );
5056
5057   application.SendNotification();
5058   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5059
5060   // We did expect the animation to finish
5061   application.SendNotification();
5062   finishCheck.CheckSignalReceived();
5063   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION );
5064   END_TEST;
5065 }
5066
5067 int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void)
5068 {
5069   TestApplication application;
5070
5071   Actor actor = Actor::New();
5072
5073   // Register a Vector4 property
5074   Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
5075   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
5076   Stage::GetCurrent().Add(actor);
5077   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
5078
5079   // Build the animation
5080   float durationSeconds(1.0f);
5081   Animation animation = Animation::New(durationSeconds);
5082   Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
5083   Vector4 relativeValue(targetValue - startValue);
5084   float delay = 0.5f;
5085   animation.AnimateTo(Property(actor, index),
5086                       targetValue,
5087                       AlphaFunction::LINEAR,
5088                       TimePeriod(delay, durationSeconds - delay));
5089
5090   // Start the animation
5091   animation.Play();
5092
5093   bool signalReceived(false);
5094   AnimationFinishCheck finishCheck(signalReceived);
5095   animation.FinishedSignal().Connect(&application, finishCheck);
5096
5097   application.SendNotification();
5098   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5099
5100   // We didn't expect the animation to finish yet
5101   application.SendNotification();
5102   finishCheck.CheckSignalNotReceived();
5103   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
5104
5105   application.SendNotification();
5106   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
5107
5108   // We didn't expect the animation to finish yet
5109   application.SendNotification();
5110   finishCheck.CheckSignalNotReceived();
5111   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
5112
5113   application.SendNotification();
5114   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5115
5116   // We did expect the animation to finish
5117   application.SendNotification();
5118   finishCheck.CheckSignalReceived();
5119   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
5120   END_TEST;
5121 }
5122
5123 int UtcDaliAnimationAnimateToActorParentOriginP(void)
5124 {
5125   TestApplication application;
5126
5127   Actor actor = Actor::New();
5128   Stage::GetCurrent().Add(actor);
5129   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
5130
5131   // Build the animation
5132   float durationSeconds(1.0f);
5133   Animation animation = Animation::New(durationSeconds);
5134   Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
5135
5136   try
5137   {
5138     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
5139   }
5140   catch (Dali::DaliException& e)
5141   {
5142     DALI_TEST_PRINT_ASSERT( e );
5143     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5144   }
5145   END_TEST;
5146 }
5147
5148 int UtcDaliAnimationAnimateToActorParentOriginXP(void)
5149 {
5150   TestApplication application;
5151
5152   Actor actor = Actor::New();
5153   Stage::GetCurrent().Add(actor);
5154   float startValue(0.0f);
5155   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION );
5156   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_X), startValue, TEST_LOCATION );
5157
5158   // Build the animation
5159   float durationSeconds(1.0f);
5160   Animation animation = Animation::New(durationSeconds);
5161   float targetX(1.0f);
5162
5163   try
5164   {
5165     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
5166   }
5167   catch (Dali::DaliException& e)
5168   {
5169     DALI_TEST_PRINT_ASSERT( e );
5170     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5171   }
5172   END_TEST;
5173 }
5174
5175 int UtcDaliAnimationAnimateToActorParentOriginYP(void)
5176 {
5177   TestApplication application;
5178
5179   Actor actor = Actor::New();
5180   Stage::GetCurrent().Add(actor);
5181   float startValue(0.0f);
5182   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION );
5183   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Y), startValue, TEST_LOCATION );
5184
5185   // Build the animation
5186   float durationSeconds(1.0f);
5187   Animation animation = Animation::New(durationSeconds);
5188   float targetY(1.0f);
5189
5190   try
5191   {
5192     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
5193   }
5194   catch (Dali::DaliException& e)
5195   {
5196     DALI_TEST_PRINT_ASSERT( e );
5197     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5198   }
5199   END_TEST;
5200 }
5201
5202 int UtcDaliAnimationAnimateToActorParentOriginZP(void)
5203 {
5204   TestApplication application;
5205
5206   Actor actor = Actor::New();
5207   Stage::GetCurrent().Add(actor);
5208   float startValue(0.5f);
5209   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION );
5210   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::PARENT_ORIGIN_Z), startValue, TEST_LOCATION );
5211
5212   // Build the animation
5213   float durationSeconds(1.0f);
5214   Animation animation = Animation::New(durationSeconds);
5215   float targetZ(1.0f);
5216
5217   try
5218   {
5219     animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
5220   }
5221   catch (Dali::DaliException& e)
5222   {
5223     DALI_TEST_PRINT_ASSERT( e );
5224     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5225   }
5226   END_TEST;
5227 }
5228
5229 int UtcDaliAnimationAnimateToActorAnchorPointP(void)
5230 {
5231   TestApplication application;
5232
5233   Actor actor = Actor::New();
5234   Stage::GetCurrent().Add(actor);
5235   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION );
5236
5237   // Build the animation
5238   float durationSeconds(1.0f);
5239   Animation animation = Animation::New(durationSeconds);
5240   Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT);
5241
5242   try
5243   {
5244     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
5245   }
5246   catch (Dali::DaliException& e)
5247   {
5248     DALI_TEST_PRINT_ASSERT( e );
5249     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5250   }
5251   END_TEST;
5252 }
5253
5254 int UtcDaliAnimationAnimateToActorAnchorPointXP(void)
5255 {
5256   TestApplication application;
5257
5258   Actor actor = Actor::New();
5259   Stage::GetCurrent().Add(actor);
5260   float startValue(0.5f);
5261   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION );
5262   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_X), startValue, TEST_LOCATION );
5263
5264   // Build the animation
5265   float durationSeconds(1.0f);
5266   Animation animation = Animation::New(durationSeconds);
5267   float targetX(1.0f);
5268
5269   try
5270   {
5271     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
5272   }
5273   catch (Dali::DaliException& e)
5274   {
5275     DALI_TEST_PRINT_ASSERT( e );
5276     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5277   }
5278   END_TEST;
5279 }
5280
5281 int UtcDaliAnimationAnimateToActorAnchorPointYP(void)
5282 {
5283   TestApplication application;
5284
5285   Actor actor = Actor::New();
5286   Stage::GetCurrent().Add(actor);
5287   float startValue(0.5f);
5288   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION );
5289   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Y), startValue, TEST_LOCATION );
5290
5291   // Build the animation
5292   float durationSeconds(1.0f);
5293   Animation animation = Animation::New(durationSeconds);
5294   float targetY(0.0f);
5295
5296   try
5297   {
5298     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
5299   }
5300   catch (Dali::DaliException& e)
5301   {
5302     DALI_TEST_PRINT_ASSERT( e );
5303     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5304   }
5305   END_TEST;
5306 }
5307
5308 int UtcDaliAnimationAnimateToActorAnchorPointZP(void)
5309 {
5310   TestApplication application;
5311
5312   Actor actor = Actor::New();
5313   Stage::GetCurrent().Add(actor);
5314   float startValue(0.5f);
5315   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION );
5316   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::ANCHOR_POINT_Z), startValue, TEST_LOCATION );
5317
5318   // Build the animation
5319   float durationSeconds(1.0f);
5320   Animation animation = Animation::New(durationSeconds);
5321   float targetZ(100.0f);
5322
5323   try
5324   {
5325     animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
5326   }
5327   catch (Dali::DaliException& e)
5328   {
5329     DALI_TEST_PRINT_ASSERT( e );
5330     DALI_TEST_ASSERT(e, "IsPropertyAnimatable( index )", TEST_LOCATION);
5331   }
5332   END_TEST;
5333 }
5334
5335 int UtcDaliAnimationAnimateToActorSizeP(void)
5336 {
5337   TestApplication application;
5338
5339   Actor actor = Actor::New();
5340   Stage::GetCurrent().Add(actor);
5341   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5342
5343   // Build the animation
5344   float durationSeconds(1.0f);
5345   Animation animation = Animation::New(durationSeconds);
5346   Vector3 targetSize(100.0f, 100.0f, 100.0f);
5347   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize );
5348
5349   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
5350
5351   // Start the animation
5352   animation.Play();
5353
5354   bool signalReceived(false);
5355   AnimationFinishCheck finishCheck(signalReceived);
5356   animation.FinishedSignal().Connect(&application, finishCheck);
5357
5358   application.SendNotification();
5359   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5360
5361   // We didn't expect the animation to finish yet
5362   application.SendNotification();
5363   finishCheck.CheckSignalNotReceived();
5364   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
5365
5366   application.SendNotification();
5367   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5368
5369   // We did expect the animation to finish
5370   application.SendNotification();
5371   finishCheck.CheckSignalReceived();
5372   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5373
5374   // Reset everything
5375   finishCheck.Reset();
5376   actor.SetSize(Vector3::ZERO);
5377   application.SendNotification();
5378   application.Render(0);
5379   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5380
5381   // Repeat with a different (ease-in) alpha function
5382   animation = Animation::New(durationSeconds);
5383   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN);
5384   animation.FinishedSignal().Connect(&application, finishCheck);
5385   animation.Play();
5386
5387   application.SendNotification();
5388   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5389
5390   // We didn't expect the animation to finish yet
5391   application.SendNotification();
5392   finishCheck.CheckSignalNotReceived();
5393
5394   // The size should have travelled less, than with a linear alpha function
5395   Vector3 current(actor.GetCurrentSize());
5396   DALI_TEST_CHECK( current.x > 0.0f );
5397   DALI_TEST_CHECK( current.y > 0.0f );
5398   DALI_TEST_CHECK( current.z > 0.0f );
5399   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5400   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5401   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
5402
5403   application.SendNotification();
5404   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5405
5406   // We did expect the animation to finish
5407   application.SendNotification();
5408   finishCheck.CheckSignalReceived();
5409   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5410
5411   // Reset everything
5412   finishCheck.Reset();
5413   actor.SetSize(Vector3::ZERO);
5414   application.SendNotification();
5415   application.Render(0);
5416   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5417
5418   // Repeat with a delay
5419   float delay = 0.5f;
5420   animation = Animation::New(durationSeconds);
5421   animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
5422   animation.FinishedSignal().Connect(&application, finishCheck);
5423   animation.Play();
5424
5425   application.SendNotification();
5426   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5427
5428   // We didn't expect the animation to finish yet
5429   application.SendNotification();
5430   finishCheck.CheckSignalNotReceived();
5431   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5432
5433   application.SendNotification();
5434   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5435
5436   // We did expect the animation to finish
5437   application.SendNotification();
5438   finishCheck.CheckSignalReceived();
5439   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5440   END_TEST;
5441 }
5442
5443 int UtcDaliAnimationAnimateToActorSizeWidthP(void)
5444 {
5445   TestApplication application;
5446
5447   Actor actor = Actor::New();
5448   Stage::GetCurrent().Add(actor);
5449   float startValue(0.0f);
5450   DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION );
5451   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), startValue, TEST_LOCATION );
5452
5453   // Build the animation
5454   float durationSeconds(1.0f);
5455   Animation animation = Animation::New(durationSeconds);
5456   float targetWidth(10.0f);
5457   animation.AnimateTo( Property(actor, Actor::Property::SIZE_WIDTH), targetWidth );
5458
5459   float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f);
5460
5461   // Start the animation
5462   animation.Play();
5463
5464   bool signalReceived(false);
5465   AnimationFinishCheck finishCheck(signalReceived);
5466   animation.FinishedSignal().Connect(&application, finishCheck);
5467
5468   application.SendNotification();
5469   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5470
5471   // We didn't expect the animation to finish yet
5472   application.SendNotification();
5473   finishCheck.CheckSignalNotReceived();
5474   DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION );
5475
5476   application.SendNotification();
5477   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5478
5479   // We did expect the animation to finish
5480   application.SendNotification();
5481   finishCheck.CheckSignalReceived();
5482   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5483   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5484   END_TEST;
5485 }
5486
5487 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
5488 {
5489   TestApplication application;
5490
5491   Actor actor = Actor::New();
5492   Stage::GetCurrent().Add(actor);
5493   float startValue(0.0f);
5494   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5495   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
5496
5497   // Build the animation
5498   float durationSeconds(1.0f);
5499   Animation animation = Animation::New(durationSeconds);
5500   float targetHeight(-10.0f);
5501   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
5502
5503   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5504
5505   // Start the animation
5506   animation.Play();
5507
5508   bool signalReceived(false);
5509   AnimationFinishCheck finishCheck(signalReceived);
5510   animation.FinishedSignal().Connect(&application, finishCheck);
5511
5512   application.SendNotification();
5513   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5514
5515   // We didn't expect the animation to finish yet
5516   application.SendNotification();
5517   finishCheck.CheckSignalNotReceived();
5518   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5519
5520   application.SendNotification();
5521   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5522
5523   // We did expect the animation to finish
5524   application.SendNotification();
5525   finishCheck.CheckSignalReceived();
5526   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5527   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5528   END_TEST;
5529 }
5530
5531 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
5532 {
5533   TestApplication application;
5534
5535   Actor actor = Actor::New();
5536   Stage::GetCurrent().Add(actor);
5537   float startValue(0.0f);
5538   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5539   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
5540
5541   // Build the animation
5542   float durationSeconds(1.0f);
5543   Animation animation = Animation::New(durationSeconds);
5544   float targetDepth(-10.0f);
5545   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
5546
5547   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5548
5549   // Start the animation
5550   animation.Play();
5551
5552   bool signalReceived(false);
5553   AnimationFinishCheck finishCheck(signalReceived);
5554   animation.FinishedSignal().Connect(&application, finishCheck);
5555
5556   application.SendNotification();
5557   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5558
5559   // We didn't expect the animation to finish yet
5560   application.SendNotification();
5561   finishCheck.CheckSignalNotReceived();
5562   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5563
5564   application.SendNotification();
5565   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5566
5567   // We did expect the animation to finish
5568   application.SendNotification();
5569   finishCheck.CheckSignalReceived();
5570   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5571   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5572   END_TEST;
5573 }
5574
5575 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
5576 {
5577   TestApplication application;
5578
5579   Actor actor = Actor::New();
5580   Stage::GetCurrent().Add(actor);
5581   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5582
5583   // Build the animation
5584   float durationSeconds(1.0f);
5585   Animation animation = Animation::New(durationSeconds);
5586   Vector3 targetSize(100.0f, 100.0f, 100.0f);
5587   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
5588
5589   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
5590
5591   // Start the animation
5592   animation.Play();
5593
5594   bool signalReceived(false);
5595   AnimationFinishCheck finishCheck(signalReceived);
5596   animation.FinishedSignal().Connect(&application, finishCheck);
5597
5598   application.SendNotification();
5599   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5600
5601   // We didn't expect the animation to finish yet
5602   application.SendNotification();
5603   finishCheck.CheckSignalNotReceived();
5604   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
5605
5606   application.SendNotification();
5607   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5608
5609   // We did expect the animation to finish
5610   application.SendNotification();
5611   finishCheck.CheckSignalReceived();
5612   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5613
5614   // Reset everything
5615   finishCheck.Reset();
5616   actor.SetSize(Vector3::ZERO);
5617   application.SendNotification();
5618   application.Render(0);
5619   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5620
5621   // Repeat with a different (ease-in) alpha function
5622   animation = Animation::New(durationSeconds);
5623   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN );
5624   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN );
5625   animation.FinishedSignal().Connect(&application, finishCheck);
5626   animation.Play();
5627
5628   application.SendNotification();
5629   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5630
5631   // We didn't expect the animation to finish yet
5632   application.SendNotification();
5633   finishCheck.CheckSignalNotReceived();
5634
5635   // The size should have travelled less, than with a linear alpha function
5636   Vector3 current(actor.GetCurrentSize());
5637   DALI_TEST_CHECK( current.x > 0.0f );
5638   DALI_TEST_CHECK( current.y > 0.0f );
5639   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5640   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5641
5642   application.SendNotification();
5643   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5644
5645   // We did expect the animation to finish
5646   application.SendNotification();
5647   finishCheck.CheckSignalReceived();
5648   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
5649   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
5650
5651   // Reset everything
5652   finishCheck.Reset();
5653   actor.SetSize(Vector3::ZERO);
5654   application.SendNotification();
5655   application.Render(0);
5656   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5657
5658   // Repeat with a delay
5659   float delay = 0.5f;
5660   animation = Animation::New(durationSeconds);
5661   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
5662   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
5663   animation.FinishedSignal().Connect(&application, finishCheck);
5664   animation.Play();
5665
5666   application.SendNotification();
5667   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5668
5669   // We didn't expect the animation to finish yet
5670   application.SendNotification();
5671   finishCheck.CheckSignalNotReceived();
5672   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5673
5674   application.SendNotification();
5675   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5676
5677   // We did expect the animation to finish
5678   application.SendNotification();
5679   finishCheck.CheckSignalReceived();
5680   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
5681   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
5682   END_TEST;
5683 }
5684
5685 int UtcDaliAnimationAnimateToActorPositionP(void)
5686 {
5687   TestApplication application;
5688
5689   Actor actor = Actor::New();
5690   Stage::GetCurrent().Add(actor);
5691   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5692
5693   // Build the animation
5694   float durationSeconds(1.0f);
5695   Animation animation = Animation::New(durationSeconds);
5696   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5697   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
5698
5699   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5700
5701   // Start the animation
5702   animation.Play();
5703
5704   bool signalReceived(false);
5705   AnimationFinishCheck finishCheck(signalReceived);
5706   animation.FinishedSignal().Connect(&application, finishCheck);
5707
5708   application.SendNotification();
5709   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5710
5711   // We didn't expect the animation to finish yet
5712   application.SendNotification();
5713   finishCheck.CheckSignalNotReceived();
5714   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5715
5716   application.SendNotification();
5717   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5718
5719   // We did expect the animation to finish
5720   application.SendNotification();
5721   finishCheck.CheckSignalReceived();
5722   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5723   END_TEST;
5724 }
5725
5726 int UtcDaliAnimationAnimateToActorPositionXP(void)
5727 {
5728   TestApplication application;
5729
5730   Actor actor = Actor::New();
5731   Stage::GetCurrent().Add(actor);
5732   float startValue(0.0f);
5733   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5734   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5735   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5736   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5737
5738   // Build the animation
5739   float durationSeconds(1.0f);
5740   Animation animation = Animation::New(durationSeconds);
5741   float targetX(1.0f);
5742   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
5743
5744   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5745
5746   // Start the animation
5747   animation.Play();
5748
5749   bool signalReceived(false);
5750   AnimationFinishCheck finishCheck(signalReceived);
5751   animation.FinishedSignal().Connect(&application, finishCheck);
5752
5753   application.SendNotification();
5754   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5755
5756   // We didn't expect the animation to finish yet
5757   application.SendNotification();
5758   finishCheck.CheckSignalNotReceived();
5759   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5760
5761   application.SendNotification();
5762   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5763
5764   // We did expect the animation to finish
5765   application.SendNotification();
5766   finishCheck.CheckSignalReceived();
5767   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
5769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5771   END_TEST;
5772 }
5773
5774 int UtcDaliAnimationAnimateToActorPositionYP(void)
5775 {
5776   TestApplication application;
5777
5778   Actor actor = Actor::New();
5779   Stage::GetCurrent().Add(actor);
5780   float startValue(0.0f);
5781   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5782   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5783   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5784   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5785
5786   // Build the animation
5787   float durationSeconds(1.0f);
5788   Animation animation = Animation::New(durationSeconds);
5789   float targetY(10.0f);
5790   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
5791
5792   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5793
5794   // Start the animation
5795   animation.Play();
5796
5797   bool signalReceived(false);
5798   AnimationFinishCheck finishCheck(signalReceived);
5799   animation.FinishedSignal().Connect(&application, finishCheck);
5800
5801   application.SendNotification();
5802   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5803
5804   // We didn't expect the animation to finish yet
5805   application.SendNotification();
5806   finishCheck.CheckSignalNotReceived();
5807   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5808
5809   application.SendNotification();
5810   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5811
5812   // We did expect the animation to finish
5813   application.SendNotification();
5814   finishCheck.CheckSignalReceived();
5815   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5816   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5817   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
5818   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5819   END_TEST;
5820 }
5821
5822 int UtcDaliAnimationAnimateToActorPositionZP(void)
5823 {
5824   TestApplication application;
5825
5826   Actor actor = Actor::New();
5827   Stage::GetCurrent().Add(actor);
5828   float startValue(0.0f);
5829   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5830   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5831   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5832   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5833
5834   // Build the animation
5835   float durationSeconds(1.0f);
5836   Animation animation = Animation::New(durationSeconds);
5837   float targetZ(-5.0f);
5838   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
5839
5840   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5841
5842   // Start the animation
5843   animation.Play();
5844
5845   bool signalReceived(false);
5846   AnimationFinishCheck finishCheck(signalReceived);
5847   animation.FinishedSignal().Connect(&application, finishCheck);
5848
5849   application.SendNotification();
5850   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5851
5852   // We didn't expect the animation to finish yet
5853   application.SendNotification();
5854   finishCheck.CheckSignalNotReceived();
5855   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5856
5857   application.SendNotification();
5858   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5859
5860   // We did expect the animation to finish
5861   application.SendNotification();
5862   finishCheck.CheckSignalReceived();
5863   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5864   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5865   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5866   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
5867   END_TEST;
5868 }
5869
5870 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionP(void)
5871 {
5872   TestApplication application;
5873
5874   Actor actor = Actor::New();
5875   Stage::GetCurrent().Add(actor);
5876   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5877
5878   // Build the animation
5879   float durationSeconds(1.0f);
5880   Animation animation = Animation::New(durationSeconds);
5881   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5882   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN);
5883
5884   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5885
5886   // Start the animation
5887   animation.Play();
5888
5889   bool signalReceived(false);
5890   AnimationFinishCheck finishCheck(signalReceived);
5891   animation.FinishedSignal().Connect(&application, finishCheck);
5892
5893   application.SendNotification();
5894   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5895
5896   // We didn't expect the animation to finish yet
5897   application.SendNotification();
5898   finishCheck.CheckSignalNotReceived();
5899
5900   // The position should have moved less, than with a linear alpha function
5901   Vector3 current(actor.GetCurrentPosition());
5902   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5903   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5904   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5905   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5906   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5907   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5908
5909   application.SendNotification();
5910   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5911
5912   // We did expect the animation to finish
5913   application.SendNotification();
5914   finishCheck.CheckSignalReceived();
5915   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5916   END_TEST;
5917 }
5918
5919 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
5920 {
5921   TestApplication application;
5922
5923   Actor actor = Actor::New();
5924   Stage::GetCurrent().Add(actor);
5925   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5926
5927   // Build the animation
5928   float durationSeconds(1.0f);
5929   Animation animation = Animation::New(durationSeconds);
5930   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5931   float delay = 0.5f;
5932   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5933                        targetPosition,
5934                        TimePeriod( delay, durationSeconds - delay ) );
5935
5936   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5937
5938   // Start the animation
5939   animation.Play();
5940
5941   bool signalReceived(false);
5942   AnimationFinishCheck finishCheck(signalReceived);
5943   animation.FinishedSignal().Connect(&application, finishCheck);
5944
5945   application.SendNotification();
5946   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5947
5948   // We didn't expect the animation to finish yet
5949   application.SendNotification();
5950   finishCheck.CheckSignalNotReceived();
5951   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5952
5953   application.SendNotification();
5954   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5955
5956   // We didn't expect the animation to finish yet
5957   application.SendNotification();
5958   finishCheck.CheckSignalNotReceived();
5959   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5960
5961   application.SendNotification();
5962   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5963
5964   // We did expect the animation to finish
5965   application.SendNotification();
5966   finishCheck.CheckSignalReceived();
5967   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5968   END_TEST;
5969 }
5970
5971 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
5972 {
5973   TestApplication application;
5974
5975   Actor actor = Actor::New();
5976   Stage::GetCurrent().Add(actor);
5977   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5978
5979   // Build the animation
5980   float durationSeconds(1.0f);
5981   Animation animation = Animation::New(durationSeconds);
5982   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5983   float delay = 0.5f;
5984   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5985                        targetPosition,
5986                        AlphaFunction::LINEAR,
5987                        TimePeriod( delay, durationSeconds - delay ) );
5988
5989   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5990
5991   // Start the animation
5992   animation.Play();
5993
5994   bool signalReceived(false);
5995   AnimationFinishCheck finishCheck(signalReceived);
5996   animation.FinishedSignal().Connect(&application, finishCheck);
5997
5998   application.SendNotification();
5999   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6000
6001   // We didn't expect the animation to finish yet
6002   application.SendNotification();
6003   finishCheck.CheckSignalNotReceived();
6004   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6005
6006   application.SendNotification();
6007   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6008
6009   // We didn't expect the animation to finish yet
6010   application.SendNotification();
6011   finishCheck.CheckSignalNotReceived();
6012   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6013
6014   application.SendNotification();
6015   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6016
6017   // We did expect the animation to finish
6018   application.SendNotification();
6019   finishCheck.CheckSignalReceived();
6020   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6021   END_TEST;
6022 }
6023
6024 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
6025 {
6026   TestApplication application;
6027
6028   Actor actor = Actor::New();
6029   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6030   Stage::GetCurrent().Add(actor);
6031   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6032
6033   // Build the animation
6034   float durationSeconds(1.0f);
6035   Animation animation = Animation::New(durationSeconds);
6036   Degree targetRotationDegrees(90.0f);
6037   Radian targetRotationRadians(targetRotationDegrees);
6038   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
6039
6040   // Start the animation
6041   animation.Play();
6042
6043   bool signalReceived(false);
6044   AnimationFinishCheck finishCheck(signalReceived);
6045   animation.FinishedSignal().Connect(&application, finishCheck);
6046
6047   application.SendNotification();
6048   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6049
6050   // We didn't expect the animation to finish yet
6051   application.SendNotification();
6052   finishCheck.CheckSignalNotReceived();
6053   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6054
6055   application.SendNotification();
6056   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6057
6058   // We didn't expect the animation to finish yet
6059   application.SendNotification();
6060   finishCheck.CheckSignalNotReceived();
6061   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6062
6063   application.SendNotification();
6064   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6065
6066   // We didn't expect the animation to finish yet
6067   application.SendNotification();
6068   finishCheck.CheckSignalNotReceived();
6069   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6070
6071   application.SendNotification();
6072   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6073
6074   // We did expect the animation to finish
6075   application.SendNotification();
6076   finishCheck.CheckSignalReceived();
6077   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6078   END_TEST;
6079 }
6080
6081 int UtcDaliAnimationAnimateToActorOrientationQuaternionP(void)
6082 {
6083   TestApplication application;
6084
6085   Actor actor = Actor::New();
6086   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6087   Stage::GetCurrent().Add(actor);
6088   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6089
6090   // Build the animation
6091   float durationSeconds(1.0f);
6092   Animation animation = Animation::New(durationSeconds);
6093   Degree targetRotationDegrees(90.0f);
6094   Radian targetRotationRadians(targetRotationDegrees);
6095   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
6096   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
6097
6098   // Start the animation
6099   animation.Play();
6100
6101   bool signalReceived(false);
6102   AnimationFinishCheck finishCheck(signalReceived);
6103   animation.FinishedSignal().Connect(&application, finishCheck);
6104
6105   application.SendNotification();
6106   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6107
6108   // We didn't expect the animation to finish yet
6109   application.SendNotification();
6110   finishCheck.CheckSignalNotReceived();
6111   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6112
6113   application.SendNotification();
6114   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6115
6116   // We didn't expect the animation to finish yet
6117   application.SendNotification();
6118   finishCheck.CheckSignalNotReceived();
6119   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6120
6121   application.SendNotification();
6122   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6123
6124   // We didn't expect the animation to finish yet
6125   application.SendNotification();
6126   finishCheck.CheckSignalNotReceived();
6127   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6128
6129   application.SendNotification();
6130   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6131
6132   // We did expect the animation to finish
6133   application.SendNotification();
6134   finishCheck.CheckSignalReceived();
6135   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6136   END_TEST;
6137 }
6138
6139 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionP(void)
6140 {
6141   TestApplication application;
6142
6143   Actor actor = Actor::New();
6144   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6145   Stage::GetCurrent().Add(actor);
6146   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6147
6148   // Build the animation
6149   float durationSeconds(1.0f);
6150   Animation animation = Animation::New(durationSeconds);
6151   Degree targetRotationDegrees(90.0f);
6152   Radian targetRotationRadians(targetRotationDegrees);
6153   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN);
6154
6155   // Start the animation
6156   animation.Play();
6157
6158   bool signalReceived(false);
6159   AnimationFinishCheck finishCheck(signalReceived);
6160   animation.FinishedSignal().Connect(&application, finishCheck);
6161
6162   application.SendNotification();
6163   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6164
6165   // We didn't expect the animation to finish yet
6166   application.SendNotification();
6167   finishCheck.CheckSignalNotReceived();
6168   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6169
6170   application.SendNotification();
6171   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6172
6173   // We didn't expect the animation to finish yet
6174   application.SendNotification();
6175   finishCheck.CheckSignalNotReceived();
6176   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6177
6178   application.SendNotification();
6179   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6180
6181   // We didn't expect the animation to finish yet
6182   application.SendNotification();
6183   finishCheck.CheckSignalNotReceived();
6184   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6185
6186   application.SendNotification();
6187   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6188
6189   // We did expect the animation to finish
6190   application.SendNotification();
6191   finishCheck.CheckSignalReceived();
6192   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6193   END_TEST;
6194 }
6195
6196 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
6197 {
6198   TestApplication application;
6199
6200   Actor actor = Actor::New();
6201   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6202   Stage::GetCurrent().Add(actor);
6203   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6204
6205   // Build the animation
6206   float durationSeconds(1.0f);
6207   Animation animation = Animation::New(durationSeconds);
6208   Degree targetRotationDegrees(90.0f);
6209   Radian targetRotationRadians(targetRotationDegrees);
6210   float delay(0.1f);
6211   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
6212
6213   // Start the animation
6214   animation.Play();
6215
6216   bool signalReceived(false);
6217   AnimationFinishCheck finishCheck(signalReceived);
6218   animation.FinishedSignal().Connect(&application, finishCheck);
6219
6220   application.SendNotification();
6221   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6222
6223   // We didn't expect the animation to finish yet
6224   application.SendNotification();
6225   finishCheck.CheckSignalNotReceived();
6226   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6227   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6228
6229   application.SendNotification();
6230   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6231
6232   // We didn't expect the animation to finish yet
6233   application.SendNotification();
6234   finishCheck.CheckSignalNotReceived();
6235   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6236   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6237
6238   application.SendNotification();
6239   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6240
6241   // We didn't expect the animation to finish yet
6242   application.SendNotification();
6243   finishCheck.CheckSignalNotReceived();
6244   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6245   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6246
6247   application.SendNotification();
6248   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6249
6250   // We did expect the animation to finish
6251   application.SendNotification();
6252   finishCheck.CheckSignalReceived();
6253   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6254   END_TEST;
6255 }
6256
6257 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
6258 {
6259   TestApplication application;
6260
6261   Actor actor = Actor::New();
6262   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6263   Stage::GetCurrent().Add(actor);
6264   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6265
6266   // Build the animation
6267   float durationSeconds(1.0f);
6268   Animation animation = Animation::New(durationSeconds);
6269   Degree targetRotationDegrees(90.0f);
6270   Radian targetRotationRadians(targetRotationDegrees);
6271   float delay(0.1f);
6272   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay));
6273
6274   // Start the animation
6275   animation.Play();
6276
6277   bool signalReceived(false);
6278   AnimationFinishCheck finishCheck(signalReceived);
6279   animation.FinishedSignal().Connect(&application, finishCheck);
6280
6281   application.SendNotification();
6282   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6283
6284   // We didn't expect the animation to finish yet
6285   application.SendNotification();
6286   finishCheck.CheckSignalNotReceived();
6287   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6288   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6289
6290   application.SendNotification();
6291   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6292
6293   // We didn't expect the animation to finish yet
6294   application.SendNotification();
6295   finishCheck.CheckSignalNotReceived();
6296   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6297   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6298
6299   application.SendNotification();
6300   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6301
6302   // We didn't expect the animation to finish yet
6303   application.SendNotification();
6304   finishCheck.CheckSignalNotReceived();
6305   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6306   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6307
6308   application.SendNotification();
6309   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6310
6311   // We did expect the animation to finish
6312   application.SendNotification();
6313   finishCheck.CheckSignalReceived();
6314   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6315   END_TEST;
6316 }
6317
6318 int UtcDaliAnimationAnimateToActorScaleP(void)
6319 {
6320   TestApplication application;
6321
6322   Actor actor = Actor::New();
6323   Stage::GetCurrent().Add(actor);
6324   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6325
6326   // Build the animation
6327   float durationSeconds(1.0f);
6328   Animation animation = Animation::New(durationSeconds);
6329   Vector3 targetScale(2.0f, 2.0f, 2.0f);
6330   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
6331
6332   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
6333
6334   // Start the animation
6335   animation.Play();
6336
6337   bool signalReceived(false);
6338   AnimationFinishCheck finishCheck(signalReceived);
6339   animation.FinishedSignal().Connect(&application, finishCheck);
6340
6341   application.SendNotification();
6342   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6343
6344   // We didn't expect the animation to finish yet
6345   application.SendNotification();
6346   finishCheck.CheckSignalNotReceived();
6347   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
6348
6349   application.SendNotification();
6350   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6351
6352   // We did expect the animation to finish
6353   application.SendNotification();
6354   finishCheck.CheckSignalReceived();
6355   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6356
6357   // Reset everything
6358   finishCheck.Reset();
6359   actor.SetScale(Vector3::ONE);
6360   application.SendNotification();
6361   application.Render(0);
6362   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6363
6364   // Repeat with a different (ease-in) alpha function
6365   animation = Animation::New(durationSeconds);
6366   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN);
6367   animation.FinishedSignal().Connect(&application, finishCheck);
6368   animation.Play();
6369
6370   application.SendNotification();
6371   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6372
6373   // We didn't expect the animation to finish yet
6374   application.SendNotification();
6375   finishCheck.CheckSignalNotReceived();
6376
6377   // The scale should have grown less, than with a linear alpha function
6378   Vector3 current(actor.GetCurrentScale());
6379   DALI_TEST_CHECK( current.x > 1.0f );
6380   DALI_TEST_CHECK( current.y > 1.0f );
6381   DALI_TEST_CHECK( current.z > 1.0f );
6382   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6383   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6384   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6385
6386   application.SendNotification();
6387   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6388
6389   // We did expect the animation to finish
6390   application.SendNotification();
6391   finishCheck.CheckSignalReceived();
6392   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6393
6394   // Reset everything
6395   finishCheck.Reset();
6396   actor.SetScale(Vector3::ONE);
6397   application.SendNotification();
6398   application.Render(0);
6399   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6400
6401   // Repeat with a delay
6402   float delay = 0.5f;
6403   animation = Animation::New(durationSeconds);
6404   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay));
6405   animation.FinishedSignal().Connect(&application, finishCheck);
6406   animation.Play();
6407
6408   application.SendNotification();
6409   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6410
6411   // We didn't expect the animation to finish yet
6412   application.SendNotification();
6413   finishCheck.CheckSignalNotReceived();
6414   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6415
6416   application.SendNotification();
6417   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6418
6419   // We did expect the animation to finish
6420   application.SendNotification();
6421   finishCheck.CheckSignalReceived();
6422   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6423   END_TEST;
6424 }
6425
6426 int UtcDaliAnimationAnimateToActorScaleXP(void)
6427 {
6428   TestApplication application;
6429
6430   Actor actor = Actor::New();
6431   Stage::GetCurrent().Add(actor);
6432   float startValue(1.0f);
6433   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
6434   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6435   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6436   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6437
6438   // Build the animation
6439   float durationSeconds(1.0f);
6440   Animation animation = Animation::New(durationSeconds);
6441   float targetX(10.0f);
6442   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
6443
6444   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
6445
6446   // Start the animation
6447   animation.Play();
6448
6449   bool signalReceived(false);
6450   AnimationFinishCheck finishCheck(signalReceived);
6451   animation.FinishedSignal().Connect(&application, finishCheck);
6452
6453   application.SendNotification();
6454   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6455
6456   // We didn't expect the animation to finish yet
6457   application.SendNotification();
6458   finishCheck.CheckSignalNotReceived();
6459   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
6460   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
6461   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6462   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6463
6464   application.SendNotification();
6465   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6466
6467   // We did expect the animation to finish
6468   application.SendNotification();
6469   finishCheck.CheckSignalReceived();
6470   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
6471   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), targetX, TEST_LOCATION );
6472   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6473   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6474   END_TEST;
6475 }
6476
6477 int UtcDaliAnimationAnimateToActorScaleYP(void)
6478 {
6479   TestApplication application;
6480
6481   Actor actor = Actor::New();
6482   Stage::GetCurrent().Add(actor);
6483   float startValue(1.0f);
6484   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
6485   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6486   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6487   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6488
6489   // Build the animation
6490   float durationSeconds(1.0f);
6491   Animation animation = Animation::New(durationSeconds);
6492   float targetY(1000.0f);
6493   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
6494
6495   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6496
6497   // Start the animation
6498   animation.Play();
6499
6500   bool signalReceived(false);
6501   AnimationFinishCheck finishCheck(signalReceived);
6502   animation.FinishedSignal().Connect(&application, finishCheck);
6503
6504   application.SendNotification();
6505   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6506
6507   // We didn't expect the animation to finish yet
6508   application.SendNotification();
6509   finishCheck.CheckSignalNotReceived();
6510   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
6511   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6512   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
6513   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6514
6515   application.SendNotification();
6516   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6517
6518   // We did expect the animation to finish
6519   application.SendNotification();
6520   finishCheck.CheckSignalReceived();
6521   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
6522   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6523   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), targetY, TEST_LOCATION );
6524   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6525   END_TEST;
6526 }
6527
6528 int UtcDaliAnimationAnimateToActorScaleZP(void)
6529 {
6530   TestApplication application;
6531
6532   Actor actor = Actor::New();
6533   Stage::GetCurrent().Add(actor);
6534   float startValue(1.0f);
6535   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
6536   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6537   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6538   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6539
6540   // Build the animation
6541   float durationSeconds(1.0f);
6542   Animation animation = Animation::New(durationSeconds);
6543   float targetZ(-1000.0f);
6544   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
6545
6546   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6547
6548   // Start the animation
6549   animation.Play();
6550
6551   bool signalReceived(false);
6552   AnimationFinishCheck finishCheck(signalReceived);
6553   animation.FinishedSignal().Connect(&application, finishCheck);
6554
6555   application.SendNotification();
6556   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6557
6558   // We didn't expect the animation to finish yet
6559   application.SendNotification();
6560   finishCheck.CheckSignalNotReceived();
6561   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
6562   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6563   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6564   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
6565
6566   application.SendNotification();
6567   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6568
6569   // We did expect the animation to finish
6570   application.SendNotification();
6571   finishCheck.CheckSignalReceived();
6572   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
6573   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6574   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6575   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), targetZ, TEST_LOCATION );
6576   END_TEST;
6577 }
6578
6579 int UtcDaliAnimationAnimateToActorColorP(void)
6580 {
6581   TestApplication application;
6582
6583   Actor actor = Actor::New();
6584   Stage::GetCurrent().Add(actor);
6585   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6586
6587   // Build the animation
6588   float durationSeconds(1.0f);
6589   Animation animation = Animation::New(durationSeconds);
6590   Vector4 targetColor(Color::RED);
6591   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
6592
6593   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6594   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6595
6596   // Start the animation
6597   animation.Play();
6598
6599   bool signalReceived(false);
6600   AnimationFinishCheck finishCheck(signalReceived);
6601   animation.FinishedSignal().Connect(&application, finishCheck);
6602
6603   application.SendNotification();
6604   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6605
6606   // We didn't expect the animation to finish yet
6607   application.SendNotification();
6608   finishCheck.CheckSignalNotReceived();
6609   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6610
6611   application.SendNotification();
6612   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6613
6614   // We did expect the animation to finish
6615   application.SendNotification();
6616   finishCheck.CheckSignalReceived();
6617   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6618
6619   // Reset everything
6620   finishCheck.Reset();
6621   actor.SetColor(Color::WHITE);
6622   application.SendNotification();
6623   application.Render(0);
6624   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6625
6626   // Repeat with a different (ease-in) alpha function
6627   animation = Animation::New(durationSeconds);
6628   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN);
6629   animation.FinishedSignal().Connect(&application, finishCheck);
6630   animation.Play();
6631
6632   application.SendNotification();
6633   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6634
6635   // We didn't expect the animation to finish yet
6636   application.SendNotification();
6637   finishCheck.CheckSignalNotReceived();
6638
6639   // The color should have changed less, than with a linear alpha function
6640   Vector4 current(actor.GetCurrentColor());
6641   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6642   DALI_TEST_CHECK( current.y < 1.0f );
6643   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6644   DALI_TEST_CHECK( current.z  < 1.0f );
6645   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
6646   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6647
6648   application.SendNotification();
6649   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6650
6651   // We did expect the animation to finish
6652   application.SendNotification();
6653   finishCheck.CheckSignalReceived();
6654   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6655
6656   // Reset everything
6657   finishCheck.Reset();
6658   actor.SetColor(Color::WHITE);
6659   application.SendNotification();
6660   application.Render(0);
6661   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6662
6663   // Repeat with a shorter animator duration
6664   float animatorDuration = 0.5f;
6665   animation = Animation::New(durationSeconds);
6666   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration));
6667   animation.FinishedSignal().Connect(&application, finishCheck);
6668   animation.Play();
6669
6670   application.SendNotification();
6671   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6672
6673   // We didn't expect the animation to finish yet
6674   application.SendNotification();
6675   finishCheck.CheckSignalNotReceived();
6676   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6677
6678   application.SendNotification();
6679   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6680
6681   // We didn't expect the animation to finish yet
6682   application.SendNotification();
6683   finishCheck.CheckSignalNotReceived();
6684   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6685
6686   application.SendNotification();
6687   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6688
6689   // We did expect the animation to finish
6690   application.SendNotification();
6691   finishCheck.CheckSignalReceived();
6692   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6693   END_TEST;
6694 }
6695
6696 int UtcDaliAnimationAnimateToActorColorRedP(void)
6697 {
6698   TestApplication application;
6699
6700   Actor actor = Actor::New();
6701   Stage::GetCurrent().Add(actor);
6702   float startValue(1.0f);
6703   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6704   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6705   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6706   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6707   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6708
6709   // Build the animation
6710   float durationSeconds(1.0f);
6711   Animation animation = Animation::New(durationSeconds);
6712   float targetRed(0.5f);
6713   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
6714
6715   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6716
6717   // Start the animation
6718   animation.Play();
6719
6720   bool signalReceived(false);
6721   AnimationFinishCheck finishCheck(signalReceived);
6722   animation.FinishedSignal().Connect(&application, finishCheck);
6723
6724   application.SendNotification();
6725   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6726
6727   // We didn't expect the animation to finish yet
6728   application.SendNotification();
6729   finishCheck.CheckSignalNotReceived();
6730   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6731   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   fiftyPercentProgress, TEST_LOCATION );
6732   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
6733   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
6734   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
6735
6736   application.SendNotification();
6737   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6738
6739   // We did expect the animation to finish
6740   application.SendNotification();
6741   finishCheck.CheckSignalReceived();
6742   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6743   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
6744   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6745   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6746   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6747   END_TEST;
6748 }
6749
6750 int UtcDaliAnimationAnimateToActorColorGreenP(void)
6751 {
6752   TestApplication application;
6753
6754   Actor actor = Actor::New();
6755   Stage::GetCurrent().Add(actor);
6756   float startValue(1.0f);
6757   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6758   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6759   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6760   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6761   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6762
6763   // Build the animation
6764   float durationSeconds(1.0f);
6765   Animation animation = Animation::New(durationSeconds);
6766   float targetGreen(0.5f);
6767   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
6768
6769   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6770
6771   // Start the animation
6772   animation.Play();
6773
6774   bool signalReceived(false);
6775   AnimationFinishCheck finishCheck(signalReceived);
6776   animation.FinishedSignal().Connect(&application, finishCheck);
6777
6778   application.SendNotification();
6779   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6780
6781   // We didn't expect the animation to finish yet
6782   application.SendNotification();
6783   finishCheck.CheckSignalNotReceived();
6784   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION );
6785   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
6786   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION );
6787   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
6788   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
6789
6790   application.SendNotification();
6791   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6792
6793   // We did expect the animation to finish
6794   application.SendNotification();
6795   finishCheck.CheckSignalReceived();
6796   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6797   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
6798   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
6799   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
6800   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
6801   END_TEST;
6802 }
6803
6804 int UtcDaliAnimationAnimateToActorColorBlueP(void)
6805 {
6806   TestApplication application;
6807
6808   Actor actor = Actor::New();
6809   Stage::GetCurrent().Add(actor);
6810   float startValue(1.0f);
6811   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6812   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6813   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6814   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6816
6817   // Build the animation
6818   float durationSeconds(1.0f);
6819   Animation animation = Animation::New(durationSeconds);
6820   float targetBlue(0.5f);
6821   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
6822
6823   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
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*500.0f)/* 50% progress */);
6834
6835   // We didn't expect the animation to finish yet
6836   application.SendNotification();
6837   finishCheck.CheckSignalNotReceived();
6838   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION );
6839   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
6840   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
6841   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  fiftyPercentProgress, TEST_LOCATION );
6842   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
6843
6844   application.SendNotification();
6845   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6846
6847   // We did expect the animation to finish
6848   application.SendNotification();
6849   finishCheck.CheckSignalReceived();
6850   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6851   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6852   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6853   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  targetBlue, TEST_LOCATION );
6854   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6855   END_TEST;
6856 }
6857
6858 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
6859 {
6860   TestApplication application;
6861
6862   Actor actor = Actor::New();
6863   Stage::GetCurrent().Add(actor);
6864   float startValue(1.0f);
6865   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6866   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6867   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6868   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6869   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6870
6871   // Build the animation
6872   float durationSeconds(1.0f);
6873   Animation animation = Animation::New(durationSeconds);
6874   float targetAlpha(0.5f);
6875   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
6876
6877   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6878
6879   // Start the animation
6880   animation.Play();
6881
6882   bool signalReceived(false);
6883   AnimationFinishCheck finishCheck(signalReceived);
6884   animation.FinishedSignal().Connect(&application, finishCheck);
6885
6886   application.SendNotification();
6887   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6888
6889   // We didn't expect the animation to finish yet
6890   application.SendNotification();
6891   finishCheck.CheckSignalNotReceived();
6892   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION );
6893   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,           TEST_LOCATION );
6894   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,           TEST_LOCATION );
6895   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,           TEST_LOCATION );
6896   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION );
6897
6898   application.SendNotification();
6899   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6900
6901   // We did expect the animation to finish
6902   application.SendNotification();
6903   finishCheck.CheckSignalReceived();
6904   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6905   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
6906   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,  TEST_LOCATION );
6907   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
6908   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6909   END_TEST;
6910 }
6911
6912 int UtcDaliAnimationKeyFrames01P(void)
6913 {
6914   TestApplication application;
6915
6916   KeyFrames keyFrames = KeyFrames::New();
6917   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6918
6919   keyFrames.Add(0.0f, 0.1f);
6920
6921   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6922
6923   KeyFrames keyFrames2( keyFrames);
6924   DALI_TEST_CHECK( keyFrames2 );
6925   DALI_TEST_EQUALS(keyFrames2.GetType(), Property::FLOAT, TEST_LOCATION);
6926
6927   KeyFrames keyFrames3 = KeyFrames::New();
6928   keyFrames3.Add(0.6f, true);
6929   DALI_TEST_CHECK( keyFrames3 );
6930   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::BOOLEAN, TEST_LOCATION);
6931
6932   keyFrames3 = keyFrames;
6933   DALI_TEST_CHECK( keyFrames3 );
6934   DALI_TEST_EQUALS(keyFrames3.GetType(), Property::FLOAT, TEST_LOCATION);
6935
6936   END_TEST;
6937 }
6938
6939 int UtcDaliAnimationKeyFrames02P(void)
6940 {
6941   TestApplication application;
6942
6943   KeyFrames keyFrames = KeyFrames::New();
6944   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6945
6946   keyFrames.Add(0.0f, 0.1f);
6947   keyFrames.Add(0.2f, 0.5f);
6948   keyFrames.Add(0.4f, 0.0f);
6949   keyFrames.Add(0.6f, 1.0f);
6950   keyFrames.Add(0.8f, 0.7f);
6951   keyFrames.Add(1.0f, 0.9f);
6952
6953   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6954
6955   try
6956   {
6957     keyFrames.Add(1.9f, false);
6958   }
6959   catch (Dali::DaliException& e)
6960   {
6961     DALI_TEST_PRINT_ASSERT( e );
6962     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6963   }
6964   END_TEST;
6965 }
6966
6967 int UtcDaliAnimationKeyFrames03P(void)
6968 {
6969   TestApplication application;
6970
6971   KeyFrames keyFrames = KeyFrames::New();
6972   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6973
6974   keyFrames.Add(0.0f, true);
6975   keyFrames.Add(0.2f, false);
6976   keyFrames.Add(0.4f, false);
6977   keyFrames.Add(0.6f, true);
6978   keyFrames.Add(0.8f, true);
6979   keyFrames.Add(1.0f, false);
6980
6981   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6982
6983   try
6984   {
6985     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6986   }
6987   catch (Dali::DaliException& e)
6988   {
6989     DALI_TEST_PRINT_ASSERT( e );
6990     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6991   }
6992   END_TEST;
6993 }
6994
6995 int UtcDaliAnimationKeyFrames04P(void)
6996 {
6997   TestApplication application;
6998
6999   KeyFrames keyFrames = KeyFrames::New();
7000   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7001
7002   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
7003   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
7004   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
7005   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
7006   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
7007   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
7008
7009   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
7010
7011   try
7012   {
7013     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
7014   }
7015   catch (Dali::DaliException& e)
7016   {
7017     DALI_TEST_PRINT_ASSERT( e );
7018     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7019   }
7020   END_TEST;
7021 }
7022
7023 int UtcDaliAnimationKeyFrames05P(void)
7024 {
7025   TestApplication application;
7026
7027   KeyFrames keyFrames = KeyFrames::New();
7028   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7029
7030   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
7031   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
7032   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
7033   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
7034   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
7035   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
7036
7037   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
7038
7039   try
7040   {
7041     keyFrames.Add(0.7f, 1.0f);
7042   }
7043   catch (Dali::DaliException& e)
7044   {
7045     DALI_TEST_PRINT_ASSERT( e );
7046     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7047   }
7048   END_TEST;
7049 }
7050
7051 int UtcDaliAnimationKeyFrames06P(void)
7052 {
7053   TestApplication application;
7054
7055   KeyFrames keyFrames = KeyFrames::New();
7056   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7057
7058   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
7059   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7060   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
7061   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
7062   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
7063   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
7064
7065   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
7066
7067   try
7068   {
7069     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
7070   }
7071   catch (Dali::DaliException& e)
7072   {
7073     DALI_TEST_PRINT_ASSERT( e );
7074     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7075   }
7076   END_TEST;
7077 }
7078
7079 int UtcDaliAnimationKeyFrames07P(void)
7080 {
7081   TestApplication application;
7082
7083   KeyFrames keyFrames = KeyFrames::New();
7084   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7085
7086   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
7087   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
7088   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
7089   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
7090   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
7091   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
7092
7093   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
7094
7095   try
7096   {
7097     keyFrames.Add(0.7f, 1.1f);
7098   }
7099   catch (Dali::DaliException& e)
7100   {
7101     DALI_TEST_PRINT_ASSERT( e );
7102     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7103   }
7104   END_TEST;
7105 }
7106
7107 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
7108 {
7109   TestApplication application;
7110
7111   float startValue(1.0f);
7112   Actor actor = Actor::New();
7113   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7114   Stage::GetCurrent().Add(actor);
7115
7116   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7117   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7118   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7119   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7120   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7121
7122   // Build the animation
7123   float durationSeconds(1.0f);
7124   Animation animation = Animation::New(durationSeconds);
7125
7126   KeyFrames keyFrames = KeyFrames::New();
7127   keyFrames.Add(0.0f, 0.1f);
7128   keyFrames.Add(0.2f, 0.5f);
7129   keyFrames.Add(0.4f, 0.0f);
7130   keyFrames.Add(0.6f, 1.0f);
7131   keyFrames.Add(0.8f, 0.7f);
7132   keyFrames.Add(1.0f, 0.9f);
7133
7134   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
7135
7136   // Start the animation
7137   animation.Play();
7138
7139   bool signalReceived(false);
7140   AnimationFinishCheck finishCheck(signalReceived);
7141   animation.FinishedSignal().Connect(&application, finishCheck);
7142   application.SendNotification();
7143   application.Render(0);
7144   application.SendNotification();
7145   finishCheck.CheckSignalNotReceived();
7146   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
7147
7148   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7149   application.SendNotification();
7150   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7151   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7152   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7153   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
7154   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
7155
7156   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
7157   application.SendNotification();
7158   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7159   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7160   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7161   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
7162   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
7163
7164   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
7165   application.SendNotification();
7166   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7167   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7168   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7169   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
7170   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
7171
7172   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
7173   application.SendNotification();
7174   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7175   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7176   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7177   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
7178   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
7179
7180   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
7181   application.SendNotification();
7182   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7183   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7184   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7185   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
7186   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
7187
7188   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
7189   application.SendNotification();
7190   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7191   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7192   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7193   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
7194   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
7195
7196   // We did expect the animation to finish
7197
7198   finishCheck.CheckSignalReceived();
7199   END_TEST;
7200 }
7201
7202 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
7203 {
7204   TestApplication application;
7205
7206   float startValue(1.0f);
7207   Actor actor = Actor::New();
7208   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7209   Stage::GetCurrent().Add(actor);
7210
7211   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7212   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7213   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7214   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7215   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7216
7217   // Build the animation
7218   float durationSeconds(1.0f);
7219   Animation animation = Animation::New(durationSeconds);
7220
7221   KeyFrames keyFrames = KeyFrames::New();
7222   keyFrames.Add(0.0f, 0.1f);
7223   keyFrames.Add(0.2f, 0.5f);
7224   keyFrames.Add(0.4f, 0.0f);
7225   keyFrames.Add(0.6f, 1.0f);
7226   keyFrames.Add(0.8f, 0.7f);
7227   keyFrames.Add(1.0f, 0.9f);
7228
7229   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
7230
7231   // Start the animation
7232   animation.Play();
7233
7234   bool signalReceived(false);
7235   AnimationFinishCheck finishCheck(signalReceived);
7236   animation.FinishedSignal().Connect(&application, finishCheck);
7237   application.SendNotification();
7238   application.Render(0);
7239   application.SendNotification();
7240   finishCheck.CheckSignalNotReceived();
7241   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
7242
7243   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7244   application.SendNotification();
7245   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7246   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7247   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7248   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION );
7249   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
7250
7251   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
7252   application.SendNotification();
7253   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7254   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7255   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7256   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION );
7257   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
7258
7259   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
7260   application.SendNotification();
7261   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7262   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7263   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7264   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
7265   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
7266
7267   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
7268   application.SendNotification();
7269   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7270   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7271   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7272   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
7273   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
7274
7275   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
7276   application.SendNotification();
7277   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7278   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7279   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7280   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION );
7281   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
7282
7283   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
7284   application.SendNotification();
7285   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7286   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7287   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7288   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
7289   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
7290
7291   // We did expect the animation to finish
7292
7293   finishCheck.CheckSignalReceived();
7294   END_TEST;
7295 }
7296
7297 int UtcDaliAnimationAnimateBetweenActorColorP(void)
7298 {
7299   TestApplication application;
7300
7301   float startValue(1.0f);
7302   Actor actor = Actor::New();
7303   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7304   Stage::GetCurrent().Add(actor);
7305
7306   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7307   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7308   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7309   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7310   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7311
7312   // Build the animation
7313   float durationSeconds(1.0f);
7314   Animation animation = Animation::New(durationSeconds);
7315
7316   KeyFrames keyFrames = KeyFrames::New();
7317   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7318   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7319   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7320
7321   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
7322
7323   // Start the animation
7324   animation.Play();
7325
7326   bool signalReceived(false);
7327   AnimationFinishCheck finishCheck(signalReceived);
7328   animation.FinishedSignal().Connect(&application, finishCheck);
7329   application.SendNotification();
7330   application.Render(0);
7331   application.SendNotification();
7332   finishCheck.CheckSignalNotReceived();
7333   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7334   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7335   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7336   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7337
7338   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7339   application.SendNotification();
7340   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7341   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7342   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7343   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7344
7345   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7346   application.SendNotification();
7347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7349   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7350   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7351
7352   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7353   application.SendNotification();
7354   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7355   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7356   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7357   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7358
7359   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7360   application.SendNotification();
7361   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7362   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7363   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7364   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7365
7366   // We did expect the animation to finish
7367
7368   finishCheck.CheckSignalReceived();
7369   END_TEST;
7370 }
7371
7372 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
7373 {
7374   TestApplication application;
7375
7376   float startValue(1.0f);
7377   Actor actor = Actor::New();
7378   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7379   Stage::GetCurrent().Add(actor);
7380
7381   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7382   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7383   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7384   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7385   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7386
7387   // Build the animation
7388   float durationSeconds(1.0f);
7389   Animation animation = Animation::New(durationSeconds);
7390
7391   KeyFrames keyFrames = KeyFrames::New();
7392   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7393   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7394   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7395
7396   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
7397
7398   // Start the animation
7399   animation.Play();
7400
7401   bool signalReceived(false);
7402   AnimationFinishCheck finishCheck(signalReceived);
7403   animation.FinishedSignal().Connect(&application, finishCheck);
7404   application.SendNotification();
7405   application.Render(0);
7406   application.SendNotification();
7407   finishCheck.CheckSignalNotReceived();
7408   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7409   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7410   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7411   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7412
7413   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7414   application.SendNotification();
7415   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
7416   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
7417   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
7418   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
7419
7420   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7421   application.SendNotification();
7422   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7423   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7424   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7425   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7426
7427   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7428   application.SendNotification();
7429   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
7430   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
7431   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
7432   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
7433
7434   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7435   application.SendNotification();
7436   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7437   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7438   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7439   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7440
7441   // We did expect the animation to finish
7442
7443   finishCheck.CheckSignalReceived();
7444   END_TEST;
7445 }
7446
7447 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
7448 {
7449   TestApplication application;
7450
7451   Actor actor = Actor::New();
7452   AngleAxis aa(Degree(90), Vector3::XAXIS);
7453   actor.SetOrientation(aa.angle, aa.axis);
7454   Stage::GetCurrent().Add(actor);
7455
7456   application.SendNotification();
7457   application.Render(0);
7458
7459   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
7460
7461   // Build the animation
7462   float durationSeconds(1.0f);
7463   Animation animation = Animation::New(durationSeconds);
7464
7465   KeyFrames keyFrames = KeyFrames::New();
7466   keyFrames.Add(0.0f, false);
7467   keyFrames.Add(0.2f, true);
7468   keyFrames.Add(0.4f, true);
7469   keyFrames.Add(0.8f, false);
7470   keyFrames.Add(1.0f, true);
7471
7472   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
7473
7474   // Start the animation
7475   animation.Play();
7476
7477   bool signalReceived(false);
7478   AnimationFinishCheck finishCheck(signalReceived);
7479   animation.FinishedSignal().Connect(&application, finishCheck);
7480   application.SendNotification();
7481   application.SendNotification();
7482   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7483   application.SendNotification();
7484   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7485   application.SendNotification();
7486
7487   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
7488   finishCheck.CheckSignalReceived();
7489   END_TEST;
7490 }
7491
7492 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
7493 {
7494   TestApplication application;
7495
7496   Actor actor = Actor::New();
7497   AngleAxis aa(Degree(90), Vector3::XAXIS);
7498   actor.SetOrientation(aa.angle, aa.axis);
7499   Stage::GetCurrent().Add(actor);
7500
7501   application.SendNotification();
7502   application.Render(0);
7503
7504   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
7505
7506   // Build the animation
7507   float durationSeconds(1.0f);
7508   Animation animation = Animation::New(durationSeconds);
7509
7510   KeyFrames keyFrames = KeyFrames::New();
7511   keyFrames.Add(0.0f, false);
7512   keyFrames.Add(0.2f, true);
7513   keyFrames.Add(0.4f, true);
7514   keyFrames.Add(0.8f, false);
7515   keyFrames.Add(1.0f, true);
7516
7517   //Cubic interpolation for boolean values should be ignored
7518   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
7519
7520   // Start the animation
7521   animation.Play();
7522
7523   bool signalReceived(false);
7524   AnimationFinishCheck finishCheck(signalReceived);
7525   animation.FinishedSignal().Connect(&application, finishCheck);
7526   application.SendNotification();
7527   application.SendNotification();
7528   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7529   application.SendNotification();
7530   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7531   application.SendNotification();
7532
7533   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
7534   finishCheck.CheckSignalReceived();
7535   END_TEST;
7536 }
7537
7538 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
7539 {
7540   TestApplication application;
7541
7542   Actor actor = Actor::New();
7543   AngleAxis aa(Degree(90), Vector3::XAXIS);
7544   actor.SetOrientation(aa.angle, aa.axis);
7545   Stage::GetCurrent().Add(actor);
7546
7547   application.SendNotification();
7548   application.Render(0);
7549   Quaternion start(Radian(aa.angle), aa.axis);
7550   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7551
7552   // Build the animation
7553   float durationSeconds(1.0f);
7554   Animation animation = Animation::New(durationSeconds);
7555
7556   KeyFrames keyFrames = KeyFrames::New();
7557   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
7558
7559   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
7560
7561   // Start the animation
7562   animation.Play();
7563
7564   bool signalReceived(false);
7565   AnimationFinishCheck finishCheck(signalReceived);
7566   animation.FinishedSignal().Connect(&application, finishCheck);
7567   application.SendNotification();
7568   application.SendNotification();
7569   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7570   application.SendNotification();
7571   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7572   application.SendNotification();
7573
7574   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
7575
7576   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7577   finishCheck.CheckSignalReceived();
7578   END_TEST;
7579 }
7580
7581 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
7582 {
7583   TestApplication application;
7584
7585   Actor actor = Actor::New();
7586   AngleAxis aa(Degree(90), Vector3::XAXIS);
7587   actor.SetOrientation(aa.angle, aa.axis);
7588   application.SendNotification();
7589   application.Render(0);
7590   Stage::GetCurrent().Add(actor);
7591
7592   Quaternion start(Radian(aa.angle), aa.axis);
7593   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7594
7595   // Build the animation
7596   float durationSeconds(1.0f);
7597   Animation animation = Animation::New(durationSeconds);
7598
7599   KeyFrames keyFrames = KeyFrames::New();
7600   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
7601   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
7602   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
7603
7604   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
7605
7606   // Start the animation
7607   animation.Play();
7608
7609   bool signalReceived(false);
7610   AnimationFinishCheck finishCheck(signalReceived);
7611   animation.FinishedSignal().Connect(&application, finishCheck);
7612   application.SendNotification();
7613   application.Render(0);
7614   application.SendNotification();
7615   finishCheck.CheckSignalNotReceived();
7616
7617   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7618   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7619
7620   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7621   application.SendNotification();
7622   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
7623   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7624
7625   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7626   application.SendNotification();
7627   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
7628   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7629
7630   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7631   application.SendNotification();
7632   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
7633   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7634
7635   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7636   application.SendNotification();
7637   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
7638   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7639
7640   // We did expect the animation to finish
7641
7642   finishCheck.CheckSignalReceived();
7643   END_TEST;
7644 }
7645
7646 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
7647 {
7648   TestApplication application;
7649
7650   Actor actor = Actor::New();
7651   AngleAxis aa(Degree(90), Vector3::XAXIS);
7652   actor.SetOrientation(aa.angle, aa.axis);
7653   Stage::GetCurrent().Add(actor);
7654
7655   application.SendNotification();
7656   application.Render(0);
7657   Quaternion start(Radian(aa.angle), aa.axis);
7658   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7659
7660   // Build the animation
7661   float durationSeconds(1.0f);
7662   Animation animation = Animation::New(durationSeconds);
7663
7664   KeyFrames keyFrames = KeyFrames::New();
7665   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
7666
7667   //Cubic interpolation should be ignored for quaternions
7668   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7669
7670   // Start the animation
7671   animation.Play();
7672
7673   bool signalReceived(false);
7674   AnimationFinishCheck finishCheck(signalReceived);
7675   animation.FinishedSignal().Connect(&application, finishCheck);
7676   application.SendNotification();
7677   application.SendNotification();
7678   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7679   application.SendNotification();
7680   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7681   application.SendNotification();
7682
7683   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
7684
7685   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7686   finishCheck.CheckSignalReceived();
7687   END_TEST;
7688 }
7689
7690 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
7691 {
7692   TestApplication application;
7693
7694   Actor actor = Actor::New();
7695   AngleAxis aa(Degree(90), Vector3::XAXIS);
7696   actor.SetOrientation(aa.angle, aa.axis);
7697   application.SendNotification();
7698   application.Render(0);
7699   Stage::GetCurrent().Add(actor);
7700
7701   Quaternion start(Radian(aa.angle), aa.axis);
7702   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7703
7704   // Build the animation
7705   float durationSeconds(1.0f);
7706   Animation animation = Animation::New(durationSeconds);
7707
7708   KeyFrames keyFrames = KeyFrames::New();
7709   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
7710   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
7711   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
7712
7713   //Cubic interpolation should be ignored for quaternions
7714   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7715
7716   // Start the animation
7717   animation.Play();
7718
7719   bool signalReceived(false);
7720   AnimationFinishCheck finishCheck(signalReceived);
7721   animation.FinishedSignal().Connect(&application, finishCheck);
7722   application.SendNotification();
7723   application.Render(0);
7724   application.SendNotification();
7725   finishCheck.CheckSignalNotReceived();
7726
7727   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7728   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7729
7730   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7731   application.SendNotification();
7732   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
7733   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7734
7735   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7736   application.SendNotification();
7737   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
7738   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7739
7740   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7741   application.SendNotification();
7742   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
7743   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7744
7745   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7746   application.SendNotification();
7747   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
7748   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7749
7750   // We did expect the animation to finish
7751
7752   finishCheck.CheckSignalReceived();
7753   END_TEST;
7754 }
7755
7756 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionP(void)
7757 {
7758   TestApplication application;
7759
7760   float startValue(1.0f);
7761   Actor actor = Actor::New();
7762   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7763   Stage::GetCurrent().Add(actor);
7764
7765   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7766   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7767   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7768   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7769   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7770
7771   // Build the animation
7772   float durationSeconds(1.0f);
7773   Animation animation = Animation::New(durationSeconds);
7774
7775   KeyFrames keyFrames = KeyFrames::New();
7776   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7777   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7778   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7779
7780   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR );
7781
7782   // Start the animation
7783   animation.Play();
7784
7785   bool signalReceived(false);
7786   AnimationFinishCheck finishCheck(signalReceived);
7787   animation.FinishedSignal().Connect(&application, finishCheck);
7788   application.SendNotification();
7789   application.Render(0);
7790   application.SendNotification();
7791   finishCheck.CheckSignalNotReceived();
7792   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7793   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7794   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7795   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7796
7797   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7798   application.SendNotification();
7799   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7800   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7801   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7802   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7803
7804   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7805   application.SendNotification();
7806   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7807   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7808   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7809   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7810
7811   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7812   application.SendNotification();
7813   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7814   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7816   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7817
7818   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7819   application.SendNotification();
7820   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7821   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7822   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7823   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7824
7825   // We did expect the animation to finish
7826
7827   finishCheck.CheckSignalReceived();
7828   END_TEST;
7829 }
7830
7831 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
7832 {
7833   TestApplication application;
7834
7835   float startValue(1.0f);
7836   Actor actor = Actor::New();
7837   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7838   Stage::GetCurrent().Add(actor);
7839
7840   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7841   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7842   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7843   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7844   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7845
7846   // Build the animation
7847   float durationSeconds(1.0f);
7848   Animation animation = Animation::New(durationSeconds);
7849
7850   KeyFrames keyFrames = KeyFrames::New();
7851   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7852   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7853   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7854
7855   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic );
7856
7857   // Start the animation
7858   animation.Play();
7859
7860   bool signalReceived(false);
7861   AnimationFinishCheck finishCheck(signalReceived);
7862   animation.FinishedSignal().Connect(&application, finishCheck);
7863   application.SendNotification();
7864   application.Render(0);
7865   application.SendNotification();
7866   finishCheck.CheckSignalNotReceived();
7867   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7868   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7869   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7870   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7871
7872   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7873   application.SendNotification();
7874   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
7875   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
7876   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
7877   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
7878
7879   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7880   application.SendNotification();
7881   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7882   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7883   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7884   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7885
7886   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7887   application.SendNotification();
7888   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
7889   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
7890   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
7891   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
7892
7893   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7894   application.SendNotification();
7895   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7896   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7897   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7898   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7899
7900   // We did expect the animation to finish
7901
7902   finishCheck.CheckSignalReceived();
7903   END_TEST;
7904 }
7905
7906 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
7907 {
7908   TestApplication application;
7909
7910   float startValue(1.0f);
7911   Actor actor = Actor::New();
7912   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7913   Stage::GetCurrent().Add(actor);
7914
7915   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7916   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7917   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7918   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7920
7921   // Build the animation
7922   float durationSeconds(1.0f);
7923   float delay = 0.5f;
7924   Animation animation = Animation::New(durationSeconds);
7925
7926   KeyFrames keyFrames = KeyFrames::New();
7927   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7928   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7929   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7930
7931   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
7932
7933   // Start the animation
7934   animation.Play();
7935
7936   bool signalReceived(false);
7937   AnimationFinishCheck finishCheck(signalReceived);
7938   animation.FinishedSignal().Connect(&application, finishCheck);
7939   application.SendNotification();
7940
7941   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
7942   application.SendNotification();
7943   finishCheck.CheckSignalNotReceived();
7944   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7945   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7946   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7947   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7948
7949   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
7950   application.SendNotification();
7951   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7952   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7953   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7954   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7955
7956   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
7957   application.SendNotification();
7958   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7960   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7961   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7962
7963   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
7964   application.SendNotification();
7965   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7966   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7967   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7968   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7969
7970   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
7971   application.SendNotification();
7972   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7973   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7974   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7975   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7976
7977   // We did expect the animation to finish
7978
7979   finishCheck.CheckSignalReceived();
7980   END_TEST;
7981 }
7982
7983 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
7984 {
7985   TestApplication application;
7986
7987   float startValue(1.0f);
7988   Actor actor = Actor::New();
7989   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7990   Stage::GetCurrent().Add(actor);
7991
7992   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7993   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7994   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7995   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7996   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7997
7998   // Build the animation
7999   float durationSeconds(1.0f);
8000   float delay = 0.5f;
8001   Animation animation = Animation::New(durationSeconds);
8002
8003   KeyFrames keyFrames = KeyFrames::New();
8004   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8005   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8006   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8007
8008   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
8009
8010   // Start the animation
8011   animation.Play();
8012
8013   bool signalReceived(false);
8014   AnimationFinishCheck finishCheck(signalReceived);
8015   animation.FinishedSignal().Connect(&application, finishCheck);
8016   application.SendNotification();
8017
8018   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8019   application.SendNotification();
8020   finishCheck.CheckSignalNotReceived();
8021   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8022   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8023   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8024   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8025
8026   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8027   application.SendNotification();
8028   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8029   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8030   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8031   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8032
8033   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8034   application.SendNotification();
8035   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8036   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8037   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8038   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8039
8040   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8041   application.SendNotification();
8042   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
8043   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
8044   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
8045   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
8046
8047   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8048   application.SendNotification();
8049   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8050   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8051   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8052   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8053
8054   // We did expect the animation to finish
8055
8056   finishCheck.CheckSignalReceived();
8057   END_TEST;
8058 }
8059
8060 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
8061 {
8062   TestApplication application;
8063
8064   float startValue(1.0f);
8065   float delay = 0.5f;
8066   Actor actor = Actor::New();
8067   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8068   Stage::GetCurrent().Add(actor);
8069
8070   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8071   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8072   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8073   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8074   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8075
8076   // Build the animation
8077   float durationSeconds(1.0f);
8078   Animation animation = Animation::New(durationSeconds);
8079
8080   KeyFrames keyFrames = KeyFrames::New();
8081   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8082   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8083   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8084
8085   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) );
8086
8087   // Start the animation
8088   animation.Play();
8089
8090   bool signalReceived(false);
8091   AnimationFinishCheck finishCheck(signalReceived);
8092   animation.FinishedSignal().Connect(&application, finishCheck);
8093   application.SendNotification();
8094
8095   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8096   application.SendNotification();
8097   finishCheck.CheckSignalNotReceived();
8098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8099   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8100   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8101   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8102
8103   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8104   application.SendNotification();
8105   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
8106   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8107   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
8108   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8109
8110   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8111   application.SendNotification();
8112   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8113   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8114   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8115   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8116
8117   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8118   application.SendNotification();
8119   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
8120   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8121   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
8122   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8123
8124   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8125   application.SendNotification();
8126   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8127   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8128   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8129   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8130
8131   // We did expect the animation to finish
8132
8133   finishCheck.CheckSignalReceived();
8134   END_TEST;
8135 }
8136
8137 int UtcDaliAnimationAnimateBetweenActorColorCubicWithDelayP(void)
8138 {
8139   TestApplication application;
8140
8141   float startValue(1.0f);
8142   Actor actor = Actor::New();
8143   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8144   Stage::GetCurrent().Add(actor);
8145
8146   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8147   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8148   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8149   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8150   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8151
8152   // Build the animation
8153   float durationSeconds(1.0f);
8154   float delay = 0.5f;
8155   Animation animation = Animation::New(durationSeconds);
8156
8157   KeyFrames keyFrames = KeyFrames::New();
8158   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8159   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8160   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8161
8162   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
8163
8164   // Start the animation
8165   animation.Play();
8166
8167   bool signalReceived(false);
8168   AnimationFinishCheck finishCheck(signalReceived);
8169   animation.FinishedSignal().Connect(&application, finishCheck);
8170   application.SendNotification();
8171
8172   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8173   application.SendNotification();
8174   finishCheck.CheckSignalNotReceived();
8175   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8176   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8177   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8178   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8179
8180   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8181   application.SendNotification();
8182   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8183   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8184   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8185   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8186
8187   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8188   application.SendNotification();
8189   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8190   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8191   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8192   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8193
8194   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8195   application.SendNotification();
8196   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
8197   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
8198   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
8199   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
8200
8201   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8202   application.SendNotification();
8203   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8204   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8205   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8206   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8207
8208   // We did expect the animation to finish
8209
8210   finishCheck.CheckSignalReceived();
8211   END_TEST;
8212 }
8213
8214 int UtcDaliAnimationAnimateP(void)
8215 {
8216   TestApplication application;
8217
8218   Actor actor = Actor::New();
8219   Stage::GetCurrent().Add(actor);
8220
8221   //Build the path
8222   Vector3 position0( 30.0,  80.0,  0.0);
8223   Vector3 position1( 70.0,  120.0, 0.0);
8224   Vector3 position2( 100.0, 100.0, 0.0);
8225
8226   Dali::Path path = Dali::Path::New();
8227   path.AddPoint(position0);
8228   path.AddPoint(position1);
8229   path.AddPoint(position2);
8230
8231   //Control points for first segment
8232   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8233   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8234
8235   //Control points for second segment
8236   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8237   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8238
8239   // Build the animation
8240   float durationSeconds( 1.0f );
8241   Animation animation = Animation::New(durationSeconds);
8242   animation.Animate(actor, path, Vector3::XAXIS);
8243
8244   // Start the animation
8245   animation.Play();
8246
8247   bool signalReceived(false);
8248   AnimationFinishCheck finishCheck(signalReceived);
8249   animation.FinishedSignal().Connect(&application, finishCheck);
8250   application.SendNotification();
8251   application.Render(0);
8252   application.SendNotification();
8253   finishCheck.CheckSignalNotReceived();
8254   Vector3 position, tangent;
8255   Quaternion rotation;
8256   path.Sample( 0.0f, position, tangent );
8257   rotation = Quaternion( Vector3::XAXIS, tangent );
8258   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8259   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8260
8261   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8262   application.SendNotification();
8263   path.Sample( 0.25f, position, tangent );
8264   rotation = Quaternion( Vector3::XAXIS, tangent );
8265   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8266   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8267
8268   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8269   application.SendNotification();
8270   path.Sample( 0.5f, position, tangent );
8271   rotation = Quaternion( Vector3::XAXIS, tangent );
8272   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8273   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8274
8275   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8276   application.SendNotification();
8277   path.Sample( 0.75f, position, tangent );
8278   rotation = Quaternion( Vector3::XAXIS, tangent );
8279   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8280   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8281
8282   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8283   application.SendNotification();
8284   path.Sample( 1.0f, position, tangent );
8285   rotation = Quaternion( Vector3::XAXIS, tangent );
8286   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8287   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8288
8289   finishCheck.CheckSignalReceived();
8290   END_TEST;
8291 }
8292
8293 int UtcDaliAnimationAnimateAlphaFunctionP(void)
8294 {
8295   TestApplication application;
8296
8297   Actor actor = Actor::New();
8298   Stage::GetCurrent().Add(actor);
8299
8300   //Build the path
8301   Vector3 position0( 30.0,  80.0,  0.0);
8302   Vector3 position1( 70.0,  120.0, 0.0);
8303   Vector3 position2( 100.0, 100.0, 0.0);
8304
8305   Dali::Path path = Dali::Path::New();
8306   path.AddPoint(position0);
8307   path.AddPoint(position1);
8308   path.AddPoint(position2);
8309
8310   //Control points for first segment
8311   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8312   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8313
8314   //Control points for second segment
8315   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8316   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8317
8318   // Build the animation
8319   float durationSeconds( 1.0f );
8320   Animation animation = Animation::New(durationSeconds);
8321   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR);
8322
8323   // Start the animation
8324   animation.Play();
8325
8326   bool signalReceived(false);
8327   AnimationFinishCheck finishCheck(signalReceived);
8328   animation.FinishedSignal().Connect(&application, finishCheck);
8329   application.SendNotification();
8330   application.Render(0);
8331   application.SendNotification();
8332   finishCheck.CheckSignalNotReceived();
8333   Vector3 position, tangent;
8334   Quaternion rotation;
8335   path.Sample( 0.0f, position, tangent );
8336   rotation = Quaternion( Vector3::XAXIS, tangent );
8337   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8338   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8339
8340   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8341   application.SendNotification();
8342   path.Sample( 0.25f, position, tangent );
8343   rotation = Quaternion( Vector3::XAXIS, tangent );
8344   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8345   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8346
8347   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8348   application.SendNotification();
8349   path.Sample( 0.5f, position, tangent );
8350   rotation = Quaternion( Vector3::XAXIS, tangent );
8351   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8352   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8353
8354   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8355   application.SendNotification();
8356   path.Sample( 0.75f, position, tangent );
8357   rotation = Quaternion( Vector3::XAXIS, tangent );
8358   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8359   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8360
8361   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8362   application.SendNotification();
8363   path.Sample( 1.0f, position, tangent );
8364   rotation = Quaternion( Vector3::XAXIS, tangent );
8365   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8366   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8367
8368   finishCheck.CheckSignalReceived();
8369   END_TEST;
8370 }
8371
8372 int UtcDaliAnimationAnimateTimePeriodP(void)
8373 {
8374   TestApplication application;
8375
8376   Actor actor = Actor::New();
8377   Stage::GetCurrent().Add(actor);
8378
8379   //Build the path
8380   Vector3 position0( 30.0,  80.0,  0.0);
8381   Vector3 position1( 70.0,  120.0, 0.0);
8382   Vector3 position2( 100.0, 100.0, 0.0);
8383
8384   Dali::Path path = Dali::Path::New();
8385   path.AddPoint(position0);
8386   path.AddPoint(position1);
8387   path.AddPoint(position2);
8388
8389   //Control points for first segment
8390   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8391   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8392
8393   //Control points for second segment
8394   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8395   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8396
8397   // Build the animation
8398   float durationSeconds( 1.0f );
8399   Animation animation = Animation::New(durationSeconds);
8400   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
8401
8402   // Start the animation
8403   animation.Play();
8404
8405   bool signalReceived(false);
8406   AnimationFinishCheck finishCheck(signalReceived);
8407   animation.FinishedSignal().Connect(&application, finishCheck);
8408   application.SendNotification();
8409   application.Render(0);
8410   application.SendNotification();
8411   finishCheck.CheckSignalNotReceived();
8412   Vector3 position, tangent;
8413   Quaternion rotation;
8414   path.Sample( 0.0f, position, tangent );
8415   rotation = Quaternion( Vector3::XAXIS, tangent );
8416   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8417   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8418
8419   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8420   application.SendNotification();
8421   path.Sample( 0.25f, position, tangent );
8422   rotation = Quaternion( Vector3::XAXIS, tangent );
8423   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8424   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8425
8426   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8427   application.SendNotification();
8428   path.Sample( 0.5f, position, tangent );
8429   rotation = Quaternion( Vector3::XAXIS, tangent );
8430   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8431   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8432
8433   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8434   application.SendNotification();
8435   path.Sample( 0.75f, position, tangent );
8436   rotation = Quaternion( Vector3::XAXIS, tangent );
8437   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8438   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8439
8440   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8441   application.SendNotification();
8442   path.Sample( 1.0f, position, tangent );
8443   rotation = Quaternion( Vector3::XAXIS, tangent );
8444   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8445   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8446
8447   finishCheck.CheckSignalReceived();
8448   END_TEST;
8449 }
8450
8451 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
8452 {
8453   TestApplication application;
8454
8455   Actor actor = Actor::New();
8456   Stage::GetCurrent().Add(actor);
8457
8458   //Build the path
8459   Vector3 position0( 30.0,  80.0,  0.0);
8460   Vector3 position1( 70.0,  120.0, 0.0);
8461   Vector3 position2( 100.0, 100.0, 0.0);
8462
8463   Dali::Path path = Dali::Path::New();
8464   path.AddPoint(position0);
8465   path.AddPoint(position1);
8466   path.AddPoint(position2);
8467
8468   //Control points for first segment
8469   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8470   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8471
8472   //Control points for second segment
8473   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8474   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8475
8476   // Build the animation
8477   float durationSeconds( 1.0f );
8478   Animation animation = Animation::New(durationSeconds);
8479   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f));
8480
8481   // Start the animation
8482   animation.Play();
8483
8484   bool signalReceived(false);
8485   AnimationFinishCheck finishCheck(signalReceived);
8486   animation.FinishedSignal().Connect(&application, finishCheck);
8487   application.SendNotification();
8488   application.Render(0);
8489   application.SendNotification();
8490   finishCheck.CheckSignalNotReceived();
8491   Vector3 position, tangent;
8492   Quaternion rotation;
8493   path.Sample( 0.0f, position, tangent );
8494   rotation = Quaternion( Vector3::XAXIS, tangent );
8495   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8496   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8497
8498   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8499   application.SendNotification();
8500   path.Sample( 0.25f, position, tangent );
8501   rotation = Quaternion( Vector3::XAXIS, tangent );
8502   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8503   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8504
8505   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8506   application.SendNotification();
8507   path.Sample( 0.5f, position, tangent );
8508   rotation = Quaternion( Vector3::XAXIS, tangent );
8509   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8510   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8511
8512   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8513   application.SendNotification();
8514   path.Sample( 0.75f, position, tangent );
8515   rotation = Quaternion( Vector3::XAXIS, tangent );
8516   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8517   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8518
8519   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8520   application.SendNotification();
8521   path.Sample( 1.0f, position, tangent );
8522   rotation = Quaternion( Vector3::XAXIS, tangent );
8523   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8524   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8525
8526   finishCheck.CheckSignalReceived();
8527   END_TEST;
8528 }
8529
8530 int UtcDaliAnimationShowP(void)
8531 {
8532   TestApplication application;
8533
8534   Actor actor = Actor::New();
8535   actor.SetVisible(false);
8536   application.SendNotification();
8537   application.Render(0);
8538   DALI_TEST_CHECK( !actor.IsVisible() );
8539   Stage::GetCurrent().Add(actor);
8540
8541   // Start the animation
8542   float durationSeconds(10.0f);
8543   Animation animation = Animation::New(durationSeconds);
8544   animation.Show(actor, durationSeconds*0.5f);
8545   animation.Play();
8546
8547   bool signalReceived(false);
8548   AnimationFinishCheck finishCheck(signalReceived);
8549   animation.FinishedSignal().Connect(&application, finishCheck);
8550
8551   application.SendNotification();
8552   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8553
8554   // We didn't expect the animation to finish yet
8555   application.SendNotification();
8556   finishCheck.CheckSignalNotReceived();
8557   DALI_TEST_CHECK( !actor.IsVisible() );
8558
8559   application.SendNotification();
8560   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8561
8562   // We didn't expect the animation to finish yet
8563   application.SendNotification();
8564   finishCheck.CheckSignalNotReceived();
8565   DALI_TEST_CHECK( actor.IsVisible() );
8566
8567   application.SendNotification();
8568   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8569
8570   // We did expect the animation to finish
8571   application.SendNotification();
8572   finishCheck.CheckSignalReceived();
8573   DALI_TEST_CHECK( actor.IsVisible() );
8574   END_TEST;
8575 }
8576
8577 int UtcDaliAnimationHideP(void)
8578 {
8579   TestApplication application;
8580
8581   Actor actor = Actor::New();
8582   DALI_TEST_CHECK( actor.IsVisible() );
8583   Stage::GetCurrent().Add(actor);
8584
8585   // Start the animation
8586   float durationSeconds(10.0f);
8587   Animation animation = Animation::New(durationSeconds);
8588   animation.Hide(actor, durationSeconds*0.5f);
8589   animation.Play();
8590
8591   bool signalReceived(false);
8592   AnimationFinishCheck finishCheck(signalReceived);
8593   animation.FinishedSignal().Connect(&application, finishCheck);
8594
8595   application.SendNotification();
8596   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8597
8598   // We didn't expect the animation to finish yet
8599   application.SendNotification();
8600   finishCheck.CheckSignalNotReceived();
8601   DALI_TEST_CHECK( actor.IsVisible() );
8602
8603   application.SendNotification();
8604   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8605
8606   // We didn't expect the animation to finish yet
8607   application.SendNotification();
8608   finishCheck.CheckSignalNotReceived();
8609   DALI_TEST_CHECK( !actor.IsVisible() );
8610
8611   application.SendNotification();
8612   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8613
8614   // We did expect the animation to finish
8615   application.SendNotification();
8616   finishCheck.CheckSignalReceived();
8617   DALI_TEST_CHECK( !actor.IsVisible() );
8618   END_TEST;
8619 }
8620
8621 int UtcDaliAnimationShowHideAtEndP(void)
8622 {
8623   // Test that show/hide delay can be the same as animation duration
8624   // i.e. to show/hide at the end of the animation
8625
8626   TestApplication application;
8627
8628   Actor actor = Actor::New();
8629   DALI_TEST_CHECK( actor.IsVisible() );
8630   Stage::GetCurrent().Add(actor);
8631
8632   // Start Hide animation
8633   float durationSeconds(10.0f);
8634   Animation animation = Animation::New(durationSeconds);
8635   animation.Hide(actor, durationSeconds/*Hide at end*/);
8636   animation.Play();
8637
8638   bool signalReceived(false);
8639   AnimationFinishCheck finishCheck(signalReceived);
8640   animation.FinishedSignal().Connect(&application, finishCheck);
8641
8642   application.SendNotification();
8643   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8644
8645   // We did expect the animation to finish
8646   application.SendNotification();
8647   finishCheck.CheckSignalReceived();
8648   DALI_TEST_CHECK( !actor.IsVisible() );
8649
8650   // Start Show animation
8651   animation = Animation::New(durationSeconds);
8652   animation.Show(actor, durationSeconds/*Show at end*/);
8653   animation.FinishedSignal().Connect(&application, finishCheck);
8654   animation.Play();
8655
8656   application.SendNotification();
8657   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8658
8659   // We did expect the animation to finish
8660   application.SendNotification();
8661   finishCheck.CheckSignalReceived();
8662   DALI_TEST_CHECK( actor.IsVisible() );
8663   END_TEST;
8664 }
8665
8666 int UtcDaliKeyFramesCreateDestroyP(void)
8667 {
8668   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8669
8670   KeyFrames* keyFrames = new KeyFrames;
8671   delete keyFrames;
8672   DALI_TEST_CHECK( true );
8673   END_TEST;
8674 }
8675
8676 int UtcDaliKeyFramesDownCastP(void)
8677 {
8678   TestApplication application;
8679   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
8680
8681   KeyFrames keyFrames = KeyFrames::New();
8682   BaseHandle object(keyFrames);
8683
8684   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
8685   DALI_TEST_CHECK(keyFrames2);
8686
8687   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
8688   DALI_TEST_CHECK(keyFrames3);
8689
8690   BaseHandle unInitializedObject;
8691   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
8692   DALI_TEST_CHECK(!keyFrames4);
8693
8694   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
8695   DALI_TEST_CHECK(!keyFrames5);
8696   END_TEST;
8697 }
8698
8699 int UtcDaliAnimationCreateDestroyP(void)
8700 {
8701   TestApplication application;
8702   Animation* animation = new Animation;
8703   DALI_TEST_CHECK( animation );
8704   delete animation;
8705   END_TEST;
8706 }
8707
8708 struct UpdateManagerTestConstraint
8709 {
8710   UpdateManagerTestConstraint(TestApplication& application)
8711   : mApplication(application)
8712   {
8713   }
8714
8715   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
8716   {
8717     mApplication.SendNotification();  // Process events
8718   }
8719
8720   TestApplication& mApplication;
8721 };
8722
8723 int UtcDaliAnimationUpdateManagerP(void)
8724 {
8725   TestApplication application;
8726
8727   Actor actor = Actor::New();
8728   Stage::GetCurrent().Add( actor );
8729
8730   // Build the animation
8731   Animation animation = Animation::New( 0.0f );
8732
8733   bool signalReceived = false;
8734   AnimationFinishCheck finishCheck( signalReceived );
8735   animation.FinishedSignal().Connect( &application, finishCheck );
8736
8737   Vector3 startValue(1.0f, 1.0f, 1.0f);
8738   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
8739   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
8740   constraint.Apply();
8741
8742   // Apply animation to actor
8743   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR );
8744
8745   animation.Play();
8746
8747   application.SendNotification();
8748   application.UpdateOnly( 16 );
8749
8750   finishCheck.CheckSignalNotReceived();
8751
8752   application.SendNotification();   // Process events
8753
8754   finishCheck.CheckSignalReceived();
8755
8756   END_TEST;
8757 }
8758
8759 int UtcDaliAnimationSignalOrderP(void)
8760 {
8761   TestApplication application;
8762
8763   Actor actor = Actor::New();
8764   Stage::GetCurrent().Add( actor );
8765
8766   // Build the animations
8767   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
8768   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
8769
8770   bool signal1Received = false;
8771   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
8772
8773   bool signal2Received = false;
8774   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
8775
8776   // Apply animations to actor
8777   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR );
8778   animation1.Play();
8779   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR );
8780   animation2.Play();
8781
8782   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8783   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8784
8785   application.SendNotification();
8786   application.UpdateOnly( 10 ); // 10ms progress
8787
8788   // no notifications yet
8789   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8790   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8791
8792   application.SendNotification();
8793
8794   // first completed
8795   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
8796   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8797   signal1Received = false;
8798
8799   // 1st animation is complete now, do another update with no ProcessEvents in between
8800   application.UpdateOnly( 20 ); // 20ms progress
8801
8802   // ProcessEvents
8803   application.SendNotification();
8804
8805   // 2nd should complete now
8806   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8807   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
8808
8809   END_TEST;
8810 }
8811
8812 int UtcDaliAnimationExtendDurationP(void)
8813 {
8814   TestApplication application;
8815
8816   Actor actor = Actor::New();
8817
8818   // Register a float property
8819   float startValue(10.0f);
8820   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
8821   Stage::GetCurrent().Add(actor);
8822   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8823
8824   // Build the animation
8825   float initialDurationSeconds(1.0f);
8826   float animatorDelay = 5.0f;
8827   float animatorDurationSeconds(5.0f);
8828   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
8829   Animation animation = Animation::New(initialDurationSeconds);
8830   float targetValue(30.0f);
8831   float relativeValue(targetValue - startValue);
8832
8833   animation.AnimateTo(Property(actor, index),
8834                       targetValue,
8835                       TimePeriod(animatorDelay, animatorDurationSeconds));
8836
8837   // The duration should have been extended
8838   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
8839
8840   // Start the animation
8841   animation.Play();
8842
8843   bool signalReceived(false);
8844   AnimationFinishCheck finishCheck(signalReceived);
8845   animation.FinishedSignal().Connect(&application, finishCheck);
8846
8847   application.SendNotification();
8848   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8849
8850   // We didn't expect the animation to finish yet
8851   application.SendNotification();
8852   finishCheck.CheckSignalNotReceived();
8853   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8854
8855   application.SendNotification();
8856   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
8857
8858   // We didn't expect the animation to finish yet
8859   application.SendNotification();
8860   finishCheck.CheckSignalNotReceived();
8861   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
8862
8863   application.SendNotification();
8864   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8865
8866   // We did expect the animation to finish
8867   application.SendNotification();
8868   finishCheck.CheckSignalReceived();
8869   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
8870   END_TEST;
8871 }
8872
8873 int UtcDaliAnimationCustomIntProperty(void)
8874 {
8875   TestApplication application;
8876
8877   Actor actor = Actor::New();
8878   Stage::GetCurrent().Add(actor);
8879   int startValue(0u);
8880
8881   Property::Index index = actor.RegisterProperty("anIndex",  startValue);
8882   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
8883
8884   // Build the animation
8885   float durationSeconds(1.0f);
8886   Animation animation = Animation::New(durationSeconds);
8887   animation.AnimateTo( Property(actor, index), 20 );
8888
8889   // Start the animation
8890   animation.Play();
8891
8892   bool signalReceived(false);
8893   AnimationFinishCheck finishCheck(signalReceived);
8894   animation.FinishedSignal().Connect(&application, finishCheck);
8895
8896   application.SendNotification();
8897   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8898
8899   // We didn't expect the animation to finish yet
8900   application.SendNotification();
8901   finishCheck.CheckSignalNotReceived();
8902   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 10, TEST_LOCATION );
8903
8904   application.SendNotification();
8905   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8906
8907   // We did expect the animation to finish
8908   application.SendNotification();
8909   finishCheck.CheckSignalReceived();
8910   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 20, TEST_LOCATION );
8911   END_TEST;
8912 }