Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Constraint.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 void utc_dali_constraint_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void utc_dali_constraint_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36
37 namespace
38 {
39
40 struct EqualToQuaternion
41 {
42   EqualToQuaternion()
43   {
44   }
45
46   Quaternion operator()( const Quaternion& current, const PropertyInput& property )
47   {
48     return property.GetQuaternion();
49   }
50 };
51
52 struct EqualToVector4
53 {
54   EqualToVector4()
55   {
56   }
57
58   Vector4 operator()( const Vector4& current, const PropertyInput& property )
59   {
60     return property.GetVector4();
61   }
62 };
63
64 class PropertyInputAbstraction : public Dali::PropertyInput
65 {
66 public:
67   PropertyInputAbstraction(const bool& val) : mType(Dali::Property::BOOLEAN), mBoolData( val )  {}
68   PropertyInputAbstraction(const float& val) : mType(Dali::Property::FLOAT), mFloatData( val )  {}
69   PropertyInputAbstraction(const int& val) : mType(Dali::Property::INTEGER), mIntData( val )  {}
70   PropertyInputAbstraction(const Vector2& val) : mType(Dali::Property::VECTOR2), mVector2Data( val )  {}
71   PropertyInputAbstraction(const Vector3& val) : mType(Dali::Property::VECTOR3), mVector3Data( val )  {}
72   PropertyInputAbstraction(const Vector4& val) : mType(Dali::Property::VECTOR4), mVector4Data( val )  {}
73   PropertyInputAbstraction(const Matrix3& val) : mType(Dali::Property::MATRIX3), mMatrix3Data( val )  {}
74   PropertyInputAbstraction(const Matrix& val) : mType(Dali::Property::MATRIX), mMatrixData( val )  {}
75   PropertyInputAbstraction(const Quaternion& val) : mType(Dali::Property::ROTATION), mQuaternionData( val )  {}
76
77   ~PropertyInputAbstraction() {}
78
79   Dali::Property::Type GetType() const { return mType; }
80
81   const bool& GetBoolean() const { return mBoolData; }
82
83   const float& GetFloat() const { return mFloatData; }
84
85   const int& GetInteger() const { return mIntData; }
86
87   const Vector2& GetVector2() const { return mVector2Data; }
88   const Vector3& GetVector3() const { return mVector3Data; }
89   const Vector4& GetVector4() const { return mVector4Data; }
90
91   const Matrix3& GetMatrix3() const { return mMatrix3Data; }
92   const Matrix& GetMatrix() const { return mMatrixData; }
93
94   const Quaternion& GetQuaternion() const { return mQuaternionData; }
95
96 private:
97   Dali::Property::Type mType;
98   bool mBoolData;
99   float mFloatData;
100   int mIntData;
101   Vector2 mVector2Data;
102   Vector3 mVector3Data;
103   Vector4 mVector4Data;
104   Matrix3 mMatrix3Data;
105   Matrix mMatrixData;
106   Quaternion mQuaternionData;
107 };
108
109 static const float POSITION_EPSILON = 0.0001f;
110 static const float ROTATION_EPSILON = 0.0001f;
111
112 struct TestConstraint
113 {
114   Vector4 operator()(const Vector4&    color)
115   {
116     return Vector4(color.x, color.y, color.z, 0.1f);
117   }
118 };
119
120 struct TestConstraintToVector3
121 {
122   TestConstraintToVector3(Vector3 target)
123   : mTarget(target)
124   {
125   }
126
127   Vector3 operator()(const Vector3& current)
128   {
129     return mTarget;
130   }
131
132   Vector3 mTarget;
133 };
134
135 struct TestColorConstraint
136 {
137   TestColorConstraint(Vector4 target)
138   : mTarget(target)
139   {
140   }
141
142   Vector4 operator()(const Vector4&    color)
143   {
144     return mTarget;
145   }
146
147   Vector4 mTarget;
148 };
149
150 struct TestPositionConstraint
151 {
152   TestPositionConstraint(Vector3 target)
153   : mTarget(target)
154   {
155   }
156
157   Vector3 operator()(const Vector3&    position)
158   {
159     return mTarget;
160   }
161
162   Vector3 mTarget;
163 };
164
165
166 struct TestAlwaysTrueConstraint
167 {
168   bool operator()( const bool& current )
169   {
170     return true;
171   }
172 };
173
174 struct TestAlwaysEqualOrGreaterThanConstraintFloat
175 {
176   TestAlwaysEqualOrGreaterThanConstraintFloat( float value )
177   : mValue( value )
178   {
179   }
180
181   float operator()( const float& current )
182   {
183     return ( current < mValue ) ? mValue : current;
184   }
185
186   float mValue;
187 };
188
189 struct TestAlwaysEqualOrGreaterThanConstraintInteger
190 {
191   TestAlwaysEqualOrGreaterThanConstraintInteger( int value )
192   : mValue( value )
193   {
194   }
195
196   int operator()( const int& current )
197   {
198     return ( current < mValue ) ? mValue : current;
199   }
200
201   int mValue;
202 };
203
204 struct TestAlwaysEqualOrGreaterThanConstraintVector2
205 {
206   TestAlwaysEqualOrGreaterThanConstraintVector2( Vector2 value )
207   : mValue( value )
208   {
209   }
210
211   Vector2 operator()( const Vector2& current )
212   {
213     return Vector2( ( current.x < mValue.x ) ? mValue.x : current.x,
214                     ( current.y < mValue.y ) ? mValue.y : current.y
215                   );
216   }
217
218   Vector2 mValue;
219 };
220
221 struct TestAlwaysEqualOrGreaterThanConstraintVector3
222 {
223   TestAlwaysEqualOrGreaterThanConstraintVector3( Vector3 value )
224   : mValue( value )
225   {
226   }
227
228   Vector3 operator()( const Vector3& current )
229   {
230     return Vector3( ( current.x < mValue.x ) ? mValue.x : current.x,
231                     ( current.y < mValue.y ) ? mValue.y : current.y,
232                     ( current.z < mValue.z ) ? mValue.z : current.z
233                   );
234   }
235
236   Vector3 mValue;
237 };
238
239 struct TestAlwaysEqualOrGreaterThanConstraintVector4
240 {
241   TestAlwaysEqualOrGreaterThanConstraintVector4( Vector4 value )
242   : mValue( value )
243   {
244   }
245
246   Vector4 operator()( const Vector4& current )
247   {
248     return Vector4( ( current.x < mValue.x ) ? mValue.x : current.x,
249                     ( current.y < mValue.y ) ? mValue.y : current.y,
250                     ( current.z < mValue.z ) ? mValue.z : current.z,
251                     ( current.w < mValue.w ) ? mValue.w : current.w
252                   );
253   }
254
255   Vector4 mValue;
256 };
257
258 struct TestConstraintFloat
259 {
260   TestConstraintFloat( float value )
261   : mValue( value )
262   {
263   }
264
265   float operator()( const float& current )
266   {
267     return mValue;
268   }
269
270   float mValue;
271 };
272
273 struct TestConstraintInteger
274 {
275   TestConstraintInteger( int value )
276   : mValue( value )
277   {
278   }
279
280   int operator()( const int& current )
281   {
282     return mValue;
283   }
284
285   int mValue;
286 };
287
288 struct TestConstraintVector2
289 {
290   TestConstraintVector2( Vector2 value )
291   : mValue( value )
292   {
293   }
294
295   Vector2 operator()( const Vector2& current )
296   {
297     return mValue;
298   }
299
300   Vector2 mValue;
301 };
302
303 struct TestConstraintVector3
304 {
305   TestConstraintVector3( Vector3 value )
306   : mValue( value )
307   {
308   }
309
310   Vector3 operator()( const Vector3& current )
311   {
312     return mValue;
313   }
314
315   Vector3 mValue;
316 };
317
318 struct TestConstraintVector4
319 {
320   TestConstraintVector4( Vector4 value )
321   : mValue( value )
322   {
323   }
324
325   Vector4 operator()( const Vector4& current )
326   {
327     return mValue;
328   }
329
330   Vector4 mValue;
331 };
332
333 struct TestConstraintRotation
334 {
335   TestConstraintRotation( Quaternion rotation )
336   : mRotation( rotation )
337   {
338   }
339
340   Quaternion operator()( const Quaternion& current )
341   {
342     return mRotation;
343   }
344
345   Quaternion mRotation;
346 };
347
348 struct TestConstraintMatrix3
349 {
350   TestConstraintMatrix3(Matrix3 matrix3)
351   : mMatrix3( matrix3 )
352   {
353   }
354
355   Matrix3 operator()( const Matrix3& current )
356   {
357     return mMatrix3;
358   }
359
360   Matrix3 mMatrix3;
361 };
362
363 struct TestConstraintMatrix
364 {
365   TestConstraintMatrix(Matrix matrix)
366   : mMatrix( matrix )
367   {
368   }
369
370   Matrix operator()( const Matrix& current )
371   {
372     return mMatrix;
373   }
374
375   Matrix mMatrix;
376 };
377
378 struct MoveAwayWithFadeConstraint
379 {
380   MoveAwayWithFadeConstraint( float distance )
381   : mDistance( distance )
382   {
383   }
384
385   Vector3 operator()( const Vector3& current,
386                       const PropertyInput& color )
387   {
388     return Vector3( current.x,
389                     current.y,
390                     -mDistance * (1.0f - color.GetVector4().a) );
391   }
392
393   float mDistance;
394 };
395
396 struct TestBottomRightAlignConstraint
397 {
398   Vector3 operator()( const Vector3& current,
399                       const PropertyInput& parentSize )
400   {
401     return Vector3( parentSize.GetVector3().x, parentSize.GetVector3().y, 0.0f );
402   }
403 };
404
405 struct MeanPositionConstraint1
406 {
407   Vector3 operator()( const Vector3& current,
408                       const PropertyInput& position1 )
409   {
410     return Vector3( position1.GetVector3() );
411   }
412 };
413
414 struct MeanPositionConstraint2
415 {
416   Vector3 operator()( const Vector3& current,
417                       const PropertyInput& position1,
418                       const PropertyInput& position2 )
419   {
420     Vector3 meanValue = position1.GetVector3() +
421                         position2.GetVector3();
422
423     return meanValue * 0.5f; // div 2
424   }
425 };
426
427 struct MeanPositionConstraint3
428 {
429   Vector3 operator()( const Vector3& current,
430                       const PropertyInput& position1,
431                       const PropertyInput& position2,
432                       const PropertyInput& position3 )
433   {
434     Vector3 meanValue = position1.GetVector3() +
435                         position2.GetVector3() +
436                         position3.GetVector3();
437
438     return meanValue * (1.0f / 3.0f); // div 3
439   }
440 };
441
442 struct MeanPositionConstraint4
443 {
444   Vector3 operator()( const Vector3& current,
445                       const PropertyInput& position1,
446                       const PropertyInput& position2,
447                       const PropertyInput& position3,
448                       const PropertyInput& position4 )
449   {
450     Vector3 meanValue = position1.GetVector3() +
451                         position2.GetVector3() +
452                         position3.GetVector3() +
453                         position4.GetVector3();
454
455     return meanValue * 0.25f; // div 4
456   }
457 };
458
459 struct MeanPositionConstraint5
460 {
461   Vector3 operator()( const Vector3& current,
462                       const PropertyInput& position1,
463                       const PropertyInput& position2,
464                       const PropertyInput& position3,
465                       const PropertyInput& position4,
466                       const PropertyInput& position5 )
467   {
468     Vector3 meanValue = position1.GetVector3() +
469                         position2.GetVector3() +
470                         position3.GetVector3() +
471                         position4.GetVector3() +
472                         position5.GetVector3();
473
474     return meanValue * 0.2f; // div 5
475   }
476 };
477
478 struct MeanPositionConstraint6
479 {
480   Vector3 operator()( const Vector3& current,
481                       const PropertyInput& position1,
482                       const PropertyInput& position2,
483                       const PropertyInput& position3,
484                       const PropertyInput& position4,
485                       const PropertyInput& position5,
486                       const PropertyInput& position6 )
487   {
488     Vector3 meanValue = position1.GetVector3() +
489                         position2.GetVector3() +
490                         position3.GetVector3() +
491                         position4.GetVector3() +
492                         position5.GetVector3() +
493                         position6.GetVector3();
494
495     return meanValue * (1.0f / 6.0f); // div 6
496   }
497 };
498
499 struct TestRelativeConstraintFloat
500 {
501   TestRelativeConstraintFloat(float scale)
502   : mScale(scale)
503   {
504   }
505
506   float operator()( const float& current, const PropertyInput& relative )
507   {
508     return relative.GetFloat() * mScale;
509   }
510
511   float mScale;
512 };
513
514 struct TestRelativeConstraintVector3
515 {
516   TestRelativeConstraintVector3(float scale)
517   : mScale(scale)
518   {
519   }
520
521   Vector3 operator()( const Vector3& current, const PropertyInput& relative )
522   {
523     return relative.GetVector3() * mScale;
524   }
525
526   float mScale;
527 };
528
529 } // anonymous namespace
530
531
532
533
534
535
536 int UtcDaliConstraintNewBoolean(void)
537 {
538   TestApplication application;
539
540   Actor actor = Actor::New();
541
542   // Register a boolean property
543   bool startValue(false);
544   Property::Index index = actor.RegisterProperty( "test-property", startValue );
545   Stage::GetCurrent().Add(actor);
546   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
547
548   /**
549    * Test that the Constraint is correctly applied on a clean Node
550    */
551   application.SendNotification();
552   application.Render(0);
553   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
554   application.Render(0);
555   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
556   application.Render(0);
557   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
558
559   // Apply constraint
560
561   Constraint constraint = Constraint::New<bool>( index, TestAlwaysTrueConstraint() );
562
563   actor.ApplyConstraint( constraint );
564   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
565
566   application.SendNotification();
567   application.Render(0);
568
569   // Constraint should be fully applied
570   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
571
572   // Check that nothing has changed after a couple of buffer swaps
573   application.Render(0);
574   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
575   application.Render(0);
576   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
577
578   // Try to fight with the constraint - this shouldn't work!
579   actor.SetProperty( index, false );
580
581   application.SendNotification();
582   application.Render(0);
583
584   // Check that nothing has changed after a couple of buffer swaps
585   application.Render(0);
586   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
587   application.Render(0);
588   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
589
590   // Remove the constraint, then set new value
591   actor.RemoveConstraints();
592   actor.SetProperty( index, false );
593
594   // Constraint should have been removed
595   application.SendNotification();
596   application.Render(0);
597   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
598   application.Render(0);
599   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
600   END_TEST;
601 }
602
603 int UtcDaliConstraintNewFloat(void)
604 {
605   TestApplication application;
606
607   Actor actor = Actor::New();
608
609   // Register a float property
610   float startValue(1.0f);
611   Property::Index index = actor.RegisterProperty( "test-property", startValue );
612   Stage::GetCurrent().Add(actor);
613   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
614
615   /**
616    * Test that the Constraint is correctly applied on a clean Node
617    */
618   application.SendNotification();
619   application.Render(0);
620   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
621   application.Render(0);
622   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
623   application.Render(0);
624   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
625
626   // Apply constraint
627
628   float minValue( 2.0f );
629   Constraint constraint = Constraint::New<float>( index, TestAlwaysEqualOrGreaterThanConstraintFloat( minValue ) );
630
631   actor.ApplyConstraint( constraint );
632   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
633
634   application.SendNotification();
635   application.Render(0);
636
637   // Constraint should be fully applied
638   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue, TEST_LOCATION );
639
640   // Check that nothing has changed after a couple of buffer swaps
641   application.Render(0);
642   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue, TEST_LOCATION );
643   application.Render(0);
644   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue, TEST_LOCATION );
645
646   // Set to greater than 2.0f, the constraint will allow this
647   actor.SetProperty( index, 3.0f );
648
649   application.SendNotification();
650   application.Render(0);
651
652   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 3.0f, TEST_LOCATION );
653
654   // Check that nothing has changed after a couple of buffer swaps
655   application.Render(0);
656   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 3.0f, TEST_LOCATION );
657   application.Render(0);
658   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 3.0f, TEST_LOCATION );
659
660   // Set to less than 2.0f, the constraint will NOT allow this
661   actor.SetProperty( index, 1.0f );
662
663   application.SendNotification();
664   application.Render(0);
665
666   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue/*not 1.0f*/, TEST_LOCATION );
667
668   // Check that nothing has changed after a couple of buffer swaps
669   application.Render(0);
670   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue, TEST_LOCATION );
671   application.Render(0);
672   DALI_TEST_EQUALS( actor.GetProperty<float>(index), minValue, TEST_LOCATION );
673
674   // Remove the constraint, then set new value
675   actor.RemoveConstraints();
676   actor.SetProperty( index, 1.0f );
677
678   // Constraint should have been removed
679   application.SendNotification();
680   application.Render(0);
681   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 1.0f, TEST_LOCATION );
682   application.Render(0);
683   DALI_TEST_EQUALS( actor.GetProperty<float>(index), 1.0f, TEST_LOCATION );
684   END_TEST;
685 }
686
687 int UtcDaliConstraintNewInteger(void)
688 {
689   TestApplication application;
690
691   Actor actor = Actor::New();
692
693   // Register an integer property
694   int startValue( 1 );
695   Property::Index index = actor.RegisterProperty( "test-property", startValue );
696   Stage::GetCurrent().Add(actor);
697   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
698
699   /**
700    * Test that the Constraint is correctly applied on a clean Node
701    */
702   application.SendNotification();
703   application.Render(0);
704   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
705   application.Render(0);
706   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
707   application.Render(0);
708   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
709
710   // Apply constraint
711
712   int minValue( 2 );
713   Constraint constraint = Constraint::New<int>( index, TestAlwaysEqualOrGreaterThanConstraintInteger( minValue ) );
714
715   actor.ApplyConstraint( constraint );
716   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
717
718   application.SendNotification();
719   application.Render(0);
720
721   // Constraint should be fully applied
722   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
723
724   // Check that nothing has changed after a couple of buffer swaps
725   application.Render(0);
726   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
727   application.Render(0);
728   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
729
730   // Set to greater than 2f, the constraint will allow this
731   actor.SetProperty( index, 3 );
732
733   application.SendNotification();
734   application.Render(0);
735
736   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
737
738   // Check that nothing has changed after a couple of buffer swaps
739   application.Render(0);
740   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
741   application.Render(0);
742   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
743
744   // Set to less than 2, the constraint will NOT allow this
745   actor.SetProperty( index, 1 );
746
747   application.SendNotification();
748   application.Render(0);
749
750   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue/*not 1*/, TEST_LOCATION );
751
752   // Check that nothing has changed after a couple of buffer swaps
753   application.Render(0);
754   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
755   application.Render(0);
756   DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
757
758   // Remove the constraint, then set new value
759   actor.RemoveConstraints();
760   actor.SetProperty( index, 1 );
761
762   // Constraint should have been removed
763   application.SendNotification();
764   application.Render(0);
765   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 1, TEST_LOCATION );
766   application.Render(0);
767   DALI_TEST_EQUALS( actor.GetProperty<int>(index), 1, TEST_LOCATION );
768   END_TEST;
769
770 }
771
772 int UtcDaliConstraintNewVector2(void)
773 {
774   TestApplication application;
775
776   Actor actor = Actor::New();
777
778   // Register a Vector2 property
779   Vector2 startValue( 1.0f, 1.0f );
780   Property::Index index = actor.RegisterProperty( "test-property", startValue );
781   Stage::GetCurrent().Add(actor);
782   DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
783
784   /**
785    * Test that the Constraint is correctly applied on a clean Node
786    */
787   application.SendNotification();
788   application.Render(0);
789   DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
790   application.Render(0);
791   DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
792   application.Render(0);
793   DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
794
795   // Apply constraint
796
797   Vector2 minValue( 2.0f, 2.0f );
798   Constraint constraint = Constraint::New<Vector2>( index, TestAlwaysEqualOrGreaterThanConstraintVector2( minValue ) );
799
800   actor.ApplyConstraint( constraint );
801   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
802
803   application.SendNotification();
804   application.Render(0);
805
806   // Constraint should be fully applied
807   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue, TEST_LOCATION );
808
809   // Check that nothing has changed after a couple of buffer swaps
810   application.Render(0);
811   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue, TEST_LOCATION );
812   application.Render(0);
813   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue, TEST_LOCATION );
814
815   // Set to greater than 2.0f, the constraint will allow this
816   Vector2 greaterValue( 3.0f, 3.0f );
817   actor.SetProperty( index, greaterValue );
818
819   application.SendNotification();
820   application.Render(0);
821
822   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), greaterValue, TEST_LOCATION );
823
824   // Check that nothing has changed after a couple of buffer swaps
825   application.Render(0);
826   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), greaterValue, TEST_LOCATION );
827   application.Render(0);
828   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), greaterValue, TEST_LOCATION );
829
830   // Set to less than 2.0f, the constraint will NOT allow this
831   Vector2 lesserValue( 1.0f, 1.0f );
832   actor.SetProperty( index, lesserValue );
833
834   application.SendNotification();
835   application.Render(0);
836
837   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue/*not lesserValue*/, TEST_LOCATION );
838
839   // Check that nothing has changed after a couple of buffer swaps
840   application.Render(0);
841   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue, TEST_LOCATION );
842   application.Render(0);
843   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), minValue, TEST_LOCATION );
844
845   // Remove the constraint, then set new value
846   actor.RemoveConstraints();
847   actor.SetProperty( index, lesserValue );
848
849   // Constraint should have been removed
850   application.SendNotification();
851   application.Render(0);
852   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), lesserValue, TEST_LOCATION );
853   application.Render(0);
854   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), lesserValue, TEST_LOCATION );
855   END_TEST;
856 }
857
858 int UtcDaliConstraintNewVector3(void)
859 {
860   TestApplication application;
861
862   Actor actor = Actor::New();
863
864   // Register a Vector3 property
865   Vector3 startValue(1.0f, 1.0f, 1.0f);
866   Property::Index index = actor.RegisterProperty( "test-property", startValue );
867   Stage::GetCurrent().Add(actor);
868   DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
869
870   /**
871    * Test that the Constraint is correctly applied on a clean Node
872    */
873   application.SendNotification();
874   application.Render(0);
875   DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
876   application.Render(0);
877   DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
878   application.Render(0);
879   DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
880
881   // Apply constraint
882
883   Vector3 minValue( 2.0f, 2.0f, 2.0f );
884   Constraint constraint = Constraint::New<Vector3>( index, TestAlwaysEqualOrGreaterThanConstraintVector3( minValue ) );
885
886   actor.ApplyConstraint( constraint );
887   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
888
889   application.SendNotification();
890   application.Render(0);
891
892   // Constraint should be fully applied
893   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
894
895   // Check that nothing has changed after a couple of buffer swaps
896   application.Render(0);
897   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
898   application.Render(0);
899   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
900
901   // Set to greater than 2.0f, the constraint will allow this
902   Vector3 greaterValue( 3.0f, 3.0f, 3.0f );
903   actor.SetProperty( index, greaterValue );
904
905   application.SendNotification();
906   application.Render(0);
907
908   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
909
910   // Check that nothing has changed after a couple of buffer swaps
911   application.Render(0);
912   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
913   application.Render(0);
914   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), greaterValue, TEST_LOCATION );
915
916   // Set to less than 2.0f, the constraint will NOT allow this
917   Vector3 lesserValue( 1.0f, 1.0f, 1.0f );
918   actor.SetProperty( index, lesserValue );
919
920   application.SendNotification();
921   application.Render(0);
922
923   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue/*not lesserValue*/, TEST_LOCATION );
924
925   // Check that nothing has changed after a couple of buffer swaps
926   application.Render(0);
927   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
928   application.Render(0);
929   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), minValue, TEST_LOCATION );
930
931   // Remove the constraint, then set new value
932   actor.RemoveConstraints();
933   actor.SetProperty( index, lesserValue );
934
935   // Constraint should have been removed
936   application.SendNotification();
937   application.Render(0);
938   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), lesserValue, TEST_LOCATION );
939   application.Render(0);
940   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), lesserValue, TEST_LOCATION );
941   END_TEST;
942 }
943
944 int UtcDaliConstraintNewVector4(void)
945 {
946   TestApplication application;
947
948   Actor actor = Actor::New();
949
950   // Register a Vector4 property
951   Vector4 startValue( 1.0f, 1.0f, 1.0f, 1.0f );
952   Property::Index index = actor.RegisterProperty( "test-property", startValue );
953   Stage::GetCurrent().Add(actor);
954   DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
955
956   /**
957    * Test that the Constraint is correctly applied on a clean Node
958    */
959   application.SendNotification();
960   application.Render(0);
961   DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
962   application.Render(0);
963   DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
964   application.Render(0);
965   DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
966
967   // Apply constraint
968
969   Vector4 minValue( 2.0f, 2.0f, 2.0f, 2.0f );
970   Constraint constraint = Constraint::New<Vector4>( index, TestAlwaysEqualOrGreaterThanConstraintVector4( minValue ) );
971
972   actor.ApplyConstraint( constraint );
973   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
974
975   application.SendNotification();
976   application.Render(0);
977
978   // Constraint should be fully applied
979   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
980
981   // Check that nothing has changed after a couple of buffer swaps
982   application.Render(0);
983   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
984   application.Render(0);
985   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
986
987   // Set to greater than 2.0f, the constraint will allow this
988   Vector4 greaterValue( 3.0f, 3.0f, 3.0f, 3.0f );
989   actor.SetProperty( index, greaterValue );
990
991   application.SendNotification();
992   application.Render(0);
993
994   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
995
996   // Check that nothing has changed after a couple of buffer swaps
997   application.Render(0);
998   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
999   application.Render(0);
1000   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), greaterValue, TEST_LOCATION );
1001
1002   // Set to less than 2.0f, the constraint will NOT allow this
1003   Vector4 lesserValue( 1.0f, 1.0f, 1.0f, 1.0f );
1004   actor.SetProperty( index, lesserValue );
1005
1006   application.SendNotification();
1007   application.Render(0);
1008
1009   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue/*not lesserValue*/, TEST_LOCATION );
1010
1011   // Check that nothing has changed after a couple of buffer swaps
1012   application.Render(0);
1013   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
1014   application.Render(0);
1015   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), minValue, TEST_LOCATION );
1016
1017   // Remove the constraint, then set new value
1018   actor.RemoveConstraints();
1019   actor.SetProperty( index, lesserValue );
1020
1021   // Constraint should have been removed
1022   application.SendNotification();
1023   application.Render(0);
1024   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), lesserValue, TEST_LOCATION );
1025   application.Render(0);
1026   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), lesserValue, TEST_LOCATION );
1027   END_TEST;
1028 }
1029
1030 int UtcDaliConstraintNewMatrix(void)
1031 {
1032   try
1033   {
1034     TestApplication application;
1035
1036     Actor actor = Actor::New();
1037
1038     // Register a Matrix property
1039     Matrix startValue = Matrix::IDENTITY;
1040     Property::Index index = actor.RegisterProperty( "test-property", startValue );
1041     DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1042     if (index != Property::INVALID_INDEX)
1043     {
1044       Stage::GetCurrent().Add(actor);
1045       DALI_TEST_CHECK( actor.GetProperty<Matrix>(index) == startValue );
1046
1047       // Apply constraint
1048       Matrix constraintLimit;
1049       constraintLimit.SetTransformComponents(Vector3::ONE, Quaternion(Radian(Degree(30.0f)), Vector3::YAXIS), Vector3::ZAXIS );
1050       Constraint constraint = Constraint::New<Matrix>( index, TestConstraintMatrix(constraintLimit));
1051       actor.ApplyConstraint( constraint );
1052       DALI_TEST_EQUALS( actor.GetProperty<Matrix>(index), startValue, TEST_LOCATION );
1053
1054       application.SendNotification();
1055       application.Render(0);
1056
1057       DALI_TEST_EQUALS( actor.GetProperty<Matrix>(index), constraintLimit, TEST_LOCATION );
1058     }
1059   }
1060   catch (Dali::DaliException& e)
1061   {
1062     DALI_TEST_PRINT_ASSERT( e );
1063     DALI_TEST_CHECK(0);
1064   }
1065   END_TEST;
1066 }
1067
1068 int UtcDaliConstraintNewMatrix3(void)
1069 {
1070   try
1071   {
1072     TestApplication application;
1073
1074     Actor actor = Actor::New();
1075
1076     // Register a Matrix3 property
1077     Matrix3 startValue(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
1078     Property::Index index = actor.RegisterProperty( "test-property", startValue );
1079     DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1080     if (index != Property::INVALID_INDEX)
1081     {
1082       Stage::GetCurrent().Add(actor);
1083       DALI_TEST_CHECK( actor.GetProperty<Matrix3>(index) == startValue );
1084
1085       // Apply constraint
1086       Matrix3 constraintLimit(42.0f, 0.0f, 0.0f, 0.0f, 42.0f, 0.0f, 0.0f, 0.0f, 1.0f);
1087       Constraint constraint = Constraint::New<Matrix3>( index, TestConstraintMatrix3(constraintLimit));
1088       actor.ApplyConstraint( constraint );
1089       DALI_TEST_EQUALS( actor.GetProperty<Matrix3>(index), startValue, 0.001f, TEST_LOCATION );
1090
1091       application.SendNotification();
1092       application.Render(0);
1093
1094       DALI_TEST_EQUALS( actor.GetProperty<Matrix3>(index), constraintLimit, 0.001f, TEST_LOCATION );
1095     }
1096   }
1097   catch (Dali::DaliException& e)
1098   {
1099     DALI_TEST_PRINT_ASSERT( e );
1100     DALI_TEST_CHECK(0);
1101   }
1102   END_TEST;
1103 }
1104
1105 int UtcDaliConstraintNewQuaternion(void)
1106 {
1107   TestApplication application;
1108
1109   Actor actor = Actor::New();
1110
1111   // Register a Quaternion property
1112   Quaternion startValue( 0.0f, Vector3::YAXIS );
1113   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1114   Stage::GetCurrent().Add(actor);
1115   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1116
1117   /**
1118    * Test that the Constraint is correctly applied on a clean Node
1119    */
1120   application.SendNotification();
1121   application.Render(0);
1122   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1123   application.Render(0);
1124   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1125   application.Render(0);
1126   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1127
1128   // Apply constraint
1129
1130   Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS );
1131   Constraint constraint = Constraint::New<Quaternion>( index, TestConstraintRotation( constrainedRotation ) );
1132
1133   actor.ApplyConstraint( constraint );
1134   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1135
1136   application.SendNotification();
1137   application.Render(0);
1138
1139   // Constraint should be fully applied
1140   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1141
1142   // Check that nothing has changed after a couple of buffer swaps
1143   application.Render(0);
1144   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1145   application.Render(0);
1146   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1147
1148   // Set to a different rotation, the constraint will NOT allow this
1149   Quaternion differentRotation( M_PI*0.5f, Vector3::YAXIS );
1150   actor.SetProperty( index, differentRotation );
1151
1152   application.SendNotification();
1153   application.Render(0);
1154
1155   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation/*not differentRotation*/, ROTATION_EPSILON, TEST_LOCATION );
1156
1157   // Check that nothing has changed after a couple of buffer swaps
1158   application.Render(0);
1159   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1160   application.Render(0);
1161   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1162
1163   // Remove the constraint, then set new value
1164   actor.RemoveConstraints();
1165   actor.SetProperty( index, differentRotation );
1166
1167   // Constraint should have been removed
1168   application.SendNotification();
1169   application.Render(0);
1170   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION );
1171   application.Render(0);
1172   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION );
1173   END_TEST;
1174 }
1175
1176 int UtcDaliConstraintNewOffStageBoolean(void)
1177 {
1178   TestApplication application;
1179
1180   Actor actor = Actor::New();
1181
1182   // Register a boolean property
1183   bool startValue(false);
1184   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1185   DALI_TEST_CHECK( actor.GetProperty<bool>(index) == startValue );
1186
1187   // Apply constraint to off-stage Actor
1188   Constraint constraint = Constraint::New<bool>( index, TestAlwaysTrueConstraint() );
1189   actor.ApplyConstraint( constraint );
1190
1191   application.SendNotification();
1192   application.Render(0);
1193   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1194
1195   // Add actor to stage
1196   Stage::GetCurrent().Add(actor);
1197   application.SendNotification();
1198   application.Render(0);
1199
1200   // Constraint should be fully applied
1201   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1202
1203   // Check that nothing has changed after a couple of buffer swaps
1204   application.Render(0);
1205   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1206   application.Render(0);
1207   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1208
1209   // Take the actor off-stage
1210   Stage::GetCurrent().Remove(actor);
1211   application.SendNotification();
1212   application.Render(0);
1213   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1214
1215   // Set a new value; the constraint will not prevent this
1216   actor.SetProperty( index, false );
1217   application.SendNotification();
1218   application.Render(0);
1219   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1220
1221   // Add actor to stage (2nd time)
1222   Stage::GetCurrent().Add(actor);
1223   application.SendNotification();
1224   application.Render(0);
1225
1226   // Constraint should be fully applied (2nd time)
1227   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1228
1229   // Check that nothing has changed after a couple of buffer swaps
1230   application.Render(0);
1231   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1232   application.Render(0);
1233   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1234
1235   // Take the actor off-stage (2nd-time)
1236   Stage::GetCurrent().Remove(actor);
1237   application.SendNotification();
1238   application.Render(0);
1239   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), true, TEST_LOCATION );
1240
1241   // Remove the constraint, and set a new value
1242   actor.RemoveConstraints();
1243   actor.SetProperty( index, false );
1244   application.SendNotification();
1245   application.Render(0);
1246   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1247
1248   // Add actor to stage (3rd time)
1249   Stage::GetCurrent().Add(actor);
1250   application.SendNotification();
1251   application.Render(0);
1252
1253   // Constraint should be gone
1254   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1255
1256   // Check that nothing has changed after a couple of buffer swaps
1257   application.Render(0);
1258   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1259   application.Render(0);
1260   DALI_TEST_EQUALS( actor.GetProperty<bool>(index), false, TEST_LOCATION );
1261   END_TEST;
1262 }
1263
1264 int UtcDaliConstraintNewOffStageFloat(void)
1265 {
1266   TestApplication application;
1267
1268   Actor actor = Actor::New();
1269
1270   // Register a float property
1271   float startValue(1.0f);
1272   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1273   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
1274
1275   // Apply constraint to off-stage Actor
1276   float constrainedValue( 2.0f );
1277   Constraint constraint = Constraint::New<float>( index, TestConstraintFloat( constrainedValue ) );
1278   actor.ApplyConstraint( constraint );
1279
1280   application.SendNotification();
1281   application.Render(0);
1282   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1283
1284   // Add actor to stage
1285   Stage::GetCurrent().Add(actor);
1286   application.SendNotification();
1287   application.Render(0);
1288
1289   // Constraint should be fully applied
1290   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1291
1292   // Check that nothing has changed after a couple of buffer swaps
1293   application.Render(0);
1294   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1295   application.Render(0);
1296   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1297
1298   // Take the actor off-stage
1299   Stage::GetCurrent().Remove(actor);
1300   application.SendNotification();
1301   application.Render(0);
1302   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1303
1304   // Set back to startValue; the constraint will not prevent this
1305   actor.SetProperty( index, startValue );
1306   application.SendNotification();
1307   application.Render(0);
1308   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1309
1310   // Add actor to stage (2nd time)
1311   Stage::GetCurrent().Add(actor);
1312   application.SendNotification();
1313   application.Render(0);
1314
1315   // Constraint should be fully applied (2nd time)
1316   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1317
1318   // Check that nothing has changed after a couple of buffer swaps
1319   application.Render(0);
1320   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1321   application.Render(0);
1322   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1323
1324   // Take the actor off-stage (2nd-time)
1325   Stage::GetCurrent().Remove(actor);
1326   application.SendNotification();
1327   application.Render(0);
1328   DALI_TEST_EQUALS( actor.GetProperty<float>(index), constrainedValue, TEST_LOCATION );
1329
1330   // Remove the constraint, and set back to startValue
1331   actor.RemoveConstraints();
1332   actor.SetProperty( index, startValue );
1333   application.SendNotification();
1334   application.Render(0);
1335   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1336
1337   // Add actor to stage (3rd time)
1338   Stage::GetCurrent().Add(actor);
1339   application.SendNotification();
1340   application.Render(0);
1341
1342   // Constraint should be gone
1343   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1344
1345   // Check that nothing has changed after a couple of buffer swaps
1346   application.Render(0);
1347   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1348   application.Render(0);
1349   DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
1350   END_TEST;
1351 }
1352
1353 int UtcDaliConstraintNewOffStageInteger(void)
1354 {
1355   TestApplication application;
1356
1357   Actor actor = Actor::New();
1358
1359   // Register an integer property
1360   int startValue(1);
1361   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1362   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
1363
1364   // Apply constraint to off-stage Actor
1365   int constrainedValue( 2 );
1366   Constraint constraint = Constraint::New<int>( index, TestConstraintInteger( constrainedValue ) );
1367   actor.ApplyConstraint( constraint );
1368
1369   application.SendNotification();
1370   application.Render(0);
1371   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1372
1373   // Add actor to stage
1374   Stage::GetCurrent().Add(actor);
1375   application.SendNotification();
1376   application.Render(0);
1377
1378   // Constraint should be fully applied
1379   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1380
1381   // Check that nothing has changed after a couple of buffer swaps
1382   application.Render(0);
1383   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1384   application.Render(0);
1385   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1386
1387   // Take the actor off-stage
1388   Stage::GetCurrent().Remove(actor);
1389   application.SendNotification();
1390   application.Render(0);
1391   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1392
1393   // Set back to startValue; the constraint will not prevent this
1394   actor.SetProperty( index, startValue );
1395   application.SendNotification();
1396   application.Render(0);
1397   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1398
1399   // Add actor to stage (2nd time)
1400   Stage::GetCurrent().Add(actor);
1401   application.SendNotification();
1402   application.Render(0);
1403
1404   // Constraint should be fully applied (2nd time)
1405   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1406
1407   // Check that nothing has changed after a couple of buffer swaps
1408   application.Render(0);
1409   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1410   application.Render(0);
1411   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1412
1413   // Take the actor off-stage (2nd-time)
1414   Stage::GetCurrent().Remove(actor);
1415   application.SendNotification();
1416   application.Render(0);
1417   DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
1418
1419   // Remove the constraint, and set back to startValue
1420   actor.RemoveConstraints();
1421   actor.SetProperty( index, startValue );
1422   application.SendNotification();
1423   application.Render(0);
1424   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1425
1426   // Add actor to stage (3rd time)
1427   Stage::GetCurrent().Add(actor);
1428   application.SendNotification();
1429   application.Render(0);
1430
1431   // Constraint should be gone
1432   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1433
1434   // Check that nothing has changed after a couple of buffer swaps
1435   application.Render(0);
1436   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1437   application.Render(0);
1438   DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
1439   END_TEST;
1440 }
1441
1442 int UtcDaliConstraintNewOffStageVector2(void)
1443 {
1444   TestApplication application;
1445
1446   Actor actor = Actor::New();
1447
1448   // Register a Vector2 property
1449   Vector2 startValue(1.0f, 1.0f);
1450   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1451   DALI_TEST_CHECK( actor.GetProperty<Vector2>(index) == startValue );
1452
1453   // Apply constraint to off-stage Actor
1454   Vector2 constrainedValue( 2.0f, 2.0f );
1455   Constraint constraint = Constraint::New<Vector2>( index, TestConstraintVector2( constrainedValue ) );
1456   actor.ApplyConstraint( constraint );
1457
1458   application.SendNotification();
1459   application.Render(0);
1460   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1461
1462   // Add actor to stage
1463   Stage::GetCurrent().Add(actor);
1464   application.SendNotification();
1465   application.Render(0);
1466
1467   // Constraint should be fully applied
1468   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1469
1470   // Check that nothing has changed after a couple of buffer swaps
1471   application.Render(0);
1472   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1473   application.Render(0);
1474   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1475
1476   // Take the actor off-stage
1477   Stage::GetCurrent().Remove(actor);
1478   application.SendNotification();
1479   application.Render(0);
1480   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1481
1482   // Set back to startValue; the constraint will not prevent this
1483   actor.SetProperty( index, startValue );
1484   application.SendNotification();
1485   application.Render(0);
1486   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1487
1488   // Add actor to stage (2nd time)
1489   Stage::GetCurrent().Add(actor);
1490   application.SendNotification();
1491   application.Render(0);
1492
1493   // Constraint should be fully applied (2nd time)
1494   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1495
1496   // Check that nothing has changed after a couple of buffer swaps
1497   application.Render(0);
1498   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1499   application.Render(0);
1500   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1501
1502   // Take the actor off-stage (2nd-time)
1503   Stage::GetCurrent().Remove(actor);
1504   application.SendNotification();
1505   application.Render(0);
1506   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), constrainedValue, TEST_LOCATION );
1507
1508   // Remove the constraint, and set back to startValue
1509   actor.RemoveConstraints();
1510   actor.SetProperty( index, startValue );
1511   application.SendNotification();
1512   application.Render(0);
1513   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1514
1515   // Add actor to stage (3rd time)
1516   Stage::GetCurrent().Add(actor);
1517   application.SendNotification();
1518   application.Render(0);
1519
1520   // Constraint should be gone
1521   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1522
1523   // Check that nothing has changed after a couple of buffer swaps
1524   application.Render(0);
1525   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1526   application.Render(0);
1527   DALI_TEST_EQUALS( actor.GetProperty<Vector2>(index), startValue, TEST_LOCATION );
1528   END_TEST;
1529 }
1530
1531 int UtcDaliConstraintNewOffStageVector3(void)
1532 {
1533   TestApplication application;
1534   Vector3 startValue(1.0f, 1.0f, 1.0f);
1535   Vector3 constrainedValue = Vector3( 2.0f, 3.0f, 4.0f );
1536
1537   Actor actor = Actor::New();
1538   // Register a Vector3 property
1539
1540   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1541   DALI_TEST_CHECK( actor.GetProperty<Vector3>(index) == startValue );
1542
1543   // Apply constraint to off-stage Actor
1544   Constraint constraint = Constraint::New<Vector3>( index, TestConstraintVector3( constrainedValue ) );
1545   actor.ApplyConstraint( constraint );
1546
1547   application.SendNotification();
1548   application.Render(0);
1549   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1550
1551   // Add actor to stage
1552   Stage::GetCurrent().Add(actor);
1553   application.SendNotification();
1554   application.Render();
1555
1556   // Constraint should be fully applied
1557   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1558
1559   // Check that nothing has changed after a couple of buffer swaps
1560   application.Render();
1561   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1562   application.Render();
1563   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1564
1565   // Take the actor off-stage
1566   Stage::GetCurrent().Remove(actor);
1567   application.SendNotification();
1568   application.Render();
1569   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1570
1571   // Set back to startValue; the constraint will not prevent this
1572   Vector3 intermediateValue(5.0f, 6.0f, 7.0f);
1573   actor.SetProperty( index, intermediateValue );
1574   application.SendNotification();
1575   application.Render();
1576   application.Render(); // ensure both buffers are set to intermediateValue
1577   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), intermediateValue, TEST_LOCATION );
1578
1579   // Add actor to stage (2nd time)
1580   Stage::GetCurrent().Add(actor);
1581   application.SendNotification();
1582   application.Render();
1583
1584   // Constraint should be fully applied (2nd time)
1585   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1586
1587   // Check that nothing has changed after a couple of buffer swaps
1588   application.Render();
1589   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1590   application.Render();
1591   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1592
1593   // Take the actor off-stage (2nd-time)
1594   Stage::GetCurrent().Remove(actor);
1595   application.SendNotification();
1596   application.Render();
1597   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), constrainedValue, TEST_LOCATION );
1598
1599   // Remove the constraint, and set back to startValue
1600   actor.RemoveConstraints();
1601   actor.SetProperty( index, startValue );
1602   application.SendNotification();
1603   application.Render();
1604   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1605
1606   // Add actor to stage (3rd time)
1607   Stage::GetCurrent().Add(actor);
1608   application.SendNotification();
1609   application.Render();
1610
1611   // Constraint should be gone
1612   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1613
1614   // Check that nothing has changed after a couple of buffer swaps
1615   application.Render();
1616   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1617   application.Render();
1618   DALI_TEST_EQUALS( actor.GetProperty<Vector3>(index), startValue, TEST_LOCATION );
1619   END_TEST;
1620 }
1621
1622 int UtcDaliConstraintNewOffStageVector4(void)
1623 {
1624   TestApplication application;
1625
1626   Actor actor = Actor::New();
1627
1628   // Register a Vector4 property
1629   Vector4 startValue(1.0f, 1.0f, 1.0f, 1.0f);
1630   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1631   DALI_TEST_CHECK( actor.GetProperty<Vector4>(index) == startValue );
1632
1633   // Apply constraint to off-stage Actor
1634   Vector4 constrainedValue( 2.0f, 2.0f, 2.0f, 2.0f );
1635   Constraint constraint = Constraint::New<Vector4>( index, TestConstraintVector4( constrainedValue ) );
1636   actor.ApplyConstraint( constraint );
1637
1638   application.SendNotification();
1639   application.Render(0);
1640   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1641
1642   // Add actor to stage
1643   Stage::GetCurrent().Add(actor);
1644   application.SendNotification();
1645   application.Render(0);
1646
1647   // Constraint should be fully applied
1648   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1649
1650   // Check that nothing has changed after a couple of buffer swaps
1651   application.Render(0);
1652   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1653   application.Render(0);
1654   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1655
1656   // Take the actor off-stage
1657   Stage::GetCurrent().Remove(actor);
1658   application.SendNotification();
1659   application.Render(0);
1660   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1661
1662   // Set back to startValue; the constraint will not prevent this
1663   actor.SetProperty( index, startValue );
1664   application.SendNotification();
1665   application.Render(0);
1666   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1667
1668   // Add actor to stage (2nd time)
1669   Stage::GetCurrent().Add(actor);
1670   application.SendNotification();
1671   application.Render(0);
1672
1673   // Constraint should be fully applied (2nd time)
1674   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1675
1676   // Check that nothing has changed after a couple of buffer swaps
1677   application.Render(0);
1678   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1679   application.Render(0);
1680   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1681
1682   // Take the actor off-stage (2nd-time)
1683   Stage::GetCurrent().Remove(actor);
1684   application.SendNotification();
1685   application.Render(0);
1686   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), constrainedValue, TEST_LOCATION );
1687
1688   // Remove the constraint, and set back to startValue
1689   actor.RemoveConstraints();
1690   actor.SetProperty( index, startValue );
1691   application.SendNotification();
1692   application.Render(0);
1693   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1694
1695   // Add actor to stage (3rd time)
1696   Stage::GetCurrent().Add(actor);
1697   application.SendNotification();
1698   application.Render(0);
1699
1700   // Constraint should be gone
1701   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1702
1703   // Check that nothing has changed after a couple of buffer swaps
1704   application.Render(0);
1705   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1706   application.Render(0);
1707   DALI_TEST_EQUALS( actor.GetProperty<Vector4>(index), startValue, TEST_LOCATION );
1708   END_TEST;
1709 }
1710
1711 int UtcDaliConstraintNewOffStageQuaternion(void)
1712 {
1713   TestApplication application;
1714
1715   Actor actor = Actor::New();
1716
1717   // Register a Quaternion property
1718   Quaternion startValue( 0.0f, Vector3::YAXIS );
1719   Property::Index index = actor.RegisterProperty( "test-property", startValue );
1720   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1721
1722   // Apply constraint to off-stage Actor
1723   Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS );
1724   Constraint constraint = Constraint::New<Quaternion>( index, TestConstraintRotation( constrainedRotation ) );
1725   actor.ApplyConstraint( constraint );
1726
1727   application.SendNotification();
1728   application.Render(0);
1729   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1730
1731   // Add actor to stage
1732   Stage::GetCurrent().Add(actor);
1733   application.SendNotification();
1734   application.Render(0);
1735
1736   // Constraint should be fully applied
1737   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1738
1739   // Check that nothing has changed after a couple of buffer swaps
1740   application.Render(0);
1741   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1742   application.Render(0);
1743   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1744
1745   // Take the actor off-stage
1746   Stage::GetCurrent().Remove(actor);
1747   application.SendNotification();
1748   application.Render(0);
1749   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1750
1751   // Set back to startValue; the constraint will not prevent this
1752   actor.SetProperty( index, startValue );
1753   application.SendNotification();
1754   application.Render(0);
1755   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1756
1757   // Add actor to stage (2nd time)
1758   Stage::GetCurrent().Add(actor);
1759   application.SendNotification();
1760   application.Render(0);
1761
1762   // Constraint should be fully applied (2nd time)
1763   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1764
1765   // Check that nothing has changed after a couple of buffer swaps
1766   application.Render(0);
1767   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1768   application.Render(0);
1769   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1770
1771   // Take the actor off-stage (2nd-time)
1772   Stage::GetCurrent().Remove(actor);
1773   application.SendNotification();
1774   application.Render(0);
1775   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION );
1776
1777   // Remove the constraint, and set back to startValue
1778   actor.RemoveConstraints();
1779   actor.SetProperty( index, startValue );
1780   application.SendNotification();
1781   application.Render(0);
1782   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1783
1784   // Add actor to stage (3rd time)
1785   Stage::GetCurrent().Add(actor);
1786   application.SendNotification();
1787   application.Render(0);
1788
1789   // Constraint should be gone
1790   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1791
1792   // Check that nothing has changed after a couple of buffer swaps
1793   application.Render(0);
1794   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1795   application.Render(0);
1796   DALI_TEST_EQUALS( actor.GetProperty<Quaternion>(index), startValue, ROTATION_EPSILON, TEST_LOCATION );
1797   END_TEST;
1798 }
1799
1800 int UtcDaliConstraintNewLocalInput(void)
1801 {
1802   TestApplication application;
1803
1804   Actor actor = Actor::New();
1805   Stage::GetCurrent().Add(actor);
1806
1807   Vector3 startValue( 0.0f, 0.0f, 0.0f );
1808   float distanceWhenFullyTransparent( 100.0f );
1809
1810   /**
1811    * Test that the Constraint is correctly applied on a clean Node
1812    */
1813   application.SendNotification();
1814   application.Render(0);
1815   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1816   application.Render(0);
1817   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1818   application.Render(0);
1819   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1820
1821   // Apply constraint with a local input property
1822
1823   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
1824                                                     LocalSource( Actor::Property::COLOR ),
1825                                                     MoveAwayWithFadeConstraint(distanceWhenFullyTransparent) );
1826
1827   actor.ApplyConstraint( constraint );
1828   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1829
1830   application.SendNotification();
1831   application.Render(0);
1832
1833   // Gradually set the color to fully-transparent; the actor should move back
1834
1835   for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f )
1836   {
1837     actor.SetOpacity( 1.0f - progress );
1838
1839     application.SendNotification();
1840     application.Render(0);
1841     DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), ( startValue - Vector3(0.0f, 0.0f, progress*distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION );
1842   }
1843   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), ( startValue - Vector3(0.0f, 0.0f, distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION );
1844   END_TEST;
1845 }
1846
1847 int UtcDaliConstraintNewParentInput(void)
1848 {
1849   TestApplication application;
1850
1851   Actor parent = Actor::New();
1852   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
1853   parent.SetSize( parentStartSize );
1854   Stage::GetCurrent().Add( parent );
1855
1856   Actor actor = Actor::New();
1857   parent.Add( actor );
1858
1859   Vector3 startValue( 0.0f, 0.0f, 0.0f );
1860
1861   /**
1862    * Test that the Constraint is correctly applied on a clean Node
1863    */
1864   application.SendNotification();
1865   application.Render(0);
1866   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1867   application.Render(0);
1868   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1869   application.Render(0);
1870   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1871
1872   // Apply constraint with a parent input property
1873
1874   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
1875                                                     ParentSource( Actor::Property::SIZE ),
1876                                                     TestBottomRightAlignConstraint() );
1877
1878   actor.ApplyConstraint( constraint );
1879   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1880
1881   application.SendNotification();
1882   application.Render(0);
1883
1884   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), parentStartSize,         TEST_LOCATION );
1885   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), parent.GetCurrentSize(), TEST_LOCATION );
1886
1887   // Gradually shrink the parent; the actor should move inwards
1888
1889   for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f )
1890   {
1891     Vector3 size( parentStartSize * std::max(0.0f, 1.0f - progress) );
1892     parent.SetSize( size );
1893
1894     application.SendNotification();
1895     application.Render(0);
1896
1897     DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), size,                    POSITION_EPSILON, TEST_LOCATION );
1898     DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), parent.GetCurrentSize(), POSITION_EPSILON, TEST_LOCATION );
1899   }
1900   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3::ZERO, POSITION_EPSILON, TEST_LOCATION );
1901   END_TEST;
1902 }
1903
1904 int UtcDaliConstraintNewInput1(void)
1905 {
1906   TestApplication application;
1907
1908   Actor parent = Actor::New();
1909   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
1910   parent.SetSize( parentStartSize );
1911   Stage::GetCurrent().Add( parent );
1912
1913   Actor actor = Actor::New();
1914   parent.Add( actor );
1915
1916   Actor sibling1 = Actor::New();
1917   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
1918   parent.Add( sibling1 );
1919
1920   Vector3 startValue( 0.0f, 0.0f, 0.0f );
1921
1922   /**
1923    * Test that the Constraint is correctly applied on a clean Node
1924    */
1925   application.SendNotification();
1926   application.Render(0);
1927   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1928   application.Render(0);
1929   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1930   application.Render(0);
1931   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1932
1933   // Apply constraint with a parent input property
1934
1935   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
1936                                                     Source( sibling1, Actor::Property::POSITION ),
1937                                                     MeanPositionConstraint1() );
1938
1939   actor.ApplyConstraint( constraint );
1940   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1941
1942   application.SendNotification();
1943   application.Render(0);
1944   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
1945
1946   // Check that nothing has changed after a couple of buffer swaps
1947   application.Render(0);
1948   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
1949   application.Render(0);
1950   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION );
1951   END_TEST;
1952 }
1953
1954 int UtcDaliConstraintNewInput2(void)
1955 {
1956   TestApplication application;
1957
1958   Actor parent = Actor::New();
1959   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
1960   parent.SetSize( parentStartSize );
1961   Stage::GetCurrent().Add( parent );
1962
1963   Actor actor = Actor::New();
1964   parent.Add( actor );
1965
1966   Actor sibling1 = Actor::New();
1967   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
1968   parent.Add( sibling1 );
1969
1970   Actor sibling2 = Actor::New();
1971   sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
1972   parent.Add( sibling2 );
1973
1974   application.SendNotification();
1975   application.Render(0);
1976
1977   Vector3 startValue( 0.0f, 0.0f, 0.0f );
1978   Vector3 meanValue = sibling1.GetCurrentPosition() +
1979                       sibling2.GetCurrentPosition();
1980   meanValue *= (1.0f / 2.0f); // divide by number of siblings
1981
1982   /**
1983    * Test that the Constraint is correctly applied on a clean Node
1984    */
1985   application.SendNotification();
1986   application.Render(0);
1987   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1988   application.Render(0);
1989   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1990   application.Render(0);
1991   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
1992
1993   // Apply constraint with a parent input property
1994
1995   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
1996                                                     Source( sibling1, Actor::Property::POSITION ),
1997                                                     Source( sibling2, Actor::Property::POSITION ),
1998                                                     MeanPositionConstraint2() );
1999
2000   actor.ApplyConstraint( constraint );
2001   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2002
2003   application.SendNotification();
2004   application.Render(0);
2005   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2006
2007   // Check that nothing has changed after a couple of buffer swaps
2008   application.Render(0);
2009   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2010   application.Render(0);
2011   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2012   END_TEST;
2013 }
2014
2015 int UtcDaliConstraintNewInput3(void)
2016 {
2017   TestApplication application;
2018
2019   Actor parent = Actor::New();
2020   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
2021   parent.SetSize( parentStartSize );
2022   Stage::GetCurrent().Add( parent );
2023
2024   Actor actor = Actor::New();
2025   parent.Add( actor );
2026
2027   Actor sibling1 = Actor::New();
2028   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
2029   parent.Add( sibling1 );
2030
2031   Actor sibling2 = Actor::New();
2032   sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
2033   parent.Add( sibling2 );
2034
2035   Actor sibling3 = Actor::New();
2036   sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
2037   parent.Add( sibling3 );
2038
2039   application.SendNotification();
2040   application.Render(0);
2041
2042   Vector3 startValue( 0.0f, 0.0f, 0.0f );
2043   Vector3 meanValue = sibling1.GetCurrentPosition() +
2044                       sibling2.GetCurrentPosition() +
2045                       sibling3.GetCurrentPosition();
2046   meanValue *= (1.0f / 3.0f); // divide by number of siblings
2047
2048   /**
2049    * Test that the Constraint is correctly applied on a clean Node
2050    */
2051   application.SendNotification();
2052   application.Render(0);
2053   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2054   application.Render(0);
2055   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2056   application.Render(0);
2057   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2058
2059   // Apply constraint with a parent input property
2060
2061   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2062                                                     Source( sibling1, Actor::Property::POSITION ),
2063                                                     Source( sibling2, Actor::Property::POSITION ),
2064                                                     Source( sibling3, Actor::Property::POSITION ),
2065                                                     MeanPositionConstraint3() );
2066
2067   actor.ApplyConstraint( constraint );
2068   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2069
2070   application.SendNotification();
2071   application.Render(0);
2072   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2073
2074   // Check that nothing has changed after a couple of buffer swaps
2075   application.Render(0);
2076   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2077   application.Render(0);
2078   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2079   END_TEST;
2080 }
2081
2082 int UtcDaliConstraintNewInput4(void)
2083 {
2084   TestApplication application;
2085
2086   Actor parent = Actor::New();
2087   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
2088   parent.SetSize( parentStartSize );
2089   parent.SetPosition( 10.0f, 10.0f, 10.0f );
2090   Stage::GetCurrent().Add( parent );
2091
2092   Actor actor = Actor::New();
2093   parent.Add( actor );
2094
2095   Actor sibling1 = Actor::New();
2096   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
2097   parent.Add( sibling1 );
2098
2099   Actor sibling2 = Actor::New();
2100   sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
2101   parent.Add( sibling2 );
2102
2103   Actor sibling3 = Actor::New();
2104   sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
2105   parent.Add( sibling3 );
2106
2107   application.SendNotification();
2108   application.Render(0);
2109
2110   Vector3 startValue( 0.0f, 0.0f, 0.0f );
2111   Vector3 meanValue = parent.GetCurrentPosition() +
2112                       sibling1.GetCurrentPosition() +
2113                       sibling2.GetCurrentPosition() +
2114                       sibling3.GetCurrentPosition();
2115   meanValue *= (1.0f / 4.0f); // divide by number of positions
2116
2117   /**
2118    * Test that the Constraint is correctly applied on a clean Node
2119    */
2120   application.SendNotification();
2121   application.Render(0);
2122   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2123   application.Render(0);
2124   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2125   application.Render(0);
2126   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2127
2128   // Apply constraint with a parent input property
2129
2130   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2131                                                     Source( sibling1, Actor::Property::POSITION ),
2132                                                     Source( sibling2, Actor::Property::POSITION ),
2133                                                     ParentSource( Actor::Property::POSITION ),
2134                                                     Source( sibling3, Actor::Property::POSITION ),
2135                                                     MeanPositionConstraint4() );
2136
2137   actor.ApplyConstraint( constraint );
2138   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2139
2140   application.SendNotification();
2141   application.Render(0);
2142   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2143
2144   // Check that nothing has changed after a couple of buffer swaps
2145   application.Render(0);
2146   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2147   application.Render(0);
2148   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2149   END_TEST;
2150 }
2151
2152 int UtcDaliConstraintNewInput5(void)
2153 {
2154   TestApplication application;
2155
2156   Actor parent = Actor::New();
2157   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
2158   parent.SetSize( parentStartSize );
2159   parent.SetPosition( 10.0f, 10.0f, 10.0f );
2160   Stage::GetCurrent().Add( parent );
2161
2162   Actor actor = Actor::New();
2163   parent.Add( actor );
2164
2165   Actor sibling1 = Actor::New();
2166   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
2167   parent.Add( sibling1 );
2168
2169   Actor sibling2 = Actor::New();
2170   sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
2171   parent.Add( sibling2 );
2172
2173   Actor sibling3 = Actor::New();
2174   sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
2175   parent.Add( sibling3 );
2176
2177   Actor sibling4 = Actor::New();
2178   sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) );
2179   parent.Add( sibling4 );
2180
2181   application.SendNotification();
2182   application.Render(0);
2183
2184   Vector3 startValue( 0.0f, 0.0f, 0.0f );
2185   Vector3 meanValue = parent.GetCurrentPosition() +
2186                       sibling1.GetCurrentPosition() +
2187                       sibling2.GetCurrentPosition() +
2188                       sibling3.GetCurrentPosition() +
2189                       sibling4.GetCurrentPosition();
2190   meanValue *= (1.0f / 5.0f); // divide by number of positions
2191
2192   /**
2193    * Test that the Constraint is correctly applied on a clean Node
2194    */
2195   application.SendNotification();
2196   application.Render(0);
2197   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2198   application.Render(0);
2199   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2200   application.Render(0);
2201   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2202
2203   // Apply constraint with a parent input property
2204
2205   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2206                                                     Source( sibling1, Actor::Property::POSITION ),
2207                                                     Source( sibling2, Actor::Property::POSITION ),
2208                                                     ParentSource( Actor::Property::POSITION ),
2209                                                     Source( sibling3, Actor::Property::POSITION ),
2210                                                     Source( sibling4, Actor::Property::POSITION ),
2211                                                     MeanPositionConstraint5() );
2212
2213   actor.ApplyConstraint( constraint );
2214   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2215
2216   application.SendNotification();
2217   application.Render(0);
2218   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2219
2220   // Check that nothing has changed after a couple of buffer swaps
2221   application.Render(0);
2222   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2223   application.Render(0);
2224   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2225   END_TEST;
2226 }
2227
2228 int UtcDaliConstraintNewInput6(void)
2229 {
2230   TestApplication application;
2231
2232   Actor parent = Actor::New();
2233   Vector3 parentStartSize( 100.0f, 100.0f, 0.0f );
2234   parent.SetSize( parentStartSize );
2235   parent.SetPosition( 10.0f, 10.0f, 10.0f );
2236   Stage::GetCurrent().Add( parent );
2237
2238   Actor actor = Actor::New();
2239   parent.Add( actor );
2240
2241   Actor child = Actor::New();
2242   child.SetPosition( Vector3(7.0f, 7.0f, 7.0f) );
2243   actor.Add( child );
2244
2245   Actor sibling1 = Actor::New();
2246   sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
2247   parent.Add( sibling1 );
2248
2249   Actor sibling2 = Actor::New();
2250   sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) );
2251   parent.Add( sibling2 );
2252
2253   Actor sibling3 = Actor::New();
2254   sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) );
2255   parent.Add( sibling3 );
2256
2257   Actor sibling4 = Actor::New();
2258   sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) );
2259   parent.Add( sibling4 );
2260
2261   application.SendNotification();
2262   application.Render(0);
2263
2264   Vector3 startValue( 0.0f, 0.0f, 0.0f );
2265   Vector3 meanValue = parent.GetCurrentPosition() +
2266                       child.GetCurrentPosition() +
2267                       sibling1.GetCurrentPosition() +
2268                       sibling2.GetCurrentPosition() +
2269                       sibling3.GetCurrentPosition() +
2270                       sibling4.GetCurrentPosition();
2271   meanValue *= (1.0f / 6.0f); // divide by number of positions
2272
2273   /**
2274    * Test that the Constraint is correctly applied on a clean Node
2275    */
2276   application.SendNotification();
2277   application.Render(0);
2278   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2279   application.Render(0);
2280   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2281   application.Render(0);
2282   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2283
2284   // Apply constraint with a parent input property
2285
2286   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2287                                                     Source( child, Actor::Property::POSITION ),
2288                                                     Source( sibling1, Actor::Property::POSITION ),
2289                                                     Source( sibling2, Actor::Property::POSITION ),
2290                                                     ParentSource( Actor::Property::POSITION ),
2291                                                     Source( sibling3, Actor::Property::POSITION ),
2292                                                     Source( sibling4, Actor::Property::POSITION ),
2293                                                     MeanPositionConstraint6() );
2294
2295   actor.ApplyConstraint( constraint );
2296   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2297
2298   application.SendNotification();
2299   application.Render(0);
2300   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2301
2302   // Check that nothing has changed after a couple of buffer swaps
2303   application.Render(0);
2304   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2305   application.Render(0);
2306   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION );
2307   END_TEST;
2308 }
2309
2310 int UtcDaliConstraintDownCast(void)
2311 {
2312   TestApplication application;
2313   tet_infoline("Testing Dali::Constraint::DownCast()");
2314
2315   Actor actor = Actor::New();
2316
2317   // Register a boolean property
2318   bool startValue(false);
2319   Property::Index index = actor.RegisterProperty( "test-property", startValue );
2320   Constraint constraint = Constraint::New<bool>( index, TestAlwaysTrueConstraint() );
2321
2322   BaseHandle object(constraint);
2323
2324   Constraint constraint2 = Constraint::DownCast(object);
2325   DALI_TEST_CHECK(constraint2);
2326
2327   Constraint constraint3 = DownCast< Constraint >(object);
2328   DALI_TEST_CHECK(constraint3);
2329
2330   BaseHandle unInitializedObject;
2331   Constraint constraint4 = Constraint::DownCast(unInitializedObject);
2332   DALI_TEST_CHECK(!constraint4);
2333
2334   Constraint constraint5 = DownCast< Constraint >(unInitializedObject);
2335   DALI_TEST_CHECK(!constraint5);
2336   END_TEST;
2337 }
2338
2339 int UtcDaliConstraintSetApplyTime(void)
2340 {
2341   TestApplication application;
2342
2343   // Build constraint
2344
2345   Vector4 targetColor(Color::BLACK);
2346   Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestColorConstraint(targetColor) );
2347   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION);
2348
2349   float applySeconds(7.0f);
2350   constraint.SetApplyTime(applySeconds);
2351   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
2352
2353   // Apply to an actor
2354
2355   Actor actor = Actor::New();
2356   Stage::GetCurrent().Add(actor);
2357
2358   actor.ApplyConstraint( constraint );
2359   DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2360
2361   application.SendNotification();
2362   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 20% progress */);
2363
2364   // Constraint shouldn't be fully applied yet
2365   Vector4 twentyPercentColor( Color::WHITE.x*0.8f, Color::WHITE.y*0.8f, Color::WHITE.z*0.8f, Color::WHITE.a );
2366   DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentColor, TEST_LOCATION );
2367
2368   // Constraint shouldn't be fully applied yet
2369   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 40% progress */);
2370   Vector4 fourtyPercentColor( Color::WHITE.x*0.6f, Color::WHITE.y*0.6f, Color::WHITE.z*0.6f, Color::WHITE.a );
2371   DALI_TEST_EQUALS( actor.GetCurrentColor(), fourtyPercentColor, TEST_LOCATION );
2372
2373   // Constraint shouldn't be fully applied yet
2374   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 60% progress */);
2375   Vector4 sixtyPercentColor( Color::WHITE.x*0.4f, Color::WHITE.y*0.4f, Color::WHITE.z*0.4f, Color::WHITE.a );
2376   DALI_TEST_EQUALS( actor.GetCurrentColor(), sixtyPercentColor, TEST_LOCATION );
2377
2378   // Constraint shouldn't be fully applied yet
2379   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 80% progress */);
2380   Vector4 eightyPercentColor( Color::WHITE.x*0.2f, Color::WHITE.y*0.2f, Color::WHITE.z*0.2f, Color::WHITE.a );
2381   DALI_TEST_EQUALS( actor.GetCurrentColor(), eightyPercentColor, TEST_LOCATION );
2382
2383   // Constraint should be fully applied
2384   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* 100% progress */);
2385   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
2386
2387   // Constraint should still be fully applied
2388   application.Render(static_cast<unsigned int>(applySeconds*200.0f)/* Still 100% progress */);
2389   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
2390
2391   // Check that nothing has changed after a couple of buffer swaps
2392   application.Render(0);
2393   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
2394   application.Render(0);
2395   DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
2396   END_TEST;
2397 }
2398
2399 int UtcDaliConstraintGetApplyTime(void)
2400 {
2401   TestApplication application;
2402
2403   Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
2404   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION);
2405
2406   float applySeconds(7.0f);
2407   constraint.SetApplyTime(applySeconds);
2408   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
2409
2410   constraint.SetApplyTime(applySeconds - 3.0f);
2411   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds - 3.0f), TEST_LOCATION);
2412   END_TEST;
2413 }
2414
2415 int UtcDaliConstraintSetAlphaFunction(void)
2416 {
2417   TestApplication application;
2418
2419   Vector3 startValue( Vector3::ZERO );
2420   Vector3 targetValue(100.0f, 100.0f, 100.0f);
2421
2422   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2423                                                     TestConstraintVector3( targetValue ) );
2424
2425   // Test the alpha-function itself
2426
2427   AlphaFunction func = constraint.GetAlphaFunction();
2428   DALI_TEST_EQUALS(func(0.1f), 0.1f, TEST_LOCATION); // Default is Linear
2429
2430   // Test that the alpha-function is used correctly
2431
2432   Actor actor = Actor::New();
2433   Stage::GetCurrent().Add(actor);
2434
2435   application.SendNotification();
2436   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2437   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2438   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2439   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2440   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2441   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2442
2443   constraint.SetApplyTime( 10.0f );
2444   actor.ApplyConstraint( constraint );
2445
2446   application.SendNotification();
2447   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2448   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.1f, TEST_LOCATION );
2449   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2450   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.2f, TEST_LOCATION );
2451   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2452   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.3f, TEST_LOCATION );
2453   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2454   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.4f, TEST_LOCATION );
2455   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2456   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.5f, TEST_LOCATION );
2457   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2458   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.6f, TEST_LOCATION );
2459   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2460   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.7f, TEST_LOCATION );
2461   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2462   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.8f, TEST_LOCATION );
2463   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2464   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue) * 0.9f, TEST_LOCATION );
2465   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2466   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2467
2468   // Check that the constrained value is stable
2469   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2470   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2471   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2472   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2473
2474   // Remove the constraint
2475
2476   actor.RemoveConstraints();
2477   actor.SetPosition( startValue );
2478
2479   application.SendNotification();
2480   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2481   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2482   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2483   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2484   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2485   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
2486
2487   // Change to non-linear alpha and retest
2488
2489   constraint.SetAlphaFunction(AlphaFunctions::EaseIn);
2490   func = constraint.GetAlphaFunction();
2491   DALI_TEST_CHECK(func(0.1f) < 0.09f);
2492
2493   actor.ApplyConstraint( constraint );
2494
2495   application.SendNotification();
2496   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2497
2498   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).x > startValue.x );
2499   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).y > startValue.y );
2500   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).z > startValue.z );
2501
2502   Vector3 lessThanTenPercentProgress( (targetValue - startValue) * 0.09f );
2503   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).x < lessThanTenPercentProgress.x );
2504   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).y < lessThanTenPercentProgress.y );
2505   DALI_TEST_CHECK( actor.GetProperty<Vector3>( Actor::Property::POSITION ).z < lessThanTenPercentProgress.z );
2506
2507   application.Render(static_cast<unsigned int>(9000.0f/*9 seconds*/));
2508   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2509
2510   // Check that the constrained value is stable
2511   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2512   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2513   application.Render(static_cast<unsigned int>(1000.0f/*1 second*/));
2514   DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), (targetValue - startValue), TEST_LOCATION );
2515   END_TEST;
2516 }
2517
2518 int UtcDaliConstraintGetAlphaFunction(void)
2519 {
2520   TestApplication application;
2521
2522   Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
2523
2524   AlphaFunction func = constraint.GetAlphaFunction();
2525   DALI_TEST_EQUALS(func(0.5f), 0.5f, TEST_LOCATION); // Default is Linear
2526   END_TEST;
2527 }
2528
2529 int UtcDaliConstraintSetRemoveAction(void)
2530 {
2531   TestApplication application;
2532
2533   Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
2534   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2535
2536   // Build constraint, with "Discard" remove action
2537
2538   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION, TestPositionConstraint(targetPosition) );
2539   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
2540
2541   constraint.SetRemoveAction(Constraint::Discard);
2542   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION);
2543
2544   // Apply to an actor
2545
2546   Actor actor = Actor::New();
2547   Stage::GetCurrent().Add(actor);
2548
2549   actor.ApplyConstraint( constraint );
2550   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2551
2552   application.SendNotification();
2553   application.Render(100u/*0.1 seconds*/);
2554
2555   // Constraint should be fully applied
2556   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2557
2558   // Check that nothing has changed after a couple of buffer swaps
2559   application.Render(0);
2560   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2561   application.Render(0);
2562   DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
2563
2564   // Remove from the actor
2565   actor.RemoveConstraints(); // should go back to source position
2566
2567   application.SendNotification();
2568   application.Render(static_cast<unsigned int>(1000.0f));
2569
2570   // Constraint should be fully removed
2571   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2572
2573   // Constraint should still be fully removed
2574   application.Render(static_cast<unsigned int>(1000.0f)/* Still 100% removal progress */);
2575   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2576
2577   // Check that nothing has changed after a couple of buffer swaps
2578   application.Render(0);
2579   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2580   application.Render(0);
2581   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2582   END_TEST;
2583 }
2584
2585 int UtcDaliConstraintGetRemoveAction(void)
2586 {
2587   TestApplication application;
2588
2589   Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
2590   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
2591
2592   constraint.SetRemoveAction(Constraint::Discard);
2593   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION);
2594
2595   constraint.SetRemoveAction(Constraint::Bake);
2596   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
2597   END_TEST;
2598 }
2599
2600 /**
2601  * Test a constraint with non-zero apply-time & zero (immediate) remove-time, where the constraint is removed during the apply-time
2602  */
2603 int UtcDaliConstraintImmediateRemoveDuringApply(void)
2604 {
2605   TestApplication application;
2606
2607   Vector3 sourcePosition(0.0f, 0.0f, 0.0f);
2608   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
2609
2610   // Build constraint
2611
2612   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION, TestPositionConstraint(targetPosition) );
2613   DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION);
2614
2615   float applySeconds(4.0f);
2616   constraint.SetApplyTime(applySeconds);
2617   DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION);
2618
2619   // Apply to an actor
2620
2621   Actor actor = Actor::New();
2622   Stage::GetCurrent().Add(actor);
2623
2624   actor.ApplyConstraint( constraint );
2625   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2626
2627   application.SendNotification();
2628   application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 25% progress */);
2629
2630   // Constraint shouldn't be fully applied yet
2631   Vector3 twentyFivePercent( targetPosition * 0.25f );
2632   DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION );
2633
2634   application.Render(static_cast<unsigned int>(applySeconds*250.0f)/* 50% progress */);
2635
2636   // Constraint shouldn't be fully applied yet
2637   Vector3 fiftyPercent( targetPosition * 0.5f );
2638   DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercent, TEST_LOCATION );
2639
2640   // Remove from the actor
2641
2642   actor.RemoveConstraints(); // should go back to source position
2643   application.SendNotification();
2644
2645   // Constraint should be fully removed
2646   application.Render(static_cast<unsigned int>(200.0f /*0.2 seconds*/));
2647   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2648
2649   // Constraint should still be fully applied
2650   application.Render(static_cast<unsigned int>(200.0f /*0.2 seconds*/));
2651   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2652
2653   // Check that nothing has changed after a couple of buffer swaps
2654   application.Render(0);
2655   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2656   application.Render(0);
2657   DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION );
2658   END_TEST;
2659 }
2660
2661 int UtcDaliConstraintActorSize(void)
2662 {
2663   TestApplication application;
2664
2665   // Build constraint, to make child 20% of parent size
2666
2667   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
2668                                                     ParentSource( Actor::Property::SIZE ),
2669                                                     TestRelativeConstraintVector3(0.2f) );
2670   // Apply to a child actor
2671
2672   Actor parent = Actor::New();
2673   Stage::GetCurrent().Add(parent);
2674
2675   Actor child = Actor::New();
2676   parent.Add(child);
2677
2678   child.ApplyConstraint( constraint );
2679   DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
2680
2681   // Animate the parent between two sizes
2682
2683   Vector3 targetParentSize(100.0f, 100.0f, 100.0f);
2684
2685   float durationSeconds(10.0f);
2686   Animation animation = Animation::New(durationSeconds);
2687   animation.AnimateTo( Property(parent, Actor::Property::SIZE), targetParentSize );
2688   animation.Play();
2689
2690   application.SendNotification();
2691
2692   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
2693   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
2694   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize*0.25f * 0.2f, TEST_LOCATION );
2695
2696   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
2697   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
2698   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize*0.5f * 0.2f, TEST_LOCATION );
2699
2700   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
2701   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
2702   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize*0.75f * 0.2f, TEST_LOCATION );
2703
2704   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
2705   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2706   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize * 0.2f, TEST_LOCATION );
2707
2708   // Check that nothing has changed after a couple of buffer swaps
2709   application.Render(0);
2710   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2711   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize * 0.2f, TEST_LOCATION );
2712   application.Render(0);
2713   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2714   DALI_TEST_EQUALS( child.GetCurrentSize(),  targetParentSize * 0.2f, TEST_LOCATION );
2715   END_TEST;
2716 }
2717
2718 int UtcDaliConstraintActorSizeWidth(void)
2719 {
2720   TestApplication application;
2721
2722   // Build constraint, to make child 20% of parent width
2723
2724   Constraint constraint = Constraint::New<float>( Actor::Property::SIZE_WIDTH,
2725                                                   ParentSource( Actor::Property::SIZE_WIDTH ),
2726                                                   TestRelativeConstraintFloat(0.2f) );
2727   // Apply to a child actor
2728
2729   Actor parent = Actor::New();
2730   Stage::GetCurrent().Add(parent);
2731
2732   Actor child = Actor::New();
2733   parent.Add(child);
2734
2735   child.ApplyConstraint( constraint );
2736   DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
2737
2738   // Animate the parent between two sizes
2739
2740   Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
2741
2742   float durationSeconds(10.0f);
2743   Animation animation = Animation::New(durationSeconds);
2744   animation.AnimateTo( Property(parent, Actor::Property::SIZE), targetParentSize );
2745   animation.Play();
2746
2747   application.SendNotification();
2748
2749   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
2750   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
2751   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width*0.25f * 0.2f, TEST_LOCATION );
2752   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2753   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2754
2755   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
2756   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
2757   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width*0.5f * 0.2f, TEST_LOCATION );
2758   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2759   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2760
2761   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
2762   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
2763   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width*0.75f * 0.2f, TEST_LOCATION );
2764   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2765   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2766
2767   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
2768   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2769   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width * 0.2f, TEST_LOCATION );
2770   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2771   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2772
2773   // Check that nothing has changed after a couple of buffer swaps
2774   application.Render(0);
2775   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2776   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width * 0.2f, TEST_LOCATION );
2777   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2778   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2779
2780   application.Render(0);
2781   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2782   DALI_TEST_EQUALS( child.GetCurrentSize().width,  targetParentSize.width * 0.2f, TEST_LOCATION );
2783   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2784   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2785   END_TEST;
2786 }
2787
2788 int UtcDaliConstraintActorSizeHeight(void)
2789 {
2790   TestApplication application;
2791
2792   // Build constraint, to make child 20% of parent height
2793
2794   Constraint constraint = Constraint::New<float>( Actor::Property::SIZE_HEIGHT,
2795                                                   ParentSource( Actor::Property::SIZE_HEIGHT ),
2796                                                   TestRelativeConstraintFloat(0.2f) );
2797   // Apply to a child actor
2798
2799   Actor parent = Actor::New();
2800   Stage::GetCurrent().Add(parent);
2801
2802   Actor child = Actor::New();
2803   parent.Add(child);
2804
2805   child.ApplyConstraint( constraint );
2806   DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
2807
2808   // Animate the parent between two sizes
2809
2810   Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
2811
2812   float durationSeconds(10.0f);
2813   Animation animation = Animation::New(durationSeconds);
2814   animation.AnimateTo( Property(parent, Actor::Property::SIZE), targetParentSize );
2815   animation.Play();
2816
2817   application.SendNotification();
2818
2819   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
2820   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
2821   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2822   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.25f * 0.2f, TEST_LOCATION );
2823   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2824
2825   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
2826   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
2827   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2828   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.5f * 0.2f, TEST_LOCATION );
2829   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2830
2831   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
2832   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
2833   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2834   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.75f * 0.2f, TEST_LOCATION );
2835   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2836
2837   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
2838   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2839   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2840   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
2841   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2842
2843   // Check that nothing has changed after a couple of buffer swaps
2844   application.Render(0);
2845   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2846   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2847   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
2848   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2849
2850   application.Render(0);
2851   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2852   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2853   DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION );
2854   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  0.0f, TEST_LOCATION );
2855   END_TEST;
2856 }
2857
2858 int UtcDaliConstraintActorSizeDepth(void)
2859 {
2860   TestApplication application;
2861
2862   // Build constraint, to make child 20% of parent height
2863
2864   Constraint constraint = Constraint::New<float>( Actor::Property::SIZE_DEPTH,
2865                                                   ParentSource( Actor::Property::SIZE_DEPTH ),
2866                                                   TestRelativeConstraintFloat(0.2f) );
2867   // Apply to a child actor
2868
2869   Actor parent = Actor::New();
2870   Stage::GetCurrent().Add(parent);
2871
2872   Actor child = Actor::New();
2873   parent.Add(child);
2874
2875   child.ApplyConstraint( constraint );
2876   DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
2877
2878   // Animate the parent between two sizes
2879
2880   Vector3 targetParentSize(80.0f, 90.0f, 100.0f);
2881
2882   float durationSeconds(10.0f);
2883   Animation animation = Animation::New(durationSeconds);
2884   animation.AnimateTo( Property(parent, Actor::Property::SIZE), targetParentSize );
2885   animation.Play();
2886
2887   application.SendNotification();
2888
2889   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
2890   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION );
2891   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2892   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2893   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth*0.25f * 0.2f, TEST_LOCATION );
2894
2895   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
2896   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION );
2897   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2898   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2899   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth*0.5f * 0.2f, TEST_LOCATION );
2900
2901   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
2902   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION );
2903   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2904   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2905   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth*0.75f * 0.2f, TEST_LOCATION );
2906
2907   application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
2908   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2909   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2910   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2911   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth * 0.2f, TEST_LOCATION );
2912
2913   // Check that nothing has changed after a couple of buffer swaps
2914   application.Render(0);
2915   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2916   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2917   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2918   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth * 0.2f, TEST_LOCATION );
2919
2920   application.Render(0);
2921   DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION );
2922   DALI_TEST_EQUALS( child.GetCurrentSize().width,  0.0f, TEST_LOCATION );
2923   DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION );
2924   DALI_TEST_EQUALS( child.GetCurrentSize().depth,  targetParentSize.depth * 0.2f, TEST_LOCATION );
2925   END_TEST;
2926 }
2927
2928 int UtcDaliConstraintInputWorldPosition(void)
2929 {
2930   TestApplication application;
2931
2932   Actor parent = Actor::New();
2933   Vector3 parentPosition( 10.0f, 10.0f, 10.0f );
2934   parent.SetPosition( parentPosition );
2935   parent.SetParentOrigin( ParentOrigin::CENTER );
2936   parent.SetAnchorPoint( AnchorPoint::CENTER );
2937   Stage::GetCurrent().Add( parent );
2938
2939   Actor child = Actor::New();
2940   child.SetParentOrigin( ParentOrigin::CENTER );
2941   child.SetAnchorPoint( AnchorPoint::CENTER );
2942   Vector3 childPosition( 10.0f, 10.0f, 10.0f );
2943   child.SetPosition( childPosition );
2944   parent.Add( child );
2945
2946   Actor trackingActor = Actor::New();
2947   trackingActor.SetParentOrigin( ParentOrigin::CENTER );
2948   trackingActor.SetAnchorPoint( AnchorPoint::CENTER );
2949   Stage::GetCurrent().Add( trackingActor );
2950
2951   // The actors should not have a world position yet
2952   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
2953   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
2954   DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
2955
2956   application.SendNotification();
2957   application.Render(0);
2958
2959   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
2960   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
2961   DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
2962
2963   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
2964   Vector3 previousPosition( parentPosition + childPosition );
2965   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );
2966   DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
2967
2968   // Build constraint, to make actor track the world-position of another actor
2969   // Note that the world-position is always from the previous frame, so the tracking actor will lag behind
2970
2971   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
2972                                                     Source( child, Actor::Property::WORLD_POSITION ),
2973                                                     EqualToConstraint() );
2974
2975   trackingActor.ApplyConstraint( constraint );
2976
2977   application.SendNotification();
2978   application.Render(0);
2979
2980   DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
2981
2982   // Move the actors and try again
2983   Vector3 relativePosition( 5, 5, 5 );
2984   parent.MoveBy( relativePosition );
2985
2986   application.SendNotification();
2987   application.Render(0);
2988
2989   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION );
2990   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
2991
2992   // The tracking actor lags behind
2993   DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
2994
2995   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION );
2996   previousPosition = Vector3( parentPosition + childPosition + relativePosition );
2997   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );
2998
2999   // Allow the tracking actor to catch up
3000   application.SendNotification();
3001   application.Render(0);
3002
3003   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION );
3004   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
3005
3006   // The tracking actor catches up!
3007   DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION );
3008   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION );
3009   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION );
3010   END_TEST;
3011 }
3012
3013 int UtcDaliConstraintInputWorldRotation(void)
3014 {
3015   TestApplication application;
3016
3017   Actor parent = Actor::New();
3018   Radian rotationAngle( Degree(90.0f) );
3019   Quaternion rotation( rotationAngle, Vector3::YAXIS );
3020   parent.SetRotation( rotation );
3021   Stage::GetCurrent().Add( parent );
3022
3023   Actor child = Actor::New();
3024   child.SetRotation( rotation );
3025   parent.Add( child );
3026
3027   Actor trackingActor = Actor::New();
3028   Stage::GetCurrent().Add( trackingActor );
3029
3030   // The actors should not have a world rotation yet
3031   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
3032   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
3033
3034   application.SendNotification();
3035   application.Render(0);
3036
3037   DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
3038   DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
3039   DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
3040
3041   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
3042   Quaternion previousRotation( rotationAngle * 2.0f, Vector3::YAXIS );
3043   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION );
3044
3045   // Build constraint, to make actor track the world-rotation of another actor
3046   // Note that the world-rotation is always from the previous frame, so the tracking actor will lag behind
3047
3048   Constraint constraint = Constraint::New<Quaternion>( Actor::Property::ROTATION,
3049                                                        Source( child, Actor::Property::WORLD_ROTATION ),
3050                                                        EqualToQuaternion() );
3051
3052   trackingActor.ApplyConstraint( constraint );
3053
3054   application.SendNotification();
3055   application.Render(0);
3056
3057   DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION );
3058
3059   // Rotate the actors and try again
3060   parent.RotateBy( rotation );
3061
3062   application.SendNotification();
3063   application.Render(0);
3064
3065   DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation * rotation, 0.001, TEST_LOCATION );
3066   DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
3067
3068   // The tracking actor lags behind
3069   DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION );
3070
3071   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
3072   previousRotation = Quaternion( rotationAngle * 3.0f, Vector3::YAXIS );
3073   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION );
3074
3075   // Allow the tracking actor to catch up
3076   application.SendNotification();
3077   application.Render(0);
3078
3079   DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation * rotation, 0.001, TEST_LOCATION );
3080   DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
3081
3082   // The tracking actor catches up!
3083   DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION );
3084   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
3085   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION );
3086   END_TEST;
3087 }
3088
3089 int UtcDaliConstraintInputWorldScale(void)
3090 {
3091   TestApplication application;
3092
3093   Actor parent = Actor::New();
3094   Vector3 parentScale( 2.0f, 2.0f, 2.0f );
3095   parent.SetScale( parentScale );
3096   Stage::GetCurrent().Add( parent );
3097
3098   Actor child = Actor::New();
3099   Vector3 childScale( 1.0f, 2.0f, 3.0f );
3100   child.SetScale( childScale );
3101   parent.Add( child );
3102
3103   Actor trackingActor = Actor::New();
3104   Stage::GetCurrent().Add( trackingActor );
3105
3106   // The actors should not have a world scale yet
3107   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
3108   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
3109   DALI_TEST_EQUALS( trackingActor.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
3110
3111   application.SendNotification();
3112   application.Render(0);
3113
3114   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
3115   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
3116   DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3117
3118   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
3119   Vector3 previousScale( parentScale * childScale );
3120   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION );
3121   DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
3122
3123   // Build constraint, to make actor track the world-scale of another actor
3124   // Note that the world-scale is always from the previous frame, so the tracking actor will lag behind
3125
3126   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
3127                                                     Source( child, Actor::Property::WORLD_SCALE ),
3128                                                     EqualToConstraint() );
3129
3130   trackingActor.ApplyConstraint( constraint );
3131
3132   application.SendNotification();
3133   application.Render(0);
3134
3135   DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION );
3136
3137   // Scale the actors and try again
3138   Vector3 relativeScale( 3, 3, 3 );
3139   parent.ScaleBy( relativeScale );
3140
3141   application.SendNotification();
3142   application.Render(0);
3143
3144   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale * relativeScale, TEST_LOCATION );
3145   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
3146
3147   // The tracking actor lags behind
3148   DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION );
3149
3150   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale * relativeScale, TEST_LOCATION );
3151   previousScale = Vector3( parentScale * childScale * relativeScale );
3152   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION );
3153
3154   // Allow the tracking actor to catch up
3155   application.SendNotification();
3156   application.Render(0);
3157
3158   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale * relativeScale, TEST_LOCATION );
3159   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
3160
3161   // The tracking actor catches up!
3162   DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION );
3163   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale * relativeScale, TEST_LOCATION );
3164   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION );
3165   END_TEST;
3166 }
3167
3168 int UtcDaliConstraintInputWorldColor(void)
3169 {
3170   TestApplication application;
3171
3172   Actor parent = Actor::New();
3173   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 1.0f );
3174   parent.SetColor( parentColor );
3175   Stage::GetCurrent().Add( parent );
3176
3177   Actor child = Actor::New();
3178   Vector4 childColor( 0.5f, 0.5f, 0.5f, 1.0f );
3179   child.SetColor( childColor );
3180   parent.Add( child );
3181
3182   Actor trackingActor = Actor::New();
3183   Stage::GetCurrent().Add( trackingActor );
3184
3185   // The actors should not have a world color yet
3186   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
3187   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
3188
3189   application.SendNotification();
3190   application.Render(0);
3191
3192   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
3193   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
3194   DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
3195
3196   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
3197   Vector4 previousColor( childColor );
3198   previousColor.a *= parentColor.a;
3199   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION );
3200
3201   // Build constraint, to make actor track the world-color of another actor
3202   // Note that the world-color is always from the previous frame, so the tracking actor will lag behind
3203
3204   Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
3205                                                     Source( child, Actor::Property::WORLD_COLOR ),
3206                                                     EqualToVector4() );
3207
3208   trackingActor.ApplyConstraint( constraint );
3209
3210   application.SendNotification();
3211   application.Render(0);
3212
3213   DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION );
3214
3215   // Set the color and try again
3216   Vector4 newChildColor( 0.75f, 0.75f, 0.75f, 1.0f );
3217   child.SetColor( newChildColor );
3218
3219   application.SendNotification();
3220   application.Render(0);
3221
3222   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
3223   DALI_TEST_EQUALS( child.GetCurrentColor(), newChildColor, TEST_LOCATION );
3224
3225   // The tracking actor lags behind
3226   DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION );
3227
3228   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
3229   previousColor = Vector3( newChildColor );
3230   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION );
3231
3232   // Allow the tracking actor to catch up
3233   application.SendNotification();
3234   application.Render(0);
3235
3236   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
3237   DALI_TEST_EQUALS( child.GetCurrentColor(), newChildColor, TEST_LOCATION );
3238
3239   // The tracking actor catches up!
3240   DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION );
3241   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
3242   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION );
3243   END_TEST;
3244 }
3245
3246 int UtcDaliConstraintInvalidInputProperty(void)
3247 {
3248   TestApplication application;
3249   Actor actor = Actor::New();
3250   Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION, LocalSource( PROPERTY_REGISTRATION_START_INDEX ), EqualToConstraint() );
3251
3252   Stage::GetCurrent().Add( actor );
3253
3254   // Cannot use type registered properties as input to constraints
3255   try
3256   {
3257     actor.ApplyConstraint( constraint );
3258     tet_result( TET_FAIL );
3259   }
3260   catch ( DaliException& e )
3261   {
3262     DALI_TEST_ASSERT( e, "mTargetObject->IsPropertyAConstraintInput( source.propertyIndex )", TEST_LOCATION );
3263   }
3264   END_TEST;
3265 }
3266
3267 int UtcDaliBuiltinConstraintParentSize(void)
3268 {
3269   TestApplication application;
3270
3271   Actor parent = Actor::New();
3272   Vector3 parentSize(9,9,9);
3273   parent.SetSize( parentSize );
3274   Stage::GetCurrent().Add( parent );
3275
3276   Actor actor = Actor::New();
3277   parent.Add( actor );
3278
3279   Vector3 startValue( Vector3::ZERO );
3280
3281   application.SendNotification();
3282   application.Render(0);
3283   DALI_TEST_CHECK( actor.GetCurrentSize() == startValue );
3284
3285   // Apply constraint
3286
3287   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() );
3288   actor.ApplyConstraint( constraint );
3289
3290   application.SendNotification();
3291   application.Render(0);
3292
3293   // Constraint should be fully applied
3294   DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION );
3295
3296   // This should be ignored
3297   actor.SetSize( startValue );
3298
3299   // Check that nothing has changed after a couple of buffer swaps
3300   application.SendNotification();
3301   application.Render(0);
3302   DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION );
3303   application.Render(0);
3304   DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION );
3305
3306   // Remove the constraint, then set new value
3307   actor.RemoveConstraints();
3308   actor.SetSize( startValue );
3309
3310   // Constraint should have been removed
3311   application.SendNotification();
3312   application.Render(0);
3313   DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION );
3314   application.Render(0);
3315   DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION );
3316   END_TEST;
3317 }
3318
3319 int UtcDaliBuiltinConstraintParentSizeRelative(void)
3320 {
3321   TestApplication application;
3322
3323   Actor parent = Actor::New();
3324   Vector3 parentSize(9,9,9);
3325   parent.SetSize( parentSize );
3326   Stage::GetCurrent().Add( parent );
3327
3328   Actor actor = Actor::New();
3329   parent.Add( actor );
3330
3331   Vector3 startValue( Vector3::ZERO );
3332   Vector3 scale(2,3,4);
3333   Vector3 endValue( parentSize * scale );
3334
3335   application.SendNotification();
3336   application.Render(0);
3337   DALI_TEST_CHECK( actor.GetCurrentSize() == startValue );
3338
3339   // Apply constraint
3340
3341   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), RelativeToConstraint( scale ) );
3342   actor.ApplyConstraint( constraint );
3343
3344   application.SendNotification();
3345   application.Render(0);
3346
3347   // Constraint should be fully applied
3348   DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION );
3349
3350   // This should be ignored
3351   actor.SetSize( startValue );
3352
3353   // Check that nothing has changed after a couple of buffer swaps
3354   application.SendNotification();
3355   application.Render(0);
3356   DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION );
3357   application.Render(0);
3358   DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION );
3359
3360   // Remove the constraint, then set new value
3361   actor.RemoveConstraints();
3362   actor.SetSize( startValue );
3363
3364   // Constraint should have been removed
3365   application.SendNotification();
3366   application.Render(0);
3367   DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION );
3368   application.Render(0);
3369   DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION );
3370   END_TEST;
3371 }
3372
3373 int UtcDaliBuiltinConstraintScaleToFitConstraint(void)
3374 {
3375   TestApplication application;
3376
3377   Actor parent = Actor::New();
3378   Vector3 startParentSize( 10, 10, 10 );
3379   parent.SetSize( startParentSize );
3380   Stage::GetCurrent().Add( parent );
3381
3382   Actor actor = Actor::New();
3383   Vector3 startChildSize( 5, 5, 5 );
3384   actor.SetSize( startChildSize );
3385   parent.Add( actor );
3386
3387   Vector3 endChildSize( 8, 8, 8 );
3388   Vector3 endParentSize( 4, 4, 4 );
3389   Vector3 startChildScale( 2, 2, 2 ); // startParentSize / startChildSize
3390   Vector3 intermediateChildScale( 1.25, 1.25, 1.25 ); // startParentSize / endChildSize
3391   Vector3 endChildScale( 0.5, 0.5, 0.5 ); // endParentSize / endChildSize
3392
3393   application.SendNotification();
3394   application.Render(0);
3395   DALI_TEST_CHECK( actor.GetCurrentSize() == startChildSize );
3396
3397   // Apply constraint
3398
3399   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
3400                                                     LocalSource( Actor::Property::SIZE ),
3401                                                     ParentSource( Actor::Property::SIZE ),
3402                                                     ScaleToFitConstraint() );
3403   actor.ApplyConstraint( constraint );
3404
3405   application.SendNotification();
3406   application.Render(0);
3407
3408   // Constraint should be fully applied, but parent size is larger than child
3409   DALI_TEST_EQUALS( actor.GetCurrentSize(), startChildSize, TEST_LOCATION );
3410   DALI_TEST_EQUALS( actor.GetCurrentScale(), startChildScale, TEST_LOCATION );
3411
3412   // This should be allowed (still less than parent size)
3413   actor.SetSize( endChildSize );
3414
3415   application.SendNotification();
3416   application.Render(0);
3417   DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION );
3418   DALI_TEST_EQUALS( actor.GetCurrentScale(), intermediateChildScale, TEST_LOCATION );
3419
3420   // Reduce the parent size
3421   parent.SetSize( endParentSize );
3422
3423   application.SendNotification();
3424   application.Render(0);
3425
3426   // Constraint should be fully applied
3427   DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION );
3428   DALI_TEST_EQUALS( actor.GetCurrentScale(), endChildScale, TEST_LOCATION );
3429   application.Render(0);
3430   DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION );
3431   DALI_TEST_EQUALS( actor.GetCurrentScale(), endChildScale, TEST_LOCATION );
3432   END_TEST;
3433 }
3434
3435 int UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio(void)
3436 {
3437   TestApplication application;
3438
3439   Actor parent = Actor::New();
3440   Vector3 parentSize1( 10, 10, 10 );
3441   parent.SetSize( parentSize1 );
3442   Stage::GetCurrent().Add( parent );
3443
3444   Actor actor = Actor::New();
3445   Vector3 childSize( 4, 5, 5 );
3446   actor.SetSize( childSize );
3447   parent.Add( actor );
3448
3449   application.SendNotification();
3450   application.Render(0);
3451   Vector3 childScale1( 1.0f, 1.0f, 1.0f );
3452   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION );
3453
3454   // Apply constraint
3455
3456   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
3457                                                     LocalSource( Actor::Property::SIZE ),
3458                                                     ParentSource( Actor::Property::SIZE ),
3459                                                     ScaleToFitKeepAspectRatioConstraint() );
3460   actor.ApplyConstraint( constraint );
3461
3462   application.SendNotification();
3463   application.Render(0);
3464
3465   // Constraint should be fully applied, but parent size is larger than child
3466   Vector3 childScale2( 2.0f, 2.0f, 2.0f );
3467   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION );
3468
3469   // change parent size
3470   Vector3 parentSize2( 40, 50, 50 );
3471   parent.SetSize( parentSize2 );
3472
3473   application.SendNotification();
3474   application.Render(0);
3475
3476   // Constraint should be fully applied, but parent size is larger than child
3477   Vector3 childScale3( 10.0f, 10.0f, 10.0f );
3478   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION );
3479   END_TEST;
3480 }
3481
3482
3483 int UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio(void)
3484 {
3485   TestApplication application;
3486
3487   Actor parent = Actor::New();
3488   Vector3 parentSize1( 10, 10, 10 );
3489   parent.SetSize( parentSize1 );
3490   Stage::GetCurrent().Add( parent );
3491
3492   Actor actor = Actor::New();
3493   Vector3 childSize( 4, 5, 5 );
3494   actor.SetSize( childSize );
3495   parent.Add( actor );
3496
3497   application.SendNotification();
3498   application.Render(0);
3499   Vector3 childScale1( 1.0f, 1.0f, 1.0f );
3500   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION );
3501
3502   // Apply constraint
3503
3504   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
3505                                                     LocalSource( Actor::Property::SIZE ),
3506                                                     ParentSource( Actor::Property::SIZE ),
3507                                                     ScaleToFillXYKeepAspectRatioConstraint() );
3508   actor.ApplyConstraint( constraint );
3509
3510   application.SendNotification();
3511   application.Render(0);
3512
3513   // Constraint should be fully applied, but parent size is larger than child
3514   float val = 10.f / 4.f;
3515   Vector3 childScale2( val, val, val );
3516   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION );
3517
3518   // change parent size
3519   Vector3 parentSize2( 40, 50, 50 );
3520   parent.SetSize( parentSize2 );
3521
3522   application.SendNotification();
3523   application.Render(0);
3524
3525   // Constraint should be fully applied, but parent size is larger than child
3526   Vector3 childScale3( 10.0f, 10.0f, 10.0f );
3527   DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION );
3528   END_TEST;
3529 }
3530
3531 int UtcDaliBuiltinConstraintEqualToConstraint(void)
3532 {
3533   TestApplication application;
3534
3535   Actor actor1 = Actor::New();
3536   Vector3 startPosition( 10, 10, 10 );
3537   actor1.SetPosition( startPosition );
3538   Stage::GetCurrent().Add( actor1 );
3539
3540   Actor actor2 = Actor::New();
3541   Vector3 startSize( 100, 100, 100 );
3542   actor2.SetSize( startSize );
3543   Stage::GetCurrent().Add( actor2 );
3544
3545   application.SendNotification();
3546   application.Render(0);
3547   DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition );
3548   DALI_TEST_CHECK( actor2.GetCurrentSize()     == startSize );
3549
3550   // Apply constraint - actor1 size == actor2 position
3551
3552   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
3553                                                     Source( actor1, Actor::Property::POSITION ),
3554                                                     EqualToConstraint() );
3555   constraint.SetRemoveAction( Constraint::Discard );
3556   actor2.ApplyConstraint( constraint );
3557
3558   application.SendNotification();
3559   application.Render(0);
3560
3561   // Constraint should be fully applied
3562   DALI_TEST_EQUALS( actor2.GetCurrentSize(), startPosition, TEST_LOCATION );
3563
3564   // Change the input
3565   Vector3 endPosition( 2, 2, 2 );
3566   actor1.SetPosition( endPosition );
3567
3568   application.SendNotification();
3569   application.Render(0);
3570
3571   // Constraint should be fully applied
3572   DALI_TEST_EQUALS( actor2.GetCurrentSize(), endPosition, TEST_LOCATION );
3573   application.Render(0);
3574   DALI_TEST_EQUALS( actor2.GetCurrentSize(), endPosition, TEST_LOCATION );
3575
3576   //
3577   // Check float variant of constraint
3578   //
3579   float startOpacity(1.0f);
3580   float endOpacity(0.2f);
3581   actor1.SetOpacity( startOpacity );
3582   actor2.SetOpacity( startOpacity );
3583
3584   application.SendNotification();
3585   application.Render(0);
3586   DALI_TEST_EQUALS( actor1.GetCurrentOpacity(), startOpacity, TEST_LOCATION );
3587   DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity, TEST_LOCATION );
3588
3589   Constraint constraint2 = Constraint::New<float>( Actor::Property::COLOR_ALPHA,
3590                                                   Source( actor1, Actor::Property::COLOR_ALPHA ),
3591                                                   EqualToConstraint() );
3592   constraint2.SetRemoveAction( Constraint::Discard );
3593   actor2.ApplyConstraint( constraint2 );
3594
3595   actor1.SetOpacity(endOpacity);
3596
3597   application.SendNotification();
3598   application.Render(0);
3599
3600   DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), endOpacity, 0.000001f, TEST_LOCATION );
3601
3602   //
3603   // Check Vector4 variant of constraint
3604   //
3605   actor1.SetColor( Color::GREEN );
3606   actor2.SetColor( Color::RED );
3607
3608   application.SendNotification();
3609   application.Render(0);
3610   DALI_TEST_CHECK( actor1.GetCurrentColor() == Color::GREEN );
3611   DALI_TEST_CHECK( actor2.GetCurrentColor() == Color::RED );
3612
3613   Constraint constraint3 = Constraint::New<Vector4>( Actor::Property::COLOR,
3614                                                     Source( actor1, Actor::Property::COLOR ),
3615                                                     EqualToConstraint() );
3616   constraint3.SetRemoveAction( Constraint::Discard );
3617   actor2.ApplyConstraint( constraint3 );
3618   application.SendNotification();
3619   application.Render(0);
3620   DALI_TEST_CHECK( actor2.GetCurrentColor() == Color::GREEN );
3621
3622   //
3623   // Check Quaternion variant of constraint
3624   //
3625   Quaternion q1 = Quaternion( Math::PI_2, Vector3::XAXIS );
3626   Quaternion q2 = Quaternion( Math::PI_4, Vector3::YAXIS );
3627   actor1.SetRotation( q1 );
3628   actor2.SetRotation( q2 );
3629
3630   application.SendNotification();
3631   application.Render(0);
3632   DALI_TEST_EQUALS( actor1.GetCurrentRotation(), q1, 0.01, TEST_LOCATION );
3633   DALI_TEST_EQUALS( actor2.GetCurrentRotation(), q2, 0.01, TEST_LOCATION );
3634
3635   Constraint constraint4 = Constraint::New<Quaternion>( Actor::Property::ROTATION,
3636                                                     Source( actor1, Actor::Property::ROTATION ),
3637                                                     EqualToConstraint() );
3638   constraint4.SetRemoveAction( Constraint::Discard );
3639   actor2.ApplyConstraint( constraint4 );
3640   application.SendNotification();
3641   application.Render(0);
3642   DALI_TEST_EQUALS( actor2.GetCurrentRotation(), q1, 0.01, TEST_LOCATION );
3643
3644   //
3645   // Check Matrix3 variant
3646   //
3647   EqualToConstraint equalToConstraint;
3648
3649   Matrix3 a;
3650   a.AsFloat()[0] = 1.f;
3651   Matrix3 b;
3652   b.AsFloat()[0] = 2.f;
3653   PropertyInputAbstraction pi(b);
3654
3655   Matrix3 c = equalToConstraint(a,pi);
3656   DALI_TEST_EQUALS( c.AsFloat()[0], b.AsFloat()[0], 0.01, TEST_LOCATION);
3657   END_TEST;
3658 }
3659
3660 int UtcDaliBuiltinConstraintRelativeToConstraint(void)
3661 {
3662   TestApplication application;
3663
3664   Actor actor1 = Actor::New();
3665   Vector3 startPosition( 10, 10, 10 );
3666   actor1.SetPosition( startPosition );
3667   Stage::GetCurrent().Add( actor1 );
3668
3669   Actor actor2 = Actor::New();
3670   Vector3 startSize( 100, 100, 100 );
3671   actor2.SetSize( startSize );
3672   Stage::GetCurrent().Add( actor2 );
3673
3674   application.SendNotification();
3675   application.Render(0);
3676   DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition );
3677   DALI_TEST_CHECK( actor2.GetCurrentSize()     == startSize );
3678
3679   // Apply constraint - actor1 size == actor2 position
3680
3681   RelativeToConstraint( 0.f );
3682   Vector3 scale( 0.5, 0.6, 0.7 );
3683   Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
3684                                                     Source( actor1, Actor::Property::POSITION ),
3685                                                     RelativeToConstraint( scale ) );
3686   constraint.SetRemoveAction( Constraint::Discard );
3687   actor2.ApplyConstraint( constraint );
3688
3689   application.SendNotification();
3690   application.Render(0);
3691
3692   // Constraint should be fully applied
3693   DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * startPosition, TEST_LOCATION );
3694
3695   // Change the input
3696   Vector3 endPosition( 2, 2, 2 );
3697   actor1.SetPosition( endPosition );
3698
3699   application.SendNotification();
3700   application.Render(0);
3701
3702   // Constraint should be fully applied
3703   DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * endPosition, TEST_LOCATION );
3704   application.Render(0);
3705   DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * endPosition, TEST_LOCATION );
3706
3707   //
3708   // Check float variant of constraint
3709   //
3710   float scale2( 0.5f );
3711   float startOpacity(1.0f);
3712   actor1.SetOpacity( startOpacity );
3713   actor2.SetOpacity( startOpacity );
3714
3715   application.SendNotification();
3716   application.Render(0);
3717   DALI_TEST_EQUALS( actor1.GetCurrentOpacity(), startOpacity, TEST_LOCATION );
3718   DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity, TEST_LOCATION );
3719
3720   Constraint constraint2 = Constraint::New<float>( Actor::Property::COLOR_ALPHA,
3721                                                   Source( actor1, Actor::Property::COLOR_ALPHA ),
3722                                                   RelativeToConstraintFloat(scale2) );
3723   constraint2.SetRemoveAction( Constraint::Discard );
3724   actor2.ApplyConstraint(constraint2);
3725   application.SendNotification();
3726   application.Render(0);
3727
3728   DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity * scale2, TEST_LOCATION );
3729   END_TEST;
3730 }
3731
3732 int UtcDaliBuiltinConstraintFunctions(void)
3733 {
3734   TestApplication application;
3735
3736   {
3737     SourceWidthFixedHeight sourceWidthFixedHeight( 10.f );
3738     Vector3 current;
3739     {
3740       Vector3 reference(1, 10, 0);
3741       Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE) );
3742       DALI_TEST_EQUALS( reference, value, TEST_LOCATION );
3743     }
3744     {
3745       Vector3 reference(10, 10, 0);
3746       Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE*10.f) );
3747       DALI_TEST_EQUALS( reference, value, TEST_LOCATION );
3748     }
3749     {
3750       Vector3 reference(10,10,0);
3751       Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE*10.f) );
3752       DALI_TEST_EQUALS( reference, value, TEST_LOCATION );
3753     }
3754   }
3755
3756   { // LookAt
3757     Quaternion current(0, Vector3::YAXIS);
3758     PropertyInputAbstraction target(Vector3::ZAXIS);
3759     PropertyInputAbstraction targetRotation(Vector3::YAXIS);
3760     PropertyInputAbstraction camera(Vector3::ZERO);
3761
3762     {
3763       Quaternion reference(1., 0., 0., 0.);
3764       Quaternion value = LookAt( current, target, camera, targetRotation );
3765       DALI_TEST_EQUALS( reference, value, 0.001, TEST_LOCATION );
3766     }
3767
3768   }
3769
3770   END_TEST;
3771 }