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