Dali 3D User Interface Engine
utc-Dali-Animation.cpp
Go to the documentation of this file.
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>
23 #include <dali-test-suite-utils.h>
24 
25 using std::max;
26 using namespace Dali;
27 
29 {
31 }
32 
34 {
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
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");
68  }
69  else
70  {
72  }
73  }
74 
75  void CheckSignalNotReceived()
76  {
77  if (mSignalReceived)
78  {
79  tet_printf("Unexpected Finish signal was received\n");
81  }
82  else
83  {
85  }
86  }
87 
88  bool& mSignalReceived; // owned by individual tests
89 };
90 
91 } // anon namespace
92 
94 {
95  TestApplication application;
96 
97  Animation animation;
98 
99  DALI_TEST_CHECK( !animation );
100  END_TEST;
101 }
102 
104 {
105  TestApplication application;
106 
107  Animation animation = Animation::New( 1.0f );
108 
109  DALI_TEST_CHECK(animation);
110  END_TEST;
111 }
112 
114 {
115  TestApplication application;
116 
117  Animation animation = Animation::New( -1.0f );
118 
119  DALI_TEST_CHECK(animation);
120  DALI_TEST_EQUALS(animation.GetDuration(), 0.0f, TEST_LOCATION);
121  END_TEST;
122 }
123 
125 {
126  TestApplication application;
127 
128  tet_infoline("Testing Dali::Animation::DownCast()");
129 
130  float durationSeconds(1.0f);
131  Animation animation = Animation::New(durationSeconds);
132 
133  BaseHandle object(animation);
134 
135  Animation animation2 = Animation::DownCast(object);
136  DALI_TEST_CHECK(animation2);
137 
138  Animation animation3 = DownCast< Animation >(object);
139  DALI_TEST_CHECK(animation3);
140  END_TEST;
141 }
142 
144 {
145  TestApplication application;
146 
147  BaseHandle unInitializedObject;
148 
149  Animation animation1 = Animation::DownCast( unInitializedObject );
150  DALI_TEST_CHECK( !animation1 );
151 
152  Animation animation2 = DownCast< Animation >( unInitializedObject );
153  DALI_TEST_CHECK( !animation2 );
154  END_TEST;
155 }
156 
158 {
159  TestApplication application;
160 
161  // Initialize an object, ref count == 1
162  Animation animation = Animation::New( 1.0f );
163 
164  Animation copy( animation );
165  DALI_TEST_CHECK( copy );
166 
167  DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
168  END_TEST;
169 }
170 
172 {
173  TestApplication application;
174 
175  Animation animation = Animation::New( 1.0f );
176 
177  Animation copy = animation;
178  DALI_TEST_CHECK( copy );
179 
180  DALI_TEST_CHECK( animation == copy );
181 
182  DALI_TEST_CHECK( copy.GetDuration() == animation.GetDuration() );
183  END_TEST;
184 }
185 
187 {
188  TestApplication application;
189 
190  Actor actor = Actor::New();
191  Stage::GetCurrent().Add(actor);
192 
193  // Build the animation
194  float durationSeconds(1.0f);
195  Animation animation = Animation::New(durationSeconds);
196  DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
197 
198  // Start the animation
199  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
200  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
201  animation.Play();
202 
203  bool signalReceived(false);
204  AnimationFinishCheck finishCheck(signalReceived);
205  animation.FinishedSignal().Connect(&application, finishCheck);
206 
207  application.SendNotification();
208  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
209 
210  // We didn't expect the animation to finish yet
211  application.SendNotification();
212  finishCheck.CheckSignalNotReceived();
213 
214  application.Render(2u/*just beyond the animation duration*/);
215 
216  // We did expect the animation to finish
217  application.SendNotification();
218  finishCheck.CheckSignalReceived();
219  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
220 
221  // Restart the animation, with a different duration
222  finishCheck.Reset();
223  actor.SetPosition(Vector3::ZERO);
224  durationSeconds = 3.5f;
225  animation.SetDuration(durationSeconds);
226  DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
227  animation.Play();
228 
229  application.SendNotification();
230  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
231 
232  // We didn't expect the animation to finish yet
233  application.SendNotification();
234  finishCheck.CheckSignalNotReceived();
235 
236  application.Render(2u/*just beyond the animation duration*/);
237 
238  // We did expect the animation to finish
239  application.SendNotification();
240  finishCheck.CheckSignalReceived();
241  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
242 
243  // Check that nothing has changed after a couple of buffer swaps
244  application.Render(0);
245  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
246  application.Render(0);
247  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
248  END_TEST;
249 }
250 
252 {
253  TestApplication application;
254 
255  Animation animation = Animation::New( 1.0f );
256  DALI_TEST_EQUALS( animation.GetDuration(), 1.0f, TEST_LOCATION );
257 
258  animation.SetDuration( -1.0f );
259  DALI_TEST_EQUALS( animation.GetDuration(), 0.0f, TEST_LOCATION );
260  END_TEST;
261 }
262 
264 {
265  TestApplication application;
266 
267  Animation animation = Animation::New(1.0f);
268  DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION);
269 
270  animation.SetDuration(2.0f);
271  DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION);
272  END_TEST;
273 }
274 
276 {
277  TestApplication application;
278 
279  Actor actor = Actor::New();
280  Stage::GetCurrent().Add(actor);
281 
282  // Build the animation
283  float durationSeconds(1.0f);
284  Animation animation = Animation::New(durationSeconds);
285  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
286  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
287 
288  // Start the animation
289  animation.SetLooping(true);
290  DALI_TEST_CHECK(animation.IsLooping());
291  animation.Play();
292 
293  bool signalReceived(false);
294  AnimationFinishCheck finishCheck(signalReceived);
295  animation.FinishedSignal().Connect(&application, finishCheck);
296 
297  application.SendNotification();
298 
299  // Loop 5 times
300  float intervalSeconds = 0.25f;
301  float progress = 0.0f;
302  for (int iterations = 0; iterations < 5;)
303  {
304  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
305 
306  progress += intervalSeconds;
307  DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
308 
309  if (progress >= 1.0f)
310  {
311  progress = progress - 1.0f;
312  ++iterations;
313  }
314  }
315 
316  // We didn't expect the animation to finish yet
317  application.SendNotification();
318  finishCheck.CheckSignalNotReceived();
319 
320  animation.SetLooping(false);
321  DALI_TEST_CHECK(!animation.IsLooping());
322 
323  application.SendNotification();
324  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
325 
326  // We did expect the animation to finish
327  application.SendNotification();
328  finishCheck.CheckSignalReceived();
329  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
330 
331  // Check that nothing has changed after a couple of buffer swaps
332  application.Render(0);
333  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
334  application.Render(0);
335  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
336  END_TEST;
337 }
338 
340 {
341  TestApplication application;
342 
343  Actor actor = Actor::New();
344  Stage::GetCurrent().Add(actor);
345 
346  // Build the animation
347  float durationSeconds(1.0f);
348  Animation animation = Animation::New(durationSeconds);
349  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
350  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
351 
352  // Start the animation
353  animation.SetLoopCount(3);
354  DALI_TEST_CHECK(animation.IsLooping());
355  animation.Play();
356 
357  bool signalReceived(false);
358  AnimationFinishCheck finishCheck(signalReceived);
359  animation.FinishedSignal().Connect(&application, finishCheck);
360 
361  application.Render(0);
362  application.SendNotification();
363  application.Render(0);
364  application.SendNotification();
365  application.Render(0);
366  application.SendNotification();
367  application.Render(0);
368  application.SendNotification();
369 
370  // Loop
371  float intervalSeconds = 3.0f;
372 
373  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
374  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
375 
376  application.Render(0);
377  application.SendNotification();
378  application.Render(0);
379  application.SendNotification();
380  application.Render(0);
381  application.SendNotification();
382  application.Render(0);
383  application.SendNotification();
384  finishCheck.CheckSignalNotReceived();
385 
386  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
387 
388  application.SendNotification();
389  finishCheck.CheckSignalReceived();
390  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
391 
392  finishCheck.Reset();
393 
394  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
395  application.SendNotification();
396  finishCheck.CheckSignalNotReceived();
397 
398  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
399  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
400  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
401  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
402  application.SendNotification();
403  finishCheck.CheckSignalNotReceived();
404 
405  END_TEST;
406 }
407 
409 {
410  TestApplication application;
411 
412  //
413  // switching between forever and loop count
414  //
415 
416  Actor actor = Actor::New();
417  Stage::GetCurrent().Add(actor);
418 
419  // Build the animation
420  float durationSeconds(1.0f);
421  Animation animation = Animation::New(durationSeconds);
422  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
423  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
424  animation.SetEndAction(Animation::Discard);
425 
426  // Start the animation
427  animation.SetLoopCount(3);
428  DALI_TEST_CHECK(animation.IsLooping());
429  animation.Play();
430 
431  bool signalReceived(false);
432  AnimationFinishCheck finishCheck(signalReceived);
433  animation.FinishedSignal().Connect(&application, finishCheck);
434 
435  float intervalSeconds = 3.0f;
436 
437  application.SendNotification();
438  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
439  application.SendNotification();
440  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
441  application.SendNotification();
442  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
443  application.SendNotification();
444 
445  application.SendNotification();
446  finishCheck.CheckSignalReceived();
447 
448  finishCheck.Reset();
449 
450  // Loop forever
451  animation.SetLooping(true);
452  DALI_TEST_CHECK(animation.IsLooping());
453 
454  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
455  application.SendNotification();
456  finishCheck.CheckSignalNotReceived();
457 
458  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
459  application.SendNotification();
460  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
461  application.SendNotification();
462  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
463  application.SendNotification();
464  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
465  application.SendNotification();
466  application.SendNotification();
467  finishCheck.CheckSignalNotReceived();
468 
469  finishCheck.Reset();
470 
471  // Loop N again
472  animation.SetLoopCount(3);
473  DALI_TEST_CHECK(animation.IsLooping());
474  animation.Play();
475 
476  application.SendNotification();
477  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
478  application.SendNotification();
479  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
480  application.SendNotification();
481  finishCheck.CheckSignalNotReceived();
482 
483  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
484  application.SendNotification();
485  finishCheck.CheckSignalReceived();
486 
487  finishCheck.Reset();
488 
489  // loop forever
490  animation.SetLooping(true);
491  DALI_TEST_CHECK(animation.IsLooping());
492 
493  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
494  application.SendNotification();
495  finishCheck.CheckSignalNotReceived();
496 
497  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
498  application.SendNotification();
499  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
500  application.SendNotification();
501  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
502  application.SendNotification();
503  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
504  application.SendNotification();
505  finishCheck.CheckSignalNotReceived();
506 
507  finishCheck.Reset();
508 
509  // Loop N again
510  animation.SetLoopCount(3);
511  DALI_TEST_CHECK(animation.IsLooping());
512 
513  application.SendNotification();
514  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
515  application.SendNotification();
516  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
517  application.SendNotification();
518  finishCheck.CheckSignalNotReceived();
519 
520  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
521  application.SendNotification();
522  finishCheck.CheckSignalNotReceived(); // we never hit play
523 
524  finishCheck.Reset();
525 
526 
527  END_TEST;
528 }
529 
531 {
532  TestApplication application;
533 
534  //
535  // switching between forever and loop count
536  //
537  Actor actor = Actor::New();
538  Stage::GetCurrent().Add(actor);
539 
540  // Build the animation
541  float durationSeconds(1.0f);
542  Animation animation = Animation::New(durationSeconds);
543  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
544  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
545  animation.SetEndAction(Animation::Discard);
546 
547  float intervalSeconds = 3.0f;
548 
549  bool signalReceived(false);
550  AnimationFinishCheck finishCheck(signalReceived);
551  animation.FinishedSignal().Connect(&application, finishCheck);
552 
553  // loop forever
554  animation.SetLooping(true);
555  DALI_TEST_CHECK(animation.IsLooping());
556 
557  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
558  application.SendNotification();
559  finishCheck.CheckSignalNotReceived();
560 
561  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
562  application.SendNotification();
563  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
564  application.SendNotification();
565  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
566  application.SendNotification();
567  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
568  application.SendNotification();
569  finishCheck.CheckSignalNotReceived();
570 
571  finishCheck.Reset();
572 
573  // Loop N again
574  animation.SetLoopCount(3);
575  DALI_TEST_CHECK(animation.IsLooping());
576 
577  application.SendNotification();
578  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
579  application.SendNotification();
580  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
581  application.SendNotification();
582  finishCheck.CheckSignalNotReceived();
583 
584  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
585  application.SendNotification();
586  finishCheck.CheckSignalNotReceived(); // we never hit play
587 
588  finishCheck.Reset();
589 
590 
591  END_TEST;
592 }
593 
595 {
596  TestApplication application;
597 
598  //
599  // ..and play again
600  //
601  Actor actor = Actor::New();
602  Stage::GetCurrent().Add(actor);
603 
604  // Build the animation
605  float durationSeconds(1.0f);
606  Animation animation = Animation::New(durationSeconds);
607  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
608  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
609  animation.SetEndAction(Animation::Bake);
610 
611  float intervalSeconds = 3.0f;
612 
613  bool signalReceived(false);
614  AnimationFinishCheck finishCheck(signalReceived);
615  animation.FinishedSignal().Connect(&application, finishCheck);
616 
617  animation.SetLoopCount(1);
618  animation.Play();
619  DALI_TEST_CHECK(!animation.IsLooping());
620 
621  application.SendNotification();
622  finishCheck.CheckSignalNotReceived();
623  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
624  application.SendNotification();
625  finishCheck.CheckSignalReceived();
626 
627  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
628  actor.SetProperty( Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f) );
629 
630  finishCheck.Reset();
631 
632  animation.Play(); // again
633  DALI_TEST_CHECK(!animation.IsLooping());
634 
635  application.SendNotification();
636  finishCheck.CheckSignalNotReceived();
637  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
638  application.SendNotification();
639  finishCheck.CheckSignalReceived();
640 
641  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
642 
643  END_TEST;
644 }
645 
647 {
648  TestApplication application;
649 
650  Actor actor = Actor::New();
651  Stage::GetCurrent().Add(actor);
652 
653  // Build the animation
654  float durationSeconds(1.0f);
655  Animation animation = Animation::New(durationSeconds);
656  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
657  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
658 
659  DALI_TEST_CHECK(1 == animation.GetLoopCount());
660 
661  // Start the animation
662  animation.SetLoopCount(3);
663  DALI_TEST_CHECK(animation.IsLooping());
664  DALI_TEST_CHECK(3 == animation.GetLoopCount());
665 
666  animation.Play();
667 
668  application.Render(0);
669  application.SendNotification();
670 
671  // Loop
672  float intervalSeconds = 3.0f;
673 
674  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
675  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
676 
677  application.Render(0);
678  application.SendNotification();
679 
680  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
681  application.SendNotification();
682 
683  animation.SetLoopCount(0);
684  DALI_TEST_CHECK(animation.IsLooping());
685  DALI_TEST_CHECK(0 == animation.GetLoopCount());
686 
687  animation.SetLoopCount(1);
688  DALI_TEST_CHECK(!animation.IsLooping());
689  DALI_TEST_CHECK(1 == animation.GetLoopCount());
690 
691  END_TEST;
692 }
693 
694 
696 {
697  TestApplication application;
698 
699  Actor actor = Actor::New();
700  Stage::GetCurrent().Add(actor);
701 
702  // Build the animation
703  float durationSeconds(1.0f);
704  Animation animation = Animation::New(durationSeconds);
705  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
706  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
707 
708  // Start the animation
709  animation.SetLoopCount(3);
710  DALI_TEST_CHECK(animation.IsLooping());
711  DALI_TEST_CHECK(0 == animation.GetCurrentLoop());
712  animation.Play();
713 
714  bool signalReceived(false);
715  AnimationFinishCheck finishCheck(signalReceived);
716  animation.FinishedSignal().Connect(&application, finishCheck);
717 
718  application.SendNotification();
719 
720  // Loop
721  float intervalSeconds = 3.0f;
722 
723  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
724  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
725 
726  application.SendNotification();
727  finishCheck.CheckSignalNotReceived();
728  DALI_TEST_CHECK(2 == animation.GetCurrentLoop());
729 
730  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
731 
732  application.SendNotification();
733  finishCheck.CheckSignalReceived();
734  DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
735  DALI_TEST_CHECK(animation.GetLoopCount() == animation.GetCurrentLoop());
736 
737  finishCheck.Reset();
738 
739  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
740  application.SendNotification();
741  finishCheck.CheckSignalNotReceived();
742  DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
743 
744  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
745  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
746  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
747  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
748  application.SendNotification();
749  finishCheck.CheckSignalNotReceived();
750  DALI_TEST_CHECK(3 == animation.GetCurrentLoop());
751 
752  END_TEST;
753 }
754 
756 {
757  TestApplication application;
758 
759  Animation animation = Animation::New(1.0f);
760  DALI_TEST_CHECK(!animation.IsLooping());
761 
762  animation.SetLooping(true);
763  DALI_TEST_CHECK(animation.IsLooping());
764  END_TEST;
765 }
766 
768 {
769  TestApplication application;
770 
771  Actor actor = Actor::New();
772  Stage::GetCurrent().Add(actor);
773 
774  // Build the animation
775  float durationSeconds(1.0f);
776  Animation animation = Animation::New(durationSeconds);
778 
779  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
780  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
781 
782  // Start the animation
783  animation.Play();
784 
785  bool signalReceived(false);
786  AnimationFinishCheck finishCheck(signalReceived);
787  animation.FinishedSignal().Connect(&application, finishCheck);
788 
789  application.SendNotification();
790  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
791 
792  // We did expect the animation to finish
793  application.SendNotification();
794  finishCheck.CheckSignalReceived();
795  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
796 
797  // Go back to the start
798  actor.SetPosition(Vector3::ZERO);
799  application.SendNotification();
800  application.Render(0);
802 
803  // Test BakeFinal, animate again, for half the duration
804  finishCheck.Reset();
807  animation.Play();
808 
809  application.SendNotification();
810  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f*0.5f) /*half of the animation duration*/);
811 
812  // Stop the animation early
813  animation.Stop();
814 
815  // We did NOT expect the animation to finish
816  application.SendNotification();
817  finishCheck.CheckSignalNotReceived();
818  DALI_TEST_EQUALS( targetPosition * 0.5f, actor.GetCurrentPosition(), VECTOR4_EPSILON, TEST_LOCATION );
819 
820  // The position should be same with target position in the next frame
821  application.Render(0);
822  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
823 
824  // Go back to the start
825  actor.SetPosition(Vector3::ZERO);
826  application.SendNotification();
827  application.Render(0);
829 
830  // Test EndAction::Discard, animate again, but don't bake this time
831  finishCheck.Reset();
832  animation.SetEndAction(Animation::Discard);
834  animation.Play();
835 
836  application.SendNotification();
837  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
838 
839  // We did expect the animation to finish
840  application.SendNotification();
841  finishCheck.CheckSignalReceived();
842  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
843 
844  // The position should be discarded in the next frame
845  application.Render(0);
847 
848  // Check that nothing has changed after a couple of buffer swaps
849  application.Render(0);
851  application.Render(0);
853  END_TEST;
854 }
855 
857 {
858  TestApplication application;
859 
860  Animation animation = Animation::New(1.0f);
862 
863  animation.SetEndAction(Animation::Discard);
865 
868 
869  END_TEST;
870 }
871 
873 {
874  TestApplication application;
875  Stage stage( Stage::GetCurrent() );
876 
877  // Default: BakeFinal
878  {
879  Actor actor = Actor::New();
880  stage.Add(actor);
881 
882  // Build the animation
883  float durationSeconds(1.0f);
884  Animation animation = Animation::New(durationSeconds);
886 
887  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
888  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
889 
890  // Start the animation
891  animation.Play();
892 
893  application.SendNotification();
894  application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
895 
896  actor.Unparent();
897 
898  application.SendNotification();
899  application.Render();
900 
901  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
902  }
903 
904  // Bake
905  {
906  Actor actor = Actor::New();
907  stage.Add(actor);
908 
909  // Build the animation
910  float durationSeconds(1.0f);
911  Animation animation = Animation::New(durationSeconds);
913 
914  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
915  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
916 
917  // Start the animation
918  animation.Play();
919 
920  application.SendNotification();
921  application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
922 
923  actor.Unparent();
924 
925  application.SendNotification();
926  application.Render();
927 
928  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition*0.5f, TEST_LOCATION );
929  }
930 
931  // Discard
932  {
933  Actor actor = Actor::New();
934  stage.Add(actor);
935 
936  // Build the animation
937  float durationSeconds(1.0f);
938  Animation animation = Animation::New(durationSeconds);
940 
941  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
942  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
943 
944  // Start the animation
945  animation.Play();
946 
947  application.SendNotification();
948  application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
949 
950  actor.Unparent();
951 
952  application.SendNotification();
953  application.Render();
954 
956  }
957 
958  // Don't play the animation: disconnect action should not be applied
959  {
960  Actor actor = Actor::New();
961  stage.Add(actor);
962 
963  // Build the animation
964  float durationSeconds(1.0f);
965  Animation animation = Animation::New(durationSeconds);
966 
967  Vector3 targetPosition(10.0f, 10.0f, 10.0f);
968  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
969 
970  application.SendNotification();
971  application.Render(static_cast<unsigned int>(durationSeconds*0.5f*1000.0f)/*Only half the animation*/);
972 
973  actor.Unparent();
974 
975  application.SendNotification();
976  application.Render();
977 
979  }
980 
981  END_TEST;
982 }
983 
985 {
986  TestApplication application;
987  Animation animation = Animation::New(1.0f);
988  DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); // default!
989 
992 
995 
996  END_TEST;
997 }
998 
1000 {
1001  TestApplication application;
1002 
1003  Animation animation = Animation::New(1.0f);
1004  AlphaFunction func = animation.GetDefaultAlphaFunction();
1006 
1008  AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1010  END_TEST;
1011 }
1012 
1014 {
1015  TestApplication application;
1016 
1017  Animation animation = Animation::New(1.0f);
1018  AlphaFunction func = animation.GetDefaultAlphaFunction();
1019 
1020  // Test that the default is linear
1022 
1024  AlphaFunction func2 = animation.GetDefaultAlphaFunction();
1026 
1027  END_TEST;
1028 }
1029 
1031 {
1032  TestApplication application;
1033 
1034  Actor actor = Actor::New();
1035  Stage::GetCurrent().Add(actor);
1036 
1037  // Build the animation
1038  Animation animation = Animation::New(0.0f);
1039 
1040  //Set duration
1041  float durationSeconds(1.0f);
1042  animation.SetDuration(durationSeconds);
1043 
1044  bool signalReceived(false);
1045  AnimationFinishCheck finishCheck(signalReceived);
1046  animation.FinishedSignal().Connect(&application, finishCheck);
1047  application.SendNotification();
1048 
1049  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1050  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1051 
1052  // Start the animation from 40% progress
1053  animation.SetCurrentProgress( 0.4f );
1054  animation.Play();
1055 
1056  application.SendNotification();
1057  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1058 
1059  // We didn't expect the animation to finish yet
1060  application.SendNotification();
1061  finishCheck.CheckSignalNotReceived();
1062  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1063  DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1064 
1065  animation.Play(); // Test that calling play has no effect, when animation is already playing
1066  application.SendNotification();
1067 
1068  //Set the progress to 70%
1069  animation.SetCurrentProgress( 0.7f );
1070  application.SendNotification();
1071  application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1072  DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1073 
1074  application.SendNotification();
1075  finishCheck.CheckSignalNotReceived();
1076  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1077  DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1078 
1079  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1080  // We did expect the animation to finish
1081  application.SendNotification();
1082  finishCheck.CheckSignalReceived();
1083  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1084 
1085  // Check that nothing has changed after a couple of buffer swaps
1086  application.Render(0);
1087  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1088  application.Render(0);
1089  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1090  END_TEST;
1091 }
1092 
1094 {
1095  TestApplication application;
1096 
1097  Actor actor = Actor::New();
1098  Stage::GetCurrent().Add(actor);
1099 
1100  // Build the animation
1101  Animation animation = Animation::New(0.0f);
1102 
1103  //Set duration
1104  float durationSeconds(1.0f);
1105  animation.SetDuration(durationSeconds);
1106 
1107  bool signalReceived(false);
1108  AnimationFinishCheck finishCheck(signalReceived);
1109  animation.FinishedSignal().Connect(&application, finishCheck);
1110  application.SendNotification();
1111 
1112  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1113  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1114 
1115  //Trying to set the current cursor outside the range [0..1] is ignored
1116  animation.SetCurrentProgress( -1.0f);
1117  application.SendNotification();
1118  DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1119 
1120  animation.SetCurrentProgress( 100.0f);
1121  application.SendNotification();
1122  DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1123  END_TEST;
1124 }
1125 
1127 {
1128  TestApplication application;
1129 
1130  Actor actor = Actor::New();
1131  Stage::GetCurrent().Add(actor);
1132 
1133  // Build the animation
1134  Animation animation = Animation::New(0.0f);
1135  animation.Play();
1136 
1137  //Test GetCurrentProgress return 0.0 as the duration is 0.0
1138  DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1139 
1140  animation.SetCurrentProgress( 0.5f );
1141  application.SendNotification();
1142  application.Render(static_cast<unsigned int>(100.0f));
1143 
1144  //Progress should still be 0.0
1145  DALI_TEST_EQUALS( 0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
1146 
1147  //Set duration
1148  float durationSeconds(1.0f);
1149  animation.SetDuration(durationSeconds);
1150  application.SendNotification();
1151 
1152  bool signalReceived(false);
1153  AnimationFinishCheck finishCheck(signalReceived);
1154  animation.FinishedSignal().Connect(&application, finishCheck);
1155  application.SendNotification();
1156 
1157  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1158  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1159 
1160  // Start the animation from 40% progress
1161  animation.SetCurrentProgress( 0.4f );
1162  animation.Play();
1163 
1164  application.SendNotification();
1165  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1166 
1167  // We didn't expect the animation to finish yet
1168  application.SendNotification();
1169  finishCheck.CheckSignalNotReceived();
1170  DALI_TEST_EQUALS( 0.6f, animation.GetCurrentProgress(), TEST_LOCATION );
1171 
1172  animation.Play(); // Test that calling play has no effect, when animation is already playing
1173  application.SendNotification();
1174 
1175  //Set the progress to 70%
1176  animation.SetCurrentProgress( 0.7f );
1177  application.SendNotification();
1178  application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 80% progress */);
1179  DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1180 
1181  application.SendNotification();
1182  finishCheck.CheckSignalNotReceived();
1183  DALI_TEST_EQUALS( 0.8f, animation.GetCurrentProgress(), TEST_LOCATION );
1184 
1185  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1186  // We did expect the animation to finish
1187  application.SendNotification();
1188  finishCheck.CheckSignalReceived();
1189  END_TEST;
1190 }
1191 
1193 {
1194  TestApplication application;
1195 
1196  tet_printf("Testing that setting a speed factor of 2 takes half the time\n");
1197 
1198  Actor actor = Actor::New();
1199  Stage::GetCurrent().Add(actor);
1200 
1201  // Build the animation
1202  float durationSeconds(1.0f);
1203  Animation animation = Animation::New(durationSeconds);
1204 
1205  const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1206  const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1207 
1208  KeyFrames keyframes = KeyFrames::New();
1209  keyframes.Add( 0.0f, initialPosition);
1210  keyframes.Add( 1.0f, targetPosition );
1212 
1213  //Set speed to be x2
1214  animation.SetSpeedFactor(2.0f);
1215 
1216  // Start the animation
1217  animation.Play();
1218 
1219  bool signalReceived(false);
1220  AnimationFinishCheck finishCheck(signalReceived);
1221  animation.FinishedSignal().Connect(&application, finishCheck);
1222 
1223  application.SendNotification();
1224  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1225 
1226  // We didn't expect the animation to finish yet
1227  application.SendNotification();
1228  finishCheck.CheckSignalNotReceived();
1229  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1230 
1231  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1232 
1233  // We didn't expect the animation to finish yet
1234  application.SendNotification();
1235  finishCheck.CheckSignalNotReceived();
1236  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1237 
1238  application.Render(static_cast<unsigned int>(durationSeconds*100.0f) + 1u/*just beyond half the duration*/);
1239 
1240  // We did expect the animation to finish
1241  application.SendNotification();
1242  finishCheck.CheckSignalReceived();
1243  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1244 
1245  // Check that nothing has changed after a couple of buffer swaps
1246  application.Render(0);
1247  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1248  application.Render(0);
1249  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1250 
1251  END_TEST;
1252 }
1253 
1255 {
1256  TestApplication application;
1257 
1258  Actor actor = Actor::New();
1259  Stage::GetCurrent().Add(actor);
1260 
1261  // Build the animation
1262  float durationSeconds(1.0f);
1263  Animation animation = Animation::New(durationSeconds);
1264 
1265  const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1266  const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1267 
1268  KeyFrames keyframes = KeyFrames::New();
1269  keyframes.Add( 0.0f, initialPosition);
1270  keyframes.Add( 1.0f, targetPosition );
1272 
1273  tet_printf("Test -1 speed factor. Animation will play in reverse at normal speed\n");
1274  animation.SetSpeedFactor( -1.0f );
1275 
1276  // Start the animation
1277  animation.Play();
1278 
1279  bool signalReceived(false);
1280  AnimationFinishCheck finishCheck(signalReceived);
1281  animation.FinishedSignal().Connect(&application, finishCheck);
1282 
1283  application.SendNotification();
1284  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
1285 
1286  // We didn't expect the animation to finish yet
1287  application.SendNotification();
1288  finishCheck.CheckSignalNotReceived();
1289  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
1290 
1291  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1292 
1293  // We didn't expect the animation to finish yet
1294  application.SendNotification();
1295  finishCheck.CheckSignalNotReceived();
1296  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1297 
1298  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1299 
1300  // We didn't expect the animation to finish yet
1301  application.SendNotification();
1302  finishCheck.CheckSignalNotReceived();
1303  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1304 
1305  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1306 
1307  // We didn't expect the animation to finish yet
1308  application.SendNotification();
1309  finishCheck.CheckSignalNotReceived();
1310  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1311 
1312  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1313 
1314  // We did expect the animation to finish
1315  application.SendNotification();
1316  finishCheck.CheckSignalReceived();
1317  DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1318 
1319  // Check that nothing has changed after a couple of buffer swaps
1320  application.Render(0);
1321  DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1322  application.Render(0);
1323  DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1324 
1325  END_TEST;
1326 }
1327 
1329 {
1330  TestApplication application;
1331 
1332  Actor actor = Actor::New();
1333  Stage::GetCurrent().Add(actor);
1334 
1335  // Build the animation
1336  float durationSeconds(1.0f);
1337  Animation animation = Animation::New(durationSeconds);
1338 
1339  const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1340  const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1341 
1342  KeyFrames keyframes = KeyFrames::New();
1343  keyframes.Add( 0.0f, initialPosition);
1344  keyframes.Add( 1.0f, targetPosition );
1346 
1347  bool signalReceived(false);
1348  AnimationFinishCheck finishCheck(signalReceived);
1349  animation.FinishedSignal().Connect(&application, finishCheck);
1350 
1351  tet_printf("Test half speed factor. Animation will take twice the duration\n");
1352 
1353  //Set speed to be half of normal speed
1354  animation.SetSpeedFactor( 0.5f );
1355 
1356  // Start the animation
1357  animation.Play();
1358 
1359  application.SendNotification();
1360  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1361 
1362  // We didn't expect the animation to finish yet
1363  application.SendNotification();
1364  finishCheck.CheckSignalNotReceived();
1365  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1366 
1367  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1368 
1369  // We didn't expect the animation to finish yet
1370  application.SendNotification();
1371  finishCheck.CheckSignalNotReceived();
1372  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1373 
1374  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1375 
1376  // We didn't expect the animation to finish yet
1377  application.SendNotification();
1378  finishCheck.CheckSignalNotReceived();
1379  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1380 
1381  application.SendNotification();
1382  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1383 
1384  // We didn't expect the animation to finish yet
1385  application.SendNotification();
1386  finishCheck.CheckSignalNotReceived();
1387  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1388 
1389  application.Render(static_cast<unsigned int>(durationSeconds*1200.0f) + 1u/*just beyond the animation duration*/);
1390 
1391  // We did expect the animation to finish
1392  application.SendNotification();
1393  finishCheck.CheckSignalReceived();
1394  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
1395 
1396  // Check that nothing has changed after a couple of buffer swaps
1397  application.Render(0);
1398  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1399  application.Render(0);
1400  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1401  END_TEST;
1402 }
1403 
1404 
1406 {
1407  TestApplication application;
1408 
1409  Actor actor = Actor::New();
1410  Stage::GetCurrent().Add(actor);
1411 
1412  // Build the animation
1413  float durationSeconds(1.0f);
1414  Animation animation = Animation::New(durationSeconds);
1415 
1416  const Vector3 initialPosition(0.0f, 0.0f, 0.0f);
1417  const Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1418 
1419  KeyFrames keyframes = KeyFrames::New();
1420  keyframes.Add( 0.0f, initialPosition);
1421  keyframes.Add( 1.0f, targetPosition );
1423 
1424  bool signalReceived(false);
1425  AnimationFinishCheck finishCheck(signalReceived);
1426  animation.FinishedSignal().Connect(&application, finishCheck);
1427 
1428  tet_printf("Test half speed factor. Animation will take twice the duration\n");
1429 
1430  tet_printf("Set speed to be half of normal speed\n");
1431  tet_printf("SetSpeedFactor(0.5f)\n");
1432  animation.SetSpeedFactor( 0.5f );
1433 
1434  // Start the animation
1435  animation.Play();
1436 
1437  application.SendNotification();
1438  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1439 
1440  // We didn't expect the animation to finish yet
1441  application.SendNotification();
1442  finishCheck.CheckSignalNotReceived();
1443  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), TEST_LOCATION );
1444 
1445  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1446 
1447  // We didn't expect the animation to finish yet
1448  application.SendNotification();
1449  finishCheck.CheckSignalNotReceived();
1450  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1451 
1452  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 30% progress */);
1453 
1454  // We didn't expect the animation to finish yet
1455  application.SendNotification();
1456  finishCheck.CheckSignalNotReceived();
1457  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.3f), TEST_LOCATION );
1458 
1459  tet_printf("Reverse direction of animation whilst playing\n");
1460  tet_printf("SetSpeedFactor(-0.5f)\n");
1461  animation.SetSpeedFactor(-0.5f);
1462 
1463  application.SendNotification();
1464  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1465 
1466  // We didn't expect the animation to finish yet
1467  application.SendNotification();
1468  finishCheck.CheckSignalNotReceived();
1469  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1470 
1471  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 10% progress */);
1472 
1473  // We didn't expect the animation to finish yet
1474  application.SendNotification();
1475  finishCheck.CheckSignalNotReceived();
1476  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.1f), 0.0001, TEST_LOCATION );
1477 
1478  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
1479 
1480  // We did expect the animation to finish
1481  application.SendNotification();
1482  finishCheck.CheckSignalReceived();
1483  DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION );
1484 
1485  // Check that nothing has changed after a couple of buffer swaps
1486  application.Render(0);
1487  DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1488  application.Render(0);
1489  DALI_TEST_EQUALS( initialPosition, actor.GetCurrentPosition(), TEST_LOCATION );
1490  END_TEST;
1491 }
1492 
1494 {
1495  TestApplication application;
1496 
1497  const unsigned int NUM_FRAMES(15);
1498 
1499  struct TestData
1500  {
1501  float startTime;
1502  float endTime;
1503  float startX;
1504  float endX;
1505  float expected[NUM_FRAMES];
1506  };
1507 
1508  TestData testData[] = {
1509  // ACTOR 0
1510  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1511  /* |----------PlayRange---------------| */
1512  /* | reverse */
1513  { 0.0f, 1.0f, // TimePeriod
1514  0.0f, 100.0f, // POS
1515  { 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1516  30.0f, 40.0f, 50.0f, 60.0f, /* Reverse direction */
1517  50.0f,
1518  40.0f,
1519  30.0f,
1520  70.0f,
1521  60.0f,
1522  50.0f,
1523 
1524  }
1525  },
1526 
1527  // ACTOR 1 - Across start of range
1528  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1529  /* |----------PlayRange---------------| */
1530  /* | reverse */
1531  { 0.2f, 0.5f, // TimePeriod
1532  20.0f, 50.0f, // POS
1533  { 30.0f, 40.0f, 50.0f, 50.0f, 50.0f, /* Loop */
1534  30.0f, 40.0f, 50.0f, 50.0f, /* Reverse direction @ frame #9 */
1535  50.0f,
1536  40.0f,
1537  30.0f,
1538  50.0f,
1539  50.0f,
1540  50.0f
1541  }
1542  },
1543 
1544  // ACTOR 2 - Across end of range
1545  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1546  /* |----------PlayRange---------------| */
1547  /* | reverse */
1548  { 0.5f, 0.9f, // TimePeriod
1549  50.0f, 90.0f, // POS
1550  { 50.0f, 50.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1551  50.0f, 50.0f, 50.0f, 60.0f,/* Reverse direction @ frame #9 */
1552  50.0f,
1553  50.0f,
1554  50.0f, 70.0f,
1555  60.0f,
1556  50.0f,
1557  }
1558  },
1559 
1560  // ACTOR 3 - Before beginning of range
1561  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1562  /* |----------PlayRange---------------| */
1563  /* | reverse */
1564  { 0.1f, 0.25f, // TimePeriod
1565  10.0f, 25.0f, // POS
1566  {
1567  25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f
1568 
1569  }
1570  },
1571 
1572  // ACTOR 4 - After end of range
1573  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1574  /* |----------PlayRange---------------| */
1575  /* | reverse */
1576  { 0.85f, 1.0f, // TimePeriod
1577  85.0f, 100.0f, // POS
1578  {
1579  85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f, 85.0f
1580 
1581  }
1582  },
1583  // Actor 5 - Middle of range
1584  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1585  /* |----------PlayRange---------------| */
1586  /* | reverse */
1587  { 0.4f, 0.65f, // Time Period
1588  40.0f, 65.0f, // Position
1589  { 40.0f, 40.0f, 50.0f, 60.0f, 65.0f,
1590  40.0f, 40.0f, 50.0f, 60.0f, // Reverse
1591  50.0f,
1592  40.0f,
1593  40.0f,
1594  65.0f,
1595  60.0f,
1596  50.0f,
1597  }
1598  }
1599  };
1600 
1601  const size_t NUM_ENTRIES(sizeof(testData)/sizeof(TestData));
1602 
1603  // Build the animation
1604  float durationSeconds(1.0f);
1605  Animation animation = Animation::New(durationSeconds);
1606  bool signalReceived(false);
1607  AnimationFinishCheck finishCheck(signalReceived);
1608  animation.FinishedSignal().Connect(&application, finishCheck);
1609 
1610  std::vector<Dali::Actor> actors;
1611 
1612  for( unsigned int actorIndex = 0; actorIndex < NUM_ENTRIES; ++actorIndex )
1613  {
1614  Actor actor = Actor::New();
1615  actor.SetPosition( Vector3( testData[actorIndex].startX, 0, 0 ) );
1616  actors.push_back(actor);
1617  Stage::GetCurrent().Add(actor);
1618 
1619  if( actorIndex == 0 || actorIndex == NUM_ENTRIES-1 )
1620  {
1621  KeyFrames keyframes = KeyFrames::New();
1622  keyframes.Add( testData[actorIndex].startTime, Vector3(testData[actorIndex].startX, 0, 0));
1623  keyframes.Add( testData[actorIndex].endTime, Vector3(testData[actorIndex].endX, 0, 0));
1625  }
1626  else
1627  {
1628  animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( testData[actorIndex].endX, 0, 0 ), TimePeriod( testData[actorIndex].startTime, testData[actorIndex].endTime - testData[actorIndex].startTime) );
1629  }
1630  }
1631 
1632  tet_printf("Test half speed factor. Animation will take twice the duration\n");
1633  tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1634  tet_printf("SetSpeedFactor(0.5f)\n");
1635  animation.SetSpeedFactor( 0.5f );
1636  animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1637  animation.SetLooping(true);
1638 
1639  // Start the animation
1640  animation.Play();
1641  application.SendNotification();
1642  application.Render(0); // Frame 0 tests initial values
1643 
1644  for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1645  {
1646  unsigned int actorIndex = 0u;
1647  for( actorIndex = 0u; actorIndex < NUM_ENTRIES; ++actorIndex )
1648  {
1649  DALI_TEST_EQUALS( actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame], 0.001, TEST_LOCATION );
1650  if( ! Equals(actors[actorIndex].GetCurrentPosition().x, testData[actorIndex].expected[frame]) )
1651  {
1652  tet_printf("Failed at frame %u, actorIndex %u\n", frame, actorIndex );
1653  }
1654  }
1655 
1656  if( frame == 8 )
1657  {
1658  tet_printf("Reverse direction of animation whilst playing after frame 8\n");
1659  tet_printf("SetSpeedFactor(-0.5f)\n");
1660  animation.SetSpeedFactor(-0.5f);
1661  application.SendNotification();
1662  }
1663  application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1664 
1665  // We didn't expect the animation to finish yet
1666  application.SendNotification();
1667  finishCheck.CheckSignalNotReceived();
1668  }
1669 
1670  END_TEST;
1671 }
1672 
1674 {
1675  TestApplication application;
1676 
1677  const unsigned int NUM_FRAMES(15);
1678 
1679  struct TestData
1680  {
1681  float startTime;
1682  float endTime;
1683  float startX;
1684  float endX;
1685  float expected[NUM_FRAMES];
1686  };
1687 
1688  TestData testData =
1689  // ACTOR 0
1690  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1691  /* |----------PlayRange---------------| */
1692  { 0.0f, 1.0f, // TimePeriod
1693  0.0f, 100.0f, // POS
1694  { 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, /* Loop */
1695  30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1696  30.0f, 40.0f, 50.0f, 60.0f, 70.0f,
1697 
1698  }
1699  };
1700 
1701 
1702  // Build the animation
1703  float durationSeconds(1.0f);
1704  Animation animation = Animation::New(durationSeconds);
1705  bool signalReceived(false);
1706  AnimationFinishCheck finishCheck(signalReceived);
1707  animation.FinishedSignal().Connect(&application, finishCheck);
1708 
1709  std::vector<Dali::Actor> actors;
1710 
1711  Actor actor = Actor::New();
1712  actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1713  actors.push_back(actor);
1714  Stage::GetCurrent().Add(actor);
1715 
1716  KeyFrames keyframes = KeyFrames::New();
1717  keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1718  keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1720 
1721  tet_printf("Test half speed factor. Animation will take twice the duration\n");
1722  tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1723  tet_printf("SetSpeedFactor(0.5f)\n");
1724  tet_printf("SetLoopCount(3)\n");
1725  animation.SetSpeedFactor( 0.5f );
1726  animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1727  animation.SetLoopCount(3);
1728 
1729  // Start the animation
1730  animation.Play();
1731  application.SendNotification();
1732  application.Render(0); // Frame 0 tests initial values
1733 
1734  for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1735  {
1736  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1737 
1738  application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1739 
1740  if( frame < NUM_FRAMES-1 )
1741  {
1742  // We didn't expect the animation to finish yet
1743  application.SendNotification();
1744  finishCheck.CheckSignalNotReceived();
1745  }
1746  }
1747 
1748  // We did expect the animation to finish
1749  application.SendNotification();
1750  finishCheck.CheckSignalReceived();
1751  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 80.0f, 0.001, TEST_LOCATION );
1752 
1753  END_TEST;
1754 }
1755 
1757 {
1758  TestApplication application;
1759 
1760  const unsigned int NUM_FRAMES(15);
1761 
1762  struct TestData
1763  {
1764  float startTime;
1765  float endTime;
1766  float startX;
1767  float endX;
1768  float expected[NUM_FRAMES];
1769  };
1770 
1771  TestData testData =
1772  // ACTOR 0
1773  /*0.0f, 0.1f 0.2f 0.3f 0.4f 0.5f 0.6f 0.7f 0.8f 0.9f 1.0f */
1774  /* |----------PlayRange---------------| */
1775  { 0.0f, 1.0f, // TimePeriod
1776  0.0f, 100.0f, // POS
1777  { 80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1778  80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1779  80.0f, 70.0f, 60.0f, 50.0f, 40.0f,
1780  }
1781  };
1782 
1783 
1784  // Build the animation
1785  float durationSeconds(1.0f);
1786  Animation animation = Animation::New(durationSeconds);
1787  bool signalReceived(false);
1788  AnimationFinishCheck finishCheck(signalReceived);
1789  animation.FinishedSignal().Connect(&application, finishCheck);
1790 
1791  std::vector<Dali::Actor> actors;
1792 
1793  Actor actor = Actor::New();
1794  actor.SetPosition( Vector3( testData.startX, 0, 0 ) );
1795  actors.push_back(actor);
1796  Stage::GetCurrent().Add(actor);
1797 
1798  KeyFrames keyframes = KeyFrames::New();
1799  keyframes.Add( testData.startTime, Vector3(testData.startX, 0, 0));
1800  keyframes.Add( testData.endTime, Vector3(testData.endX, 0, 0));
1802 
1803  tet_printf("Test reverse half speed factor. Animation will take twice the duration\n");
1804  tet_printf("Set play range to be 0.3 - 0.8 of the duration\n");
1805  tet_printf("SetSpeedFactor(-0.5f)\n");
1806  tet_printf("SetLoopCount(3)\n");
1807  animation.SetSpeedFactor( -0.5f );
1808  animation.SetPlayRange( Vector2(0.3f, 0.8f) );
1809  animation.SetLoopCount(3);
1810 
1811  // Start the animation
1812  animation.Play();
1813  application.SendNotification();
1814  application.Render(0); // Frame 0 tests initial values
1815 
1816  for( unsigned int frame = 0; frame < NUM_FRAMES; ++frame )
1817  {
1818  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, testData.expected[frame], 0.001, TEST_LOCATION );
1819 
1820  application.Render(200); // 200 ms at half speed corresponds to 0.1 s
1821 
1822  if( frame < NUM_FRAMES-1 )
1823  {
1824  // We didn't expect the animation to finish yet
1825  application.SendNotification();
1826  finishCheck.CheckSignalNotReceived();
1827  }
1828  }
1829 
1830  // We did expect the animation to finish
1831  application.SendNotification();
1832  finishCheck.CheckSignalReceived();
1833  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 30.0f, 0.001, TEST_LOCATION );
1834 
1835  END_TEST;
1836 }
1837 
1838 
1840 {
1841  TestApplication application;
1842 
1843  Animation animation = Animation::New(1.0f);
1844  animation.SetSpeedFactor(0.5f);
1845  DALI_TEST_EQUALS(animation.GetSpeedFactor(), 0.5f, TEST_LOCATION);
1846 
1847  animation.SetSpeedFactor(-2.5f);
1848  DALI_TEST_EQUALS(animation.GetSpeedFactor(), -2.5f, TEST_LOCATION);
1849  END_TEST;
1850 }
1851 
1853 {
1854  TestApplication application;
1855 
1856  Actor actor = Actor::New();
1857  Stage::GetCurrent().Add( actor );
1858 
1859  // Build the animation
1860  float durationSeconds( 1.0f );
1861  Animation animation = Animation::New( durationSeconds );
1862 
1863  bool signalReceived( false );
1864  AnimationFinishCheck finishCheck( signalReceived );
1865  animation.FinishedSignal().Connect( &application, finishCheck );
1866  application.SendNotification();
1867 
1868  // Set range between 0.4 and 0.8
1869  animation.SetPlayRange( Vector2( 0.4f, 0.9f ) );
1870  application.SendNotification();
1871  DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION );
1872 
1873  Vector3 targetPosition( 100.0f, 100.0f, 100.0f );
1874  animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR );
1875 
1876  // Start the animation from 40% progress
1877  animation.Play();
1878 
1879  application.SendNotification();
1880  application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 60% progress */ );
1881 
1882  // We didn't expect the animation to finish yet
1883  application.SendNotification();
1884  finishCheck.CheckSignalNotReceived();
1885  DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.6f ), TEST_LOCATION );
1886 
1887  application.SendNotification();
1888  application.Render( static_cast< unsigned int >( durationSeconds * 200.0f )/* 80% progress */ );
1889 
1890  application.SendNotification();
1891  finishCheck.CheckSignalNotReceived();
1892  DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.8f ), TEST_LOCATION );
1893 
1894  application.SendNotification();
1895  application.Render( static_cast< unsigned int >( durationSeconds*100.0f ) + 1u/*just beyond the animation duration*/ );
1896 
1897  // We did expect the animation to finish
1898  application.SendNotification();
1899  finishCheck.CheckSignalReceived();
1900  DALI_TEST_EQUALS( actor.GetCurrentPosition(), ( targetPosition * 0.9f ), TEST_LOCATION );
1901  END_TEST;
1902 }
1903 
1905 {
1906  TestApplication application;
1907 
1908  Actor actor = Actor::New();
1909  Stage::GetCurrent().Add(actor);
1910 
1911  // Build the animation
1912  Animation animation = Animation::New(0);
1913  application.SendNotification();
1914 
1915  //PlayRange out of bounds
1916  animation.SetPlayRange( Vector2(-1.0f,1.0f) );
1917  application.SendNotification();
1918  DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1919  animation.SetPlayRange( Vector2(0.0f,2.0f) );
1920  application.SendNotification();
1921  DALI_TEST_EQUALS( Vector2(0.0f,1.0f), animation.GetPlayRange(), TEST_LOCATION );
1922 
1923  //If playRange is not in the correct order it has to be ordered
1924  animation.SetPlayRange( Vector2(0.8f,0.2f) );
1925  application.SendNotification();
1926  DALI_TEST_EQUALS( Vector2(0.2f,0.8f), animation.GetPlayRange(), TEST_LOCATION );
1927 
1928  END_TEST;
1929 }
1930 
1932 {
1933  TestApplication application;
1934 
1935  Actor actor = Actor::New();
1936  Stage::GetCurrent().Add( actor );
1937 
1938  // Build the animation
1939  Animation animation = Animation::New( 1.0f );
1940  application.SendNotification();
1941 
1942  //If PlayRange not specified it should be 0.0-1.0 by default
1943  DALI_TEST_EQUALS( Vector2( 0.0f,1.0f ), animation.GetPlayRange(), TEST_LOCATION );
1944 
1945  // Set range between 0.4 and 0.8
1946  animation.SetPlayRange( Vector2( 0.4f, 0.8f ) );
1947  application.SendNotification();
1948  DALI_TEST_EQUALS( Vector2( 0.4f, 0.8f ), animation.GetPlayRange(), TEST_LOCATION );
1949 
1950  END_TEST;
1951 }
1952 
1954 {
1955  TestApplication application;
1956 
1957  Actor actor = Actor::New();
1958  Stage::GetCurrent().Add(actor);
1959 
1960  // Build the animation
1961  float durationSeconds(1.0f);
1962  Animation animation = Animation::New(durationSeconds);
1963  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
1964  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
1965 
1966  // Start the animation
1967  animation.Play();
1968 
1969  bool signalReceived(false);
1970  AnimationFinishCheck finishCheck(signalReceived);
1971  animation.FinishedSignal().Connect(&application, finishCheck);
1972 
1973  application.SendNotification();
1974  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
1975 
1976  // We didn't expect the animation to finish yet
1977  application.SendNotification();
1978  finishCheck.CheckSignalNotReceived();
1979  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
1980 
1981  animation.Play(); // Test that calling play has no effect, when animation is already playing
1982  application.SendNotification();
1983  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
1984 
1985  // We didn't expect the animation to finish yet
1986  application.SendNotification();
1987  finishCheck.CheckSignalNotReceived();
1988  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
1989 
1990  animation.Play(); // Test that calling play has no effect, when animation is already playing
1991  application.SendNotification();
1992  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
1993 
1994  // We didn't expect the animation to finish yet
1995  application.SendNotification();
1996  finishCheck.CheckSignalNotReceived();
1997  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
1998 
1999  animation.Play(); // Test that calling play has no effect, when animation is already playing
2000  application.SendNotification();
2001  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2002 
2003  // We didn't expect the animation to finish yet
2004  application.SendNotification();
2005  finishCheck.CheckSignalNotReceived();
2006  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2007 
2008  animation.Play(); // Test that calling play has no effect, when animation is already playing
2009  application.SendNotification();
2010  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2011 
2012  // We did expect the animation to finish
2013  application.SendNotification();
2014  finishCheck.CheckSignalReceived();
2015  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2016 
2017  // Check that nothing has changed after a couple of buffer swaps
2018  application.Render(0);
2019  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2020  application.Render(0);
2021  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2022  END_TEST;
2023 }
2024 
2026 {
2027  // Test that an animation can be played, when the actor is off-stage.
2028  // When the actor is added to the stage, it should appear at the current position
2029  // i.e. where it would have been anyway, if on-stage from the beginning.
2030 
2031  TestApplication application;
2032 
2033  Actor actor = Actor::New();
2034  Vector3 basePosition(Vector3::ZERO);
2035  DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
2036  // Not added to the stage!
2037 
2038  // Build the animation
2039  float durationSeconds(1.0f);
2040  Animation animation = Animation::New(durationSeconds);
2042  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2043  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2044 
2045  // Start the animation
2046  animation.Play();
2047 
2048  bool signalReceived(false);
2049  AnimationFinishCheck finishCheck(signalReceived);
2050  animation.FinishedSignal().Connect(&application, finishCheck);
2051 
2052  application.SendNotification();
2053  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2054 
2055  // We didn't expect the animation to finish yet
2056  application.SendNotification();
2057  finishCheck.CheckSignalNotReceived();
2059 
2060  // Add to the stage
2061  Stage::GetCurrent().Add(actor);
2062 
2063  application.SendNotification();
2064  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2065 
2066  // We didn't expect the animation to finish yet
2067  application.SendNotification();
2068  finishCheck.CheckSignalNotReceived();
2069  Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
2070  DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
2071 
2072  // Remove from the stage
2073  Stage::GetCurrent().Remove(actor);
2074 
2075  application.SendNotification();
2076  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2077 
2078  // We didn't expect the animation to finish yet
2079  application.SendNotification();
2080  finishCheck.CheckSignalNotReceived();
2081  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
2082 
2083  // Add to the stage
2084  Stage::GetCurrent().Add(actor);
2085 
2086  application.SendNotification();
2087  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2088 
2089  // We didn't expect the animation to finish yet
2090  application.SendNotification();
2091  finishCheck.CheckSignalNotReceived();
2092  expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
2093  DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
2094 
2095  application.SendNotification();
2096  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2097 
2098  // We did expect the animation to finish
2099  application.SendNotification();
2100  finishCheck.CheckSignalReceived();
2101  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2102 
2103  // Check that nothing has changed after a couple of buffer swaps
2104  application.Render(0);
2105  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2106  application.Render(0);
2107  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2108  END_TEST;
2109 }
2110 
2112 {
2113  TestApplication application;
2114 
2115  Actor actor = Actor::New();
2116  Stage::GetCurrent().Add(actor);
2117 
2118  // Build the animation
2119  float durationSeconds(1.0f);
2120  Animation animation = Animation::New(durationSeconds);
2121  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2122  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2123 
2124  bool signalReceived(false);
2125  AnimationFinishCheck finishCheck(signalReceived);
2126  animation.FinishedSignal().Connect(&application, finishCheck);
2127 
2128  // Start the animation
2129  animation.Play();
2130 
2131  // This is a test of the "Fire and Forget" behaviour
2132  // Discard the animation handle!
2133  animation.Reset();
2134  DALI_TEST_CHECK( !animation );
2135 
2136  application.SendNotification();
2137  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2138 
2139  // We didn't expect the animation to finish yet
2140  application.SendNotification();
2141  finishCheck.CheckSignalNotReceived();
2142  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2143 
2144  application.SendNotification();
2145  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2146 
2147  // We didn't expect the animation to finish yet
2148  application.SendNotification();
2149  finishCheck.CheckSignalNotReceived();
2150  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION );
2151 
2152  application.SendNotification();
2153  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2154 
2155  // We didn't expect the animation to finish yet
2156  application.SendNotification();
2157  finishCheck.CheckSignalNotReceived();
2158  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2159 
2160  application.SendNotification();
2161  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2162 
2163  // We didn't expect the animation to finish yet
2164  application.SendNotification();
2165  finishCheck.CheckSignalNotReceived();
2166  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2167 
2168  application.SendNotification();
2169  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2170 
2171  // We did expect the animation to finish
2172  application.SendNotification();
2173  finishCheck.CheckSignalReceived();
2174  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2175 
2176  // Check that nothing has changed after a couple of buffer swaps
2177  application.Render(0);
2178  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2179  application.Render(0);
2180  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2181  END_TEST;
2182 }
2183 
2185 {
2186  TestApplication application;
2187 
2188  Actor actor = Actor::New();
2189  Stage::GetCurrent().Add(actor);
2190 
2191  // Build the animation
2192  float durationSeconds(1.0f);
2193  Animation animation = Animation::New(durationSeconds);
2194  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2195  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2196 
2197  // Start the animation
2198  animation.Play();
2199 
2200  bool signalReceived(false);
2201  AnimationFinishCheck finishCheck(signalReceived);
2202  animation.FinishedSignal().Connect(&application, finishCheck);
2203 
2204  application.SendNotification();
2205  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
2206 
2207  // We didn't expect the animation to finish yet
2208  application.SendNotification();
2209  finishCheck.CheckSignalNotReceived();
2210  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2211 
2212  // This is a test of the "Fire and Forget" behaviour
2213  // Stop the animation, and Discard the animation handle!
2214  animation.Stop();
2215  animation.Reset();
2216  DALI_TEST_CHECK( !animation );
2217 
2218  application.SendNotification();
2219  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
2220 
2221  // We expect the animation to finish at 20% progress
2222  application.SendNotification();
2223  finishCheck.CheckSignalReceived();
2224  finishCheck.Reset();
2225  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2226 
2227  application.SendNotification();
2228  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2229 
2230  // Check that nothing has changed
2231  application.SendNotification();
2232  finishCheck.CheckSignalNotReceived();
2233  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2234 
2235  application.SendNotification();
2236  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2237 
2238  // Check that nothing has changed
2239  application.SendNotification();
2240  finishCheck.CheckSignalNotReceived();
2241  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2242 
2243  application.SendNotification();
2244  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
2245 
2246  // Check that nothing has changed
2247  application.SendNotification();
2248  finishCheck.CheckSignalNotReceived();
2249  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION );
2250  END_TEST;
2251 }
2252 
2254 {
2255  TestApplication application;
2256 
2257  Actor actor = Actor::New();
2258  Stage::GetCurrent().Add(actor);
2259 
2260  // Build the animation
2261  float durationSeconds(1.0f);
2262  Animation animation = Animation::New(durationSeconds);
2263  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2264  KeyFrames keyframes = KeyFrames::New();
2265  keyframes.Add( 0.0f , Vector3(0.0f,0.0f,0.0f ) );
2266  keyframes.Add( 1.0f , Vector3(100.0f,100.0f,100.0f ) );
2267 
2268  animation.AnimateBetween( Property( actor, Actor::Property::POSITION), keyframes );
2269 
2270  // Set range between 0.4 and 0.8
2271  animation.SetPlayRange( Vector2(0.4f,0.8f) );
2272  animation.Play();
2273 
2274  bool signalReceived(false);
2275  AnimationFinishCheck finishCheck(signalReceived);
2276  animation.FinishedSignal().Connect(&application, finishCheck);
2277 
2278  //Test that setting progress outside the range doesn't work
2279  animation.SetCurrentProgress( 0.9f );
2280  application.SendNotification();
2281  application.Render(0);
2282  DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2283  animation.SetCurrentProgress( 0.2f );
2284  application.SendNotification();
2285  application.Render(0);
2286  DALI_TEST_EQUALS( animation.GetCurrentProgress(), 0.4f, TEST_LOCATION );
2287 
2288  application.SendNotification();
2289  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2290 
2291  // We didn't expect the animation to finish yet
2292  application.SendNotification();
2293  finishCheck.CheckSignalNotReceived();
2294  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2295 
2296  animation.Play(); // Test that calling play has no effect, when animation is already playing
2297  application.SendNotification();
2298  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/* 80% progress */);
2299 
2300  // We did expect the animation to finish
2301  application.SendNotification();
2302  finishCheck.CheckSignalReceived();
2303  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2304 
2305  // Check that nothing has changed after a couple of buffer swaps
2306  application.Render(0);
2307  DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2308  application.Render(0);
2309  DALI_TEST_EQUALS( targetPosition * 0.8f, actor.GetCurrentPosition(), TEST_LOCATION );
2310 
2311 
2312  //Loop inside the range
2313  finishCheck.Reset();
2314  animation.SetLooping( true );
2315  animation.Play();
2316  application.SendNotification();
2317  float intervalSeconds = 0.1f;
2318  float progress = 0.4f;
2319  for (int iterations = 0; iterations < 10; ++iterations )
2320  {
2321  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2322 
2323  progress += intervalSeconds;
2324  if (progress > 0.8f)
2325  {
2326  progress = progress - 0.4f;
2327  }
2328 
2329  DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2330  }
2331 
2332  // We didn't expect the animation to finish yet
2333  application.SendNotification();
2334  finishCheck.CheckSignalNotReceived();
2335 
2336 
2337  //Test change range on the fly
2338  animation.SetPlayRange( Vector2( 0.2f, 0.9f ) );
2339  application.SendNotification();
2340 
2341  for (int iterations = 0; iterations < 10; ++iterations )
2342  {
2343  application.Render(static_cast<unsigned int>(durationSeconds*intervalSeconds*1000.0f));
2344 
2345  progress += intervalSeconds;
2346  if (progress > 0.9f)
2347  {
2348  progress = progress - 0.7f;
2349  }
2350 
2351  DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION );
2352  }
2353 
2354  END_TEST;
2355 }
2356 
2358 {
2359  TestApplication application;
2360 
2361  Actor actor = Actor::New();
2362  Stage::GetCurrent().Add(actor);
2363 
2364  // Build the animation
2365  float durationSeconds(1.0f);
2366  Animation animation = Animation::New(durationSeconds);
2367  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2368  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2369 
2370  // Start the animation from 40% progress
2371  animation.PlayFrom( 0.4f );
2372 
2373  bool signalReceived(false);
2374  AnimationFinishCheck finishCheck(signalReceived);
2375  animation.FinishedSignal().Connect(&application, finishCheck);
2376 
2377  application.SendNotification();
2378  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
2379 
2380  // We didn't expect the animation to finish yet
2381  application.SendNotification();
2382  finishCheck.CheckSignalNotReceived();
2383  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION );
2384 
2385  animation.Play(); // Test that calling play has no effect, when animation is already playing
2386  application.SendNotification();
2387  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
2388 
2389  // We didn't expect the animation to finish yet
2390  application.SendNotification();
2391  finishCheck.CheckSignalNotReceived();
2392  DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION );
2393 
2394  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
2395  // We did expect the animation to finish
2396  application.SendNotification();
2397  finishCheck.CheckSignalReceived();
2398  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2399 
2400  // Check that nothing has changed after a couple of buffer swaps
2401  application.Render(0);
2402  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2403  application.Render(0);
2404  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2405  END_TEST;
2406 }
2407 
2409 {
2410  TestApplication application;
2411 
2412  Actor actor = Actor::New();
2413  Stage::GetCurrent().Add(actor);
2414 
2415  // Build the animation
2416  float durationSeconds(1.0f);
2417  Animation animation = Animation::New(durationSeconds);
2418  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2419  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2420 
2421  //PlayFrom with an argument outside the range [0..1] will be ignored
2422  animation.PlayFrom(-1.0f);
2423  application.SendNotification();
2424  DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2425 
2426  animation.PlayFrom(100.0f);
2427  application.SendNotification();
2428  DALI_TEST_EQUALS(0.0f, animation.GetCurrentProgress(), TEST_LOCATION );
2429  END_TEST;
2430 }
2431 
2433 {
2434  TestApplication application;
2435 
2436  Actor actor = Actor::New();
2437  Stage::GetCurrent().Add(actor);
2438 
2439  // Build the animation
2440  float durationSeconds(1.0f);
2441  Animation animation = Animation::New(durationSeconds);
2442  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2443  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2444 
2445  Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2446 
2447  // Start the animation
2448  animation.Play();
2449 
2450  bool signalReceived(false);
2451  AnimationFinishCheck finishCheck(signalReceived);
2452  animation.FinishedSignal().Connect(&application, finishCheck);
2453 
2454  application.SendNotification();
2455  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2456 
2457  // We didn't expect the animation to finish yet
2458  application.SendNotification();
2459  finishCheck.CheckSignalNotReceived();
2460  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2461 
2462  // Pause the animation
2463  animation.Pause();
2464  application.SendNotification();
2465 
2466  // Loop 5 times
2467  for (int i=0; i<5; ++i)
2468  {
2469  application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2470 
2471  // We didn't expect the animation to finish yet
2472  application.SendNotification();
2473  finishCheck.CheckSignalNotReceived();
2474  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2475  }
2476 
2477  // Keep going
2478  animation.Play();
2479  application.SendNotification();
2480  application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2481 
2482  // We didn't expect the animation to finish yet
2483  application.SendNotification();
2484  finishCheck.CheckSignalNotReceived();
2485 
2486  application.SendNotification();
2487  application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2488 
2489  // We did expect the animation to finish
2490  application.SendNotification();
2491  finishCheck.CheckSignalReceived();
2492  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2493 
2494  // Check that nothing has changed after a couple of buffer swaps
2495  application.Render(0);
2496  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2497  application.Render(0);
2498  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2499  END_TEST;
2500 }
2501 
2502 
2504 {
2505  TestApplication application;
2506 
2507  Actor actor = Actor::New();
2508  Stage::GetCurrent().Add(actor);
2509 
2510  // Build the animation
2511  float durationSeconds(1.0f);
2512  Animation animation = Animation::New(durationSeconds);
2513  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2514  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2516 
2517  Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2518 
2519  // Start the animation
2520  animation.Play();
2521 
2523 
2524  bool signalReceived(false);
2525  AnimationFinishCheck finishCheck(signalReceived);
2526  animation.FinishedSignal().Connect(&application, finishCheck);
2527 
2528  application.SendNotification();
2529  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2530 
2531  // We didn't expect the animation to finish yet
2532  application.SendNotification();
2533  finishCheck.CheckSignalNotReceived();
2535  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2536 
2537  // Pause the animation
2538  animation.Pause();
2540  application.SendNotification();
2541  application.Render(0.f);
2542 
2543  // Loop 5 times
2544  for (int i=0; i<5; ++i)
2545  {
2546  application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2547 
2548  // We didn't expect the animation to finish yet
2549  application.SendNotification();
2550  finishCheck.CheckSignalNotReceived();
2551  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION );
2553  }
2554 
2555  // Keep going
2556  finishCheck.Reset();
2557  animation.Play();
2559  application.SendNotification();
2560  application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2561  // We didn't expect the animation to finish yet
2562  application.SendNotification();
2563  finishCheck.CheckSignalNotReceived();
2565 
2566  application.SendNotification();
2567  application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
2568 
2569  // We did expect the animation to finish
2570  application.SendNotification();
2571  finishCheck.CheckSignalReceived();
2572  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2574 
2575  // Check that nothing has changed after a couple of buffer swaps
2576  application.Render(0);
2577  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2578  application.Render(0);
2579  DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
2581 
2582  // re-play
2583  finishCheck.Reset();
2584  animation.Play();
2586  application.SendNotification();
2587  application.Render(static_cast<unsigned int>(durationSeconds*490.0f)/*slightly less than the animation duration*/);
2588  application.SendNotification();
2589  finishCheck.CheckSignalNotReceived();
2591 
2592 
2593  END_TEST;
2594 }
2595 
2597 {
2598  TestApplication application;
2599 
2600  Actor actor = Actor::New();
2601  Stage::GetCurrent().Add(actor);
2602 
2603  // Build the animation
2604  float durationSeconds(1.0f);
2605  Animation animation = Animation::New(durationSeconds);
2606  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2607  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2608 
2609  Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2610 
2611  // Start the animation
2612  animation.Play();
2613 
2614  bool signalReceived(false);
2615  AnimationFinishCheck finishCheck(signalReceived);
2616  animation.FinishedSignal().Connect(&application, finishCheck);
2617 
2618  application.SendNotification();
2619  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2620 
2621  // We didn't expect the animation to finish yet
2622  application.SendNotification();
2623  finishCheck.CheckSignalNotReceived();
2624  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2625 
2626  // Stop the animation
2627  animation.Stop();
2628  application.SendNotification();
2629 
2630  // Loop 5 times
2631  for (int i=0; i<5; ++i)
2632  {
2633  application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2634 
2635  // We did expect the animation to finish
2636  application.SendNotification();
2637  finishCheck.CheckSignalReceived();
2638  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION );
2639  }
2640  END_TEST;
2641 }
2642 
2644 {
2645  // Test that Animation::Stop & Actor::SetPosition can be used in conjunction
2646  // i.e. to check that the animation does not interfere with the position set.
2647 
2648  TestApplication application;
2649 
2650  Actor actor = Actor::New();
2651  Stage::GetCurrent().Add(actor);
2652 
2653  // Build the animation
2654  float durationSeconds(1.0f);
2655  Animation animation = Animation::New(durationSeconds);
2656  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2657  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2658 
2659  Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2660 
2661  // Start the animation
2662  animation.Play();
2663 
2664  bool signalReceived(false);
2665  AnimationFinishCheck finishCheck(signalReceived);
2666  animation.FinishedSignal().Connect(&application, finishCheck);
2667 
2668  application.SendNotification();
2669  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2670 
2671  // We didn't expect the animation to finish yet
2672  application.SendNotification();
2673  finishCheck.CheckSignalNotReceived();
2674  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2675 
2676  // Stop the animation
2677  animation.Stop();
2678  Vector3 positionSet(2.0f, 3.0f, 4.0f);
2679  actor.SetPosition(positionSet);
2680  application.SendNotification();
2681 
2682  // Loop 5 times
2683  for (int i=0; i<5; ++i)
2684  {
2685  application.Render(static_cast<unsigned int>(durationSeconds*500.0f));
2686 
2687  // We did expect the animation to finish
2688  application.SendNotification();
2689  finishCheck.CheckSignalReceived();
2690  DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION );
2691  }
2692  END_TEST;
2693 }
2694 
2696 {
2697  TestApplication application;
2698 
2699  Actor actor = Actor::New();
2700  Stage::GetCurrent().Add(actor);
2701 
2702  // Build the animation
2703  float durationSeconds(1.0f);
2704  Animation animation = Animation::New(durationSeconds);
2705  Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2706  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
2707 
2708  Vector3 fiftyPercentProgress(targetPosition * 0.5f);
2709 
2710  // Start the animation
2711  animation.Play();
2712 
2713  bool signalReceived(false);
2714  AnimationFinishCheck finishCheck(signalReceived);
2715  animation.FinishedSignal().Connect(&application, finishCheck);
2716 
2717  application.SendNotification();
2718  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2719 
2720  // We didn't expect the animation to finish yet
2721  application.SendNotification();
2722  finishCheck.CheckSignalNotReceived();
2723  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION );
2724 
2725  // Clear the animation
2726  animation.Clear();
2727  application.SendNotification();
2728 
2729  application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2730 
2731  // We don't expect the animation to finish now
2732  application.SendNotification();
2733  finishCheck.CheckSignalNotReceived();
2734  DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION );
2735 
2736  // Restart as a scale animation; this should not move the actor's position
2737  finishCheck.Reset();
2738  actor.SetPosition(Vector3::ZERO);
2739  Vector3 targetScale(3.0f, 3.0f, 3.0f);
2740  animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR );
2741  animation.Play();
2742 
2743  application.SendNotification();
2744  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% progress */);
2745 
2746  // We didn't expect the animation to finish yet
2747  application.SendNotification();
2748  finishCheck.CheckSignalNotReceived();
2749  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2750  DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION );
2751 
2752  application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
2753 
2754  // We did expect the animation to finish
2755  application.SendNotification();
2756  finishCheck.CheckSignalReceived();
2757  DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION );
2758  DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
2759  END_TEST;
2760 }
2761 
2763 {
2764  TestApplication application;
2765 
2766  // Start the empty animation
2767  float durationSeconds(1.0f);
2768  Animation animation = Animation::New(durationSeconds);
2769  animation.Play();
2770 
2771  bool signalReceived(false);
2772  AnimationFinishCheck finishCheck(signalReceived);
2773  animation.FinishedSignal().Connect(&application, finishCheck);
2774 
2775  application.SendNotification();
2776  application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/);
2777 
2778  // We did expect the animation to finish
2779  application.SendNotification();
2780  finishCheck.CheckSignalReceived();
2781  END_TEST;
2782 }
2783 
2785 {
2786  TestApplication application;
2787 
2788  Actor actor = Actor::New();
2789 
2790  // Register a boolean property
2791  bool startValue(false);
2792  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
2793  Stage::GetCurrent().Add(actor);
2794  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2795 
2796  // Build the animation
2797  float durationSeconds(2.0f);
2798  Animation animation = Animation::New(durationSeconds);
2799  const bool relativeValue(true);
2800  const bool finalValue( false || relativeValue );
2801  animation.AnimateBy(Property(actor, index), relativeValue);
2802 
2803  // Start the animation
2804  animation.Play();
2805 
2806  bool signalReceived(false);
2807  AnimationFinishCheck finishCheck(signalReceived);
2808  animation.FinishedSignal().Connect(&application, finishCheck);
2809 
2810  application.SendNotification();
2811  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2812 
2813  // We didn't expect the animation to finish yet
2814  application.SendNotification();
2815  finishCheck.CheckSignalNotReceived();
2816  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2817 
2818  application.SendNotification();
2819  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2820 
2821  // We did expect the animation to finish
2822  application.SendNotification();
2823  finishCheck.CheckSignalReceived();
2824  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2825 
2826  // Check that nothing has changed after a couple of buffer swaps
2827  application.Render(0);
2828  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2829  application.Render(0);
2830  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2831 
2832  // Repeat with relative value "false" - this should be an NOOP
2833  animation = Animation::New(durationSeconds);
2834  bool noOpValue(false);
2835  animation.AnimateBy(Property(actor, index), noOpValue);
2836 
2837  // Start the animation
2838  animation.Play();
2839 
2840  finishCheck.Reset();
2841  animation.FinishedSignal().Connect(&application, finishCheck);
2842 
2843  application.SendNotification();
2844  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2845 
2846  // We didn't expect the animation to finish yet
2847  application.SendNotification();
2848  finishCheck.CheckSignalNotReceived();
2849  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2850 
2851  application.SendNotification();
2852  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2853 
2854  // We did expect the animation to finish
2855  application.SendNotification();
2856  finishCheck.CheckSignalReceived();
2857  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2858 
2859  // Check that nothing has changed after a couple of buffer swaps
2860  application.Render(0);
2861  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2862  application.Render(0);
2863  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2864  END_TEST;
2865 }
2866 
2868 {
2869  TestApplication application;
2870 
2871  Actor actor = Actor::New();
2872 
2873  // Register a boolean property
2874  bool startValue(false);
2875  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
2876  Stage::GetCurrent().Add(actor);
2877  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2878 
2879  // Build the animation
2880  float durationSeconds(2.0f);
2881  Animation animation = Animation::New(durationSeconds);
2882  bool relativeValue(true);
2883  bool finalValue( false || relativeValue );
2884  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN);
2885 
2886  // Start the animation
2887  animation.Play();
2888 
2889  bool signalReceived(false);
2890  AnimationFinishCheck finishCheck(signalReceived);
2891  animation.FinishedSignal().Connect(&application, finishCheck);
2892 
2893  application.SendNotification();
2894  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2895 
2896  // We didn't expect the animation to finish yet
2897  application.SendNotification();
2898  finishCheck.CheckSignalNotReceived();
2899  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2900 
2901  application.SendNotification();
2902  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2903 
2904  // We did expect the animation to finish
2905  application.SendNotification();
2906  finishCheck.CheckSignalReceived();
2907  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2908 
2909  // Check that nothing has changed after a couple of buffer swaps
2910  application.Render(0);
2911  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2912  application.Render(0);
2913  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2914 
2915  // Repeat with relative value "false" - this should be an NOOP
2916  animation = Animation::New(durationSeconds);
2917  bool noOpValue(false);
2918  animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN);
2919 
2920  // Start the animation
2921  animation.Play();
2922 
2923  finishCheck.Reset();
2924  animation.FinishedSignal().Connect(&application, finishCheck);
2925 
2926  application.SendNotification();
2927  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
2928 
2929  // We didn't expect the animation to finish yet
2930  application.SendNotification();
2931  finishCheck.CheckSignalNotReceived();
2932  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2933 
2934  application.SendNotification();
2935  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
2936 
2937  // We did expect the animation to finish
2938  application.SendNotification();
2939  finishCheck.CheckSignalReceived();
2940  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2941  END_TEST;
2942 }
2943 
2945 {
2946  TestApplication application;
2947 
2948  Actor actor = Actor::New();
2949 
2950  // Register a boolean property
2951  bool startValue(false);
2952  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
2953  Stage::GetCurrent().Add(actor);
2954  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2955 
2956  // Build the animation
2957  float durationSeconds(2.0f);
2958  Animation animation = Animation::New(durationSeconds);
2959  bool relativeValue(true);
2960  bool finalValue( false || relativeValue );
2961  float animatorDurationSeconds(durationSeconds * 0.5f);
2962  animation.AnimateBy( Property(actor, index),
2963  relativeValue,
2964  TimePeriod( animatorDurationSeconds ) );
2965 
2966  // Start the animation
2967  animation.Play();
2968 
2969  bool signalReceived(false);
2970  AnimationFinishCheck finishCheck(signalReceived);
2971  animation.FinishedSignal().Connect(&application, finishCheck);
2972 
2973  application.SendNotification();
2974  application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
2975 
2976  // We didn't expect the animation to finish yet
2977  application.SendNotification();
2978  finishCheck.CheckSignalNotReceived();
2979  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
2980 
2981  application.SendNotification();
2982  application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
2983 
2984  // We didn't expect the animation to finish yet...
2985  application.SendNotification();
2986  finishCheck.CheckSignalNotReceived();
2987 
2988  // ...however we should have reached the final value
2989  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2990 
2991  application.SendNotification();
2992  application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
2993 
2994  // We did expect the animation to finish
2995  application.SendNotification();
2996  finishCheck.CheckSignalReceived();
2997  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
2998 
2999  // Check that nothing has changed after a couple of buffer swaps
3000  application.Render(0);
3001  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3002  application.Render(0);
3003  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3004  END_TEST;
3005 }
3006 
3008 {
3009  TestApplication application;
3010 
3011  Actor actor = Actor::New();
3012 
3013  // Register a boolean property
3014  bool startValue(false);
3015  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3016  Stage::GetCurrent().Add(actor);
3017  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3018 
3019  // Build the animation
3020  float durationSeconds(2.0f);
3021  Animation animation = Animation::New(durationSeconds);
3022  bool relativeValue(true);
3023  bool finalValue( false || relativeValue );
3024  float animatorDurationSeconds(durationSeconds * 0.5f);
3025  animation.AnimateBy( Property(actor, index),
3026  relativeValue,
3028  TimePeriod( animatorDurationSeconds ) );
3029 
3030  // Start the animation
3031  animation.Play();
3032 
3033  bool signalReceived(false);
3034  AnimationFinishCheck finishCheck(signalReceived);
3035  animation.FinishedSignal().Connect(&application, finishCheck);
3036 
3037  application.SendNotification();
3038  application.Render(static_cast<unsigned int>(animatorDurationSeconds*950.0f)/* 95% animator progress */);
3039 
3040  // We didn't expect the animation to finish yet
3041  application.SendNotification();
3042  finishCheck.CheckSignalNotReceived();
3043  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
3044 
3045  application.SendNotification();
3046  application.Render(static_cast<unsigned int>(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/);
3047 
3048  // We didn't expect the animation to finish yet...
3049  application.SendNotification();
3050  finishCheck.CheckSignalNotReceived();
3051 
3052  // ...however we should have reached the final value
3053  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3054 
3055  application.SendNotification();
3056  application.Render(static_cast<unsigned int>(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/);
3057 
3058  // We did expect the animation to finish
3059  application.SendNotification();
3060  finishCheck.CheckSignalReceived();
3061  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3062 
3063  // Check that nothing has changed after a couple of buffer swaps
3064  application.Render(0);
3065  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3066  application.Render(0);
3067  DALI_TEST_CHECK( actor.GetProperty<bool>(index) == finalValue );
3068  END_TEST;
3069 }
3070 
3072 {
3073  TestApplication application;
3074 
3075  Actor actor = Actor::New();
3076 
3077  // Register a float property
3078  float startValue(10.0f);
3079  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3080  Stage::GetCurrent().Add(actor);
3081  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3082 
3083  // Build the animation
3084  float durationSeconds(2.0f);
3085  Animation animation = Animation::New(durationSeconds);
3086  float targetValue(50.0f);
3087  float relativeValue(targetValue - startValue);
3088  animation.AnimateBy(Property(actor, index), relativeValue);
3089 
3090  float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3091 
3092  // Start the animation
3093  animation.Play();
3094 
3095  bool signalReceived(false);
3096  AnimationFinishCheck finishCheck(signalReceived);
3097  animation.FinishedSignal().Connect(&application, finishCheck);
3098 
3099  application.SendNotification();
3100  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3101 
3102  // We didn't expect the animation to finish yet
3103  application.SendNotification();
3104  finishCheck.CheckSignalNotReceived();
3105  DALI_TEST_EQUALS( actor.GetProperty<float>(index), ninetyFivePercentProgress, TEST_LOCATION );
3106 
3107  application.SendNotification();
3108  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3109 
3110  // We did expect the animation to finish
3111  application.SendNotification();
3112  finishCheck.CheckSignalReceived();
3113  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3114 
3115  // Check that nothing has changed after a couple of buffer swaps
3116  application.Render(0);
3117  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3118  application.Render(0);
3119  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3120  END_TEST;
3121 }
3122 
3124 {
3125  TestApplication application;
3126 
3127  Actor actor = Actor::New();
3128 
3129  // Register a float property
3130  float startValue(10.0f);
3131  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3132  Stage::GetCurrent().Add(actor);
3133  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3134 
3135  // Build the animation
3136  float durationSeconds(1.0f);
3137  Animation animation = Animation::New(durationSeconds);
3138  float targetValue(90.0f);
3139  float relativeValue(targetValue - startValue);
3140  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3141 
3142  float ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3143 
3144  // Start the animation
3145  animation.Play();
3146 
3147  bool signalReceived(false);
3148  AnimationFinishCheck finishCheck(signalReceived);
3149  animation.FinishedSignal().Connect(&application, finishCheck);
3150 
3151  application.SendNotification();
3152  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3153 
3154  // We didn't expect the animation to finish yet
3155  application.SendNotification();
3156  finishCheck.CheckSignalNotReceived();
3157 
3158  // The position should have moved more, than with a linear alpha function
3159  float current(actor.GetProperty<float>(index));
3160  DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3161 
3162  application.SendNotification();
3163  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3164 
3165  // We did expect the animation to finish
3166  application.SendNotification();
3167  finishCheck.CheckSignalReceived();
3168  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3169 
3170  // Check that nothing has changed after a couple of buffer swaps
3171  application.Render(0);
3172  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3173  application.Render(0);
3174  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3175  END_TEST;
3176 }
3177 
3179 {
3180  TestApplication application;
3181 
3182  Actor actor = Actor::New();
3183 
3184  // Register a float property
3185  float startValue(10.0f);
3186  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3187  Stage::GetCurrent().Add(actor);
3188  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3189 
3190  // Build the animation
3191  float durationSeconds(1.0f);
3192  Animation animation = Animation::New(durationSeconds);
3193  float targetValue(30.0f);
3194  float relativeValue(targetValue - startValue);
3195  float delay = 0.5f;
3196  animation.AnimateBy(Property(actor, index),
3197  relativeValue,
3198  TimePeriod(delay, durationSeconds - delay));
3199 
3200  // Start the animation
3201  animation.Play();
3202 
3203  bool signalReceived(false);
3204  AnimationFinishCheck finishCheck(signalReceived);
3205  animation.FinishedSignal().Connect(&application, finishCheck);
3206 
3207  application.SendNotification();
3208  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3209 
3210  // We didn't expect the animation to finish yet
3211  application.SendNotification();
3212  finishCheck.CheckSignalNotReceived();
3213  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3214 
3215  application.SendNotification();
3216  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3217 
3218  // We didn't expect the animation to finish yet
3219  application.SendNotification();
3220  finishCheck.CheckSignalNotReceived();
3221  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3222 
3223  application.SendNotification();
3224  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3225 
3226  // We did expect the animation to finish
3227  application.SendNotification();
3228  finishCheck.CheckSignalReceived();
3229  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3230 
3231  // Check that nothing has changed after a couple of buffer swaps
3232  application.Render(0);
3233  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3234  application.Render(0);
3235  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3236  END_TEST;
3237 }
3238 
3240 {
3241  TestApplication application;
3242 
3243  Actor actor = Actor::New();
3244 
3245  // Register a float property
3246  float startValue(10.0f);
3247  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3248  Stage::GetCurrent().Add(actor);
3249  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3250 
3251  // Build the animation
3252  float durationSeconds(1.0f);
3253  Animation animation = Animation::New(durationSeconds);
3254  float targetValue(30.0f);
3255  float relativeValue(targetValue - startValue);
3256  float delay = 0.5f;
3257  animation.AnimateBy(Property(actor, index),
3258  relativeValue,
3260  TimePeriod(delay, durationSeconds - delay));
3261 
3262  // Start the animation
3263  animation.Play();
3264 
3265  bool signalReceived(false);
3266  AnimationFinishCheck finishCheck(signalReceived);
3267  animation.FinishedSignal().Connect(&application, finishCheck);
3268 
3269  application.SendNotification();
3270  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3271 
3272  // We didn't expect the animation to finish yet
3273  application.SendNotification();
3274  finishCheck.CheckSignalNotReceived();
3275  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
3276 
3277  application.SendNotification();
3278  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3279 
3280  // We didn't expect the animation to finish yet
3281  application.SendNotification();
3282  finishCheck.CheckSignalNotReceived();
3283  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3284 
3285  application.SendNotification();
3286  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3287 
3288  // We did expect the animation to finish
3289  application.SendNotification();
3290  finishCheck.CheckSignalReceived();
3291  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3292 
3293  // Check that nothing has changed after a couple of buffer swaps
3294  application.Render(0);
3295  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3296  application.Render(0);
3297  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
3298  END_TEST;
3299 }
3300 
3302 {
3303  TestApplication application;
3304 
3305  Actor actor = Actor::New();
3306 
3307  // Register an integer property
3308  int startValue(1);
3309  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3310  Stage::GetCurrent().Add(actor);
3311  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3312 
3313  // Build the animation
3314  float durationSeconds(2.0f);
3315  Animation animation = Animation::New(durationSeconds);
3316  int targetValue(50);
3317  int relativeValue(targetValue - startValue);
3318  animation.AnimateBy(Property(actor, index), relativeValue);
3319 
3320  int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3321 
3322  // Start the animation
3323  animation.Play();
3324 
3325  bool signalReceived(false);
3326  AnimationFinishCheck finishCheck(signalReceived);
3327  animation.FinishedSignal().Connect(&application, finishCheck);
3328 
3329  application.SendNotification();
3330  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3331 
3332  // We didn't expect the animation to finish yet
3333  application.SendNotification();
3334  finishCheck.CheckSignalNotReceived();
3335  DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
3336 
3337  application.SendNotification();
3338  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3339 
3340  // We did expect the animation to finish
3341  application.SendNotification();
3342  finishCheck.CheckSignalReceived();
3343  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3344 
3345  // Check that nothing has changed after a couple of buffer swaps
3346  application.Render(0);
3347  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3348  application.Render(0);
3349  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3350  END_TEST;
3351 }
3352 
3354 {
3355  TestApplication application;
3356 
3357  Actor actor = Actor::New();
3358 
3359  // Register an integer property
3360  int startValue(1);
3361  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3362  Stage::GetCurrent().Add(actor);
3363  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3364 
3365  // Build the animation
3366  float durationSeconds(1.0f);
3367  Animation animation = Animation::New(durationSeconds);
3368  int targetValue(90);
3369  int relativeValue(targetValue - startValue);
3370  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3371 
3372  int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
3373 
3374  // Start the animation
3375  animation.Play();
3376 
3377  bool signalReceived(false);
3378  AnimationFinishCheck finishCheck(signalReceived);
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 
3388  // The position should have moved more, than with a linear alpha function
3389  int current(actor.GetProperty<int>(index));
3390  DALI_TEST_CHECK( current > ninetyFivePercentProgress );
3391 
3392  application.SendNotification();
3393  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3394 
3395  // We did expect the animation to finish
3396  application.SendNotification();
3397  finishCheck.CheckSignalReceived();
3398  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3399 
3400  // Check that nothing has changed after a couple of buffer swaps
3401  application.Render(0);
3402  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3403  application.Render(0);
3404  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3405  END_TEST;
3406 }
3407 
3409 {
3410  TestApplication application;
3411 
3412  Actor actor = Actor::New();
3413 
3414  // Register an integer property
3415  int startValue(10);
3416  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3417  Stage::GetCurrent().Add(actor);
3418  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3419 
3420  // Build the animation
3421  float durationSeconds(1.0f);
3422  Animation animation = Animation::New(durationSeconds);
3423  int targetValue(30);
3424  int relativeValue(targetValue - startValue);
3425  float delay = 0.5f;
3426  animation.AnimateBy(Property(actor, index),
3427  relativeValue,
3428  TimePeriod(delay, durationSeconds - delay));
3429 
3430  // Start the animation
3431  animation.Play();
3432 
3433  bool signalReceived(false);
3434  AnimationFinishCheck finishCheck(signalReceived);
3435  animation.FinishedSignal().Connect(&application, finishCheck);
3436 
3437  application.SendNotification();
3438  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3439 
3440  // We didn't expect the animation to finish yet
3441  application.SendNotification();
3442  finishCheck.CheckSignalNotReceived();
3443  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3444 
3445  application.SendNotification();
3446  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3447 
3448  // We didn't expect the animation to finish yet
3449  application.SendNotification();
3450  finishCheck.CheckSignalNotReceived();
3451  DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3452 
3453  application.SendNotification();
3454  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3455 
3456  // We did expect the animation to finish
3457  application.SendNotification();
3458  finishCheck.CheckSignalReceived();
3459  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3460 
3461  // Check that nothing has changed after a couple of buffer swaps
3462  application.Render(0);
3463  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3464  application.Render(0);
3465  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3466  END_TEST;
3467 }
3468 
3470 {
3471  TestApplication application;
3472 
3473  Actor actor = Actor::New();
3474 
3475  // Register an integer property
3476  int startValue(10);
3477  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3478  Stage::GetCurrent().Add(actor);
3479  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3480 
3481  // Build the animation
3482  float durationSeconds(1.0f);
3483  Animation animation = Animation::New(durationSeconds);
3484  int targetValue(30);
3485  int relativeValue(targetValue - startValue);
3486  float delay = 0.5f;
3487  animation.AnimateBy(Property(actor, index),
3488  relativeValue,
3490  TimePeriod(delay, durationSeconds - delay));
3491 
3492  // Start the animation
3493  animation.Play();
3494 
3495  bool signalReceived(false);
3496  AnimationFinishCheck finishCheck(signalReceived);
3497  animation.FinishedSignal().Connect(&application, finishCheck);
3498 
3499  application.SendNotification();
3500  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3501 
3502  // We didn't expect the animation to finish yet
3503  application.SendNotification();
3504  finishCheck.CheckSignalNotReceived();
3505  DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
3506 
3507  application.SendNotification();
3508  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3509 
3510  // We didn't expect the animation to finish yet
3511  application.SendNotification();
3512  finishCheck.CheckSignalNotReceived();
3513  DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
3514 
3515  application.SendNotification();
3516  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3517 
3518  // We did expect the animation to finish
3519  application.SendNotification();
3520  finishCheck.CheckSignalReceived();
3521  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3522 
3523  // Check that nothing has changed after a couple of buffer swaps
3524  application.Render(0);
3525  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3526  application.Render(0);
3527  DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
3528  END_TEST;
3529 }
3530 
3532 {
3533  TestApplication application;
3534 
3535  Actor actor = Actor::New();
3536 
3537  // Register a Vector2 property
3538  Vector2 startValue(10.0f, 10.0f);
3539  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3540  Stage::GetCurrent().Add(actor);
3541  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3542 
3543  // Build the animation
3544  float durationSeconds(2.0f);
3545  Animation animation = Animation::New(durationSeconds);
3546  Vector2 targetValue(60.0f, 60.0f);
3547  Vector2 relativeValue(targetValue - startValue);
3548  animation.AnimateBy(Property(actor, index), relativeValue);
3549 
3550  Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3551 
3552  // Start the animation
3553  animation.Play();
3554 
3555  bool signalReceived(false);
3556  AnimationFinishCheck finishCheck(signalReceived);
3557  animation.FinishedSignal().Connect(&application, finishCheck);
3558 
3559  application.SendNotification();
3560  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3561 
3562  // We didn't expect the animation to finish yet
3563  application.SendNotification();
3564  finishCheck.CheckSignalNotReceived();
3565  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), ninetyFivePercentProgress, TEST_LOCATION );
3566 
3567  application.SendNotification();
3568  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3569 
3570  // We did expect the animation to finish
3571  application.SendNotification();
3572  finishCheck.CheckSignalReceived();
3573  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3574 
3575  // Check that nothing has changed after a couple of buffer swaps
3576  application.Render(0);
3577  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3578  application.Render(0);
3579  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3580  END_TEST;
3581 }
3582 
3584 {
3585  TestApplication application;
3586 
3587  Actor actor = Actor::New();
3588 
3589  // Register a Vector2 property
3590  Vector2 startValue(100.0f, 100.0f);
3591  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3592  Stage::GetCurrent().Add(actor);
3593  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3594 
3595  // Build the animation
3596  float durationSeconds(1.0f);
3597  Animation animation = Animation::New(durationSeconds);
3598  Vector2 targetValue(20.0f, 20.0f);
3599  Vector2 relativeValue(targetValue - startValue);
3600  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3601 
3602  Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3603 
3604  // Start the animation
3605  animation.Play();
3606 
3607  bool signalReceived(false);
3608  AnimationFinishCheck finishCheck(signalReceived);
3609  animation.FinishedSignal().Connect(&application, finishCheck);
3610 
3611  application.SendNotification();
3612  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3613 
3614  // We didn't expect the animation to finish yet
3615  application.SendNotification();
3616  finishCheck.CheckSignalNotReceived();
3617 
3618  // The position should have moved more, than with a linear alpha function
3619  Vector2 current(actor.GetProperty<Vector2>(index));
3620  DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3621  DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3622 
3623  application.SendNotification();
3624  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3625 
3626  // We did expect the animation to finish
3627  application.SendNotification();
3628  finishCheck.CheckSignalReceived();
3629  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3630 
3631  // Check that nothing has changed after a couple of buffer swaps
3632  application.Render(0);
3633  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3634  application.Render(0);
3635  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3636  END_TEST;
3637 }
3638 
3640 {
3641  TestApplication application;
3642 
3643  Actor actor = Actor::New();
3644 
3645  // Register a Vector2 property
3646  Vector2 startValue(10.0f, 10.0f);
3647  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3648  Stage::GetCurrent().Add(actor);
3649  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3650 
3651  // Build the animation
3652  float durationSeconds(1.0f);
3653  Animation animation = Animation::New(durationSeconds);
3654  Vector2 targetValue(30.0f, 30.0f);
3655  Vector2 relativeValue(targetValue - startValue);
3656  float delay = 0.5f;
3657  animation.AnimateBy(Property(actor, index),
3658  relativeValue,
3659  TimePeriod(delay, durationSeconds - delay));
3660 
3661  // Start the animation
3662  animation.Play();
3663 
3664  bool signalReceived(false);
3665  AnimationFinishCheck finishCheck(signalReceived);
3666  animation.FinishedSignal().Connect(&application, finishCheck);
3667 
3668  application.SendNotification();
3669  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3670 
3671  // We didn't expect the animation to finish yet
3672  application.SendNotification();
3673  finishCheck.CheckSignalNotReceived();
3674  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3675 
3676  application.SendNotification();
3677  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3678 
3679  // We didn't expect the animation to finish yet
3680  application.SendNotification();
3681  finishCheck.CheckSignalNotReceived();
3682  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3683 
3684  application.SendNotification();
3685  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3686 
3687  // We did expect the animation to finish
3688  application.SendNotification();
3689  finishCheck.CheckSignalReceived();
3690  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3691 
3692  // Check that nothing has changed after a couple of buffer swaps
3693  application.Render(0);
3694  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3695  application.Render(0);
3696  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3697  END_TEST;
3698 }
3699 
3701 {
3702  TestApplication application;
3703 
3704  Actor actor = Actor::New();
3705 
3706  // Register a Vector2 property
3707  Vector2 startValue(5.0f, 5.0f);
3708  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3709  Stage::GetCurrent().Add(actor);
3710  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3711 
3712  // Build the animation
3713  float durationSeconds(1.0f);
3714  Animation animation = Animation::New(durationSeconds);
3715  Vector2 targetValue(10.0f, 10.0f);
3716  Vector2 relativeValue(targetValue - startValue);
3717  float delay = 0.5f;
3718  animation.AnimateBy(Property(actor, index),
3719  relativeValue,
3721  TimePeriod(delay, durationSeconds - delay));
3722 
3723  // Start the animation
3724  animation.Play();
3725 
3726  bool signalReceived(false);
3727  AnimationFinishCheck finishCheck(signalReceived);
3728  animation.FinishedSignal().Connect(&application, finishCheck);
3729 
3730  application.SendNotification();
3731  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3732 
3733  // We didn't expect the animation to finish yet
3734  application.SendNotification();
3735  finishCheck.CheckSignalNotReceived();
3736  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
3737 
3738  application.SendNotification();
3739  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3740 
3741  // We didn't expect the animation to finish yet
3742  application.SendNotification();
3743  finishCheck.CheckSignalNotReceived();
3744  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3745 
3746  application.SendNotification();
3747  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3748 
3749  // We did expect the animation to finish
3750  application.SendNotification();
3751  finishCheck.CheckSignalReceived();
3752  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3753 
3754  // Check that nothing has changed after a couple of buffer swaps
3755  application.Render(0);
3756  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3757  application.Render(0);
3758  DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION );
3759  END_TEST;
3760 }
3761 
3763 {
3764  TestApplication application;
3765 
3766  Actor actor = Actor::New();
3767 
3768  // Register a Vector3 property
3769  Vector3 startValue(10.0f, 10.0f, 10.0f);
3770  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3771  Stage::GetCurrent().Add(actor);
3772  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3773 
3774  // Build the animation
3775  float durationSeconds(2.0f);
3776  Animation animation = Animation::New(durationSeconds);
3777  Vector3 targetValue(60.0f, 60.0f, 60.0f);
3778  Vector3 relativeValue(targetValue - startValue);
3779  animation.AnimateBy(Property(actor, index), relativeValue);
3780 
3781  Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3782 
3783  // Start the animation
3784  animation.Play();
3785 
3786  bool signalReceived(false);
3787  AnimationFinishCheck finishCheck(signalReceived);
3788  animation.FinishedSignal().Connect(&application, finishCheck);
3789 
3790  application.SendNotification();
3791  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3792 
3793  // We didn't expect the animation to finish yet
3794  application.SendNotification();
3795  finishCheck.CheckSignalNotReceived();
3796  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), ninetyFivePercentProgress, TEST_LOCATION );
3797 
3798  application.SendNotification();
3799  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3800 
3801  // We did expect the animation to finish
3802  application.SendNotification();
3803  finishCheck.CheckSignalReceived();
3804  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3805 
3806  // Check that nothing has changed after a couple of buffer swaps
3807  application.Render(0);
3808  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3809  application.Render(0);
3810  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3811  END_TEST;
3812 }
3813 
3815 {
3816  TestApplication application;
3817 
3818  Actor actor = Actor::New();
3819 
3820  // Register a Vector3 property
3821  Vector3 startValue(100.0f, 100.0f, 100.0f);
3822  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3823  Stage::GetCurrent().Add(actor);
3824  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3825 
3826  // Build the animation
3827  float durationSeconds(1.0f);
3828  Animation animation = Animation::New(durationSeconds);
3829  Vector3 targetValue(20.0f, 20.0f, 20.0f);
3830  Vector3 relativeValue(targetValue - startValue);
3831  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
3832 
3833  Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
3834 
3835  // Start the animation
3836  animation.Play();
3837 
3838  bool signalReceived(false);
3839  AnimationFinishCheck finishCheck(signalReceived);
3840  animation.FinishedSignal().Connect(&application, finishCheck);
3841 
3842  application.SendNotification();
3843  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
3844 
3845  // We didn't expect the animation to finish yet
3846  application.SendNotification();
3847  finishCheck.CheckSignalNotReceived();
3848 
3849  // The position should have moved more, than with a linear alpha function
3850  Vector3 current(actor.GetProperty<Vector3>(index));
3851  DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
3852  DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
3853  DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
3854 
3855  application.SendNotification();
3856  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
3857 
3858  // We did expect the animation to finish
3859  application.SendNotification();
3860  finishCheck.CheckSignalReceived();
3861  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3862 
3863  // Check that nothing has changed after a couple of buffer swaps
3864  application.Render(0);
3865  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3866  application.Render(0);
3867  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3868  END_TEST;
3869 }
3870 
3872 {
3873  TestApplication application;
3874 
3875  Actor actor = Actor::New();
3876 
3877  // Register a Vector3 property
3878  Vector3 startValue(10.0f, 10.0f, 10.0f);
3879  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3880  Stage::GetCurrent().Add(actor);
3881  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3882 
3883  // Build the animation
3884  float durationSeconds(1.0f);
3885  Animation animation = Animation::New(durationSeconds);
3886  Vector3 targetValue(30.0f, 30.0f, 30.0f);
3887  Vector3 relativeValue(targetValue - startValue);
3888  float delay = 0.5f;
3889  animation.AnimateBy(Property(actor, index),
3890  relativeValue,
3891  TimePeriod(delay, durationSeconds - delay));
3892 
3893  // Start the animation
3894  animation.Play();
3895 
3896  bool signalReceived(false);
3897  AnimationFinishCheck finishCheck(signalReceived);
3898  animation.FinishedSignal().Connect(&application, finishCheck);
3899 
3900  application.SendNotification();
3901  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3902 
3903  // We didn't expect the animation to finish yet
3904  application.SendNotification();
3905  finishCheck.CheckSignalNotReceived();
3906  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3907 
3908  application.SendNotification();
3909  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3910 
3911  // We didn't expect the animation to finish yet
3912  application.SendNotification();
3913  finishCheck.CheckSignalNotReceived();
3914  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3915 
3916  application.SendNotification();
3917  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
3918 
3919  // We did expect the animation to finish
3920  application.SendNotification();
3921  finishCheck.CheckSignalReceived();
3922  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3923 
3924  // Check that nothing has changed after a couple of buffer swaps
3925  application.Render(0);
3926  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3927  application.Render(0);
3928  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3929  END_TEST;
3930 }
3931 
3933 {
3934  TestApplication application;
3935 
3936  Actor actor = Actor::New();
3937 
3938  // Register a Vector3 property
3939  Vector3 startValue(5.0f, 5.0f, 5.0f);
3940  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
3941  Stage::GetCurrent().Add(actor);
3942  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3943 
3944  // Build the animation
3945  float durationSeconds(1.0f);
3946  Animation animation = Animation::New(durationSeconds);
3947  Vector3 targetValue(10.0f, 10.0f, 10.0f);
3948  Vector3 relativeValue(targetValue - startValue);
3949  float delay = 0.5f;
3950  animation.AnimateBy(Property(actor, index),
3951  relativeValue,
3953  TimePeriod(delay, durationSeconds - delay));
3954 
3955  // Start the animation
3956  animation.Play();
3957 
3958  bool signalReceived(false);
3959  AnimationFinishCheck finishCheck(signalReceived);
3960  animation.FinishedSignal().Connect(&application, finishCheck);
3961 
3962  application.SendNotification();
3963  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
3964 
3965  // We didn't expect the animation to finish yet
3966  application.SendNotification();
3967  finishCheck.CheckSignalNotReceived();
3968  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
3969 
3970  application.SendNotification();
3971  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
3972 
3973  // We didn't expect the animation to finish yet
3974  application.SendNotification();
3975  finishCheck.CheckSignalNotReceived();
3976  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
3977 
3978  application.SendNotification();
3979  application.Render(static_cast<unsigned int>(durationSeconds*250.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<Vector3>(index), targetValue, TEST_LOCATION );
3985 
3986  // Check that nothing has changed after a couple of buffer swaps
3987  application.Render(0);
3988  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3989  application.Render(0);
3990  DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION );
3991  END_TEST;
3992 }
3993 
3995 {
3996  TestApplication application;
3997 
3998  Actor actor = Actor::New();
3999 
4000  // Register a Vector4 property
4001  Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4002  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4003  Stage::GetCurrent().Add(actor);
4004  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4005 
4006  // Build the animation
4007  float durationSeconds(2.0f);
4008  Animation animation = Animation::New(durationSeconds);
4009  Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f);
4010  Vector4 relativeValue(targetValue - startValue);
4011  animation.AnimateBy(Property(actor, index), relativeValue);
4012 
4013  Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4014 
4015  // Start the animation
4016  animation.Play();
4017 
4018  bool signalReceived(false);
4019  AnimationFinishCheck finishCheck(signalReceived);
4020  animation.FinishedSignal().Connect(&application, finishCheck);
4021 
4022  application.SendNotification();
4023  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4024 
4025  // We didn't expect the animation to finish yet
4026  application.SendNotification();
4027  finishCheck.CheckSignalNotReceived();
4028  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), ninetyFivePercentProgress, TEST_LOCATION );
4029 
4030  application.SendNotification();
4031  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4032 
4033  // We did expect the animation to finish
4034  application.SendNotification();
4035  finishCheck.CheckSignalReceived();
4036  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4037 
4038  // Check that nothing has changed after a couple of buffer swaps
4039  application.Render(0);
4040  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4041  application.Render(0);
4042  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4043  END_TEST;
4044 }
4045 
4047 {
4048  TestApplication application;
4049 
4050  Actor actor = Actor::New();
4051 
4052  // Register a Vector4 property
4053  Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f);
4054  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4055  Stage::GetCurrent().Add(actor);
4056  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4057 
4058  // Build the animation
4059  float durationSeconds(1.0f);
4060  Animation animation = Animation::New(durationSeconds);
4061  Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f);
4062  Vector4 relativeValue(targetValue - startValue);
4063  animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT);
4064 
4065  Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f);
4066 
4067  // Start the animation
4068  animation.Play();
4069 
4070  bool signalReceived(false);
4071  AnimationFinishCheck finishCheck(signalReceived);
4072  animation.FinishedSignal().Connect(&application, finishCheck);
4073 
4074  application.SendNotification();
4075  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4076 
4077  // We didn't expect the animation to finish yet
4078  application.SendNotification();
4079  finishCheck.CheckSignalNotReceived();
4080 
4081  // The position should have moved more, than with a linear alpha function
4082  Vector4 current(actor.GetProperty<Vector4>(index));
4083  DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x );
4084  DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y );
4085  DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z );
4086  DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w );
4087 
4088  application.SendNotification();
4089  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4090 
4091  // We did expect the animation to finish
4092  application.SendNotification();
4093  finishCheck.CheckSignalReceived();
4094  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4095 
4096  // Check that nothing has changed after a couple of buffer swaps
4097  application.Render(0);
4098  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4099  application.Render(0);
4100  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4101  END_TEST;
4102 }
4103 
4105 {
4106  TestApplication application;
4107 
4108  Actor actor = Actor::New();
4109 
4110  // Register a Vector4 property
4111  Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f);
4112  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4113  Stage::GetCurrent().Add(actor);
4114  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4115 
4116  // Build the animation
4117  float durationSeconds(1.0f);
4118  Animation animation = Animation::New(durationSeconds);
4119  Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f);
4120  Vector4 relativeValue(targetValue - startValue);
4121  float delay = 0.5f;
4122  animation.AnimateBy(Property(actor, index),
4123  relativeValue,
4124  TimePeriod(delay, durationSeconds - delay));
4125 
4126  // Start the animation
4127  animation.Play();
4128 
4129  bool signalReceived(false);
4130  AnimationFinishCheck finishCheck(signalReceived);
4131  animation.FinishedSignal().Connect(&application, finishCheck);
4132 
4133  application.SendNotification();
4134  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4135 
4136  // We didn't expect the animation to finish yet
4137  application.SendNotification();
4138  finishCheck.CheckSignalNotReceived();
4139  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4140 
4141  application.SendNotification();
4142  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4143 
4144  // We didn't expect the animation to finish yet
4145  application.SendNotification();
4146  finishCheck.CheckSignalNotReceived();
4147  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4148 
4149  application.SendNotification();
4150  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4151 
4152  // We did expect the animation to finish
4153  application.SendNotification();
4154  finishCheck.CheckSignalReceived();
4155  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4156 
4157  // Check that nothing has changed after a couple of buffer swaps
4158  application.Render(0);
4159  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4160  application.Render(0);
4161  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4162  END_TEST;
4163 }
4164 
4166 {
4167  TestApplication application;
4168 
4169  Actor actor = Actor::New();
4170 
4171  // Register a Vector4 property
4172  Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f);
4173  Property::Index index = actor.RegisterProperty( "testProperty", startValue );
4174  Stage::GetCurrent().Add(actor);
4175  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4176 
4177  // Build the animation
4178  float durationSeconds(1.0f);
4179  Animation animation = Animation::New(durationSeconds);
4180  Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f);
4181  Vector4 relativeValue(targetValue - startValue);
4182  float delay = 0.5f;
4183  animation.AnimateBy(Property(actor, index),
4184  relativeValue,
4186  TimePeriod(delay, durationSeconds - delay));
4187 
4188  // Start the animation
4189  animation.Play();
4190 
4191  bool signalReceived(false);
4192  AnimationFinishCheck finishCheck(signalReceived);
4193  animation.FinishedSignal().Connect(&application, finishCheck);
4194 
4195  application.SendNotification();
4196  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4197 
4198  // We didn't expect the animation to finish yet
4199  application.SendNotification();
4200  finishCheck.CheckSignalNotReceived();
4201  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
4202 
4203  application.SendNotification();
4204  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
4205 
4206  // We didn't expect the animation to finish yet
4207  application.SendNotification();
4208  finishCheck.CheckSignalNotReceived();
4209  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue+(relativeValue*0.5f), TEST_LOCATION );
4210 
4211  application.SendNotification();
4212  application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
4213 
4214  // We did expect the animation to finish
4215  application.SendNotification();
4216  finishCheck.CheckSignalReceived();
4217  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4218 
4219  // Check that nothing has changed after a couple of buffer swaps
4220  application.Render(0);
4221  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4222  application.Render(0);
4223  DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION );
4224  END_TEST;
4225 }
4226 
4228 {
4229  TestApplication application;
4230 
4231  Actor actor = Actor::New();
4232  Vector3 startPosition(10.0f, 10.0f, 10.0f);
4233  actor.SetPosition(startPosition);
4234  Stage::GetCurrent().Add(actor);
4235  application.SendNotification();
4236  application.Render(0);
4237  DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4238 
4239  // Build the animation
4240  float durationSeconds(1.0f);
4241  Animation animation = Animation::New(durationSeconds);
4242  Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4243  Vector3 relativePosition(targetPosition - startPosition);
4244  animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition);
4245 
4246  Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4247 
4248  // Start the animation
4249  animation.Play();
4250 
4251  bool signalReceived(false);
4252  AnimationFinishCheck finishCheck(signalReceived);
4253  animation.FinishedSignal().Connect(&application, finishCheck);
4254 
4255  application.SendNotification();
4256  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4257 
4258  // We didn't expect the animation to finish yet
4259  application.SendNotification();
4260  finishCheck.CheckSignalNotReceived();
4261  DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION );
4262 
4263  application.SendNotification();
4264  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4265 
4266  // We did expect the animation to finish
4267  application.SendNotification();
4268  finishCheck.CheckSignalReceived();
4269  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4270 
4271  // Check that nothing has changed after a couple of buffer swaps
4272  application.Render(0);
4273  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4274  application.Render(0);
4275  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4276  END_TEST;
4277 }
4278 
4280 {
4281  TestApplication application;
4282 
4283  Actor actor = Actor::New();
4284  Vector3 startPosition(10.0f, 10.0f, 10.0f);
4285  actor.SetPosition(startPosition);
4286  Stage::GetCurrent().Add(actor);
4287  application.SendNotification();
4288  application.Render(0);
4289  DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4290 
4291  // Build the animation
4292  float durationSeconds(1.0f);
4293  Animation animation = Animation::New(durationSeconds);
4294  Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4295  Vector3 relativePosition(targetPosition - startPosition);
4296  animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT);
4297 
4298  Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4299 
4300  // Start the animation
4301  animation.Play();
4302 
4303  bool signalReceived(false);
4304  AnimationFinishCheck finishCheck(signalReceived);
4305  animation.FinishedSignal().Connect(&application, finishCheck);
4306 
4307  application.SendNotification();
4308  application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
4309 
4310  // We didn't expect the animation to finish yet
4311  application.SendNotification();
4312  finishCheck.CheckSignalNotReceived();
4313 
4314  // The position should have moved more, than with a linear alpha function
4315  Vector3 current(actor.GetCurrentPosition());
4316  DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x );
4317  DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y );
4318  DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z );
4319 
4320  application.SendNotification();
4321  application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
4322 
4323  // We did expect the animation to finish
4324  application.SendNotification();
4325  finishCheck.CheckSignalReceived();
4326  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4327 
4328  // Check that nothing has changed after a couple of buffer swaps
4329  application.Render(0);
4330  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4331  application.Render(0);
4332  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4333  END_TEST;
4334 }
4335 
4337 {
4338  TestApplication application;
4339 
4340  Actor actor = Actor::New();
4341  Vector3 startPosition(10.0f, 10.0f, 10.0f);
4342  actor.SetPosition(startPosition);
4343  Stage::GetCurrent().Add(actor);
4344  application.SendNotification();
4345  application.Render(0);
4346  DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4347 
4348  // Build the animation
4349  float durationSeconds(1.0f);
4350  Animation animation = Animation::New(durationSeconds);
4351  Vector3 targetPosition(20.0f, 20.0f, 20.0f);
4352  Vector3 relativePosition(targetPosition - startPosition);
4353  float delay = 0.5f;
4354  animation.AnimateBy(Property(actor, Actor::Property::POSITION),
4355  relativePosition,
4356  TimePeriod(delay, durationSeconds - delay));
4357 
4358  Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f);
4359 
4360  // Start the animation
4361  animation.Play();
4362 
4363  bool signalReceived(false);
4364  AnimationFinishCheck finishCheck(signalReceived);
4365  animation.FinishedSignal().Connect(&application, finishCheck);
4366 
4367  application.SendNotification();
4368  application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
4369 
4370  // We didn't expect the animation to finish yet
4371  application.SendNotification();
4372  finishCheck.CheckSignalNotReceived();
4373  DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION );
4374 
4375  application.SendNotification();
4376  application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
4377 
4378  // We did expect the animation to finish
4379  application.SendNotification();
4380  finishCheck.CheckSignalReceived();
4381  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4382 
4383  // Check that nothing has changed after a couple of buffer swaps
4384  application.Render(0);
4385  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4386  application.Render(0);
4387  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
4388  END_TEST;
4389 }
4390 
4392 {
4393  TestApplication application;
4394 
4395  Actor actor = Actor::New();
4396  Vector3 startPosition(10.0f, 10.0f, 10.0f);
4397  actor.SetPosition(startPosition);