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