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