Added animation and constraint support for UNSIGNED_INTEGER property type
[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 UtcDaliAnimationSetDuratioN(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, AlphaFunctions::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 UtcDaliAnimationGetDuratioN(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, AlphaFunctions::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, AlphaFunctions::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 UtcDaliAnimationGetEndActioN(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 UtcDaliAnimationSetDisconnectActioN(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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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 UtcDaliAnimationGetDisconnectActioN(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 UtcDaliAnimationSetDefaultAlphaFunctioN(void)
584 {
585   TestApplication application;
586
587   Animation animation = Animation::New(1.0f);
588   AlphaFunction func = animation.GetDefaultAlphaFunction();
589   DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
590
591   animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
592   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
593   DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
594   END_TEST;
595 }
596
597 int UtcDaliAnimationGetDefaultAlphaFunctioN(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(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION);
606
607   animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn);
608   AlphaFunction func2 = animation.GetDefaultAlphaFunction();
609   DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in
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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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 UtcDaliAnimationStopSetPositioN(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, AlphaFunctions::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, AlphaFunctions::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, AlphaFunctions::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 UtcDaliAnimationAnimateByBooleaN(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( "test-property", 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 UtcDaliAnimationAnimateByBooleanAlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseIn);
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, AlphaFunctions::EaseIn);
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( "test-property", 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( "test-property", 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                        AlphaFunctions::EaseInOut,
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( "test-property", 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 UtcDaliAnimationAnimateByFloatAlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateByIntegerAlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateByVector2AlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateByVector3AlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateByVector4AlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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 UtcDaliAnimationAnimateByActorPositioN(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 UtcDaliAnimationAnimateByActorPositionAlphaFunctioN(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, AlphaFunctions::EaseOut);
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                       AlphaFunctions::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 UtcDaliAnimationAnimateByActorOrientatioN(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 UtcDaliAnimationAnimateByActorOrientationAlphaFunctioN(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 ), AlphaFunctions::EaseIn );
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 * AlphaFunctions::EaseIn(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 * AlphaFunctions::EaseIn(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 * AlphaFunctions::EaseIn(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                        AlphaFunctions::EaseIn, 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 * AlphaFunctions::EaseIn(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 * AlphaFunctions::EaseIn(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 * AlphaFunctions::EaseIn(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, AlphaFunctions::EaseIn );
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, AlphaFunctions::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 UtcDaliAnimationAnimateToBooleaN(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( "test-property", 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 UtcDaliAnimationAnimateToBooleanAlphaFunctioN(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( "test-property", 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, "test-property"), targetValue, AlphaFunctions::EaseOut);
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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                        AlphaFunctions::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( "test-property", 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, "test-property"), 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 UtcDaliAnimationAnimateToFloatAlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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, "test-property"), 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 UtcDaliAnimationAnimateToIntegerAlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateToVector2AlphaFunctioN(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( "test-property", 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, "test-property"), targetValue, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateToVector3AlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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, "test-property"),
4817                       targetValue,
4818                       AlphaFunctions::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( "test-property", 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, "test-property", 0),
4873                       30.0f,
4874                       AlphaFunctions::Linear,
4875                       TimePeriod(delay, durationSeconds - delay));
4876   animation.AnimateTo(Property(actor, index, 1),
4877                       30.0f,
4878                       AlphaFunctions::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( "test-property", 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 UtcDaliAnimationAnimateToVector4AlphaFunctioN(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( "test-property", 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, AlphaFunctions::EaseOut);
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( "test-property", 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( "test-property", 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                       AlphaFunctions::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 UtcDaliAnimationAnimateToActorParentOrigiN(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, AlphaFunctions::EaseIn);
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, AlphaFunctions::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   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION );
5476
5477   application.SendNotification();
5478   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5479
5480   // We did expect the animation to finish
5481   application.SendNotification();
5482   finishCheck.CheckSignalReceived();
5483   DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION );
5484   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), targetWidth, TEST_LOCATION );
5485   END_TEST;
5486 }
5487
5488 int UtcDaliAnimationAnimateToActorSizeHeightP(void)
5489 {
5490   TestApplication application;
5491
5492   Actor actor = Actor::New();
5493   Stage::GetCurrent().Add(actor);
5494   float startValue(0.0f);
5495   DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION );
5496   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), startValue, TEST_LOCATION );
5497
5498   // Build the animation
5499   float durationSeconds(1.0f);
5500   Animation animation = Animation::New(durationSeconds);
5501   float targetHeight(-10.0f);
5502   animation.AnimateTo( Property(actor, Actor::Property::SIZE_HEIGHT), targetHeight );
5503
5504   float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f);
5505
5506   // Start the animation
5507   animation.Play();
5508
5509   bool signalReceived(false);
5510   AnimationFinishCheck finishCheck(signalReceived);
5511   animation.FinishedSignal().Connect(&application, finishCheck);
5512
5513   application.SendNotification();
5514   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5515
5516   // We didn't expect the animation to finish yet
5517   application.SendNotification();
5518   finishCheck.CheckSignalNotReceived();
5519   DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION );
5520   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION );
5521
5522   application.SendNotification();
5523   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5524
5525   // We did expect the animation to finish
5526   application.SendNotification();
5527   finishCheck.CheckSignalReceived();
5528   DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION );
5529   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), targetHeight, TEST_LOCATION );
5530   END_TEST;
5531 }
5532
5533 int UtcDaliAnimationAnimateToActorSizeDepthP(void)
5534 {
5535   TestApplication application;
5536
5537   Actor actor = Actor::New();
5538   Stage::GetCurrent().Add(actor);
5539   float startValue(0.0f);
5540   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION );
5541   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), startValue, TEST_LOCATION );
5542
5543   // Build the animation
5544   float durationSeconds(1.0f);
5545   Animation animation = Animation::New(durationSeconds);
5546   float targetDepth(-10.0f);
5547   animation.AnimateTo( Property(actor, Actor::Property::SIZE_DEPTH), targetDepth );
5548
5549   float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f);
5550
5551   // Start the animation
5552   animation.Play();
5553
5554   bool signalReceived(false);
5555   AnimationFinishCheck finishCheck(signalReceived);
5556   animation.FinishedSignal().Connect(&application, finishCheck);
5557
5558   application.SendNotification();
5559   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5560
5561   // We didn't expect the animation to finish yet
5562   application.SendNotification();
5563   finishCheck.CheckSignalNotReceived();
5564   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION );
5565   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION );
5566
5567   application.SendNotification();
5568   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5569
5570   // We did expect the animation to finish
5571   application.SendNotification();
5572   finishCheck.CheckSignalReceived();
5573   DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION );
5574   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), targetDepth, TEST_LOCATION );
5575   END_TEST;
5576 }
5577
5578 int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void)
5579 {
5580   TestApplication application;
5581
5582   Actor actor = Actor::New();
5583   Stage::GetCurrent().Add(actor);
5584   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5585
5586   // Build the animation
5587   float durationSeconds(1.0f);
5588   Animation animation = Animation::New(durationSeconds);
5589   Vector3 targetSize(100.0f, 100.0f, 100.0f);
5590   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetSize );
5591
5592   Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
5593
5594   // Start the animation
5595   animation.Play();
5596
5597   bool signalReceived(false);
5598   AnimationFinishCheck finishCheck(signalReceived);
5599   animation.FinishedSignal().Connect(&application, finishCheck);
5600
5601   application.SendNotification();
5602   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5603
5604   // We didn't expect the animation to finish yet
5605   application.SendNotification();
5606   finishCheck.CheckSignalNotReceived();
5607   DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
5608
5609   application.SendNotification();
5610   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5611
5612   // We did expect the animation to finish
5613   application.SendNotification();
5614   finishCheck.CheckSignalReceived();
5615   DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
5616
5617   // Reset everything
5618   finishCheck.Reset();
5619   actor.SetSize(Vector3::ZERO);
5620   application.SendNotification();
5621   application.Render(0);
5622   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5623
5624   // Repeat with a different (ease-in) alpha function
5625   animation = Animation::New(durationSeconds);
5626   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::EaseIn );
5627   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::EaseIn );
5628   animation.FinishedSignal().Connect(&application, finishCheck);
5629   animation.Play();
5630
5631   application.SendNotification();
5632   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
5633
5634   // We didn't expect the animation to finish yet
5635   application.SendNotification();
5636   finishCheck.CheckSignalNotReceived();
5637
5638   // The size should have travelled less, than with a linear alpha function
5639   Vector3 current(actor.GetCurrentSize());
5640   DALI_TEST_CHECK( current.x > 0.0f );
5641   DALI_TEST_CHECK( current.y > 0.0f );
5642   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
5643   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
5644
5645   application.SendNotification();
5646   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
5647
5648   // We did expect the animation to finish
5649   application.SendNotification();
5650   finishCheck.CheckSignalReceived();
5651   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
5652   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
5653
5654   // Reset everything
5655   finishCheck.Reset();
5656   actor.SetSize(Vector3::ZERO);
5657   application.SendNotification();
5658   application.Render(0);
5659   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5660
5661   // Repeat with a delay
5662   float delay = 0.5f;
5663   animation = Animation::New(durationSeconds);
5664   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
5665   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
5666   animation.FinishedSignal().Connect(&application, finishCheck);
5667   animation.Play();
5668
5669   application.SendNotification();
5670   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5671
5672   // We didn't expect the animation to finish yet
5673   application.SendNotification();
5674   finishCheck.CheckSignalNotReceived();
5675   DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
5676
5677   application.SendNotification();
5678   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5679
5680   // We did expect the animation to finish
5681   application.SendNotification();
5682   finishCheck.CheckSignalReceived();
5683   DALI_TEST_EQUALS( actor.GetCurrentSize().x, targetSize.x, TEST_LOCATION );
5684   DALI_TEST_EQUALS( actor.GetCurrentSize().y, targetSize.y, TEST_LOCATION );
5685   END_TEST;
5686 }
5687
5688 int UtcDaliAnimationAnimateToActorPositioN(void)
5689 {
5690   TestApplication application;
5691
5692   Actor actor = Actor::New();
5693   Stage::GetCurrent().Add(actor);
5694   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5695
5696   // Build the animation
5697   float durationSeconds(1.0f);
5698   Animation animation = Animation::New(durationSeconds);
5699   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5700   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition);
5701
5702   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5703
5704   // Start the animation
5705   animation.Play();
5706
5707   bool signalReceived(false);
5708   AnimationFinishCheck finishCheck(signalReceived);
5709   animation.FinishedSignal().Connect(&application, finishCheck);
5710
5711   application.SendNotification();
5712   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5713
5714   // We didn't expect the animation to finish yet
5715   application.SendNotification();
5716   finishCheck.CheckSignalNotReceived();
5717   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5718
5719   application.SendNotification();
5720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5721
5722   // We did expect the animation to finish
5723   application.SendNotification();
5724   finishCheck.CheckSignalReceived();
5725   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5726   END_TEST;
5727 }
5728
5729 int UtcDaliAnimationAnimateToActorPositionXP(void)
5730 {
5731   TestApplication application;
5732
5733   Actor actor = Actor::New();
5734   Stage::GetCurrent().Add(actor);
5735   float startValue(0.0f);
5736   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION );
5737   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5738   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5739   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5740
5741   // Build the animation
5742   float durationSeconds(1.0f);
5743   Animation animation = Animation::New(durationSeconds);
5744   float targetX(1.0f);
5745   animation.AnimateTo( Property(actor, Actor::Property::POSITION_X), targetX );
5746
5747   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
5748
5749   // Start the animation
5750   animation.Play();
5751
5752   bool signalReceived(false);
5753   AnimationFinishCheck finishCheck(signalReceived);
5754   animation.FinishedSignal().Connect(&application, finishCheck);
5755
5756   application.SendNotification();
5757   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5758
5759   // We didn't expect the animation to finish yet
5760   application.SendNotification();
5761   finishCheck.CheckSignalNotReceived();
5762   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION );
5763   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), fiftyPercentProgress, TEST_LOCATION );
5764   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5765   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5766
5767   application.SendNotification();
5768   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5769
5770   // We did expect the animation to finish
5771   application.SendNotification();
5772   finishCheck.CheckSignalReceived();
5773   DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION );
5774   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), targetX, TEST_LOCATION );
5775   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5776   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5777   END_TEST;
5778 }
5779
5780 int UtcDaliAnimationAnimateToActorPositionYP(void)
5781 {
5782   TestApplication application;
5783
5784   Actor actor = Actor::New();
5785   Stage::GetCurrent().Add(actor);
5786   float startValue(0.0f);
5787   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION );
5788   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5789   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5790   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5791
5792   // Build the animation
5793   float durationSeconds(1.0f);
5794   Animation animation = Animation::New(durationSeconds);
5795   float targetY(10.0f);
5796   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Y), targetY );
5797
5798   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
5799
5800   // Start the animation
5801   animation.Play();
5802
5803   bool signalReceived(false);
5804   AnimationFinishCheck finishCheck(signalReceived);
5805   animation.FinishedSignal().Connect(&application, finishCheck);
5806
5807   application.SendNotification();
5808   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5809
5810   // We didn't expect the animation to finish yet
5811   application.SendNotification();
5812   finishCheck.CheckSignalNotReceived();
5813   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION );
5814   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5815   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), fiftyPercentProgress, TEST_LOCATION );
5816   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5817
5818   application.SendNotification();
5819   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5820
5821   // We did expect the animation to finish
5822   application.SendNotification();
5823   finishCheck.CheckSignalReceived();
5824   DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION );
5825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), targetY, TEST_LOCATION );
5827   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5828   END_TEST;
5829 }
5830
5831 int UtcDaliAnimationAnimateToActorPositionZP(void)
5832 {
5833   TestApplication application;
5834
5835   Actor actor = Actor::New();
5836   Stage::GetCurrent().Add(actor);
5837   float startValue(0.0f);
5838   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION );
5839   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5840   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5841   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), startValue, TEST_LOCATION );
5842
5843   // Build the animation
5844   float durationSeconds(1.0f);
5845   Animation animation = Animation::New(durationSeconds);
5846   float targetZ(-5.0f);
5847   animation.AnimateTo( Property(actor, Actor::Property::POSITION_Z), targetZ );
5848
5849   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
5850
5851   // Start the animation
5852   animation.Play();
5853
5854   bool signalReceived(false);
5855   AnimationFinishCheck finishCheck(signalReceived);
5856   animation.FinishedSignal().Connect(&application, finishCheck);
5857
5858   application.SendNotification();
5859   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
5860
5861   // We didn't expect the animation to finish yet
5862   application.SendNotification();
5863   finishCheck.CheckSignalNotReceived();
5864   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION );
5865   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5866   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5867   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), fiftyPercentProgress, TEST_LOCATION );
5868
5869   application.SendNotification();
5870   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
5871
5872   // We did expect the animation to finish
5873   application.SendNotification();
5874   finishCheck.CheckSignalReceived();
5875   DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION );
5876   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_X), startValue, TEST_LOCATION );
5877   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Y), startValue, TEST_LOCATION );
5878   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::POSITION_Z), targetZ, TEST_LOCATION );
5879   END_TEST;
5880 }
5881
5882 int UtcDaliAnimationAnimateToActorPositionAlphaFunctioN(void)
5883 {
5884   TestApplication application;
5885
5886   Actor actor = Actor::New();
5887   Stage::GetCurrent().Add(actor);
5888   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5889
5890   // Build the animation
5891   float durationSeconds(1.0f);
5892   Animation animation = Animation::New(durationSeconds);
5893   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5894   animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::EaseIn);
5895
5896   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5897
5898   // Start the animation
5899   animation.Play();
5900
5901   bool signalReceived(false);
5902   AnimationFinishCheck finishCheck(signalReceived);
5903   animation.FinishedSignal().Connect(&application, finishCheck);
5904
5905   application.SendNotification();
5906   application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
5907
5908   // We didn't expect the animation to finish yet
5909   application.SendNotification();
5910   finishCheck.CheckSignalNotReceived();
5911
5912   // The position should have moved less, than with a linear alpha function
5913   Vector3 current(actor.GetCurrentPosition());
5914   DALI_TEST_CHECK( current.x > Vector3::ZERO.x );
5915   DALI_TEST_CHECK( current.y > Vector3::ZERO.y );
5916   DALI_TEST_CHECK( current.z > Vector3::ZERO.z );
5917   DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x );
5918   DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y );
5919   DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z );
5920
5921   application.SendNotification();
5922   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
5923
5924   // We did expect the animation to finish
5925   application.SendNotification();
5926   finishCheck.CheckSignalReceived();
5927   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5928   END_TEST;
5929 }
5930
5931 int UtcDaliAnimationAnimateToActorPositionTimePeriodP(void)
5932 {
5933   TestApplication application;
5934
5935   Actor actor = Actor::New();
5936   Stage::GetCurrent().Add(actor);
5937   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5938
5939   // Build the animation
5940   float durationSeconds(1.0f);
5941   Animation animation = Animation::New(durationSeconds);
5942   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5943   float delay = 0.5f;
5944   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5945                        targetPosition,
5946                        TimePeriod( delay, durationSeconds - delay ) );
5947
5948   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
5949
5950   // Start the animation
5951   animation.Play();
5952
5953   bool signalReceived(false);
5954   AnimationFinishCheck finishCheck(signalReceived);
5955   animation.FinishedSignal().Connect(&application, finishCheck);
5956
5957   application.SendNotification();
5958   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
5959
5960   // We didn't expect the animation to finish yet
5961   application.SendNotification();
5962   finishCheck.CheckSignalNotReceived();
5963   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5964
5965   application.SendNotification();
5966   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
5967
5968   // We didn't expect the animation to finish yet
5969   application.SendNotification();
5970   finishCheck.CheckSignalNotReceived();
5971   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
5972
5973   application.SendNotification();
5974   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
5975
5976   // We did expect the animation to finish
5977   application.SendNotification();
5978   finishCheck.CheckSignalReceived();
5979   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
5980   END_TEST;
5981 }
5982
5983 int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void)
5984 {
5985   TestApplication application;
5986
5987   Actor actor = Actor::New();
5988   Stage::GetCurrent().Add(actor);
5989   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
5990
5991   // Build the animation
5992   float durationSeconds(1.0f);
5993   Animation animation = Animation::New(durationSeconds);
5994   Vector3 targetPosition(200.0f, 200.0f, 200.0f);
5995   float delay = 0.5f;
5996   animation.AnimateTo( Property(actor, Actor::Property::POSITION),
5997                        targetPosition,
5998                        AlphaFunctions::Linear,
5999                        TimePeriod( delay, durationSeconds - delay ) );
6000
6001   Vector3 seventyFivePercentProgress(targetPosition * 0.75f);
6002
6003   // Start the animation
6004   animation.Play();
6005
6006   bool signalReceived(false);
6007   AnimationFinishCheck finishCheck(signalReceived);
6008   animation.FinishedSignal().Connect(&application, finishCheck);
6009
6010   application.SendNotification();
6011   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6012
6013   // We didn't expect the animation to finish yet
6014   application.SendNotification();
6015   finishCheck.CheckSignalNotReceived();
6016   DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
6017
6018   application.SendNotification();
6019   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
6020
6021   // We didn't expect the animation to finish yet
6022   application.SendNotification();
6023   finishCheck.CheckSignalNotReceived();
6024   DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION );
6025
6026   application.SendNotification();
6027   application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
6028
6029   // We did expect the animation to finish
6030   application.SendNotification();
6031   finishCheck.CheckSignalReceived();
6032   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
6033   END_TEST;
6034 }
6035
6036 int UtcDaliAnimationAnimateToActorOrientationAngleAxisP(void)
6037 {
6038   TestApplication application;
6039
6040   Actor actor = Actor::New();
6041   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6042   Stage::GetCurrent().Add(actor);
6043   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6044
6045   // Build the animation
6046   float durationSeconds(1.0f);
6047   Animation animation = Animation::New(durationSeconds);
6048   Degree targetRotationDegrees(90.0f);
6049   Radian targetRotationRadians(targetRotationDegrees);
6050   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) );
6051
6052   // Start the animation
6053   animation.Play();
6054
6055   bool signalReceived(false);
6056   AnimationFinishCheck finishCheck(signalReceived);
6057   animation.FinishedSignal().Connect(&application, finishCheck);
6058
6059   application.SendNotification();
6060   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6061
6062   // We didn't expect the animation to finish yet
6063   application.SendNotification();
6064   finishCheck.CheckSignalNotReceived();
6065   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6066
6067   application.SendNotification();
6068   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6069
6070   // We didn't expect the animation to finish yet
6071   application.SendNotification();
6072   finishCheck.CheckSignalNotReceived();
6073   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6074
6075   application.SendNotification();
6076   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6077
6078   // We didn't expect the animation to finish yet
6079   application.SendNotification();
6080   finishCheck.CheckSignalNotReceived();
6081   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6082
6083   application.SendNotification();
6084   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6085
6086   // We did expect the animation to finish
6087   application.SendNotification();
6088   finishCheck.CheckSignalReceived();
6089   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6090   END_TEST;
6091 }
6092
6093 int UtcDaliAnimationAnimateToActorOrientationQuaternioN(void)
6094 {
6095   TestApplication application;
6096
6097   Actor actor = Actor::New();
6098   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6099   Stage::GetCurrent().Add(actor);
6100   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6101
6102   // Build the animation
6103   float durationSeconds(1.0f);
6104   Animation animation = Animation::New(durationSeconds);
6105   Degree targetRotationDegrees(90.0f);
6106   Radian targetRotationRadians(targetRotationDegrees);
6107   Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS);
6108   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), targetRotation );
6109
6110   // Start the animation
6111   animation.Play();
6112
6113   bool signalReceived(false);
6114   AnimationFinishCheck finishCheck(signalReceived);
6115   animation.FinishedSignal().Connect(&application, finishCheck);
6116
6117   application.SendNotification();
6118   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6119
6120   // We didn't expect the animation to finish yet
6121   application.SendNotification();
6122   finishCheck.CheckSignalNotReceived();
6123   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6124
6125   application.SendNotification();
6126   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6127
6128   // We didn't expect the animation to finish yet
6129   application.SendNotification();
6130   finishCheck.CheckSignalNotReceived();
6131   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6132
6133   application.SendNotification();
6134   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6135
6136   // We didn't expect the animation to finish yet
6137   application.SendNotification();
6138   finishCheck.CheckSignalNotReceived();
6139   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6140
6141   application.SendNotification();
6142   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6143
6144   // We did expect the animation to finish
6145   application.SendNotification();
6146   finishCheck.CheckSignalReceived();
6147   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6148   END_TEST;
6149 }
6150
6151 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctioN(void)
6152 {
6153   TestApplication application;
6154
6155   Actor actor = Actor::New();
6156   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6157   Stage::GetCurrent().Add(actor);
6158   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6159
6160   // Build the animation
6161   float durationSeconds(1.0f);
6162   Animation animation = Animation::New(durationSeconds);
6163   Degree targetRotationDegrees(90.0f);
6164   Radian targetRotationRadians(targetRotationDegrees);
6165   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn);
6166
6167   // Start the animation
6168   animation.Play();
6169
6170   bool signalReceived(false);
6171   AnimationFinishCheck finishCheck(signalReceived);
6172   animation.FinishedSignal().Connect(&application, finishCheck);
6173
6174   application.SendNotification();
6175   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6176
6177   // We didn't expect the animation to finish yet
6178   application.SendNotification();
6179   finishCheck.CheckSignalNotReceived();
6180   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6181
6182   application.SendNotification();
6183   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6184
6185   // We didn't expect the animation to finish yet
6186   application.SendNotification();
6187   finishCheck.CheckSignalNotReceived();
6188   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6189
6190   application.SendNotification();
6191   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6192
6193   // We didn't expect the animation to finish yet
6194   application.SendNotification();
6195   finishCheck.CheckSignalNotReceived();
6196   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6197
6198   application.SendNotification();
6199   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6200
6201   // We did expect the animation to finish
6202   application.SendNotification();
6203   finishCheck.CheckSignalReceived();
6204   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6205   END_TEST;
6206 }
6207
6208 int UtcDaliAnimationAnimateToActorOrientationTimePeriodP(void)
6209 {
6210   TestApplication application;
6211
6212   Actor actor = Actor::New();
6213   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6214   Stage::GetCurrent().Add(actor);
6215   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6216
6217   // Build the animation
6218   float durationSeconds(1.0f);
6219   Animation animation = Animation::New(durationSeconds);
6220   Degree targetRotationDegrees(90.0f);
6221   Radian targetRotationRadians(targetRotationDegrees);
6222   float delay(0.1f);
6223   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay));
6224
6225   // Start the animation
6226   animation.Play();
6227
6228   bool signalReceived(false);
6229   AnimationFinishCheck finishCheck(signalReceived);
6230   animation.FinishedSignal().Connect(&application, finishCheck);
6231
6232   application.SendNotification();
6233   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6234
6235   // We didn't expect the animation to finish yet
6236   application.SendNotification();
6237   finishCheck.CheckSignalNotReceived();
6238   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6239   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6240
6241   application.SendNotification();
6242   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6243
6244   // We didn't expect the animation to finish yet
6245   application.SendNotification();
6246   finishCheck.CheckSignalNotReceived();
6247   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6248   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6249
6250   application.SendNotification();
6251   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6252
6253   // We didn't expect the animation to finish yet
6254   application.SendNotification();
6255   finishCheck.CheckSignalNotReceived();
6256   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6257   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6258
6259   application.SendNotification();
6260   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6261
6262   // We did expect the animation to finish
6263   application.SendNotification();
6264   finishCheck.CheckSignalReceived();
6265   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6266   END_TEST;
6267 }
6268
6269 int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void)
6270 {
6271   TestApplication application;
6272
6273   Actor actor = Actor::New();
6274   actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
6275   Stage::GetCurrent().Add(actor);
6276   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
6277
6278   // Build the animation
6279   float durationSeconds(1.0f);
6280   Animation animation = Animation::New(durationSeconds);
6281   Degree targetRotationDegrees(90.0f);
6282   Radian targetRotationRadians(targetRotationDegrees);
6283   float delay(0.1f);
6284   animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay));
6285
6286   // Start the animation
6287   animation.Play();
6288
6289   bool signalReceived(false);
6290   AnimationFinishCheck finishCheck(signalReceived);
6291   animation.FinishedSignal().Connect(&application, finishCheck);
6292
6293   application.SendNotification();
6294   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
6295
6296   // We didn't expect the animation to finish yet
6297   application.SendNotification();
6298   finishCheck.CheckSignalNotReceived();
6299   float progress = max(0.0f, 0.25f - delay) / (1.0f - delay);
6300   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6301
6302   application.SendNotification();
6303   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
6304
6305   // We didn't expect the animation to finish yet
6306   application.SendNotification();
6307   finishCheck.CheckSignalNotReceived();
6308   progress = max(0.0f, 0.5f - delay) / (1.0f - delay);
6309   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6310
6311   application.SendNotification();
6312   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
6313
6314   // We didn't expect the animation to finish yet
6315   application.SendNotification();
6316   finishCheck.CheckSignalNotReceived();
6317   progress = max(0.0f, 0.75f - delay) / (1.0f - delay);
6318   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6319
6320   application.SendNotification();
6321   application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
6322
6323   // We did expect the animation to finish
6324   application.SendNotification();
6325   finishCheck.CheckSignalReceived();
6326   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
6327   END_TEST;
6328 }
6329
6330 int UtcDaliAnimationAnimateToActorScaleP(void)
6331 {
6332   TestApplication application;
6333
6334   Actor actor = Actor::New();
6335   Stage::GetCurrent().Add(actor);
6336   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6337
6338   // Build the animation
6339   float durationSeconds(1.0f);
6340   Animation animation = Animation::New(durationSeconds);
6341   Vector3 targetScale(2.0f, 2.0f, 2.0f);
6342   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale );
6343
6344   Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
6345
6346   // Start the animation
6347   animation.Play();
6348
6349   bool signalReceived(false);
6350   AnimationFinishCheck finishCheck(signalReceived);
6351   animation.FinishedSignal().Connect(&application, finishCheck);
6352
6353   application.SendNotification();
6354   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6355
6356   // We didn't expect the animation to finish yet
6357   application.SendNotification();
6358   finishCheck.CheckSignalNotReceived();
6359   DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
6360
6361   application.SendNotification();
6362   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6363
6364   // We did expect the animation to finish
6365   application.SendNotification();
6366   finishCheck.CheckSignalReceived();
6367   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6368
6369   // Reset everything
6370   finishCheck.Reset();
6371   actor.SetScale(Vector3::ONE);
6372   application.SendNotification();
6373   application.Render(0);
6374   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6375
6376   // Repeat with a different (ease-in) alpha function
6377   animation = Animation::New(durationSeconds);
6378   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::EaseIn);
6379   animation.FinishedSignal().Connect(&application, finishCheck);
6380   animation.Play();
6381
6382   application.SendNotification();
6383   application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
6384
6385   // We didn't expect the animation to finish yet
6386   application.SendNotification();
6387   finishCheck.CheckSignalNotReceived();
6388
6389   // The scale should have grown less, than with a linear alpha function
6390   Vector3 current(actor.GetCurrentScale());
6391   DALI_TEST_CHECK( current.x > 1.0f );
6392   DALI_TEST_CHECK( current.y > 1.0f );
6393   DALI_TEST_CHECK( current.z > 1.0f );
6394   DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
6395   DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
6396   DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
6397
6398   application.SendNotification();
6399   application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
6400
6401   // We did expect the animation to finish
6402   application.SendNotification();
6403   finishCheck.CheckSignalReceived();
6404   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6405
6406   // Reset everything
6407   finishCheck.Reset();
6408   actor.SetScale(Vector3::ONE);
6409   application.SendNotification();
6410   application.Render(0);
6411   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6412
6413   // Repeat with a delay
6414   float delay = 0.5f;
6415   animation = Animation::New(durationSeconds);
6416   animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay));
6417   animation.FinishedSignal().Connect(&application, finishCheck);
6418   animation.Play();
6419
6420   application.SendNotification();
6421   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
6422
6423   // We didn't expect the animation to finish yet
6424   application.SendNotification();
6425   finishCheck.CheckSignalNotReceived();
6426   DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
6427
6428   application.SendNotification();
6429   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6430
6431   // We did expect the animation to finish
6432   application.SendNotification();
6433   finishCheck.CheckSignalReceived();
6434   DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
6435   END_TEST;
6436 }
6437
6438 int UtcDaliAnimationAnimateToActorScaleXP(void)
6439 {
6440   TestApplication application;
6441
6442   Actor actor = Actor::New();
6443   Stage::GetCurrent().Add(actor);
6444   float startValue(1.0f);
6445   DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION );
6446   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6447   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6448   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6449
6450   // Build the animation
6451   float durationSeconds(1.0f);
6452   Animation animation = Animation::New(durationSeconds);
6453   float targetX(10.0f);
6454   animation.AnimateTo( Property(actor, Actor::Property::SCALE_X), targetX );
6455
6456   float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f);
6457
6458   // Start the animation
6459   animation.Play();
6460
6461   bool signalReceived(false);
6462   AnimationFinishCheck finishCheck(signalReceived);
6463   animation.FinishedSignal().Connect(&application, finishCheck);
6464
6465   application.SendNotification();
6466   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6467
6468   // We didn't expect the animation to finish yet
6469   application.SendNotification();
6470   finishCheck.CheckSignalNotReceived();
6471   DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION );
6472   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), fiftyPercentProgress, TEST_LOCATION );
6473   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6474   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6475
6476   application.SendNotification();
6477   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6478
6479   // We did expect the animation to finish
6480   application.SendNotification();
6481   finishCheck.CheckSignalReceived();
6482   DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION );
6483   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), targetX, TEST_LOCATION );
6484   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6485   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6486   END_TEST;
6487 }
6488
6489 int UtcDaliAnimationAnimateToActorScaleYP(void)
6490 {
6491   TestApplication application;
6492
6493   Actor actor = Actor::New();
6494   Stage::GetCurrent().Add(actor);
6495   float startValue(1.0f);
6496   DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION );
6497   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6498   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6499   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6500
6501   // Build the animation
6502   float durationSeconds(1.0f);
6503   Animation animation = Animation::New(durationSeconds);
6504   float targetY(1000.0f);
6505   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Y), targetY );
6506
6507   float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f);
6508
6509   // Start the animation
6510   animation.Play();
6511
6512   bool signalReceived(false);
6513   AnimationFinishCheck finishCheck(signalReceived);
6514   animation.FinishedSignal().Connect(&application, finishCheck);
6515
6516   application.SendNotification();
6517   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6518
6519   // We didn't expect the animation to finish yet
6520   application.SendNotification();
6521   finishCheck.CheckSignalNotReceived();
6522   DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION );
6523   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6524   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), fiftyPercentProgress, TEST_LOCATION );
6525   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6526
6527   application.SendNotification();
6528   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6529
6530   // We did expect the animation to finish
6531   application.SendNotification();
6532   finishCheck.CheckSignalReceived();
6533   DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION );
6534   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6535   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), targetY, TEST_LOCATION );
6536   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6537   END_TEST;
6538 }
6539
6540 int UtcDaliAnimationAnimateToActorScaleZP(void)
6541 {
6542   TestApplication application;
6543
6544   Actor actor = Actor::New();
6545   Stage::GetCurrent().Add(actor);
6546   float startValue(1.0f);
6547   DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION );
6548   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6549   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6550   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), startValue, TEST_LOCATION );
6551
6552   // Build the animation
6553   float durationSeconds(1.0f);
6554   Animation animation = Animation::New(durationSeconds);
6555   float targetZ(-1000.0f);
6556   animation.AnimateTo( Property(actor, Actor::Property::SCALE_Z), targetZ );
6557
6558   float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f);
6559
6560   // Start the animation
6561   animation.Play();
6562
6563   bool signalReceived(false);
6564   AnimationFinishCheck finishCheck(signalReceived);
6565   animation.FinishedSignal().Connect(&application, finishCheck);
6566
6567   application.SendNotification();
6568   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6569
6570   // We didn't expect the animation to finish yet
6571   application.SendNotification();
6572   finishCheck.CheckSignalNotReceived();
6573   DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION );
6574   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6575   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6576   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), fiftyPercentProgress, TEST_LOCATION );
6577
6578   application.SendNotification();
6579   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6580
6581   // We did expect the animation to finish
6582   application.SendNotification();
6583   finishCheck.CheckSignalReceived();
6584   DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION );
6585   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_X), startValue, TEST_LOCATION );
6586   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Y), startValue, TEST_LOCATION );
6587   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::SCALE_Z), targetZ, TEST_LOCATION );
6588   END_TEST;
6589 }
6590
6591 int UtcDaliAnimationAnimateToActorColorP(void)
6592 {
6593   TestApplication application;
6594
6595   Actor actor = Actor::New();
6596   Stage::GetCurrent().Add(actor);
6597   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6598
6599   // Build the animation
6600   float durationSeconds(1.0f);
6601   Animation animation = Animation::New(durationSeconds);
6602   Vector4 targetColor(Color::RED);
6603   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor );
6604
6605   Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
6606   Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
6607
6608   // Start the animation
6609   animation.Play();
6610
6611   bool signalReceived(false);
6612   AnimationFinishCheck finishCheck(signalReceived);
6613   animation.FinishedSignal().Connect(&application, finishCheck);
6614
6615   application.SendNotification();
6616   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6617
6618   // We didn't expect the animation to finish yet
6619   application.SendNotification();
6620   finishCheck.CheckSignalNotReceived();
6621   DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
6622
6623   application.SendNotification();
6624   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6625
6626   // We did expect the animation to finish
6627   application.SendNotification();
6628   finishCheck.CheckSignalReceived();
6629   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6630
6631   // Reset everything
6632   finishCheck.Reset();
6633   actor.SetColor(Color::WHITE);
6634   application.SendNotification();
6635   application.Render(0);
6636   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6637
6638   // Repeat with a different (ease-in) alpha function
6639   animation = Animation::New(durationSeconds);
6640   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::EaseIn);
6641   animation.FinishedSignal().Connect(&application, finishCheck);
6642   animation.Play();
6643
6644   application.SendNotification();
6645   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
6646
6647   // We didn't expect the animation to finish yet
6648   application.SendNotification();
6649   finishCheck.CheckSignalNotReceived();
6650
6651   // The color should have changed less, than with a linear alpha function
6652   Vector4 current(actor.GetCurrentColor());
6653   DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
6654   DALI_TEST_CHECK( current.y < 1.0f );
6655   DALI_TEST_CHECK( current.y > tenPercentProgress.y );
6656   DALI_TEST_CHECK( current.z  < 1.0f );
6657   DALI_TEST_CHECK( current.z  > tenPercentProgress.z );
6658   DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
6659
6660   application.SendNotification();
6661   application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
6662
6663   // We did expect the animation to finish
6664   application.SendNotification();
6665   finishCheck.CheckSignalReceived();
6666   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6667
6668   // Reset everything
6669   finishCheck.Reset();
6670   actor.SetColor(Color::WHITE);
6671   application.SendNotification();
6672   application.Render(0);
6673   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
6674
6675   // Repeat with a shorter animator duration
6676   float animatorDuration = 0.5f;
6677   animation = Animation::New(durationSeconds);
6678   animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration));
6679   animation.FinishedSignal().Connect(&application, finishCheck);
6680   animation.Play();
6681
6682   application.SendNotification();
6683   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
6684
6685   // We didn't expect the animation to finish yet
6686   application.SendNotification();
6687   finishCheck.CheckSignalNotReceived();
6688   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
6689
6690   application.SendNotification();
6691   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
6692
6693   // We didn't expect the animation to finish yet
6694   application.SendNotification();
6695   finishCheck.CheckSignalNotReceived();
6696   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6697
6698   application.SendNotification();
6699   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6700
6701   // We did expect the animation to finish
6702   application.SendNotification();
6703   finishCheck.CheckSignalReceived();
6704   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
6705   END_TEST;
6706 }
6707
6708 int UtcDaliAnimationAnimateToActorColorRedP(void)
6709 {
6710   TestApplication application;
6711
6712   Actor actor = Actor::New();
6713   Stage::GetCurrent().Add(actor);
6714   float startValue(1.0f);
6715   DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION );
6716   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6717   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6718   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6719   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6720
6721   // Build the animation
6722   float durationSeconds(1.0f);
6723   Animation animation = Animation::New(durationSeconds);
6724   float targetRed(0.5f);
6725   animation.AnimateTo( Property(actor, Actor::Property::COLOR_RED), targetRed );
6726
6727   float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f);
6728
6729   // Start the animation
6730   animation.Play();
6731
6732   bool signalReceived(false);
6733   AnimationFinishCheck finishCheck(signalReceived);
6734   animation.FinishedSignal().Connect(&application, finishCheck);
6735
6736   application.SendNotification();
6737   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6738
6739   // We didn't expect the animation to finish yet
6740   application.SendNotification();
6741   finishCheck.CheckSignalNotReceived();
6742   DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION );
6743   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   fiftyPercentProgress, 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
6748   application.SendNotification();
6749   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6750
6751   // We did expect the animation to finish
6752   application.SendNotification();
6753   finishCheck.CheckSignalReceived();
6754   DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION );
6755   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   targetRed,  TEST_LOCATION );
6756   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6757   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6758   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6759   END_TEST;
6760 }
6761
6762 int UtcDaliAnimationAnimateToActorColorGreeN(void)
6763 {
6764   TestApplication application;
6765
6766   Actor actor = Actor::New();
6767   Stage::GetCurrent().Add(actor);
6768   float startValue(1.0f);
6769   DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION );
6770   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6771   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6772   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6773   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6774
6775   // Build the animation
6776   float durationSeconds(1.0f);
6777   Animation animation = Animation::New(durationSeconds);
6778   float targetGreen(0.5f);
6779   animation.AnimateTo( Property(actor, Actor::Property::COLOR_GREEN), targetGreen );
6780
6781   float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f);
6782
6783   // Start the animation
6784   animation.Play();
6785
6786   bool signalReceived(false);
6787   AnimationFinishCheck finishCheck(signalReceived);
6788   animation.FinishedSignal().Connect(&application, finishCheck);
6789
6790   application.SendNotification();
6791   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6792
6793   // We didn't expect the animation to finish yet
6794   application.SendNotification();
6795   finishCheck.CheckSignalNotReceived();
6796   DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, 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), fiftyPercentProgress, 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
6802   application.SendNotification();
6803   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6804
6805   // We did expect the animation to finish
6806   application.SendNotification();
6807   finishCheck.CheckSignalReceived();
6808   DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION );
6809   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
6810   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), targetGreen, TEST_LOCATION );
6811   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
6812   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,  TEST_LOCATION );
6813   END_TEST;
6814 }
6815
6816 int UtcDaliAnimationAnimateToActorColorBlueP(void)
6817 {
6818   TestApplication application;
6819
6820   Actor actor = Actor::New();
6821   Stage::GetCurrent().Add(actor);
6822   float startValue(1.0f);
6823   DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION );
6824   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6825   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6827   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6828
6829   // Build the animation
6830   float durationSeconds(1.0f);
6831   Animation animation = Animation::New(durationSeconds);
6832   float targetBlue(0.5f);
6833   animation.AnimateTo( Property(actor, Actor::Property::COLOR_BLUE), targetBlue );
6834
6835   float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f);
6836
6837   // Start the animation
6838   animation.Play();
6839
6840   bool signalReceived(false);
6841   AnimationFinishCheck finishCheck(signalReceived);
6842   animation.FinishedSignal().Connect(&application, finishCheck);
6843
6844   application.SendNotification();
6845   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6846
6847   // We didn't expect the animation to finish yet
6848   application.SendNotification();
6849   finishCheck.CheckSignalNotReceived();
6850   DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, 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),  fiftyPercentProgress, TEST_LOCATION );
6854   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue,           TEST_LOCATION );
6855
6856   application.SendNotification();
6857   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6858
6859   // We did expect the animation to finish
6860   application.SendNotification();
6861   finishCheck.CheckSignalReceived();
6862   DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION );
6863   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6864   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6865   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  targetBlue, TEST_LOCATION );
6866   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6867   END_TEST;
6868 }
6869
6870 int UtcDaliAnimationAnimateToActorColorAlphaP(void)
6871 {
6872   TestApplication application;
6873
6874   Actor actor = Actor::New();
6875   Stage::GetCurrent().Add(actor);
6876   float startValue(1.0f);
6877   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
6878   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
6879   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
6880   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
6881   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
6882
6883   // Build the animation
6884   float durationSeconds(1.0f);
6885   Animation animation = Animation::New(durationSeconds);
6886   float targetAlpha(0.5f);
6887   animation.AnimateTo( Property(actor, Actor::Property::COLOR_ALPHA), targetAlpha );
6888
6889   float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f);
6890
6891   // Start the animation
6892   animation.Play();
6893
6894   bool signalReceived(false);
6895   AnimationFinishCheck finishCheck(signalReceived);
6896   animation.FinishedSignal().Connect(&application, finishCheck);
6897
6898   application.SendNotification();
6899   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
6900
6901   // We didn't expect the animation to finish yet
6902   application.SendNotification();
6903   finishCheck.CheckSignalNotReceived();
6904   DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, 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), fiftyPercentProgress, TEST_LOCATION );
6909
6910   application.SendNotification();
6911   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
6912
6913   // We did expect the animation to finish
6914   application.SendNotification();
6915   finishCheck.CheckSignalReceived();
6916   DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION );
6917   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue,  TEST_LOCATION );
6918   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue,  TEST_LOCATION );
6919   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue,  TEST_LOCATION );
6920   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), targetAlpha, TEST_LOCATION );
6921   END_TEST;
6922 }
6923
6924 int UtcDaliAnimationKeyFrames01P(void)
6925 {
6926   TestApplication application;
6927
6928   KeyFrames keyFrames = KeyFrames::New();
6929   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6930
6931   keyFrames.Add(0.0f, 0.1f);
6932   keyFrames.Add(0.2f, 0.5f);
6933   keyFrames.Add(0.4f, 0.0f);
6934   keyFrames.Add(0.6f, 1.0f);
6935   keyFrames.Add(0.8f, 0.7f);
6936   keyFrames.Add(1.0f, 0.9f);
6937
6938   DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION);
6939
6940   try
6941   {
6942     keyFrames.Add(1.9f, false);
6943   }
6944   catch (Dali::DaliException& e)
6945   {
6946     DALI_TEST_PRINT_ASSERT( e );
6947     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6948   }
6949   END_TEST;
6950 }
6951
6952 int UtcDaliAnimationKeyFrames02P(void)
6953 {
6954   TestApplication application;
6955
6956   KeyFrames keyFrames = KeyFrames::New();
6957   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6958
6959   keyFrames.Add(0.0f, true);
6960   keyFrames.Add(0.2f, false);
6961   keyFrames.Add(0.4f, false);
6962   keyFrames.Add(0.6f, true);
6963   keyFrames.Add(0.8f, true);
6964   keyFrames.Add(1.0f, false);
6965
6966   DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION);
6967
6968   try
6969   {
6970     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6971   }
6972   catch (Dali::DaliException& e)
6973   {
6974     DALI_TEST_PRINT_ASSERT( e );
6975     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
6976   }
6977   END_TEST;
6978 }
6979
6980 int UtcDaliAnimationKeyFrames03P(void)
6981 {
6982   TestApplication application;
6983
6984   KeyFrames keyFrames = KeyFrames::New();
6985   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
6986
6987   keyFrames.Add(0.0f, Vector2(0.0f, 0.0f));
6988   keyFrames.Add(0.2f, Vector2(1.0f, 1.0f));
6989   keyFrames.Add(0.4f, Vector2(2.0f, 2.0f));
6990   keyFrames.Add(0.6f, Vector2(3.0f, 5.0f));
6991   keyFrames.Add(0.8f, Vector2(4.0f, 3.0f));
6992   keyFrames.Add(1.0f, Vector2(6.0f, 2.0f));
6993
6994   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION);
6995
6996   try
6997   {
6998     keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f));
6999   }
7000   catch (Dali::DaliException& e)
7001   {
7002     DALI_TEST_PRINT_ASSERT( e );
7003     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7004   }
7005   END_TEST;
7006 }
7007
7008 int UtcDaliAnimationKeyFrames04P(void)
7009 {
7010   TestApplication application;
7011
7012   KeyFrames keyFrames = KeyFrames::New();
7013   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7014
7015   keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f));
7016   keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f));
7017   keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f));
7018   keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f));
7019   keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f));
7020   keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f));
7021
7022   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION);
7023
7024   try
7025   {
7026     keyFrames.Add(0.7f, 1.0f);
7027   }
7028   catch (Dali::DaliException& e)
7029   {
7030     DALI_TEST_PRINT_ASSERT( e );
7031     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7032   }
7033   END_TEST;
7034 }
7035
7036 int UtcDaliAnimationKeyFrames05P(void)
7037 {
7038   TestApplication application;
7039
7040   KeyFrames keyFrames = KeyFrames::New();
7041   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7042
7043   keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f));
7044   keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7045   keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f));
7046   keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f));
7047   keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f));
7048   keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f));
7049
7050   DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION);
7051
7052   try
7053   {
7054     keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
7055   }
7056   catch (Dali::DaliException& e)
7057   {
7058     DALI_TEST_PRINT_ASSERT( e );
7059     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7060   }
7061   END_TEST;
7062 }
7063
7064 int UtcDaliAnimationKeyFrames06P(void)
7065 {
7066   TestApplication application;
7067
7068   KeyFrames keyFrames = KeyFrames::New();
7069   DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
7070
7071   keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
7072   keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
7073   keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
7074   keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
7075   keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
7076   keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
7077
7078   DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
7079
7080   try
7081   {
7082     keyFrames.Add(0.7f, 1.1f);
7083   }
7084   catch (Dali::DaliException& e)
7085   {
7086     DALI_TEST_PRINT_ASSERT( e );
7087     DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION);
7088   }
7089   END_TEST;
7090 }
7091
7092 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
7093 {
7094   TestApplication application;
7095
7096   float startValue(1.0f);
7097   Actor actor = Actor::New();
7098   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7099   Stage::GetCurrent().Add(actor);
7100
7101   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7102   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7103   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7104   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7105   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7106
7107   // Build the animation
7108   float durationSeconds(1.0f);
7109   Animation animation = Animation::New(durationSeconds);
7110
7111   KeyFrames keyFrames = KeyFrames::New();
7112   keyFrames.Add(0.0f, 0.1f);
7113   keyFrames.Add(0.2f, 0.5f);
7114   keyFrames.Add(0.4f, 0.0f);
7115   keyFrames.Add(0.6f, 1.0f);
7116   keyFrames.Add(0.8f, 0.7f);
7117   keyFrames.Add(1.0f, 0.9f);
7118
7119   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames );
7120
7121   // Start the animation
7122   animation.Play();
7123
7124   bool signalReceived(false);
7125   AnimationFinishCheck finishCheck(signalReceived);
7126   animation.FinishedSignal().Connect(&application, finishCheck);
7127   application.SendNotification();
7128   application.Render(0);
7129   application.SendNotification();
7130   finishCheck.CheckSignalNotReceived();
7131   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
7132
7133   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7134   application.SendNotification();
7135   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7136   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7137   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7138   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION );
7139   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION );
7140
7141   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
7142   application.SendNotification();
7143   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7144   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7145   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7146   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION );
7147   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION );
7148
7149   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
7150   application.SendNotification();
7151   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7152   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7153   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7154   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
7155   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
7156
7157   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
7158   application.SendNotification();
7159   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7160   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7161   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7162   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
7163   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
7164
7165   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
7166   application.SendNotification();
7167   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7168   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7169   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7170   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION );
7171   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION );
7172
7173   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
7174   application.SendNotification();
7175   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7176   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7177   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7178   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
7179   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
7180
7181   // We did expect the animation to finish
7182
7183   finishCheck.CheckSignalReceived();
7184   END_TEST;
7185 }
7186
7187 int UtcDaliAnimationAnimateBetweenActorColorAlphaCubicP(void)
7188 {
7189   TestApplication application;
7190
7191   float startValue(1.0f);
7192   Actor actor = Actor::New();
7193   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7194   Stage::GetCurrent().Add(actor);
7195
7196   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7197   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7198   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7199   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7200   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7201
7202   // Build the animation
7203   float durationSeconds(1.0f);
7204   Animation animation = Animation::New(durationSeconds);
7205
7206   KeyFrames keyFrames = KeyFrames::New();
7207   keyFrames.Add(0.0f, 0.1f);
7208   keyFrames.Add(0.2f, 0.5f);
7209   keyFrames.Add(0.4f, 0.0f);
7210   keyFrames.Add(0.6f, 1.0f);
7211   keyFrames.Add(0.8f, 0.7f);
7212   keyFrames.Add(1.0f, 0.9f);
7213
7214   animation.AnimateBetween( Property(actor, Actor::Property::COLOR_ALPHA), keyFrames, Animation::Cubic );
7215
7216   // Start the animation
7217   animation.Play();
7218
7219   bool signalReceived(false);
7220   AnimationFinishCheck finishCheck(signalReceived);
7221   animation.FinishedSignal().Connect(&application, finishCheck);
7222   application.SendNotification();
7223   application.Render(0);
7224   application.SendNotification();
7225   finishCheck.CheckSignalNotReceived();
7226   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION );
7227
7228   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
7229   application.SendNotification();
7230   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7231   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7232   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7233   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.36f, 0.01f, TEST_LOCATION );
7234   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.36f, 0.01f, TEST_LOCATION );
7235
7236   application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
7237   application.SendNotification();
7238   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7239   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7240   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7241   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.21f, 0.01f, TEST_LOCATION );
7242   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.21f, 0.01f, TEST_LOCATION );
7243
7244   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 40% progress */);
7245   application.SendNotification();
7246   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7247   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7248   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7249   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION );
7250   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION );
7251
7252   application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 80% progress */);
7253   application.SendNotification();
7254   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7255   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7256   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7257   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION );
7258   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION );
7259
7260   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 90% progress */);
7261   application.SendNotification();
7262   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7263   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7264   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7265   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.76f, 0.01f, TEST_LOCATION );
7266   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.76f, 0.01f, TEST_LOCATION );
7267
7268   application.Render(static_cast<unsigned int>(durationSeconds*100.0f)+1/* 100% progress */);
7269   application.SendNotification();
7270   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7271   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7272   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7273   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION );
7274   DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION );
7275
7276   // We did expect the animation to finish
7277
7278   finishCheck.CheckSignalReceived();
7279   END_TEST;
7280 }
7281
7282 int UtcDaliAnimationAnimateBetweenActorColorP(void)
7283 {
7284   TestApplication application;
7285
7286   float startValue(1.0f);
7287   Actor actor = Actor::New();
7288   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7289   Stage::GetCurrent().Add(actor);
7290
7291   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7292   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7293   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7294   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7295   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7296
7297   // Build the animation
7298   float durationSeconds(1.0f);
7299   Animation animation = Animation::New(durationSeconds);
7300
7301   KeyFrames keyFrames = KeyFrames::New();
7302   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7303   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7304   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7305
7306   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames );
7307
7308   // Start the animation
7309   animation.Play();
7310
7311   bool signalReceived(false);
7312   AnimationFinishCheck finishCheck(signalReceived);
7313   animation.FinishedSignal().Connect(&application, finishCheck);
7314   application.SendNotification();
7315   application.Render(0);
7316   application.SendNotification();
7317   finishCheck.CheckSignalNotReceived();
7318   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7319   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7320   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7321   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7322
7323   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7324   application.SendNotification();
7325   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7326   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7327   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7328   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7329
7330   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7331   application.SendNotification();
7332   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7333   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7334   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7335   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7336
7337   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7338   application.SendNotification();
7339   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7340   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7341   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7342   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7343
7344   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7345   application.SendNotification();
7346   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7347   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7348   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7349   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7350
7351   // We did expect the animation to finish
7352
7353   finishCheck.CheckSignalReceived();
7354   END_TEST;
7355 }
7356
7357 int UtcDaliAnimationAnimateBetweenActorColorCubicP(void)
7358 {
7359   TestApplication application;
7360
7361   float startValue(1.0f);
7362   Actor actor = Actor::New();
7363   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7364   Stage::GetCurrent().Add(actor);
7365
7366   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7367   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7368   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7369   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7370   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7371
7372   // Build the animation
7373   float durationSeconds(1.0f);
7374   Animation animation = Animation::New(durationSeconds);
7375
7376   KeyFrames keyFrames = KeyFrames::New();
7377   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7378   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7379   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7380
7381   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, Animation::Cubic );
7382
7383   // Start the animation
7384   animation.Play();
7385
7386   bool signalReceived(false);
7387   AnimationFinishCheck finishCheck(signalReceived);
7388   animation.FinishedSignal().Connect(&application, finishCheck);
7389   application.SendNotification();
7390   application.Render(0);
7391   application.SendNotification();
7392   finishCheck.CheckSignalNotReceived();
7393   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7394   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7395   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7396   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7397
7398   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7399   application.SendNotification();
7400   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
7401   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
7402   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
7403   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
7404
7405   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7406   application.SendNotification();
7407   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7408   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7409   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7410   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7411
7412   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7413   application.SendNotification();
7414   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
7415   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
7416   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
7417   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
7418
7419   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7420   application.SendNotification();
7421   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7422   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7423   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7424   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7425
7426   // We did expect the animation to finish
7427
7428   finishCheck.CheckSignalReceived();
7429   END_TEST;
7430 }
7431
7432 int UtcDaliAnimationAnimateBetweenActorVisibleP(void)
7433 {
7434   TestApplication application;
7435
7436   Actor actor = Actor::New();
7437   AngleAxis aa(Degree(90), Vector3::XAXIS);
7438   actor.SetOrientation(aa.angle, aa.axis);
7439   Stage::GetCurrent().Add(actor);
7440
7441   application.SendNotification();
7442   application.Render(0);
7443
7444   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
7445
7446   // Build the animation
7447   float durationSeconds(1.0f);
7448   Animation animation = Animation::New(durationSeconds);
7449
7450   KeyFrames keyFrames = KeyFrames::New();
7451   keyFrames.Add(0.0f, false);
7452   keyFrames.Add(0.2f, true);
7453   keyFrames.Add(0.4f, true);
7454   keyFrames.Add(0.8f, false);
7455   keyFrames.Add(1.0f, true);
7456
7457   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames );
7458
7459   // Start the animation
7460   animation.Play();
7461
7462   bool signalReceived(false);
7463   AnimationFinishCheck finishCheck(signalReceived);
7464   animation.FinishedSignal().Connect(&application, finishCheck);
7465   application.SendNotification();
7466   application.SendNotification();
7467   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7468   application.SendNotification();
7469   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7470   application.SendNotification();
7471
7472   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
7473   finishCheck.CheckSignalReceived();
7474   END_TEST;
7475 }
7476
7477 int UtcDaliAnimationAnimateBetweenActorVisibleCubicP(void)
7478 {
7479   TestApplication application;
7480
7481   Actor actor = Actor::New();
7482   AngleAxis aa(Degree(90), Vector3::XAXIS);
7483   actor.SetOrientation(aa.angle, aa.axis);
7484   Stage::GetCurrent().Add(actor);
7485
7486   application.SendNotification();
7487   application.Render(0);
7488
7489   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
7490
7491   // Build the animation
7492   float durationSeconds(1.0f);
7493   Animation animation = Animation::New(durationSeconds);
7494
7495   KeyFrames keyFrames = KeyFrames::New();
7496   keyFrames.Add(0.0f, false);
7497   keyFrames.Add(0.2f, true);
7498   keyFrames.Add(0.4f, true);
7499   keyFrames.Add(0.8f, false);
7500   keyFrames.Add(1.0f, true);
7501
7502   //Cubic interpolation for boolean values should be ignored
7503   animation.AnimateBetween( Property(actor, Actor::Property::VISIBLE), keyFrames, Animation::Cubic );
7504
7505   // Start the animation
7506   animation.Play();
7507
7508   bool signalReceived(false);
7509   AnimationFinishCheck finishCheck(signalReceived);
7510   animation.FinishedSignal().Connect(&application, finishCheck);
7511   application.SendNotification();
7512   application.SendNotification();
7513   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7514   application.SendNotification();
7515   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7516   application.SendNotification();
7517
7518   DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION);
7519   finishCheck.CheckSignalReceived();
7520   END_TEST;
7521 }
7522
7523 int UtcDaliAnimationAnimateBetweenActorOrientation01P(void)
7524 {
7525   TestApplication application;
7526
7527   Actor actor = Actor::New();
7528   AngleAxis aa(Degree(90), Vector3::XAXIS);
7529   actor.SetOrientation(aa.angle, aa.axis);
7530   Stage::GetCurrent().Add(actor);
7531
7532   application.SendNotification();
7533   application.Render(0);
7534   Quaternion start(Radian(aa.angle), aa.axis);
7535   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7536
7537   // Build the animation
7538   float durationSeconds(1.0f);
7539   Animation animation = Animation::New(durationSeconds);
7540
7541   KeyFrames keyFrames = KeyFrames::New();
7542   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
7543
7544   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
7545
7546   // Start the animation
7547   animation.Play();
7548
7549   bool signalReceived(false);
7550   AnimationFinishCheck finishCheck(signalReceived);
7551   animation.FinishedSignal().Connect(&application, finishCheck);
7552   application.SendNotification();
7553   application.SendNotification();
7554   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7555   application.SendNotification();
7556   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7557   application.SendNotification();
7558
7559   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
7560
7561   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7562   finishCheck.CheckSignalReceived();
7563   END_TEST;
7564 }
7565
7566 int UtcDaliAnimationAnimateBetweenActorOrientation02P(void)
7567 {
7568   TestApplication application;
7569
7570   Actor actor = Actor::New();
7571   AngleAxis aa(Degree(90), Vector3::XAXIS);
7572   actor.SetOrientation(aa.angle, aa.axis);
7573   application.SendNotification();
7574   application.Render(0);
7575   Stage::GetCurrent().Add(actor);
7576
7577   Quaternion start(Radian(aa.angle), aa.axis);
7578   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7579
7580   // Build the animation
7581   float durationSeconds(1.0f);
7582   Animation animation = Animation::New(durationSeconds);
7583
7584   KeyFrames keyFrames = KeyFrames::New();
7585   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
7586   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
7587   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
7588
7589   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames );
7590
7591   // Start the animation
7592   animation.Play();
7593
7594   bool signalReceived(false);
7595   AnimationFinishCheck finishCheck(signalReceived);
7596   animation.FinishedSignal().Connect(&application, finishCheck);
7597   application.SendNotification();
7598   application.Render(0);
7599   application.SendNotification();
7600   finishCheck.CheckSignalNotReceived();
7601
7602   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7603   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7604
7605   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7606   application.SendNotification();
7607   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
7608   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7609
7610   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7611   application.SendNotification();
7612   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
7613   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7614
7615   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7616   application.SendNotification();
7617   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
7618   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7619
7620   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7621   application.SendNotification();
7622   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
7623   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7624
7625   // We did expect the animation to finish
7626
7627   finishCheck.CheckSignalReceived();
7628   END_TEST;
7629 }
7630
7631 int UtcDaliAnimationAnimateBetweenActorOrientation01CubicP(void)
7632 {
7633   TestApplication application;
7634
7635   Actor actor = Actor::New();
7636   AngleAxis aa(Degree(90), Vector3::XAXIS);
7637   actor.SetOrientation(aa.angle, aa.axis);
7638   Stage::GetCurrent().Add(actor);
7639
7640   application.SendNotification();
7641   application.Render(0);
7642   Quaternion start(Radian(aa.angle), aa.axis);
7643   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7644
7645   // Build the animation
7646   float durationSeconds(1.0f);
7647   Animation animation = Animation::New(durationSeconds);
7648
7649   KeyFrames keyFrames = KeyFrames::New();
7650   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS));
7651
7652   //Cubic interpolation should be ignored for quaternions
7653   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7654
7655   // Start the animation
7656   animation.Play();
7657
7658   bool signalReceived(false);
7659   AnimationFinishCheck finishCheck(signalReceived);
7660   animation.FinishedSignal().Connect(&application, finishCheck);
7661   application.SendNotification();
7662   application.SendNotification();
7663   application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
7664   application.SendNotification();
7665   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
7666   application.SendNotification();
7667
7668   Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
7669
7670   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7671   finishCheck.CheckSignalReceived();
7672   END_TEST;
7673 }
7674
7675 int UtcDaliAnimationAnimateBetweenActorOrientation02CubicP(void)
7676 {
7677   TestApplication application;
7678
7679   Actor actor = Actor::New();
7680   AngleAxis aa(Degree(90), Vector3::XAXIS);
7681   actor.SetOrientation(aa.angle, aa.axis);
7682   application.SendNotification();
7683   application.Render(0);
7684   Stage::GetCurrent().Add(actor);
7685
7686   Quaternion start(Radian(aa.angle), aa.axis);
7687   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), start, 0.001f, TEST_LOCATION );
7688
7689   // Build the animation
7690   float durationSeconds(1.0f);
7691   Animation animation = Animation::New(durationSeconds);
7692
7693   KeyFrames keyFrames = KeyFrames::New();
7694   keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS));
7695   keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS));
7696   keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS));
7697
7698   //Cubic interpolation should be ignored for quaternions
7699   animation.AnimateBetween( Property(actor, Actor::Property::ORIENTATION), keyFrames, Animation::Cubic );
7700
7701   // Start the animation
7702   animation.Play();
7703
7704   bool signalReceived(false);
7705   AnimationFinishCheck finishCheck(signalReceived);
7706   animation.FinishedSignal().Connect(&application, finishCheck);
7707   application.SendNotification();
7708   application.Render(0);
7709   application.SendNotification();
7710   finishCheck.CheckSignalNotReceived();
7711
7712   Quaternion check(Radian(Degree(60)), Vector3::XAXIS);
7713   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7714
7715   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7716   application.SendNotification();
7717   check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
7718   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7719
7720   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7721   application.SendNotification();
7722   check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
7723   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7724
7725   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7726   application.SendNotification();
7727   check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
7728   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7729
7730   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7731   application.SendNotification();
7732   check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
7733   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
7734
7735   // We did expect the animation to finish
7736
7737   finishCheck.CheckSignalReceived();
7738   END_TEST;
7739 }
7740
7741 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctioN(void)
7742 {
7743   TestApplication application;
7744
7745   float startValue(1.0f);
7746   Actor actor = Actor::New();
7747   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7748   Stage::GetCurrent().Add(actor);
7749
7750   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7751   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7752   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7753   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7754   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7755
7756   // Build the animation
7757   float durationSeconds(1.0f);
7758   Animation animation = Animation::New(durationSeconds);
7759
7760   KeyFrames keyFrames = KeyFrames::New();
7761   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7762   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7763   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7764
7765   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear );
7766
7767   // Start the animation
7768   animation.Play();
7769
7770   bool signalReceived(false);
7771   AnimationFinishCheck finishCheck(signalReceived);
7772   animation.FinishedSignal().Connect(&application, finishCheck);
7773   application.SendNotification();
7774   application.Render(0);
7775   application.SendNotification();
7776   finishCheck.CheckSignalNotReceived();
7777   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7778   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7779   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7780   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7781
7782   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7783   application.SendNotification();
7784   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7785   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7786   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7787   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7788
7789   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7790   application.SendNotification();
7791   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7792   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7793   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7794   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7795
7796   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7797   application.SendNotification();
7798   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7799   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7800   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7801   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7802
7803   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7804   application.SendNotification();
7805   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7806   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7807   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7808   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7809
7810   // We did expect the animation to finish
7811
7812   finishCheck.CheckSignalReceived();
7813   END_TEST;
7814 }
7815
7816 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void)
7817 {
7818   TestApplication application;
7819
7820   float startValue(1.0f);
7821   Actor actor = Actor::New();
7822   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7823   Stage::GetCurrent().Add(actor);
7824
7825   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7826   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7827   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7828   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7829   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7830
7831   // Build the animation
7832   float durationSeconds(1.0f);
7833   Animation animation = Animation::New(durationSeconds);
7834
7835   KeyFrames keyFrames = KeyFrames::New();
7836   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7837   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7838   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7839
7840   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, Animation::Cubic );
7841
7842   // Start the animation
7843   animation.Play();
7844
7845   bool signalReceived(false);
7846   AnimationFinishCheck finishCheck(signalReceived);
7847   animation.FinishedSignal().Connect(&application, finishCheck);
7848   application.SendNotification();
7849   application.Render(0);
7850   application.SendNotification();
7851   finishCheck.CheckSignalNotReceived();
7852   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7853   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7854   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7855   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7856
7857   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
7858   application.SendNotification();
7859   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
7860   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
7861   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
7862   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
7863
7864   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
7865   application.SendNotification();
7866   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7867   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7868   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7869   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7870
7871   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
7872   application.SendNotification();
7873   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
7874   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
7875   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
7876   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
7877
7878   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
7879   application.SendNotification();
7880   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7881   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7882   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7883   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7884
7885   // We did expect the animation to finish
7886
7887   finishCheck.CheckSignalReceived();
7888   END_TEST;
7889 }
7890
7891 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodP(void)
7892 {
7893   TestApplication application;
7894
7895   float startValue(1.0f);
7896   Actor actor = Actor::New();
7897   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7898   Stage::GetCurrent().Add(actor);
7899
7900   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7901   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7902   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7903   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7904   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7905
7906   // Build the animation
7907   float durationSeconds(1.0f);
7908   float delay = 0.5f;
7909   Animation animation = Animation::New(durationSeconds);
7910
7911   KeyFrames keyFrames = KeyFrames::New();
7912   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7913   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7914   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7915
7916   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ) );
7917
7918   // Start the animation
7919   animation.Play();
7920
7921   bool signalReceived(false);
7922   AnimationFinishCheck finishCheck(signalReceived);
7923   animation.FinishedSignal().Connect(&application, finishCheck);
7924   application.SendNotification();
7925
7926   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
7927   application.SendNotification();
7928   finishCheck.CheckSignalNotReceived();
7929   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
7930   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
7931   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
7932   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
7933
7934   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
7935   application.SendNotification();
7936   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
7937   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
7938   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
7939   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
7940
7941   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
7942   application.SendNotification();
7943   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
7944   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
7945   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
7946   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
7947
7948   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
7949   application.SendNotification();
7950   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
7951   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
7952   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
7953   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
7954
7955   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
7956   application.SendNotification();
7957   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
7958   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
7959   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
7960   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
7961
7962   // We did expect the animation to finish
7963
7964   finishCheck.CheckSignalReceived();
7965   END_TEST;
7966 }
7967
7968 int UtcDaliAnimationAnimateBetweenActorColorTimePeriodCubicP(void)
7969 {
7970   TestApplication application;
7971
7972   float startValue(1.0f);
7973   Actor actor = Actor::New();
7974   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
7975   Stage::GetCurrent().Add(actor);
7976
7977   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
7978   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
7979   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
7980   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
7981   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
7982
7983   // Build the animation
7984   float durationSeconds(1.0f);
7985   float delay = 0.5f;
7986   Animation animation = Animation::New(durationSeconds);
7987
7988   KeyFrames keyFrames = KeyFrames::New();
7989   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
7990   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
7991   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
7992
7993   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
7994
7995   // Start the animation
7996   animation.Play();
7997
7998   bool signalReceived(false);
7999   AnimationFinishCheck finishCheck(signalReceived);
8000   animation.FinishedSignal().Connect(&application, finishCheck);
8001   application.SendNotification();
8002
8003   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8004   application.SendNotification();
8005   finishCheck.CheckSignalNotReceived();
8006   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8007   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8008   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8009   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8010
8011   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8012   application.SendNotification();
8013   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8014   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8015   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8016   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8017
8018   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8019   application.SendNotification();
8020   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8021   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8022   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8023   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8024
8025   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8026   application.SendNotification();
8027   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
8028   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
8029   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
8030   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
8031
8032   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8033   application.SendNotification();
8034   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8035   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8036   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8037   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8038
8039   // We did expect the animation to finish
8040
8041   finishCheck.CheckSignalReceived();
8042   END_TEST;
8043 }
8044
8045 int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void)
8046 {
8047   TestApplication application;
8048
8049   float startValue(1.0f);
8050   float delay = 0.5f;
8051   Actor actor = Actor::New();
8052   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8053   Stage::GetCurrent().Add(actor);
8054
8055   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8056   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8057   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8058   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8059   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8060
8061   // Build the animation
8062   float durationSeconds(1.0f);
8063   Animation animation = Animation::New(durationSeconds);
8064
8065   KeyFrames keyFrames = KeyFrames::New();
8066   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8067   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8068   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8069
8070   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) );
8071
8072   // Start the animation
8073   animation.Play();
8074
8075   bool signalReceived(false);
8076   AnimationFinishCheck finishCheck(signalReceived);
8077   animation.FinishedSignal().Connect(&application, finishCheck);
8078   application.SendNotification();
8079
8080   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8081   application.SendNotification();
8082   finishCheck.CheckSignalNotReceived();
8083   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8084   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8085   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8086   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8087
8088   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8089   application.SendNotification();
8090   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.5f, 0.01f, TEST_LOCATION );
8091   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION );
8092   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.5f, 0.01f, TEST_LOCATION );
8093   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION );
8094
8095   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8096   application.SendNotification();
8097   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8098   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8099   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8100   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8101
8102   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8103   application.SendNotification();
8104   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.95f, 0.01f, TEST_LOCATION );
8105   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION );
8106   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85f, 0.01f, TEST_LOCATION );
8107   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION );
8108
8109   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8110   application.SendNotification();
8111   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8112   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8113   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8114   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8115
8116   // We did expect the animation to finish
8117
8118   finishCheck.CheckSignalReceived();
8119   END_TEST;
8120 }
8121
8122 int P(void)
8123 {
8124   TestApplication application;
8125
8126   float startValue(1.0f);
8127   Actor actor = Actor::New();
8128   actor.SetColor(Vector4(startValue, startValue, startValue, startValue));
8129   Stage::GetCurrent().Add(actor);
8130
8131   DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION );
8132   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   startValue, TEST_LOCATION );
8133   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), startValue, TEST_LOCATION );
8134   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  startValue, TEST_LOCATION );
8135   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), startValue, TEST_LOCATION );
8136
8137   // Build the animation
8138   float durationSeconds(1.0f);
8139   float delay = 0.5f;
8140   Animation animation = Animation::New(durationSeconds);
8141
8142   KeyFrames keyFrames = KeyFrames::New();
8143   keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f));
8144   keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f));
8145   keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
8146
8147   animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic );
8148
8149   // Start the animation
8150   animation.Play();
8151
8152   bool signalReceived(false);
8153   AnimationFinishCheck finishCheck(signalReceived);
8154   animation.FinishedSignal().Connect(&application, finishCheck);
8155   application.SendNotification();
8156
8157   application.Render(static_cast<unsigned int>(delay*1000.0f)/* 0% progress */);
8158   application.SendNotification();
8159   finishCheck.CheckSignalNotReceived();
8160   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.1f, 0.01f, TEST_LOCATION );
8161   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION );
8162   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.3f, 0.01f, TEST_LOCATION );
8163   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION );
8164
8165   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 25% progress */);
8166   application.SendNotification();
8167   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.55f, 0.01f, TEST_LOCATION );
8168   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.525f, 0.01f, TEST_LOCATION );
8169   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.506f, 0.01f, TEST_LOCATION );
8170   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.4875f, 0.01f, TEST_LOCATION );
8171
8172   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 50% progress */);
8173   application.SendNotification();
8174   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.9f, 0.01f, TEST_LOCATION );
8175   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION );
8176   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.7f, 0.01f, TEST_LOCATION );
8177   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION );
8178
8179   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)/* 75% progress */);
8180   application.SendNotification();
8181   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   0.99375f, 0.01f, TEST_LOCATION );
8182   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 0.925f, 0.01f, TEST_LOCATION );
8183   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  0.85625f, 0.01f, TEST_LOCATION );
8184   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 0.7875f, 0.01f, TEST_LOCATION );
8185
8186   application.Render(static_cast<unsigned int>((durationSeconds - delay)*250.0f)+1/* 100% progress */);
8187   application.SendNotification();
8188   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_RED),   1.0f, 0.01f, TEST_LOCATION );
8189   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION );
8190   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_BLUE),  1.0f, 0.01f, TEST_LOCATION );
8191   DALI_TEST_EQUALS( actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION );
8192
8193   // We did expect the animation to finish
8194
8195   finishCheck.CheckSignalReceived();
8196   END_TEST;
8197 }
8198
8199 int UtcDaliAnimationAnimateP(void)
8200 {
8201   TestApplication application;
8202
8203   Actor actor = Actor::New();
8204   Stage::GetCurrent().Add(actor);
8205
8206   //Build the path
8207   Vector3 position0( 30.0,  80.0,  0.0);
8208   Vector3 position1( 70.0,  120.0, 0.0);
8209   Vector3 position2( 100.0, 100.0, 0.0);
8210
8211   Dali::Path path = Dali::Path::New();
8212   path.AddPoint(position0);
8213   path.AddPoint(position1);
8214   path.AddPoint(position2);
8215
8216   //Control points for first segment
8217   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8218   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8219
8220   //Control points for second segment
8221   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8222   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8223
8224   // Build the animation
8225   float durationSeconds( 1.0f );
8226   Animation animation = Animation::New(durationSeconds);
8227   animation.Animate(actor, path, Vector3::XAXIS);
8228
8229   // Start the animation
8230   animation.Play();
8231
8232   bool signalReceived(false);
8233   AnimationFinishCheck finishCheck(signalReceived);
8234   animation.FinishedSignal().Connect(&application, finishCheck);
8235   application.SendNotification();
8236   application.Render(0);
8237   application.SendNotification();
8238   finishCheck.CheckSignalNotReceived();
8239   Vector3 position, tangent;
8240   Quaternion rotation;
8241   path.Sample( 0.0f, position, tangent );
8242   rotation = Quaternion( Vector3::XAXIS, tangent );
8243   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8244   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8245
8246   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8247   application.SendNotification();
8248   path.Sample( 0.25f, position, tangent );
8249   rotation = Quaternion( Vector3::XAXIS, tangent );
8250   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8251   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8252
8253   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8254   application.SendNotification();
8255   path.Sample( 0.5f, position, tangent );
8256   rotation = Quaternion( Vector3::XAXIS, tangent );
8257   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8258   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8259
8260   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8261   application.SendNotification();
8262   path.Sample( 0.75f, position, tangent );
8263   rotation = Quaternion( Vector3::XAXIS, tangent );
8264   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8265   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8266
8267   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8268   application.SendNotification();
8269   path.Sample( 1.0f, position, tangent );
8270   rotation = Quaternion( Vector3::XAXIS, tangent );
8271   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8272   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8273
8274   finishCheck.CheckSignalReceived();
8275   END_TEST;
8276 }
8277
8278 int UtcDaliAnimationAnimateAlphaFunctioN(void)
8279 {
8280   TestApplication application;
8281
8282   Actor actor = Actor::New();
8283   Stage::GetCurrent().Add(actor);
8284
8285   //Build the path
8286   Vector3 position0( 30.0,  80.0,  0.0);
8287   Vector3 position1( 70.0,  120.0, 0.0);
8288   Vector3 position2( 100.0, 100.0, 0.0);
8289
8290   Dali::Path path = Dali::Path::New();
8291   path.AddPoint(position0);
8292   path.AddPoint(position1);
8293   path.AddPoint(position2);
8294
8295   //Control points for first segment
8296   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8297   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8298
8299   //Control points for second segment
8300   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8301   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8302
8303   // Build the animation
8304   float durationSeconds( 1.0f );
8305   Animation animation = Animation::New(durationSeconds);
8306   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear);
8307
8308   // Start the animation
8309   animation.Play();
8310
8311   bool signalReceived(false);
8312   AnimationFinishCheck finishCheck(signalReceived);
8313   animation.FinishedSignal().Connect(&application, finishCheck);
8314   application.SendNotification();
8315   application.Render(0);
8316   application.SendNotification();
8317   finishCheck.CheckSignalNotReceived();
8318   Vector3 position, tangent;
8319   Quaternion rotation;
8320   path.Sample( 0.0f, position, tangent );
8321   rotation = Quaternion( Vector3::XAXIS, tangent );
8322   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8323   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8324
8325   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8326   application.SendNotification();
8327   path.Sample( 0.25f, position, tangent );
8328   rotation = Quaternion( Vector3::XAXIS, tangent );
8329   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8330   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8331
8332   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8333   application.SendNotification();
8334   path.Sample( 0.5f, position, tangent );
8335   rotation = Quaternion( Vector3::XAXIS, tangent );
8336   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8337   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8338
8339   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8340   application.SendNotification();
8341   path.Sample( 0.75f, position, tangent );
8342   rotation = Quaternion( Vector3::XAXIS, tangent );
8343   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8344   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8345
8346   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8347   application.SendNotification();
8348   path.Sample( 1.0f, position, tangent );
8349   rotation = Quaternion( Vector3::XAXIS, tangent );
8350   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8351   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8352
8353   finishCheck.CheckSignalReceived();
8354   END_TEST;
8355 }
8356
8357 int UtcDaliAnimationAnimateTimePeriodP(void)
8358 {
8359   TestApplication application;
8360
8361   Actor actor = Actor::New();
8362   Stage::GetCurrent().Add(actor);
8363
8364   //Build the path
8365   Vector3 position0( 30.0,  80.0,  0.0);
8366   Vector3 position1( 70.0,  120.0, 0.0);
8367   Vector3 position2( 100.0, 100.0, 0.0);
8368
8369   Dali::Path path = Dali::Path::New();
8370   path.AddPoint(position0);
8371   path.AddPoint(position1);
8372   path.AddPoint(position2);
8373
8374   //Control points for first segment
8375   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8376   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8377
8378   //Control points for second segment
8379   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8380   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8381
8382   // Build the animation
8383   float durationSeconds( 1.0f );
8384   Animation animation = Animation::New(durationSeconds);
8385   animation.Animate(actor, path, Vector3::XAXIS, TimePeriod(0.0f, 1.0f));
8386
8387   // Start the animation
8388   animation.Play();
8389
8390   bool signalReceived(false);
8391   AnimationFinishCheck finishCheck(signalReceived);
8392   animation.FinishedSignal().Connect(&application, finishCheck);
8393   application.SendNotification();
8394   application.Render(0);
8395   application.SendNotification();
8396   finishCheck.CheckSignalNotReceived();
8397   Vector3 position, tangent;
8398   Quaternion rotation;
8399   path.Sample( 0.0f, position, tangent );
8400   rotation = Quaternion( Vector3::XAXIS, tangent );
8401   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8402   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8403
8404   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8405   application.SendNotification();
8406   path.Sample( 0.25f, position, tangent );
8407   rotation = Quaternion( Vector3::XAXIS, tangent );
8408   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8409   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8410
8411   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8412   application.SendNotification();
8413   path.Sample( 0.5f, position, tangent );
8414   rotation = Quaternion( Vector3::XAXIS, tangent );
8415   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8416   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8417
8418   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8419   application.SendNotification();
8420   path.Sample( 0.75f, position, tangent );
8421   rotation = Quaternion( Vector3::XAXIS, tangent );
8422   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8423   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8424
8425   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8426   application.SendNotification();
8427   path.Sample( 1.0f, position, tangent );
8428   rotation = Quaternion( Vector3::XAXIS, tangent );
8429   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8430   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8431
8432   finishCheck.CheckSignalReceived();
8433   END_TEST;
8434 }
8435
8436 int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void)
8437 {
8438   TestApplication application;
8439
8440   Actor actor = Actor::New();
8441   Stage::GetCurrent().Add(actor);
8442
8443   //Build the path
8444   Vector3 position0( 30.0,  80.0,  0.0);
8445   Vector3 position1( 70.0,  120.0, 0.0);
8446   Vector3 position2( 100.0, 100.0, 0.0);
8447
8448   Dali::Path path = Dali::Path::New();
8449   path.AddPoint(position0);
8450   path.AddPoint(position1);
8451   path.AddPoint(position2);
8452
8453   //Control points for first segment
8454   path.AddControlPoint( Vector3( 39.0,  90.0, 0.0) );
8455   path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
8456
8457   //Control points for second segment
8458   path.AddControlPoint(Vector3( 78.0, 120.0, 0.0));
8459   path.AddControlPoint(Vector3( 93.0, 104.0, 0.0));
8460
8461   // Build the animation
8462   float durationSeconds( 1.0f );
8463   Animation animation = Animation::New(durationSeconds);
8464   animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f));
8465
8466   // Start the animation
8467   animation.Play();
8468
8469   bool signalReceived(false);
8470   AnimationFinishCheck finishCheck(signalReceived);
8471   animation.FinishedSignal().Connect(&application, finishCheck);
8472   application.SendNotification();
8473   application.Render(0);
8474   application.SendNotification();
8475   finishCheck.CheckSignalNotReceived();
8476   Vector3 position, tangent;
8477   Quaternion rotation;
8478   path.Sample( 0.0f, position, tangent );
8479   rotation = Quaternion( Vector3::XAXIS, tangent );
8480   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8481   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8482
8483   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
8484   application.SendNotification();
8485   path.Sample( 0.25f, position, tangent );
8486   rotation = Quaternion( Vector3::XAXIS, tangent );
8487   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8488   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8489
8490   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
8491   application.SendNotification();
8492   path.Sample( 0.5f, position, tangent );
8493   rotation = Quaternion( Vector3::XAXIS, tangent );
8494   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8495   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8496
8497   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
8498   application.SendNotification();
8499   path.Sample( 0.75f, position, tangent );
8500   rotation = Quaternion( Vector3::XAXIS, tangent );
8501   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8502   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8503
8504   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
8505   application.SendNotification();
8506   path.Sample( 1.0f, position, tangent );
8507   rotation = Quaternion( Vector3::XAXIS, tangent );
8508   DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
8509   DALI_TEST_EQUALS( actor.GetCurrentOrientation(), rotation, TEST_LOCATION );
8510
8511   finishCheck.CheckSignalReceived();
8512   END_TEST;
8513 }
8514
8515 int UtcDaliAnimationShowP(void)
8516 {
8517   TestApplication application;
8518
8519   Actor actor = Actor::New();
8520   actor.SetVisible(false);
8521   application.SendNotification();
8522   application.Render(0);
8523   DALI_TEST_CHECK( !actor.IsVisible() );
8524   Stage::GetCurrent().Add(actor);
8525
8526   // Start the animation
8527   float durationSeconds(10.0f);
8528   Animation animation = Animation::New(durationSeconds);
8529   animation.Show(actor, durationSeconds*0.5f);
8530   animation.Play();
8531
8532   bool signalReceived(false);
8533   AnimationFinishCheck finishCheck(signalReceived);
8534   animation.FinishedSignal().Connect(&application, finishCheck);
8535
8536   application.SendNotification();
8537   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8538
8539   // We didn't expect the animation to finish yet
8540   application.SendNotification();
8541   finishCheck.CheckSignalNotReceived();
8542   DALI_TEST_CHECK( !actor.IsVisible() );
8543
8544   application.SendNotification();
8545   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
8546
8547   // We didn't expect the animation to finish yet
8548   application.SendNotification();
8549   finishCheck.CheckSignalNotReceived();
8550   DALI_TEST_CHECK( actor.IsVisible() );
8551
8552   application.SendNotification();
8553   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8554
8555   // We did expect the animation to finish
8556   application.SendNotification();
8557   finishCheck.CheckSignalReceived();
8558   DALI_TEST_CHECK( actor.IsVisible() );
8559   END_TEST;
8560 }
8561
8562 int UtcDaliAnimationHideP(void)
8563 {
8564   TestApplication application;
8565
8566   Actor actor = Actor::New();
8567   DALI_TEST_CHECK( actor.IsVisible() );
8568   Stage::GetCurrent().Add(actor);
8569
8570   // Start the animation
8571   float durationSeconds(10.0f);
8572   Animation animation = Animation::New(durationSeconds);
8573   animation.Hide(actor, durationSeconds*0.5f);
8574   animation.Play();
8575
8576   bool signalReceived(false);
8577   AnimationFinishCheck finishCheck(signalReceived);
8578   animation.FinishedSignal().Connect(&application, finishCheck);
8579
8580   application.SendNotification();
8581   application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
8582
8583   // We didn't expect the animation to finish yet
8584   application.SendNotification();
8585   finishCheck.CheckSignalNotReceived();
8586   DALI_TEST_CHECK( actor.IsVisible() );
8587
8588   application.SendNotification();
8589   application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
8590
8591   // We didn't expect the animation to finish yet
8592   application.SendNotification();
8593   finishCheck.CheckSignalNotReceived();
8594   DALI_TEST_CHECK( !actor.IsVisible() );
8595
8596   application.SendNotification();
8597   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8598
8599   // We did expect the animation to finish
8600   application.SendNotification();
8601   finishCheck.CheckSignalReceived();
8602   DALI_TEST_CHECK( !actor.IsVisible() );
8603   END_TEST;
8604 }
8605
8606 int UtcDaliAnimationShowHideAtEndP(void)
8607 {
8608   // Test that show/hide delay can be the same as animation duration
8609   // i.e. to show/hide at the end of the animation
8610
8611   TestApplication application;
8612
8613   Actor actor = Actor::New();
8614   DALI_TEST_CHECK( actor.IsVisible() );
8615   Stage::GetCurrent().Add(actor);
8616
8617   // Start Hide animation
8618   float durationSeconds(10.0f);
8619   Animation animation = Animation::New(durationSeconds);
8620   animation.Hide(actor, durationSeconds/*Hide at end*/);
8621   animation.Play();
8622
8623   bool signalReceived(false);
8624   AnimationFinishCheck finishCheck(signalReceived);
8625   animation.FinishedSignal().Connect(&application, finishCheck);
8626
8627   application.SendNotification();
8628   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8629
8630   // We did expect the animation to finish
8631   application.SendNotification();
8632   finishCheck.CheckSignalReceived();
8633   DALI_TEST_CHECK( !actor.IsVisible() );
8634
8635   // Start Show animation
8636   animation = Animation::New(durationSeconds);
8637   animation.Show(actor, durationSeconds/*Show at end*/);
8638   animation.FinishedSignal().Connect(&application, finishCheck);
8639   animation.Play();
8640
8641   application.SendNotification();
8642   application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
8643
8644   // We did expect the animation to finish
8645   application.SendNotification();
8646   finishCheck.CheckSignalReceived();
8647   DALI_TEST_CHECK( actor.IsVisible() );
8648   END_TEST;
8649 }
8650
8651 int UtcDaliKeyFramesCreateDestroyP(void)
8652 {
8653   tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()");
8654
8655   KeyFrames* keyFrames = new KeyFrames;
8656   delete keyFrames;
8657   DALI_TEST_CHECK( true );
8658   END_TEST;
8659 }
8660
8661 int UtcDaliKeyFramesDownCastP(void)
8662 {
8663   TestApplication application;
8664   tet_infoline("Testing Dali::Animation::KeyFramesDownCast()");
8665
8666   KeyFrames keyFrames = KeyFrames::New();
8667   BaseHandle object(keyFrames);
8668
8669   KeyFrames keyFrames2 = KeyFrames::DownCast(object);
8670   DALI_TEST_CHECK(keyFrames2);
8671
8672   KeyFrames keyFrames3 = DownCast< KeyFrames >(object);
8673   DALI_TEST_CHECK(keyFrames3);
8674
8675   BaseHandle unInitializedObject;
8676   KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject);
8677   DALI_TEST_CHECK(!keyFrames4);
8678
8679   KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject);
8680   DALI_TEST_CHECK(!keyFrames5);
8681   END_TEST;
8682 }
8683
8684 int UtcDaliAnimationCreateDestroyP(void)
8685 {
8686   TestApplication application;
8687   Animation* animation = new Animation;
8688   DALI_TEST_CHECK( animation );
8689   delete animation;
8690   END_TEST;
8691 }
8692
8693 struct UpdateManagerTestConstraint
8694 {
8695   UpdateManagerTestConstraint(TestApplication& application)
8696   : mApplication(application)
8697   {
8698   }
8699
8700   void operator()( Vector3& current, const PropertyInputContainer& /* inputs */)
8701   {
8702     mApplication.SendNotification();  // Process events
8703   }
8704
8705   TestApplication& mApplication;
8706 };
8707
8708 int UtcDaliAnimationUpdateManagerP(void)
8709 {
8710   TestApplication application;
8711
8712   Actor actor = Actor::New();
8713   Stage::GetCurrent().Add( actor );
8714
8715   // Build the animation
8716   Animation animation = Animation::New( 0.0f );
8717
8718   bool signalReceived = false;
8719   AnimationFinishCheck finishCheck( signalReceived );
8720   animation.FinishedSignal().Connect( &application, finishCheck );
8721
8722   Vector3 startValue(1.0f, 1.0f, 1.0f);
8723   Property::Index index = actor.RegisterProperty( "test-property", startValue );
8724   Constraint constraint = Constraint::New<Vector3>( actor, index, UpdateManagerTestConstraint( application ) );
8725   constraint.Apply();
8726
8727   // Apply animation to actor
8728   animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear );
8729
8730   animation.Play();
8731
8732   application.SendNotification();
8733   application.UpdateOnly( 16 );
8734
8735   finishCheck.CheckSignalNotReceived();
8736
8737   application.SendNotification();   // Process events
8738
8739   finishCheck.CheckSignalReceived();
8740
8741   END_TEST;
8742 }
8743
8744 int UtcDaliAnimationSignalOrderP(void)
8745 {
8746   TestApplication application;
8747
8748   Actor actor = Actor::New();
8749   Stage::GetCurrent().Add( actor );
8750
8751   // Build the animations
8752   Animation animation1 = Animation::New( 0.0f ); // finishes first frame
8753   Animation animation2 = Animation::New( 0.02f ); // finishes in 20 ms
8754
8755   bool signal1Received = false;
8756   animation1.FinishedSignal().Connect( &application, AnimationFinishCheck( signal1Received ) );
8757
8758   bool signal2Received = false;
8759   animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) );
8760
8761   // Apply animations to actor
8762   animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear );
8763   animation1.Play();
8764   animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear );
8765   animation2.Play();
8766
8767   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8768   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8769
8770   application.SendNotification();
8771   application.UpdateOnly( 10 ); // 10ms progress
8772
8773   // no notifications yet
8774   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8775   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8776
8777   application.SendNotification();
8778
8779   // first completed
8780   DALI_TEST_EQUALS( signal1Received, true, TEST_LOCATION );
8781   DALI_TEST_EQUALS( signal2Received, false, TEST_LOCATION );
8782   signal1Received = false;
8783
8784   // 1st animation is complete now, do another update with no ProcessEvents in between
8785   application.UpdateOnly( 20 ); // 20ms progress
8786
8787   // ProcessEvents
8788   application.SendNotification();
8789
8790   // 2nd should complete now
8791   DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION );
8792   DALI_TEST_EQUALS( signal2Received, true, TEST_LOCATION );
8793
8794   END_TEST;
8795 }
8796
8797 int UtcDaliAnimationExtendDuratioN(void)
8798 {
8799   TestApplication application;
8800
8801   Actor actor = Actor::New();
8802
8803   // Register a float property
8804   float startValue(10.0f);
8805   Property::Index index = actor.RegisterProperty( "test-property", startValue );
8806   Stage::GetCurrent().Add(actor);
8807   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8808
8809   // Build the animation
8810   float initialDurationSeconds(1.0f);
8811   float animatorDelay = 5.0f;
8812   float animatorDurationSeconds(5.0f);
8813   float extendedDurationSeconds(animatorDelay+animatorDurationSeconds);
8814   Animation animation = Animation::New(initialDurationSeconds);
8815   float targetValue(30.0f);
8816   float relativeValue(targetValue - startValue);
8817
8818   animation.AnimateTo(Property(actor, index),
8819                       targetValue,
8820                       TimePeriod(animatorDelay, animatorDurationSeconds));
8821
8822   // The duration should have been extended
8823   DALI_TEST_EQUALS( animation.GetDuration(), extendedDurationSeconds, TEST_LOCATION );
8824
8825   // Start the animation
8826   animation.Play();
8827
8828   bool signalReceived(false);
8829   AnimationFinishCheck finishCheck(signalReceived);
8830   animation.FinishedSignal().Connect(&application, finishCheck);
8831
8832   application.SendNotification();
8833   application.Render(static_cast<unsigned int>(extendedDurationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
8834
8835   // We didn't expect the animation to finish yet
8836   application.SendNotification();
8837   finishCheck.CheckSignalNotReceived();
8838   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
8839
8840   application.SendNotification();
8841   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
8842
8843   // We didn't expect the animation to finish yet
8844   application.SendNotification();
8845   finishCheck.CheckSignalNotReceived();
8846   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
8847
8848   application.SendNotification();
8849   application.Render(static_cast<unsigned int>(extendedDurationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
8850
8851   // We did expect the animation to finish
8852   application.SendNotification();
8853   finishCheck.CheckSignalReceived();
8854   DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
8855   END_TEST;
8856 }
8857
8858 int UtcDaliAnimationCustomUnsignedIntProperty(void)
8859 {
8860   TestApplication application;
8861
8862   Actor actor = Actor::New();
8863   Stage::GetCurrent().Add(actor);
8864   unsigned int startValue(0u);
8865
8866   Property::Index index = actor.RegisterProperty("an-index", startValue);
8867   DALI_TEST_EQUALS( actor.GetProperty<unsigned int>(index), startValue, TEST_LOCATION );
8868
8869   // Build the animation
8870   float durationSeconds(1.0f);
8871   Animation animation = Animation::New(durationSeconds);
8872   animation.AnimateTo( Property(actor, index), 20u );
8873
8874   // Start the animation
8875   animation.Play();
8876
8877   bool signalReceived(false);
8878   AnimationFinishCheck finishCheck(signalReceived);
8879   animation.FinishedSignal().Connect(&application, finishCheck);
8880
8881   application.SendNotification();
8882   application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
8883
8884   // We didn't expect the animation to finish yet
8885   application.SendNotification();
8886   finishCheck.CheckSignalNotReceived();
8887   DALI_TEST_EQUALS( actor.GetProperty<unsigned int>(index), 10u, TEST_LOCATION );
8888
8889   application.SendNotification();
8890   application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
8891
8892   // We did expect the animation to finish
8893   application.SendNotification();
8894   finishCheck.CheckSignalReceived();
8895   DALI_TEST_EQUALS( actor.GetProperty<unsigned int>(index), 20u, TEST_LOCATION );
8896   END_TEST;
8897 }
8898