Supports to acknowledge for completing window rotation
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Constraint.cpp
1 /*
2  * Copyright (c) 2020 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 <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 using namespace Dali;
25
26 ///////////////////////////////////////////////////////////////////////////////
27 void utc_dali_constraint_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void utc_dali_constraint_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36 ///////////////////////////////////////////////////////////////////////////////
37
38 ///////////////////////////////////////////////////////////////////////////////
39 namespace
40 {
41 /**
42  * A function to use for a constraint, no data collected.
43  */
44 template<typename T>
45 void BasicFunction(T& /* current */, const PropertyInputContainer& /* inputs */)
46 {
47 }
48
49 /**
50  * A functor which sets a given boolean when the functor is called.
51  */
52 template<typename T>
53 struct BasicCalledFunctor
54 {
55   BasicCalledFunctor(bool& functorCalled)
56   : mCalled(functorCalled)
57   {
58   }
59
60   void operator()(T& /* current */, const PropertyInputContainer& /* inputs */)
61   {
62     mCalled = true;
63   }
64
65   bool& mCalled;
66 };
67
68 /**
69  * A functor which increments a given integer when the functor is called.
70  */
71 template<typename T>
72 struct CalledCountFunctor
73 {
74   CalledCountFunctor(int& callCount)
75   : mCallCount(callCount)
76   {
77   }
78
79   void operator()(T& /* current */, const PropertyInputContainer& /* inputs */)
80   {
81     ++mCallCount;
82   }
83
84   int& mCallCount;
85 };
86
87 /**
88  * A functor which sets the given value as the value required when the functor is called.
89  */
90 template<typename T>
91 struct SetValueFunctor
92 {
93   SetValueFunctor(const T& value)
94   : mValue(value)
95   {
96   }
97
98   void operator()(T& current, const PropertyInputContainer& /* inputs */)
99   {
100     current = mValue;
101   }
102
103   T mValue;
104 };
105
106 } // unnamed namespace
107 ///////////////////////////////////////////////////////////////////////////////
108
109 ///////////////////////////////////////////////////////////////////////////////
110 // Constraint::New(
111 //   Handle,
112 //   Property::Index,
113 //   void( *function )( T&, const PropertyInputContainer& ) )
114 ///////////////////////////////////////////////////////////////////////////////
115 namespace UtcDaliConstraintNewFunction
116 {
117 bool gConstraintFunctionCalled = false;
118 void ConstraintFunction(Vector3& /* current */, const PropertyInputContainer& /* inputs */)
119 {
120   gConstraintFunctionCalled = true;
121 }
122 } // namespace UtcDaliConstraintNewFunction
123
124 int UtcDaliConstraintNewFunctionP(void)
125 {
126   // Ensure that we can create a constraint using a C function and that it is called.
127
128   TestApplication application;
129   UtcDaliConstraintNewFunction::gConstraintFunctionCalled = false;
130
131   Actor actor = Actor::New();
132   application.GetScene().Add(actor);
133
134   application.SendNotification();
135   application.Render();
136
137   DALI_TEST_EQUALS(UtcDaliConstraintNewFunction::gConstraintFunctionCalled, false, TEST_LOCATION);
138
139   // Add a constraint
140   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &UtcDaliConstraintNewFunction::ConstraintFunction);
141   DALI_TEST_CHECK(constraint);
142   constraint.Apply();
143
144   application.SendNotification();
145   application.Render();
146
147   DALI_TEST_EQUALS(UtcDaliConstraintNewFunction::gConstraintFunctionCalled, true, TEST_LOCATION);
148
149   END_TEST;
150 }
151
152 int UtcDaliConstraintNewFunctionN(void)
153 {
154   // Create a constraint with an uninitialised handle
155
156   TestApplication application;
157
158   // Add a constraint with an uninitialised handle
159   try
160   {
161     Constraint constraint = Constraint::New<Vector3>(Actor(), Actor::Property::POSITION, &UtcDaliConstraintNewFunction::ConstraintFunction);
162     DALI_TEST_CHECK(false); // Should not reach here
163   }
164   catch(...)
165   {
166     DALI_TEST_CHECK(true); // Should assert!
167   }
168
169   END_TEST;
170 }
171
172 // helper for next test
173 void StringConstraintFunction(std::string& /* current */, const PropertyInputContainer& /* inputs */)
174 {
175 }
176
177 int UtcDaliConstraintNewFunctionNonConstrainableTypeN(void)
178 {
179   // Ensure that we can create a constraint using a C function and that it is called.
180
181   TestApplication application;
182   UtcDaliConstraintNewFunction::gConstraintFunctionCalled = false;
183
184   Actor actor = Actor::New();
185   application.GetScene().Add(actor);
186
187   application.SendNotification();
188   application.Render();
189
190   try
191   {
192     // Add a constraint
193     Constraint constraint = Constraint::New<std::string>(actor, Actor::Property::COLOR_MODE, &StringConstraintFunction);
194     DALI_TEST_CHECK(constraint);
195     constraint.Apply();
196     tet_result(TET_FAIL);
197   }
198   catch(Dali::DaliException& e)
199   {
200     DALI_TEST_ASSERT(e, "Property not constrainable", TEST_LOCATION);
201   }
202
203   END_TEST;
204 }
205
206 ///////////////////////////////////////////////////////////////////////////////
207
208 ///////////////////////////////////////////////////////////////////////////////
209 // Constraint::New(
210 //   Handle,
211 //   Property::Index,
212 //   const T& object )
213 ///////////////////////////////////////////////////////////////////////////////
214 int UtcDaliConstraintNewFunctorP(void)
215 {
216   // Ensure that we can create a constraint using a functor and that it is called.
217
218   TestApplication application;
219   bool            functorCalled = false;
220
221   Actor actor = Actor::New();
222   application.GetScene().Add(actor);
223
224   application.SendNotification();
225   application.Render();
226
227   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
228
229   // Add a constraint
230   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
231   DALI_TEST_CHECK(constraint);
232   constraint.Apply();
233
234   application.SendNotification();
235   application.Render();
236
237   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
238
239   END_TEST;
240 }
241
242 int UtcDaliConstraintNewFunctorN(void)
243 {
244   // Create a constraint with an uninitialised handle
245
246   TestApplication application;
247   bool            functorCalled = false;
248
249   // Add a constraint with an uninitialised handle
250   try
251   {
252     Constraint constraint = Constraint::New<Vector3>(Actor(), Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
253     DALI_TEST_CHECK(false); // Should not reach here
254   }
255   catch(...)
256   {
257     DALI_TEST_CHECK(true); // Should assert!
258   }
259
260   END_TEST;
261 }
262 ///////////////////////////////////////////////////////////////////////////////
263
264 ///////////////////////////////////////////////////////////////////////////////
265 // Constraint::New(
266 //   Handle,
267 //   Property::Index,
268 //   const T& object,
269 //   void ( T::*memberFunction ) ( P&, const PropertyInputContainer& ) )
270 ///////////////////////////////////////////////////////////////////////////////
271 namespace UtcDaliConstraintNewFunctorMember
272 {
273 struct Functor
274 {
275   Functor(bool& positionCalled, bool& scaleCalled)
276   : mPositionCalled(positionCalled),
277     mScaleCalled(scaleCalled)
278   {
279   }
280
281   void Position(Vector3& /* current */, const PropertyInputContainer& /* inputs */)
282   {
283     mPositionCalled = true;
284   }
285
286   void Scale(Vector3& /* current */, const PropertyInputContainer& /* inputs */)
287   {
288     mScaleCalled = true;
289   }
290
291   bool& mPositionCalled;
292   bool& mScaleCalled;
293 };
294 } // namespace UtcDaliConstraintNewFunctorMember
295
296 int UtcDaliConstraintNewFunctorMemberP(void)
297 {
298   // Ensure that we can create a constraint using a functor and that it is called.
299
300   TestApplication application;
301   bool            positionFunctorCalled = false;
302   bool            sizeFunctorCalled     = false;
303
304   Actor actor = Actor::New();
305   application.GetScene().Add(actor);
306
307   application.SendNotification();
308   application.Render();
309
310   DALI_TEST_EQUALS(positionFunctorCalled, false, TEST_LOCATION);
311   DALI_TEST_EQUALS(sizeFunctorCalled, false, TEST_LOCATION);
312
313   // Add a constraint that calls Functor::Position
314   Constraint constraint = Constraint::New<Vector3>(
315     actor,
316     Actor::Property::POSITION,
317     UtcDaliConstraintNewFunctorMember::Functor(positionFunctorCalled, sizeFunctorCalled),
318     &UtcDaliConstraintNewFunctorMember::Functor::Position);
319   DALI_TEST_CHECK(constraint);
320   constraint.Apply();
321
322   application.SendNotification();
323   application.Render();
324
325   DALI_TEST_EQUALS(positionFunctorCalled, true, TEST_LOCATION);
326   DALI_TEST_EQUALS(sizeFunctorCalled, false, TEST_LOCATION);
327
328   // Add another constraint that calls Functor::Size
329   Constraint constraint2 = Constraint::New<Vector3>(
330     actor,
331     Actor::Property::SCALE,
332     UtcDaliConstraintNewFunctorMember::Functor(positionFunctorCalled, sizeFunctorCalled),
333     &UtcDaliConstraintNewFunctorMember::Functor::Scale);
334   DALI_TEST_CHECK(constraint2);
335   constraint2.Apply();
336
337   application.SendNotification();
338   application.Render();
339
340   DALI_TEST_EQUALS(positionFunctorCalled, true, TEST_LOCATION);
341   DALI_TEST_EQUALS(sizeFunctorCalled, true, TEST_LOCATION);
342
343   END_TEST;
344 }
345
346 int UtcDaliConstraintNewFunctorMemberN(void)
347 {
348   // Create a constraint with an uninitialised handle
349
350   TestApplication application;
351   bool            positionFunctorCalled = false;
352   bool            sizeFunctorCalled     = false;
353
354   // Add a constraint with an uninitialised handle
355   try
356   {
357     Constraint constraint = Constraint::New<Vector3>(
358       Actor(),
359       Actor::Property::POSITION,
360       UtcDaliConstraintNewFunctorMember::Functor(positionFunctorCalled, sizeFunctorCalled),
361       &UtcDaliConstraintNewFunctorMember::Functor::Position);
362     DALI_TEST_CHECK(false); // Should not reach here
363   }
364   catch(Dali::DaliException& e)
365   {
366     DALI_TEST_CHECK(true); // Should assert!
367   }
368
369   END_TEST;
370 }
371 ///////////////////////////////////////////////////////////////////////////////
372
373 ///////////////////////////////////////////////////////////////////////////////
374 // Constraint::Clone
375 ///////////////////////////////////////////////////////////////////////////////
376 int UtcDaliConstraintCloneP(void)
377 {
378   // Ensure we can clone for another actor and it's called appropriately
379
380   TestApplication application;
381   int             calledCount = 0;
382
383   Actor actor = Actor::New();
384   Actor clone = Actor::New();
385
386   Integration::Scene stage = application.GetScene();
387   stage.Add(actor);
388   stage.Add(clone);
389
390   application.SendNotification();
391   application.Render();
392
393   DALI_TEST_EQUALS(calledCount, 0, TEST_LOCATION);
394
395   // Add a constraint to actor
396   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, CalledCountFunctor<Vector3>(calledCount));
397   DALI_TEST_CHECK(constraint);
398   constraint.Apply();
399
400   // Create a clone but don't apply
401   Constraint constraintClone = constraint.Clone(clone);
402
403   application.SendNotification();
404   application.Render();
405
406   DALI_TEST_EQUALS(calledCount, 1, TEST_LOCATION);
407
408   // Reset
409   calledCount = 0;
410
411   application.SendNotification();
412   application.Render();
413
414   DALI_TEST_EQUALS(calledCount, 1, TEST_LOCATION);
415
416   // Apply the clone constraint
417   constraintClone.Apply();
418
419   application.SendNotification();
420   application.Render();
421
422   // Should be called once for the new constraint clone and once for the original constraint
423   DALI_TEST_EQUALS(calledCount, 3, TEST_LOCATION);
424
425   // Reset
426   calledCount = 0;
427
428   // Change the position of both actors
429   actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
430   clone.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
431
432   application.SendNotification();
433   application.Render();
434
435   // Functor should have been called twice
436   DALI_TEST_EQUALS(calledCount, 2, TEST_LOCATION);
437
438   END_TEST;
439 }
440
441 int UtcDaliConstraintCloneN(void)
442 {
443   // Attempt to clone an uninitialised constraint should cause an assert
444
445   TestApplication application;
446
447   Constraint constraint;
448
449   try
450   {
451     Actor      actor = Actor::New();
452     Constraint clone = constraint.Clone(actor);
453     DALI_TEST_CHECK(false);
454   }
455   catch(...)
456   {
457     DALI_TEST_CHECK(true);
458   }
459
460   END_TEST;
461 }
462
463 namespace UtcDaliConstraintClone
464 {
465 void Function(Vector3& /* current */, const PropertyInputContainer& inputs)
466 {
467   DALI_TEST_EQUALS(inputs[0]->GetType(), Property::VECTOR3, TEST_LOCATION);
468   DALI_TEST_EQUALS(inputs[1]->GetType(), Property::ROTATION, TEST_LOCATION);
469   DALI_TEST_EQUALS(inputs[2]->GetType(), Property::VECTOR4, TEST_LOCATION);
470   DALI_TEST_EQUALS(inputs[3]->GetType(), Property::BOOLEAN, TEST_LOCATION);
471 }
472 } // namespace UtcDaliConstraintClone
473
474 int UtcDaliConstraintCloneCheckSourcesAndSetters(void)
475 {
476   // Ensure all sources, the tag and remove-action are cloned appropriately
477
478   TestApplication application;
479
480   Actor actor = Actor::New();
481   Actor clone = Actor::New();
482
483   Integration::Scene stage = application.GetScene();
484   stage.Add(actor);
485   stage.Add(clone);
486
487   application.SendNotification();
488   application.Render();
489
490   // Create a constraint, DON'T Apply it though
491   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &UtcDaliConstraintClone::Function);
492   constraint.AddSource(LocalSource(Actor::Property::SIZE));
493   constraint.AddSource(LocalSource(Actor::Property::ORIENTATION));
494   constraint.AddSource(LocalSource(Actor::Property::COLOR));
495   constraint.AddSource(LocalSource(Actor::Property::VISIBLE));
496   constraint.SetRemoveAction(Constraint::DISCARD);
497   constraint.SetTag(123);
498
499   // Clone the constraint & apply the clone
500   Constraint constraintClone = constraint.Clone(clone);
501   constraintClone.Apply();
502
503   application.SendNotification();
504   application.Render();
505
506   DALI_TEST_EQUALS(constraint.GetRemoveAction(), constraintClone.GetRemoveAction(), TEST_LOCATION);
507   DALI_TEST_EQUALS(constraint.GetTag(), constraintClone.GetTag(), TEST_LOCATION);
508
509   END_TEST;
510 }
511 ///////////////////////////////////////////////////////////////////////////////
512
513 ///////////////////////////////////////////////////////////////////////////////
514 // Constraint::Constraint( const Constraint& )
515 // Constraint::operator=
516 ///////////////////////////////////////////////////////////////////////////////
517 int UtcDaliConstraintCopyAndAssignment(void)
518 {
519   // Ensure copy constructor & assignment operators work
520
521   TestApplication application;
522
523   Actor actor = Actor::New();
524   application.GetScene().Add(actor);
525
526   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
527   Constraint copied(constraint);
528   Constraint assigned;
529   DALI_TEST_CHECK(constraint == copied);
530   DALI_TEST_CHECK(copied != assigned);
531
532   assigned = constraint;
533   DALI_TEST_CHECK(constraint == assigned);
534
535   END_TEST;
536 }
537 ///////////////////////////////////////////////////////////////////////////////
538
539 int UtcDaliConstraintMoveConstructor(void)
540 {
541   // Ensure copy constructor & assignment operators work
542
543   TestApplication application;
544
545   Actor actor = Actor::New();
546   application.GetScene().Add(actor);
547
548   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
549   DALI_TEST_CHECK(constraint);
550   DALI_TEST_EQUALS(1, constraint.GetBaseObject().ReferenceCount(), TEST_LOCATION);
551   DALI_TEST_CHECK(constraint.GetTargetObject() == actor);
552
553   Constraint moved = std::move(constraint);
554   DALI_TEST_CHECK(moved);
555   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
556   DALI_TEST_CHECK(moved.GetTargetObject() == actor);
557   DALI_TEST_CHECK(!constraint);
558
559   END_TEST;
560 }
561
562 int UtcDaliConstraintMoveAssignment(void)
563 {
564   // Ensure copy constructor & assignment operators work
565
566   TestApplication application;
567
568   Actor actor = Actor::New();
569   application.GetScene().Add(actor);
570
571   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
572   DALI_TEST_CHECK(constraint);
573   DALI_TEST_EQUALS(1, constraint.GetBaseObject().ReferenceCount(), TEST_LOCATION);
574   DALI_TEST_CHECK(constraint.GetTargetObject() == actor);
575
576   Constraint moved;
577   moved = std::move(constraint);
578   DALI_TEST_CHECK(moved);
579   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
580   DALI_TEST_CHECK(moved.GetTargetObject() == actor);
581   DALI_TEST_CHECK(!constraint);
582
583   END_TEST;
584 }
585
586 ///////////////////////////////////////////////////////////////////////////////
587 // Constraint::DownCast
588 ///////////////////////////////////////////////////////////////////////////////
589 int UtcDaliConstraintDownCast(void)
590 {
591   // Ensure DownCast works as expected
592
593   TestApplication application;
594
595   Actor      actor      = Actor::New();
596   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
597
598   // Another BaseHandle type
599   Constraint downCast = Constraint::DownCast(actor);
600   DALI_TEST_CHECK(!downCast);
601
602   // A constraint
603   downCast = Constraint::DownCast(constraint);
604   DALI_TEST_CHECK(downCast);
605
606   // An empty constraint
607   downCast = Constraint::DownCast(Constraint());
608   DALI_TEST_CHECK(!downCast);
609
610   END_TEST;
611 }
612 ///////////////////////////////////////////////////////////////////////////////
613
614 ///////////////////////////////////////////////////////////////////////////////
615 // Constraint::GetTargetObject
616 ///////////////////////////////////////////////////////////////////////////////
617 int UtcDaliConstraintGetTargetObjectP(void)
618 {
619   TestApplication application;
620
621   Actor      actor      = Actor::New();
622   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
623   DALI_TEST_CHECK(constraint.GetTargetObject() == actor);
624
625   Actor actor2 = Actor::New();
626   DALI_TEST_CHECK(constraint.GetTargetObject() != actor2);
627
628   END_TEST;
629 }
630
631 int UtcDaliConstraintGetTargetObjectN(void)
632 {
633   // Attempt to retrieve from uninitialised constraint
634
635   TestApplication application;
636
637   Constraint constraint;
638   try
639   {
640     Handle handle = constraint.GetTargetObject();
641     DALI_TEST_CHECK(false); // Should not reach here!
642   }
643   catch(...)
644   {
645     DALI_TEST_CHECK(true);
646   }
647
648   END_TEST;
649 }
650 ///////////////////////////////////////////////////////////////////////////////
651
652 ///////////////////////////////////////////////////////////////////////////////
653 // Constraint::GetTargetProperty
654 ///////////////////////////////////////////////////////////////////////////////
655 int UtcDaliConstraintGetTargetPropertyP(void)
656 {
657   TestApplication application;
658
659   Actor      actor      = Actor::New();
660   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
661   DALI_TEST_EQUALS(constraint.GetTargetProperty(), (Property::Index)Actor::Property::POSITION, TEST_LOCATION);
662
663   END_TEST;
664 }
665
666 int UtcDaliConstraintGetTargetPropertyN(void)
667 {
668   // Attempt to retrieve from uninitialised constraint
669
670   TestApplication application;
671
672   Constraint constraint;
673   try
674   {
675     Property::Index propertyIndex = constraint.GetTargetProperty();
676     (void)propertyIndex;
677     DALI_TEST_CHECK(false); // Should not reach here!
678   }
679   catch(...)
680   {
681     DALI_TEST_CHECK(true);
682   }
683
684   END_TEST;
685 }
686 ///////////////////////////////////////////////////////////////////////////////
687
688 ///////////////////////////////////////////////////////////////////////////////
689 // Constraint::SetTag
690 // Constraint::GetTag
691 ///////////////////////////////////////////////////////////////////////////////
692 int UtcDaliConstraintTagP(void)
693 {
694   TestApplication application;
695
696   Actor      actor      = Actor::New();
697   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
698   DALI_TEST_EQUALS(constraint.GetTag(), 0u, TEST_LOCATION);
699
700   const unsigned int tag = 123;
701   constraint.SetTag(tag);
702   DALI_TEST_EQUALS(constraint.GetTag(), tag, TEST_LOCATION);
703
704   END_TEST;
705 }
706
707 int UtcDaliConstraintSetTagN(void)
708 {
709   // Attempt to set from uninitialised constraint
710
711   TestApplication application;
712
713   Constraint constraint;
714   try
715   {
716     constraint.SetTag(123);
717     DALI_TEST_CHECK(false); // Should not reach here!
718   }
719   catch(...)
720   {
721     DALI_TEST_CHECK(true);
722   }
723
724   END_TEST;
725 }
726
727 int UtcDaliConstraintGetTagN(void)
728 {
729   // Attempt to retrieve from uninitialised constraint
730
731   TestApplication application;
732
733   Constraint constraint;
734   try
735   {
736     int tag = constraint.GetTag();
737     (void)tag;
738     DALI_TEST_CHECK(false); // Should not reach here!
739   }
740   catch(...)
741   {
742     DALI_TEST_CHECK(true);
743   }
744
745   END_TEST;
746 }
747
748 ///////////////////////////////////////////////////////////////////////////////
749
750 ///////////////////////////////////////////////////////////////////////////////
751 // Constraint::SetRemoveAction
752 // Constraint::GetRemoveAction
753 ///////////////////////////////////////////////////////////////////////////////
754 int UtcDaliConstraintRemoveActionP(void)
755 {
756   TestApplication application;
757
758   Actor      actor      = Actor::New();
759   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &BasicFunction<Vector3>);
760   DALI_TEST_EQUALS(constraint.GetRemoveAction(), Constraint::DEFAULT_REMOVE_ACTION, TEST_LOCATION);
761
762   constraint.SetRemoveAction(Constraint::DISCARD);
763   DALI_TEST_EQUALS(constraint.GetRemoveAction(), Constraint::DISCARD, TEST_LOCATION);
764
765   constraint.SetRemoveAction(Constraint::BAKE);
766   DALI_TEST_EQUALS(constraint.GetRemoveAction(), Constraint::BAKE, TEST_LOCATION);
767
768   END_TEST;
769 }
770
771 int UtcDaliConstraintSetRemoveActionN(void)
772 {
773   // Attempt to set from uninitialised constraint
774
775   TestApplication application;
776
777   Constraint constraint;
778   try
779   {
780     constraint.SetRemoveAction(Constraint::DISCARD);
781     DALI_TEST_CHECK(false); // Should not reach here!
782   }
783   catch(...)
784   {
785     DALI_TEST_CHECK(true);
786   }
787
788   END_TEST;
789 }
790
791 int UtcDaliConstraintGetRemoveActionN(void)
792 {
793   // Attempt to retrieve from uninitialised constraint
794
795   TestApplication application;
796
797   Constraint constraint;
798   try
799   {
800     Constraint::RemoveAction removeAction = constraint.GetRemoveAction();
801     (void)removeAction;
802     DALI_TEST_CHECK(false); // Should not reach here!
803   }
804   catch(...)
805   {
806     DALI_TEST_CHECK(true);
807   }
808
809   END_TEST;
810 }
811
812 int UtcDaliConstraintBakeRemoveAction(void)
813 {
814   // Ensure value is baked when constraint is removed
815
816   TestApplication application;
817
818   Actor actor = Actor::New();
819   application.GetScene().Add(actor);
820
821   application.SendNotification();
822   application.Render();
823
824   // Should not equal position by default
825   Vector3 position(10.0f, 20.0f, 30.0f);
826   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) != position);
827
828   // Create a constraint that constrains to position
829   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, SetValueFunctor<Vector3>(position));
830   constraint.SetRemoveAction(Constraint::BAKE);
831   constraint.Apply();
832
833   application.SendNotification();
834   application.Render();
835
836   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), position, TEST_LOCATION);
837
838   // Remove the constraint, it should still be at position
839   constraint.Remove();
840
841   application.SendNotification();
842   application.Render();
843
844   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), position, TEST_LOCATION);
845
846   END_TEST;
847 }
848
849 int UtcDaliConstraintDiscardRemoveAction(void)
850 {
851   // Ensure value is baked when constraint is removed
852
853   TestApplication application;
854
855   Actor actor = Actor::New();
856   application.GetScene().Add(actor);
857
858   application.SendNotification();
859   application.Render();
860
861   // Get and store current position
862   Vector3 originalPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
863
864   // Should not equal position by default
865   Vector3 position(10.0f, 20.0f, 30.0f);
866   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) != position);
867
868   // Create a constraint that constrains to position
869   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, SetValueFunctor<Vector3>(position));
870   constraint.SetRemoveAction(Constraint::DISCARD);
871   constraint.Apply();
872
873   application.SendNotification();
874   application.Render();
875
876   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), position, TEST_LOCATION);
877
878   // Remove the constraint, it should still be at position
879   constraint.Remove();
880
881   application.SendNotification();
882   application.Render();
883
884   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), originalPosition, TEST_LOCATION);
885   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) != position);
886
887   END_TEST;
888 }
889
890 ///////////////////////////////////////////////////////////////////////////////
891
892 ///////////////////////////////////////////////////////////////////////////////
893 // Constraint::Apply
894 // Constraint::Remove
895 ///////////////////////////////////////////////////////////////////////////////
896 int UtcDaliConstraintApplyRemove(void)
897 {
898   // Ensure constraint functors are called appropriately
899
900   TestApplication application;
901   bool            functorCalled = false;
902
903   Actor actor = Actor::New();
904   application.GetScene().Add(actor);
905
906   application.SendNotification();
907   application.Render();
908
909   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
910
911   // Create a constraint and apply, functor should be called
912   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
913   constraint.Apply();
914
915   application.SendNotification();
916   application.Render();
917
918   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
919
920   // Reset
921   functorCalled = false;
922
923   // Remove the constraint, functor should not be called
924   constraint.Remove();
925
926   application.SendNotification();
927   application.Render();
928
929   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
930
931   // Re-apply the constraint, functor should be called again
932   constraint.Apply();
933
934   application.SendNotification();
935   application.Render();
936
937   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
938
939   END_TEST;
940 }
941
942 int UtcDaliConstraintApplyBeforeAddedToStage(void)
943 {
944   // Constraint gets applied to an off-stage actor.
945   // Constraint should be automatically applied when the actor is added to the stage and not before
946
947   TestApplication application;
948   bool            functorCalled = false;
949
950   // Create an actor and a constraint and apply, DON'T add to stage just yet
951   Actor      actor      = Actor::New();
952   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
953   constraint.Apply();
954
955   application.SendNotification();
956   application.Render();
957
958   // Should NOT be called
959   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
960
961   // Add actor to stage
962   application.GetScene().Add(actor);
963
964   application.SendNotification();
965   application.Render();
966
967   // Should now be called
968   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
969
970   END_TEST;
971 }
972
973 int UtcDaliConstraintApplyAndRemoveBeforeAddedToStage(void)
974 {
975   // Constraint gets applied to an off-stage actor, then gets removed before it's added to the stage
976   // Constraint should NOT be called at all
977
978   TestApplication application;
979   bool            functorCalled = false;
980
981   // Create an actor and a constraint and apply, DON'T add to stage just yet
982   Actor      actor      = Actor::New();
983   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
984   constraint.Apply();
985
986   application.SendNotification();
987   application.Render();
988
989   // Should NOT be called
990   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
991
992   // Remove the constraint
993   constraint.Remove();
994
995   // Add actor to stage
996   application.GetScene().Add(actor);
997
998   application.SendNotification();
999   application.Render();
1000
1001   // Still should NOT be called
1002   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
1003
1004   END_TEST;
1005 }
1006
1007 int UtcDaliConstraintApplyActorStagedUnstaged(void)
1008 {
1009   // Apply a constraint to an actor which is staged and unstaged.
1010   // Functor should only be called while the actor is staged.
1011
1012   TestApplication application;
1013   bool            functorCalled = false;
1014
1015   // Create an actor and add to stage
1016   Actor              actor = Actor::New();
1017   Integration::Scene stage = application.GetScene();
1018   stage.Add(actor);
1019
1020   // Create a constraint and apply
1021   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, BasicCalledFunctor<Vector3>(functorCalled));
1022   constraint.Apply();
1023
1024   application.SendNotification();
1025   application.Render();
1026
1027   // Constraint should be called
1028   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1029
1030   // Reset
1031   functorCalled = false;
1032
1033   // Remove actor from stage
1034   stage.Remove(actor);
1035
1036   application.SendNotification();
1037   application.Render();
1038
1039   // Constraint should NOT be called
1040   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
1041
1042   // Re-add to stage
1043   stage.Add(actor);
1044
1045   application.SendNotification();
1046   application.Render();
1047
1048   // Constraint should be called
1049   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1050
1051   END_TEST;
1052 }
1053
1054 int UtcDaliConstraintApplySeveralTimes(void)
1055 {
1056   // Apply the same constraint several times.
1057   // Should not cause any problems (subsequent attempts should be no-ops)
1058
1059   TestApplication application;
1060   int             count = 0;
1061
1062   // Create an actor and add to stage
1063   Actor              actor = Actor::New();
1064   Integration::Scene stage = application.GetScene();
1065   stage.Add(actor);
1066
1067   // Create a constraint and apply
1068   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, CalledCountFunctor<Vector3>(count));
1069   constraint.Apply();
1070
1071   // Apply again
1072   constraint.Apply(); // no-op
1073
1074   application.SendNotification();
1075   application.Render();
1076
1077   // Should only have been called once
1078   DALI_TEST_EQUALS(count, 1, TEST_LOCATION);
1079
1080   // Reset
1081   count = 0;
1082
1083   // Apply again
1084   constraint.Apply(); // no-op
1085
1086   application.SendNotification();
1087   application.Render();
1088
1089   DALI_TEST_EQUALS(count, 1, TEST_LOCATION);
1090
1091   // Reset
1092   count = 0;
1093
1094   // Change the position property, apply again
1095   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
1096   constraint.Apply();
1097
1098   application.SendNotification();
1099   application.Render();
1100
1101   // Constraint should have been called once
1102   DALI_TEST_EQUALS(count, 1, TEST_LOCATION);
1103
1104   END_TEST;
1105 }
1106
1107 ///////////////////////////////////////////////////////////////////////////////
1108
1109 ///////////////////////////////////////////////////////////////////////////////
1110 // Constraint::AddSource
1111 ///////////////////////////////////////////////////////////////////////////////
1112 namespace UtcDaliConstraintAddSource
1113 {
1114 void Function(Vector3& /* current */, const PropertyInputContainer& inputs)
1115 {
1116   DALI_TEST_EQUALS(inputs.Size(), 4u, TEST_LOCATION);
1117   DALI_TEST_EQUALS(inputs[0]->GetType(), Property::VECTOR3, TEST_LOCATION);
1118   DALI_TEST_EQUALS(inputs[1]->GetType(), Property::ROTATION, TEST_LOCATION);
1119   DALI_TEST_EQUALS(inputs[2]->GetType(), Property::VECTOR4, TEST_LOCATION);
1120   DALI_TEST_EQUALS(inputs[3]->GetType(), Property::BOOLEAN, TEST_LOCATION);
1121 }
1122 } // namespace UtcDaliConstraintAddSource
1123
1124 int UtcDaliConstraintAddSourceP(void)
1125 {
1126   // Ensure all sources are in the correct order in the functor
1127
1128   TestApplication application;
1129
1130   Actor actor = Actor::New();
1131   application.GetScene().Add(actor);
1132
1133   // Create a constraint, add sources
1134   Constraint constraint = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &UtcDaliConstraintAddSource::Function);
1135   constraint.AddSource(LocalSource(Actor::Property::SIZE));
1136   constraint.AddSource(LocalSource(Actor::Property::ORIENTATION));
1137   constraint.AddSource(LocalSource(Actor::Property::COLOR));
1138   constraint.AddSource(LocalSource(Actor::Property::VISIBLE));
1139   constraint.Apply();
1140
1141   application.SendNotification();
1142   application.Render();
1143
1144   END_TEST;
1145 }
1146
1147 int UtcDaliConstraintAddSourceN(void)
1148 {
1149   // Attempt to set from uninitialised constraint
1150
1151   TestApplication application;
1152
1153   Constraint constraint;
1154   try
1155   {
1156     constraint.AddSource(LocalSource(Actor::Property::POSITION));
1157     DALI_TEST_CHECK(false); // Should not reach here!
1158   }
1159   catch(...)
1160   {
1161     DALI_TEST_CHECK(true);
1162   }
1163
1164   END_TEST;
1165 }
1166 ///////////////////////////////////////////////////////////////////////////////
1167
1168 ///////////////////////////////////////////////////////////////////////////////
1169 namespace TestChaining
1170 {
1171 const Vector3 gFunction1Output(Vector3::ONE);
1172 void          Function1(Vector3& current, const PropertyInputContainer& /* inputs */)
1173 {
1174   // current is original position
1175   DALI_TEST_EQUALS(current, Vector3::ZERO, TEST_LOCATION);
1176   current = gFunction1Output;
1177 }
1178
1179 const Vector3 gFunction2Output(10.0f, 20.0f, 30.0f);
1180 void          Function2(Vector3& current, const PropertyInputContainer& /* inputs */)
1181 {
1182   // current is output from Function1
1183   DALI_TEST_EQUALS(current, gFunction1Output, TEST_LOCATION);
1184
1185   current = gFunction2Output;
1186 }
1187
1188 const Vector3 gFunction3Output(10.0f, 20.0f, 30.0f);
1189 void          Function3(Vector3& current, const PropertyInputContainer& /* inputs */)
1190 {
1191   // current is output from Function2
1192   DALI_TEST_EQUALS(current, gFunction2Output, TEST_LOCATION);
1193
1194   current = gFunction3Output;
1195 }
1196
1197 const Vector3 gFunction4Output(10.0f, 20.0f, 30.0f);
1198 void          Function4(Vector3& current, const PropertyInputContainer& /* inputs */)
1199 {
1200   // current is output from Function3
1201   DALI_TEST_EQUALS(current, gFunction3Output, TEST_LOCATION);
1202
1203   current = gFunction4Output;
1204 }
1205
1206 void Function5(Vector3& current, const PropertyInputContainer& /* inputs */)
1207 {
1208   // current is output from Function4
1209   DALI_TEST_EQUALS(current, gFunction4Output, TEST_LOCATION);
1210
1211   current = Vector3::ZERO;
1212 }
1213
1214 } // namespace TestChaining
1215
1216 int UtcDaliConstraintChaining(void)
1217 {
1218   // Apply several constraints to the same property and ensure the functors are called in the correct order.
1219
1220   TestApplication application;
1221
1222   Actor actor = Actor::New();
1223   application.GetScene().Add(actor);
1224
1225   Constraint constraint1 = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &TestChaining::Function1);
1226   Constraint constraint2 = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &TestChaining::Function2);
1227   Constraint constraint3 = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &TestChaining::Function3);
1228   Constraint constraint4 = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &TestChaining::Function4);
1229   Constraint constraint5 = Constraint::New<Vector3>(actor, Actor::Property::POSITION, &TestChaining::Function5);
1230
1231   constraint1.Apply();
1232   constraint2.Apply();
1233   constraint3.Apply();
1234   constraint4.Apply();
1235   constraint5.Apply();
1236
1237   application.SendNotification();
1238   application.Render();
1239
1240   END_TEST;
1241 }
1242 ///////////////////////////////////////////////////////////////////////////////
1243
1244 ///////////////////////////////////////////////////////////////////////////////
1245 namespace TestPropertyTypes
1246 {
1247 template<typename T>
1248 void Execute(T value)
1249 {
1250   TestApplication application;
1251   bool            functorCalled = false;
1252
1253   Actor           actor = Actor::New();
1254   Property::Index index = actor.RegisterProperty("TEMP_PROPERTY_NAME", value);
1255
1256   application.GetScene().Add(actor);
1257
1258   application.SendNotification();
1259   application.Render();
1260
1261   DALI_TEST_EQUALS(functorCalled, false, TEST_LOCATION);
1262
1263   // Add a constraint
1264   Constraint constraint = Constraint::New<T>(actor, index, BasicCalledFunctor<T>(functorCalled));
1265   DALI_TEST_CHECK(constraint);
1266   constraint.Apply();
1267
1268   application.SendNotification();
1269   application.Render();
1270
1271   DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1272 }
1273 } // namespace TestPropertyTypes
1274
1275 int UtcDaliConstraintTestPropertyTypesP(void)
1276 {
1277   // Ensure we can use a constraint functor with all supported property types
1278
1279   TestPropertyTypes::Execute<bool>(false);
1280   TestPropertyTypes::Execute<int>(0);
1281   TestPropertyTypes::Execute<float>(0.0f);
1282   TestPropertyTypes::Execute<Vector2>(Vector2::ZERO);
1283   TestPropertyTypes::Execute<Vector3>(Vector3::ZERO);
1284   TestPropertyTypes::Execute<Vector4>(Vector4::ZERO);
1285   TestPropertyTypes::Execute<Quaternion>(Quaternion::IDENTITY);
1286   TestPropertyTypes::Execute<Matrix>(Matrix::IDENTITY);
1287   TestPropertyTypes::Execute<Matrix3>(Matrix3::IDENTITY);
1288
1289   END_TEST;
1290 }
1291
1292 ///////////////////////////////////////////////////////////////////////////////
1293
1294 ///////////////////////////////////////////////////////////////////////////////
1295 namespace
1296 {
1297 void SetHalfOpacity(Vector4& current, const PropertyInputContainer& inputs)
1298 {
1299   current.a = 0.5f;
1300 }
1301 } // unnamed namespace
1302
1303 int UtcDaliConstraintEnsureResetterAppliedOnSceneRemoval(void)
1304 {
1305   // Ensure BOTH double-buffered values of our color property is reset when a constraint is applied to it.
1306
1307   TestApplication application;
1308
1309   Actor actor = Actor::New();
1310   application.GetScene().Add(actor);
1311
1312   // Check initial value is fully opaque
1313   application.SendNotification();
1314   application.Render();
1315   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1316
1317   // Create a constraint whose value is discarded when it is removed
1318   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, SetHalfOpacity);
1319   constraint.SetRemoveAction(Constraint::RemoveAction::DISCARD);
1320   constraint.Apply();
1321
1322   // Check value after one render, it should be constrained
1323   application.SendNotification();
1324   application.Render();
1325   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1326
1327   // Render another frame, ensure the other value has also been updated
1328   application.SendNotification();
1329   application.Render();
1330   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1331
1332   // Remove the actor from the stage and delete the constraint
1333   actor.Unparent();
1334   constraint.Remove();
1335   constraint.Reset();
1336
1337   // Check value while off-stage, it should be fully opaque
1338   application.SendNotification();
1339   application.Render();
1340   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1341
1342   // Add the actor back to the stage and check the value, it should be fully opaque again
1343   application.GetScene().Add(actor);
1344
1345   // Check value when back on-stage, it should be fully opaque as the constraint is no longer applied to it.
1346   application.SendNotification();
1347   application.Render();
1348   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1349
1350   // Render for another frame to ensure both buffers have the correct value
1351   application.SendNotification();
1352   application.Render();
1353   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1354
1355   END_TEST;
1356 }
1357
1358 int UtcDaliConstraintOnActorAddedAndRemoved(void)
1359 {
1360   // Ensure adding and removing an actor from stage with a constraint still has it applied when it is re-added back to the stage
1361
1362   TestApplication application;
1363
1364   Actor actor = Actor::New();
1365   application.GetScene().Add(actor);
1366
1367   // Check initial value is fully opaque
1368   application.SendNotification();
1369   application.Render();
1370   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1371
1372   // Create a constraint whose value is discarded when it is removed
1373   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, SetHalfOpacity);
1374   constraint.SetRemoveAction(Constraint::RemoveAction::DISCARD);
1375   constraint.Apply();
1376
1377   // Check value after one render, it should be constrained
1378   application.SendNotification();
1379   application.Render();
1380   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1381
1382   // Render another frame, ensure the other value has also been updated
1383   application.SendNotification();
1384   application.Render();
1385   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1386
1387   // Remove the actor from the stage
1388   actor.Unparent();
1389
1390   // Check value while off-stage, the constraint is no longer being applied as it's off-stage
1391   application.SendNotification();
1392   application.Render();
1393   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1394
1395   // Check the other buffer, the constraint should not be applied to this either.
1396   application.SendNotification();
1397   application.Render();
1398   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 1.0f, TEST_LOCATION);
1399
1400   // Add the actor back to the stage and check the value, the constraint should have been re-applied
1401   application.GetScene().Add(actor);
1402   application.SendNotification();
1403   application.Render();
1404   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1405
1406   // Render for another frame to ensure both buffers have the correct value
1407   application.SendNotification();
1408   application.Render();
1409   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, 0.5f, TEST_LOCATION);
1410
1411   END_TEST;
1412 }
1413
1414 ///////////////////////////////////////////////////////////////////////////////
1415
1416 int UtcDaliConstraintGetTargetObjectNegative(void)
1417 {
1418   TestApplication  application;
1419   Dali::Constraint instance;
1420   try
1421   {
1422     instance.GetTargetObject();
1423     DALI_TEST_CHECK(false); // Should not get here
1424   }
1425   catch(...)
1426   {
1427     DALI_TEST_CHECK(true); // We expect an assert
1428   }
1429   END_TEST;
1430 }
1431
1432 int UtcDaliConstraintSetRemoveActionNegative(void)
1433 {
1434   TestApplication  application;
1435   Dali::Constraint instance;
1436   try
1437   {
1438     Dali::Constraint::RemoveAction arg1(Constraint::BAKE);
1439     instance.SetRemoveAction(arg1);
1440     DALI_TEST_CHECK(false); // Should not get here
1441   }
1442   catch(...)
1443   {
1444     DALI_TEST_CHECK(true); // We expect an assert
1445   }
1446   END_TEST;
1447 }
1448
1449 int UtcDaliConstraintGetTargetPropertyNegative(void)
1450 {
1451   TestApplication  application;
1452   Dali::Constraint instance;
1453   try
1454   {
1455     instance.GetTargetProperty();
1456     DALI_TEST_CHECK(false); // Should not get here
1457   }
1458   catch(...)
1459   {
1460     DALI_TEST_CHECK(true); // We expect an assert
1461   }
1462   END_TEST;
1463 }
1464
1465 int UtcDaliConstraintApplyNegative(void)
1466 {
1467   TestApplication  application;
1468   Dali::Constraint instance;
1469   try
1470   {
1471     instance.Apply();
1472     DALI_TEST_CHECK(false); // Should not get here
1473   }
1474   catch(...)
1475   {
1476     DALI_TEST_CHECK(true); // We expect an assert
1477   }
1478   END_TEST;
1479 }
1480
1481 int UtcDaliConstraintCloneNegative(void)
1482 {
1483   TestApplication  application;
1484   Dali::Constraint instance;
1485   try
1486   {
1487     Dali::Handle arg1;
1488     instance.Clone(arg1);
1489     DALI_TEST_CHECK(false); // Should not get here
1490   }
1491   catch(...)
1492   {
1493     DALI_TEST_CHECK(true); // We expect an assert
1494   }
1495   END_TEST;
1496 }
1497
1498 int UtcDaliConstraintRemoveNegative(void)
1499 {
1500   TestApplication  application;
1501   Dali::Constraint instance;
1502   try
1503   {
1504     instance.Remove();
1505     DALI_TEST_CHECK(false); // Should not get here
1506   }
1507   catch(...)
1508   {
1509     DALI_TEST_CHECK(true); // We expect an assert
1510   }
1511   END_TEST;
1512 }
1513
1514 int UtcDaliConstraintSetTagNegative(void)
1515 {
1516   TestApplication  application;
1517   Dali::Constraint instance;
1518   try
1519   {
1520     unsigned int arg1(0u);
1521     instance.SetTag(arg1);
1522     DALI_TEST_CHECK(false); // Should not get here
1523   }
1524   catch(...)
1525   {
1526     DALI_TEST_CHECK(true); // We expect an assert
1527   }
1528   END_TEST;
1529 }
1530
1531 int UtcDaliConstraintGetRemoveActionNegative(void)
1532 {
1533   TestApplication  application;
1534   Dali::Constraint instance;
1535   try
1536   {
1537     instance.GetRemoveAction();
1538     DALI_TEST_CHECK(false); // Should not get here
1539   }
1540   catch(...)
1541   {
1542     DALI_TEST_CHECK(true); // We expect an assert
1543   }
1544   END_TEST;
1545 }
1546
1547 int UtcDaliConstraintGetTagNegative(void)
1548 {
1549   TestApplication  application;
1550   Dali::Constraint instance;
1551   try
1552   {
1553     instance.GetTag();
1554     DALI_TEST_CHECK(false); // Should not get here
1555   }
1556   catch(...)
1557   {
1558     DALI_TEST_CHECK(true); // We expect an assert
1559   }
1560   END_TEST;
1561 }