Merge "Added sibling order property to the actor's property table" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2015 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 "assert.h"
19 #include <dali/public-api/dali-core.h>
20 #include <string>
21 #include <cfloat>   // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
27
28 //& set: DaliActor
29
30 using std::string;
31 using namespace Dali;
32
33
34 void utc_dali_actor_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_actor_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46 bool gTouchCallBackCalled=false;
47 bool gHoverCallBackCalled=false;
48
49 static bool gTestConstraintCalled;
50
51 struct TestConstraint
52 {
53   void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
54   {
55     gTestConstraintCalled = true;
56   }
57 };
58
59 /**
60  * TestConstraint reference.
61  * When constraint is called, the resultRef is updated
62  * with the value supplied.
63  */
64 template<typename T>
65 struct TestConstraintRef
66 {
67   TestConstraintRef(unsigned int& resultRef, unsigned int value)
68   : mResultRef(resultRef),
69     mValue(value)
70   {
71   }
72
73   void operator()( T& current, const PropertyInputContainer& /* inputs */ )
74   {
75     mResultRef = mValue;
76   }
77
78   unsigned int& mResultRef;
79   unsigned int mValue;
80 };
81
82 static bool TestCallback(Actor actor, const TouchEvent& event)
83 {
84   gTouchCallBackCalled = true;
85   return false;
86   END_TEST;
87 }
88
89 static bool TestCallback3(Actor actor, const HoverEvent& event)
90 {
91   gHoverCallBackCalled = true;
92   return false;
93   END_TEST;
94 }
95
96 // validation stuff for onstage & offstage signals
97 static std::vector< std::string > gActorNamesOnOffStage;
98 static int gOnStageCallBackCalled;
99 void OnStageCallback( Actor actor )
100 {
101   ++gOnStageCallBackCalled;
102   gActorNamesOnOffStage.push_back( actor.GetName() );
103   DALI_TEST_CHECK( actor.OnStage() == true );
104 }
105 static int gOffStageCallBackCalled;
106 void OffStageCallback( Actor actor )
107 {
108   ++gOffStageCallBackCalled;
109   gActorNamesOnOffStage.push_back( actor.GetName() );
110   DALI_TEST_CHECK( actor.OnStage() == false );
111 }
112
113 struct PositionComponentConstraint
114 {
115   PositionComponentConstraint(){}
116
117   void operator()( Vector3& pos, const PropertyInputContainer& inputs )
118   {
119     const Matrix& m = inputs[0]->GetMatrix();
120     Vector3 scale;
121     Quaternion rot;
122     m.GetTransformComponents(pos, rot, scale);
123   }
124 };
125
126 struct OrientationComponentConstraint
127 {
128   OrientationComponentConstraint(){}
129
130   void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
131   {
132     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
133     Vector3 pos, scale;
134     Quaternion rot;
135     orientation = parentOrientation;
136   }
137 };
138 // OnRelayout
139
140 static bool gOnRelayoutCallBackCalled = false;
141 static std::vector< std::string > gActorNamesRelayout;
142
143 void OnRelayoutCallback( Actor actor )
144 {
145   gOnRelayoutCallBackCalled = true;
146   gActorNamesRelayout.push_back( actor.GetName() );
147 }
148
149 } // anonymous namespace
150
151
152 //& purpose: Testing New API
153 int UtcDaliActorNew(void)
154 {
155   TestApplication application;
156
157   Actor actor = Actor::New();
158
159   DALI_TEST_CHECK(actor);
160   END_TEST;
161 }
162
163 //& purpose: Testing Dali::Actor::DownCast()
164 int UtcDaliActorDownCastP(void)
165 {
166   TestApplication application;
167   tet_infoline("Testing Dali::Actor::DownCast()");
168
169   Actor actor = Actor::New();
170   BaseHandle object(actor);
171   Actor actor2 = Actor::DownCast(object);
172   DALI_TEST_CHECK(actor2);
173   END_TEST;
174 }
175
176 //& purpose: Testing Dali::Actor::DownCast()
177 int UtcDaliActorDownCastN(void)
178 {
179   TestApplication application;
180   tet_infoline("Testing Dali::Actor::DownCast()");
181
182   BaseHandle unInitializedObject;
183   Actor actor = Actor::DownCast(unInitializedObject);
184   DALI_TEST_CHECK(!actor);
185   END_TEST;
186 }
187
188 //& purpose: Testing Dali::Actor::GetName()
189 int UtcDaliActorGetName(void)
190 {
191   TestApplication application;
192
193   Actor actor = Actor::New();
194
195   DALI_TEST_CHECK(actor.GetName().empty());
196   END_TEST;
197 }
198
199 //& purpose: Testing Dali::Actor::SetName()
200 int UtcDaliActorSetName(void)
201 {
202   TestApplication application;
203
204   string str("ActorName");
205   Actor actor = Actor::New();
206
207   actor.SetName(str);
208   DALI_TEST_CHECK(actor.GetName() == str);
209   END_TEST;
210 }
211
212 int UtcDaliActorGetId(void)
213 {
214   tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
215   TestApplication application;
216
217   Actor first = Actor::New();
218   Actor second = Actor::New();
219   Actor third = Actor::New();
220
221   DALI_TEST_CHECK(first.GetId() != second.GetId());
222   DALI_TEST_CHECK(second.GetId() != third.GetId());
223   END_TEST;
224 }
225
226 int UtcDaliActorIsRoot(void)
227 {
228   TestApplication application;
229
230   Actor actor = Actor::New();
231   DALI_TEST_CHECK(!actor.IsRoot());
232
233   // get the root layer
234   actor = Stage::GetCurrent().GetLayer( 0 );
235   DALI_TEST_CHECK( actor.IsRoot() );
236   END_TEST;
237 }
238
239 int UtcDaliActorOnStage(void)
240 {
241   TestApplication application;
242
243   Actor actor = Actor::New();
244   DALI_TEST_CHECK( !actor.OnStage() );
245
246   // get the root layer
247   actor = Stage::GetCurrent().GetLayer( 0 );
248   DALI_TEST_CHECK( actor.OnStage() );
249   END_TEST;
250 }
251
252 int UtcDaliActorIsLayer(void)
253 {
254   TestApplication application;
255
256   Actor actor = Actor::New();
257   DALI_TEST_CHECK( !actor.IsLayer() );
258
259   // get the root layer
260   actor = Stage::GetCurrent().GetLayer( 0 );
261   DALI_TEST_CHECK( actor.IsLayer() );
262   END_TEST;
263 }
264
265 int UtcDaliActorGetLayer(void)
266 {
267   TestApplication application;
268
269   Actor actor = Actor::New();
270   Stage::GetCurrent().Add(actor);
271   Layer layer = actor.GetLayer();
272
273   DALI_TEST_CHECK(layer);
274
275   // get the root layers layer
276   actor = Stage::GetCurrent().GetLayer( 0 );
277   DALI_TEST_CHECK( actor.GetLayer() );
278   END_TEST;
279 }
280
281 int UtcDaliActorAddP(void)
282 {
283   tet_infoline("Testing Actor::Add");
284   TestApplication application;
285
286   Actor parent = Actor::New();
287   Actor child = Actor::New();
288
289   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
290
291   parent.Add(child);
292
293   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
294
295   Actor parent2 = Actor::New();
296   parent2.Add( child );
297
298   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
299   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
300
301   // try Adding to same parent again, works
302   parent2.Add( child );
303   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
304
305   // try reparenting an orphaned child
306   {
307     Actor temporaryParent = Actor::New();
308     temporaryParent.Add( child );
309     DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
310   }
311   // temporaryParent has now died, reparent the orphaned child
312   parent2.Add( child );
313   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
314
315   END_TEST;
316 }
317
318 int UtcDaliActorAddN(void)
319 {
320   tet_infoline("Testing Actor::Add");
321   TestApplication application;
322
323   Actor child = Actor::New();
324
325   Actor parent2 = Actor::New();
326   parent2.Add( child );
327
328   // try illegal Add
329   try
330   {
331     parent2.Add( parent2 );
332     tet_printf("Assertion test failed - no Exception\n" );
333     tet_result(TET_FAIL);
334   }
335   catch(Dali::DaliException& e)
336   {
337     DALI_TEST_PRINT_ASSERT( e );
338     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
339     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
340   }
341   catch(...)
342   {
343     tet_printf("Assertion test failed - wrong Exception\n" );
344     tet_result(TET_FAIL);
345   }
346
347   // try reparenting root
348   try
349   {
350     parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
351     tet_printf("Assertion test failed - no Exception\n" );
352     tet_result(TET_FAIL);
353   }
354   catch(Dali::DaliException& e)
355   {
356     DALI_TEST_PRINT_ASSERT( e );
357     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
358     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
359   }
360   catch(...)
361   {
362     tet_printf("Assertion test failed - wrong Exception\n" );
363     tet_result(TET_FAIL);
364   }
365
366   // try Add empty
367   try
368   {
369     Actor empty;
370     parent2.Add( empty );
371     tet_printf("Assertion test failed - no Exception\n" );
372     tet_result(TET_FAIL);
373   }
374   catch(Dali::DaliException& e)
375   {
376     DALI_TEST_PRINT_ASSERT( e );
377     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
378     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
379   }
380   catch(...)
381   {
382     tet_printf("Assertion test failed - wrong Exception\n" );
383     tet_result(TET_FAIL);
384   }
385
386   END_TEST;
387 }
388
389 int UtcDaliActorRemoveN(void)
390 {
391   tet_infoline("Testing Actor::Remove");
392   TestApplication application;
393
394   Actor parent = Actor::New();
395   Actor child = Actor::New();
396   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
397
398   parent.Add(child);
399   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
400
401   parent.Remove(child);
402   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
403
404   // remove again, no problem
405   parent.Remove(child);
406   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
407
408   // add child back
409   parent.Add(child);
410   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
411   // try Remove self, its a no-op
412   parent.Remove( parent );
413   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
414
415   // try Remove empty
416   try
417   {
418     Actor empty;
419     parent.Remove( empty );
420     tet_printf("Assertion test failed - no Exception\n" );
421     tet_result(TET_FAIL);
422   }
423   catch(Dali::DaliException& e)
424   {
425     DALI_TEST_PRINT_ASSERT( e );
426     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
427     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
428   }
429   catch(...)
430   {
431     tet_printf("Assertion test failed - wrong Exception\n" );
432     tet_result(TET_FAIL);
433   }
434   END_TEST;
435 }
436
437 int UtcDaliActorRemoveP(void)
438 {
439   TestApplication application;
440
441   Actor parent = Actor::New();
442   Actor child = Actor::New();
443   Actor random = Actor::New();
444
445   Stage::GetCurrent().Add( parent );
446
447   DALI_TEST_CHECK(parent.GetChildCount() == 0);
448
449   parent.Add(child);
450
451   DALI_TEST_CHECK(parent.GetChildCount() == 1);
452
453   parent.Remove(random);
454
455   DALI_TEST_CHECK(parent.GetChildCount() == 1);
456
457   Stage::GetCurrent().Remove( parent );
458
459   DALI_TEST_CHECK(parent.GetChildCount() == 1);
460   END_TEST;
461 }
462
463 int UtcDaliActorGetChildCount(void)
464 {
465   TestApplication application;
466
467   Actor parent = Actor::New();
468   Actor child = Actor::New();
469
470   DALI_TEST_CHECK(parent.GetChildCount() == 0);
471
472   parent.Add(child);
473
474   DALI_TEST_CHECK(parent.GetChildCount() == 1);
475   END_TEST;
476 }
477
478 int UtcDaliActorGetChildren01(void)
479 {
480   TestApplication application;
481
482   Actor parent = Actor::New();
483   Actor first  = Actor::New();
484   Actor second = Actor::New();
485   Actor third  = Actor::New();
486
487   parent.Add(first);
488   parent.Add(second);
489   parent.Add(third);
490
491   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
492   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
493   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
494   END_TEST;
495 }
496
497 int UtcDaliActorGetChildren02(void)
498 {
499   TestApplication application;
500
501   Actor parent = Actor::New();
502   Actor first  = Actor::New();
503   Actor second = Actor::New();
504   Actor third  = Actor::New();
505
506   parent.Add(first);
507   parent.Add(second);
508   parent.Add(third);
509
510   const Actor& constParent = parent;
511
512   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
513   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
514   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
515   END_TEST;
516 }
517
518 int UtcDaliActorGetParent01(void)
519 {
520   TestApplication application;
521
522   Actor parent = Actor::New();
523   Actor child = Actor::New();
524
525   parent.Add(child);
526
527   DALI_TEST_CHECK(child.GetParent() == parent);
528   END_TEST;
529 }
530
531 int UtcDaliActorGetParent02(void)
532 {
533   TestApplication application;
534
535   Actor actor = Actor::New();
536
537   DALI_TEST_CHECK(!actor.GetParent());
538   END_TEST;
539 }
540
541 int UtcDaliActorSetParentOrigin(void)
542 {
543   TestApplication application;
544
545   Actor actor = Actor::New();
546
547   Vector3 vector(0.7f, 0.8f, 0.9f);
548   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
549
550   actor.SetParentOrigin(vector);
551
552   // flush the queue and render once
553   application.SendNotification();
554   application.Render();
555
556   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
557
558   Stage::GetCurrent().Add( actor );
559
560   actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
561
562   // flush the queue and render once
563   application.SendNotification();
564   application.Render();
565
566   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
567
568   Stage::GetCurrent().Remove( actor );
569   END_TEST;
570 }
571
572 int UtcDaliActorSetParentOriginIndividual(void)
573 {
574   TestApplication application;
575
576   Actor actor = Actor::New();
577
578   Vector3 vector(0.7f, 0.8f, 0.9f);
579   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
580
581   actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
582
583   // flush the queue and render once
584   application.SendNotification();
585   application.Render();
586
587   DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
588
589   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
590
591   // flush the queue and render once
592   application.SendNotification();
593   application.Render();
594
595   DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
596
597   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
598
599   // flush the queue and render once
600   application.SendNotification();
601   application.Render();
602
603   DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
604
605   END_TEST;
606 }
607
608 int UtcDaliActorGetCurrentParentOrigin(void)
609 {
610   TestApplication application;
611
612   Actor actor = Actor::New();
613
614   Vector3 vector(0.7f, 0.8f, 0.9f);
615   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
616
617   actor.SetParentOrigin(vector);
618
619   // flush the queue and render once
620   application.SendNotification();
621   application.Render();
622
623   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
624   END_TEST;
625 }
626
627 int UtcDaliActorSetAnchorPoint(void)
628 {
629   TestApplication application;
630
631   Actor actor = Actor::New();
632
633   Vector3 vector(0.7f, 0.8f, 0.9f);
634   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
635
636   actor.SetAnchorPoint(vector);
637
638   // flush the queue and render once
639   application.SendNotification();
640   application.Render();
641
642   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
643
644   Stage::GetCurrent().Add( actor );
645
646   actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
647   // flush the queue and render once
648   application.SendNotification();
649   application.Render();
650
651   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
652
653   Stage::GetCurrent().Remove( actor );
654   END_TEST;
655 }
656
657 int UtcDaliActorSetAnchorPointIndividual(void)
658 {
659   TestApplication application;
660
661   Actor actor = Actor::New();
662
663   Vector3 vector(0.7f, 0.8f, 0.9f);
664   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
665
666   actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
667
668   // flush the queue and render once
669   application.SendNotification();
670   application.Render();
671
672   DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
673
674   actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
675
676   // flush the queue and render once
677   application.SendNotification();
678   application.Render();
679
680   DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
681
682   actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
683
684   // flush the queue and render once
685   application.SendNotification();
686   application.Render();
687
688   DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
689
690   END_TEST;
691 }
692
693 int UtcDaliActorGetCurrentAnchorPoint(void)
694 {
695   TestApplication application;
696
697   Actor actor = Actor::New();
698
699   Vector3 vector(0.7f, 0.8f, 0.9f);
700   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
701
702   actor.SetAnchorPoint(vector);
703
704   // flush the queue and render once
705   application.SendNotification();
706   application.Render();
707
708   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
709   END_TEST;
710 }
711
712 // SetSize(float width, float height)
713 int UtcDaliActorSetSize01(void)
714 {
715   TestApplication application;
716
717   Actor actor = Actor::New();
718   Vector3 vector(100.0f, 100.0f, 0.0f);
719
720   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
721
722   actor.SetSize(vector.x, vector.y);
723
724   // flush the queue and render once
725   application.SendNotification();
726   application.Render();
727
728   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
729   END_TEST;
730 }
731
732 // SetSize(float width, float height, float depth)
733 int UtcDaliActorSetSize02(void)
734 {
735   TestApplication application;
736
737   Actor actor = Actor::New();
738   Vector3 vector(100.0f, 100.0f, 100.0f);
739
740   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
741
742   actor.SetSize(vector.x, vector.y, vector.z);
743
744   // flush the queue and render once
745   application.SendNotification();
746   application.Render();
747
748   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
749   END_TEST;
750 }
751
752 // SetSize(Vector2 size)
753 int UtcDaliActorSetSize03(void)
754 {
755   TestApplication application;
756
757   Actor actor = Actor::New();
758   Vector3 vector(100.0f, 100.0f, 0.0f);
759
760   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
761
762   actor.SetSize(Vector2(vector.x, vector.y));
763
764   // flush the queue and render once
765   application.SendNotification();
766   application.Render();
767
768   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
769   END_TEST;
770 }
771
772 // SetSize(Vector3 size)
773 int UtcDaliActorSetSize04(void)
774 {
775   TestApplication application;
776
777   Actor actor = Actor::New();
778   Vector3 vector(100.0f, 100.0f, 100.0f);
779
780   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
781
782   actor.SetSize(vector);
783
784   // flush the queue and render once
785   application.SendNotification();
786   application.Render();
787
788   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
789
790   Stage::GetCurrent().Add( actor );
791   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
792
793   // flush the queue and render once
794   application.SendNotification();
795   application.Render();
796
797   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
798   Stage::GetCurrent().Remove( actor );
799   END_TEST;
800 }
801
802 int UtcDaliActorSetSizeIndividual(void)
803 {
804   TestApplication application;
805
806   Actor actor = Actor::New();
807
808   Vector3 vector(0.7f, 0.8f, 0.9f);
809   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
810
811   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
812
813   // flush the queue and render once
814   application.SendNotification();
815   application.Render();
816
817   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
818
819   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
820
821   // flush the queue and render once
822   application.SendNotification();
823   application.Render();
824
825   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
826
827   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
828
829   // flush the queue and render once
830   application.SendNotification();
831   application.Render();
832
833   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
834
835   END_TEST;
836 }
837
838
839 int UtcDaliActorGetCurrentSize(void)
840 {
841   TestApplication application;
842
843   Actor actor = Actor::New();
844   Vector3 vector(100.0f, 100.0f, 20.0f);
845
846   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
847
848   actor.SetSize(vector);
849
850   // flush the queue and render once
851   application.SendNotification();
852   application.Render();
853
854   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
855   END_TEST;
856 }
857
858 int UtcDaliActorGetNaturalSize(void)
859 {
860   TestApplication application;
861
862   Actor actor = Actor::New();
863   Vector3 vector( 0.0f, 0.0f, 0.0f );
864
865   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
866
867   END_TEST;
868 }
869
870 int UtcDaliActorGetCurrentSizeImmediate(void)
871 {
872   TestApplication application;
873
874   Actor actor = Actor::New();
875   Vector3 vector(100.0f, 100.0f, 20.0f);
876
877   DALI_TEST_CHECK(vector != actor.GetTargetSize());
878   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
879
880   actor.SetSize(vector);
881
882   DALI_TEST_CHECK(vector == actor.GetTargetSize());
883   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
884
885   // flush the queue and render once
886   application.SendNotification();
887   application.Render();
888
889   DALI_TEST_CHECK(vector == actor.GetTargetSize());
890   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
891
892   // Animation
893   // Build the animation
894   const float durationSeconds = 2.0f;
895   Animation animation = Animation::New( durationSeconds );
896   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
897   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
898
899   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
900
901   // Start the animation
902   animation.Play();
903
904   application.SendNotification();
905   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
906
907   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
908
909   END_TEST;
910 }
911
912 // SetPosition(float x, float y)
913 int UtcDaliActorSetPosition01(void)
914 {
915   TestApplication application;
916
917   Actor actor = Actor::New();
918
919   // Set to random to start off with
920   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
921
922   Vector3 vector(100.0f, 100.0f, 0.0f);
923
924   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
925
926   actor.SetPosition(vector.x, vector.y);
927   // flush the queue and render once
928   application.SendNotification();
929   application.Render();
930   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
931
932   Stage::GetCurrent().Add( actor );
933   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
934   // flush the queue and render once
935   application.SendNotification();
936   application.Render();
937   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
938
939   actor.SetX( 1.0f );
940   actor.SetY( 1.1f );
941   actor.SetZ( 1.2f );
942   // flush the queue and render once
943   application.SendNotification();
944   application.Render();
945   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
946
947   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
948   // flush the queue and render once
949   application.SendNotification();
950   application.Render();
951   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
952
953   Stage::GetCurrent().Remove( actor );
954   END_TEST;
955 }
956
957 // SetPosition(float x, float y, float z)
958 int UtcDaliActorSetPosition02(void)
959 {
960   TestApplication application;
961
962   Actor actor = Actor::New();
963
964   // Set to random to start off with
965   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
966
967   Vector3 vector(100.0f, 100.0f, 100.0f);
968
969   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
970
971   actor.SetPosition(vector.x, vector.y, vector.z);
972
973   // flush the queue and render once
974   application.SendNotification();
975   application.Render();
976
977   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
978   END_TEST;
979 }
980
981 // SetPosition(Vector3 position)
982 int UtcDaliActorSetPosition03(void)
983 {
984   TestApplication application;
985
986   Actor actor = Actor::New();
987
988   // Set to random to start off with
989   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
990
991   Vector3 vector(100.0f, 100.0f, 100.0f);
992
993   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
994
995   actor.SetPosition(vector);
996
997   // flush the queue and render once
998   application.SendNotification();
999   application.Render();
1000
1001   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1002   END_TEST;
1003 }
1004
1005 int UtcDaliActorSetX(void)
1006 {
1007   TestApplication application;
1008
1009   Actor actor = Actor::New();
1010
1011   Vector3 vector(100.0f, 0.0f, 0.0f);
1012
1013   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1014
1015   actor.SetX(100.0f);
1016
1017   // flush the queue and render once
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1022   END_TEST;
1023 }
1024
1025 int UtcDaliActorSetY(void)
1026 {
1027   TestApplication application;
1028
1029   Actor actor = Actor::New();
1030
1031   Vector3 vector(0.0f, 100.0f, 0.0f);
1032
1033   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1034
1035   actor.SetY(100.0f);
1036
1037   // flush the queue and render once
1038   application.SendNotification();
1039   application.Render();
1040
1041   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1042   END_TEST;
1043 }
1044
1045 int UtcDaliActorSetZ(void)
1046 {
1047   TestApplication application;
1048
1049   Actor actor = Actor::New();
1050
1051   Vector3 vector(0.0f, 0.0f, 100.0f);
1052
1053   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1054
1055   actor.SetZ(100.0f);
1056
1057   // flush the queue and render once
1058   application.SendNotification();
1059   application.Render();
1060
1061   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1062   END_TEST;
1063 }
1064
1065 int UtcDaliActorSetPositionProperties(void)
1066 {
1067   TestApplication application;
1068
1069   Actor actor = Actor::New();
1070
1071   Vector3 vector(0.7f, 0.8f, 0.9f);
1072   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1073
1074   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1075
1076   // flush the queue and render once
1077   application.SendNotification();
1078   application.Render();
1079
1080   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1081
1082   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1083
1084   // flush the queue and render once
1085   application.SendNotification();
1086   application.Render();
1087
1088   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1089
1090   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1091
1092   // flush the queue and render once
1093   application.SendNotification();
1094   application.Render();
1095
1096   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1097
1098   END_TEST;
1099 }
1100
1101 int UtcDaliActorTranslateBy(void)
1102 {
1103   TestApplication application;
1104
1105   Actor actor = Actor::New();
1106   Vector3 vector(100.0f, 100.0f, 100.0f);
1107
1108   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1109
1110   actor.SetPosition(vector);
1111
1112   // flush the queue and render once
1113   application.SendNotification();
1114   application.Render();
1115
1116   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1117
1118   actor.TranslateBy(vector);
1119
1120   // flush the queue and render once
1121   application.SendNotification();
1122   application.Render();
1123
1124   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1125   END_TEST;
1126 }
1127
1128 int UtcDaliActorGetCurrentPosition(void)
1129 {
1130   TestApplication application;
1131
1132   Actor actor = Actor::New();
1133   Vector3 setVector(100.0f, 100.0f, 0.0f);
1134   actor.SetPosition(setVector);
1135
1136   // flush the queue and render once
1137   application.SendNotification();
1138   application.Render();
1139
1140   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1141   END_TEST;
1142 }
1143
1144 int UtcDaliActorGetCurrentWorldPosition(void)
1145 {
1146   TestApplication application;
1147
1148   Actor parent = Actor::New();
1149   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1150   parent.SetPosition( parentPosition );
1151   parent.SetParentOrigin( ParentOrigin::CENTER );
1152   parent.SetAnchorPoint( AnchorPoint::CENTER );
1153   Stage::GetCurrent().Add( parent );
1154
1155   Actor child = Actor::New();
1156   child.SetParentOrigin( ParentOrigin::CENTER );
1157   child.SetAnchorPoint( AnchorPoint::CENTER );
1158   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1159   child.SetPosition( childPosition );
1160   parent.Add( child );
1161
1162   // The actors should not have a world position yet
1163   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1164   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1165
1166   application.SendNotification();
1167   application.Render(0);
1168
1169   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1170   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1171
1172   // The actors should have a world position now
1173   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1174   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1175   END_TEST;
1176 }
1177
1178 int UtcDaliActorInheritPosition(void)
1179 {
1180   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1181   TestApplication application;
1182
1183   Actor parent = Actor::New();
1184   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1185   parent.SetPosition( parentPosition );
1186   parent.SetParentOrigin( ParentOrigin::CENTER );
1187   parent.SetAnchorPoint( AnchorPoint::CENTER );
1188   Stage::GetCurrent().Add( parent );
1189
1190   Actor child = Actor::New();
1191   child.SetParentOrigin( ParentOrigin::CENTER );
1192   child.SetAnchorPoint( AnchorPoint::CENTER );
1193   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1194   child.SetPosition( childPosition );
1195   parent.Add( child );
1196
1197   // The actors should not have a world position yet
1198   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1199   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1200
1201   // first test default, which is to inherit position
1202   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1203   application.SendNotification();
1204   application.Render(0); // should only really call Update as Render is not required to update scene
1205   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1206   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1207   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1208   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1209
1210
1211   //Change child position
1212   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1213   child.SetPosition( childOffset );
1214
1215   // Change inheritance mode to not inherit
1216   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1217   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1218   application.SendNotification();
1219   application.Render(0); // should only really call Update as Render is not required to update scene
1220   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1221   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1222   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1223   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1224   END_TEST;
1225 }
1226
1227 int UtcDaliActorSetInheritPosition(void)
1228 {
1229   tet_infoline("Testing Actor::SetInheritPosition");
1230   TestApplication application;
1231
1232   Actor parent = Actor::New();
1233   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1234   parent.SetPosition( parentPosition );
1235   parent.SetParentOrigin( ParentOrigin::CENTER );
1236   parent.SetAnchorPoint( AnchorPoint::CENTER );
1237   Stage::GetCurrent().Add( parent );
1238
1239   Actor child = Actor::New();
1240   child.SetParentOrigin( ParentOrigin::CENTER );
1241   child.SetAnchorPoint( AnchorPoint::CENTER );
1242   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1243   child.SetPosition( childPosition );
1244   parent.Add( child );
1245
1246   // The actors should not have a world position yet
1247   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1248   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1249
1250   // first test default, which is to inherit position
1251   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1252   application.SendNotification();
1253   application.Render(0); // should only really call Update as Render is not required to update scene
1254   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1255   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1256   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1257   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1258
1259   //Change child position
1260   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1261   child.SetPosition( childOffset );
1262
1263   // Use local position as world postion
1264   child.SetInheritPosition( false );
1265   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1266   application.SendNotification();
1267   application.Render(0); // should only really call Update as Render is not required to update scene
1268   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1269   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1270   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1271   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1272
1273   //Change back to inherit position from parent
1274   child.SetInheritPosition( true );
1275   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1276   application.SendNotification();
1277   application.Render(0); // should only really call Update as Render is not required to update scene
1278   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1279   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1280   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1281   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1282   END_TEST;
1283 }
1284
1285 // SetOrientation(float angleRadians, Vector3 axis)
1286 int UtcDaliActorSetOrientation01(void)
1287 {
1288   TestApplication application;
1289
1290   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1291   Actor actor = Actor::New();
1292
1293   actor.SetOrientation(rotation);
1294
1295   // flush the queue and render once
1296   application.SendNotification();
1297   application.Render();
1298
1299   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1300   END_TEST;
1301 }
1302
1303 int UtcDaliActorSetOrientation02(void)
1304 {
1305   TestApplication application;
1306
1307   Actor actor = Actor::New();
1308
1309   Radian angle( 0.785f );
1310   Vector3 axis(1.0f, 1.0f, 0.0f);
1311
1312   actor.SetOrientation( angle, axis);
1313   Quaternion rotation( angle, axis );
1314   // flush the queue and render once
1315   application.SendNotification();
1316   application.Render();
1317   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1318
1319   Stage::GetCurrent().Add( actor );
1320   actor.RotateBy( Degree( 360 ), axis);
1321   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1322
1323   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1324   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1325   // flush the queue and render once
1326   application.SendNotification();
1327   application.Render();
1328   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1329
1330   actor.SetOrientation( angle, axis);
1331   // flush the queue and render once
1332   application.SendNotification();
1333   application.Render();
1334   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1335
1336   Stage::GetCurrent().Remove( actor );
1337   END_TEST;
1338 }
1339
1340 // SetOrientation(float angleRadians, Vector3 axis)
1341 int UtcDaliActorSetOrientationProperty(void)
1342 {
1343   TestApplication application;
1344
1345   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1346   Actor actor = Actor::New();
1347
1348   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1349
1350   // flush the queue and render once
1351   application.SendNotification();
1352   application.Render();
1353
1354   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1355   END_TEST;
1356 }
1357
1358 // RotateBy(float angleRadians, Vector3 axis)
1359 int UtcDaliActorRotateBy01(void)
1360 {
1361   TestApplication application;
1362
1363   Actor actor = Actor::New();
1364
1365   Radian angle( M_PI * 0.25f );
1366   actor.RotateBy(( angle ), Vector3::ZAXIS);
1367   // flush the queue and render once
1368   application.SendNotification();
1369   application.Render();
1370   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1371
1372   Stage::GetCurrent().Add( actor );
1373
1374   actor.RotateBy( angle, Vector3::ZAXIS);
1375   // flush the queue and render once
1376   application.SendNotification();
1377   application.Render();
1378   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1379
1380   Stage::GetCurrent().Remove( actor );
1381   END_TEST;
1382 }
1383
1384 // RotateBy(Quaternion relativeRotation)
1385 int UtcDaliActorRotateBy02(void)
1386 {
1387   TestApplication application;
1388
1389   Actor actor = Actor::New();
1390
1391   Radian angle( M_PI * 0.25f );
1392   Quaternion rotation(angle, Vector3::ZAXIS);
1393   actor.RotateBy(rotation);
1394   // flush the queue and render once
1395   application.SendNotification();
1396   application.Render();
1397   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1398
1399   actor.RotateBy(rotation);
1400   // flush the queue and render once
1401   application.SendNotification();
1402   application.Render();
1403   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1404   END_TEST;
1405 }
1406
1407 int UtcDaliActorGetCurrentOrientation(void)
1408 {
1409   TestApplication application;
1410   Actor actor = Actor::New();
1411
1412   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1413   actor.SetOrientation(rotation);
1414   // flush the queue and render once
1415   application.SendNotification();
1416   application.Render();
1417   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1418   END_TEST;
1419 }
1420
1421 int UtcDaliActorGetCurrentWorldOrientation(void)
1422 {
1423   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1424   TestApplication application;
1425
1426   Actor parent = Actor::New();
1427   Radian rotationAngle( Degree(90.0f) );
1428   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1429   parent.SetOrientation( rotation );
1430   Stage::GetCurrent().Add( parent );
1431
1432   Actor child = Actor::New();
1433   child.SetOrientation( rotation );
1434   parent.Add( child );
1435
1436   // The actors should not have a world rotation yet
1437   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1438   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1439
1440   application.SendNotification();
1441   application.Render(0);
1442
1443   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1444   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1445
1446   // The actors should have a world rotation now
1447   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1448   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1449
1450   // turn off child rotation inheritance
1451   child.SetInheritOrientation( false );
1452   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1453   application.SendNotification();
1454   application.Render(0);
1455
1456   // The actors should have a world rotation now
1457   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1458   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1459   END_TEST;
1460 }
1461
1462 // SetScale(float scale)
1463 int UtcDaliActorSetScale01(void)
1464 {
1465   TestApplication application;
1466
1467   Actor actor = Actor::New();
1468
1469   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1470   actor.SetScale(0.25f);
1471
1472   Vector3 scale(10.0f, 10.0f, 10.0f);
1473   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1474
1475   actor.SetScale(scale.x);
1476
1477   // flush the queue and render once
1478   application.SendNotification();
1479   application.Render();
1480
1481   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1482   END_TEST;
1483 }
1484
1485 // SetScale(float scaleX, float scaleY, float scaleZ)
1486 int UtcDaliActorSetScale02(void)
1487 {
1488   TestApplication application;
1489   Vector3 scale(10.0f, 10.0f, 10.0f);
1490
1491   Actor actor = Actor::New();
1492
1493   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1494   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1495
1496   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1497
1498   actor.SetScale(scale.x, scale.y, scale.z);
1499   // flush the queue and render once
1500   application.SendNotification();
1501   application.Render();
1502   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1503
1504   // add to stage and test
1505   Stage::GetCurrent().Add( actor );
1506   actor.SetScale( 2.0f, 2.0f, 2.0f );
1507   // flush the queue and render once
1508   application.SendNotification();
1509   application.Render();
1510   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1511
1512   Stage::GetCurrent().Remove( actor );
1513
1514   END_TEST;
1515 }
1516
1517 // SetScale(Vector3 scale)
1518 int UtcDaliActorSetScale03(void)
1519 {
1520   TestApplication application;
1521   Vector3 scale(10.0f, 10.0f, 10.0f);
1522
1523   Actor actor = Actor::New();
1524
1525   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1526   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1527
1528   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1529
1530   actor.SetScale(scale);
1531
1532   // flush the queue and render once
1533   application.SendNotification();
1534   application.Render();
1535
1536   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1537   END_TEST;
1538 }
1539
1540 int UtcDaliActorSetScaleIndividual(void)
1541 {
1542   TestApplication application;
1543
1544   Actor actor = Actor::New();
1545
1546   Vector3 vector(0.7f, 0.8f, 0.9f);
1547   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1548
1549   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1550
1551   // flush the queue and render once
1552   application.SendNotification();
1553   application.Render();
1554
1555   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1556
1557   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1558
1559   // flush the queue and render once
1560   application.SendNotification();
1561   application.Render();
1562
1563   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1564
1565   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1566
1567   // flush the queue and render once
1568   application.SendNotification();
1569   application.Render();
1570
1571   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1572
1573   END_TEST;
1574 }
1575
1576 int UtcDaliActorScaleBy(void)
1577 {
1578   TestApplication application;
1579   Actor actor = Actor::New();
1580   Vector3 vector(100.0f, 100.0f, 100.0f);
1581
1582   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1583
1584   actor.SetScale(vector);
1585
1586   // flush the queue and render once
1587   application.SendNotification();
1588   application.Render();
1589
1590   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1591
1592   actor.ScaleBy(vector);
1593
1594   // flush the queue and render once
1595   application.SendNotification();
1596   application.Render();
1597
1598   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1599   END_TEST;
1600 }
1601
1602 int UtcDaliActorGetCurrentScale(void)
1603 {
1604   TestApplication application;
1605   Vector3 scale(12.0f, 1.0f, 2.0f);
1606
1607   Actor actor = Actor::New();
1608
1609   actor.SetScale(scale);
1610
1611   // flush the queue and render once
1612   application.SendNotification();
1613   application.Render();
1614
1615   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1616   END_TEST;
1617 }
1618
1619 int UtcDaliActorGetCurrentWorldScale(void)
1620 {
1621   TestApplication application;
1622
1623   Actor parent = Actor::New();
1624   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1625   parent.SetScale( parentScale );
1626   Stage::GetCurrent().Add( parent );
1627
1628   Actor child = Actor::New();
1629   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1630   child.SetScale( childScale );
1631   parent.Add( child );
1632
1633   // The actors should not have a scale yet
1634   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1635   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1636
1637   // The actors should not have a world scale yet
1638   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1639   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1640
1641   application.SendNotification();
1642   application.Render(0);
1643
1644   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1645   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1646
1647   // The actors should have a world scale now
1648   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1649   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1650   END_TEST;
1651 }
1652
1653 int UtcDaliActorInheritScale(void)
1654 {
1655   tet_infoline("Testing Actor::SetInheritScale");
1656   TestApplication application;
1657
1658   Actor parent = Actor::New();
1659   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1660   parent.SetScale( parentScale );
1661   Stage::GetCurrent().Add( parent );
1662
1663   Actor child = Actor::New();
1664   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1665   child.SetScale( childScale );
1666   parent.Add( child );
1667
1668   application.SendNotification();
1669   application.Render(0);
1670
1671   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1672   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1673
1674   child.SetInheritScale( false );
1675   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1676
1677   application.SendNotification();
1678   application.Render(0);
1679
1680   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1681   END_TEST;
1682 }
1683
1684 int UtcDaliActorSetVisible(void)
1685 {
1686   TestApplication application;
1687
1688   Actor actor = Actor::New();
1689   actor.SetVisible(false);
1690   // flush the queue and render once
1691   application.SendNotification();
1692   application.Render();
1693   DALI_TEST_CHECK(actor.IsVisible() == false);
1694
1695   actor.SetVisible(true);
1696   // flush the queue and render once
1697   application.SendNotification();
1698   application.Render();
1699   DALI_TEST_CHECK(actor.IsVisible() == true);
1700
1701   // put actor on stage
1702   Stage::GetCurrent().Add( actor );
1703   actor.SetVisible(false);
1704   // flush the queue and render once
1705   application.SendNotification();
1706   application.Render();
1707   DALI_TEST_CHECK(actor.IsVisible() == false);
1708   END_TEST;
1709 }
1710
1711 int UtcDaliActorIsVisible(void)
1712 {
1713   TestApplication application;
1714
1715   Actor actor = Actor::New();
1716
1717   DALI_TEST_CHECK(actor.IsVisible() == true);
1718   END_TEST;
1719 }
1720
1721 int UtcDaliActorSetOpacity(void)
1722 {
1723   TestApplication application;
1724
1725   Actor actor = Actor::New();
1726   // initial opacity is 1
1727   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1728
1729   actor.SetOpacity( 0.4f);
1730   // flush the queue and render once
1731   application.SendNotification();
1732   application.Render();
1733   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1734
1735   // change opacity, actor is on stage to change is not immediate
1736   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1737   // flush the queue and render once
1738   application.SendNotification();
1739   application.Render();
1740   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1741
1742   // put actor on stage
1743   Stage::GetCurrent().Add( actor );
1744
1745   // change opacity, actor is on stage to change is not immediate
1746   actor.SetOpacity( 0.9f );
1747   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1748   // flush the queue and render once
1749   application.SendNotification();
1750   application.Render();
1751   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1752
1753   // change opacity, actor is on stage to change is not immediate
1754   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1755   // flush the queue and render once
1756   application.SendNotification();
1757   application.Render();
1758   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1759   END_TEST;
1760 }
1761
1762 int UtcDaliActorGetCurrentOpacity(void)
1763 {
1764   TestApplication application;
1765
1766   Actor actor = Actor::New();
1767   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1768
1769   actor.SetOpacity(0.5f);
1770   // flush the queue and render once
1771   application.SendNotification();
1772   application.Render();
1773   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1774   END_TEST;
1775 }
1776
1777 int UtcDaliActorSetSensitive(void)
1778 {
1779   TestApplication application;
1780   Actor actor = Actor::New();
1781
1782   bool sensitive = !actor.IsSensitive();
1783
1784   actor.SetSensitive(sensitive);
1785
1786   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1787   END_TEST;
1788 }
1789
1790 int UtcDaliActorIsSensitive(void)
1791 {
1792   TestApplication application;
1793   Actor actor = Actor::New();
1794   actor.SetSensitive(false);
1795
1796   DALI_TEST_CHECK(false == actor.IsSensitive());
1797   END_TEST;
1798 }
1799
1800 int UtcDaliActorSetColor(void)
1801 {
1802   TestApplication application;
1803   Actor actor = Actor::New();
1804   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1805
1806   DALI_TEST_CHECK(color != actor.GetCurrentColor());
1807
1808   actor.SetColor(color);
1809   // flush the queue and render once
1810   application.SendNotification();
1811   application.Render();
1812   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1813
1814   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1815   // flush the queue and render once
1816   application.SendNotification();
1817   application.Render();
1818   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
1819
1820   Stage::GetCurrent().Add( actor );
1821   actor.SetColor( color );
1822   // flush the queue and render once
1823   application.SendNotification();
1824   application.Render();
1825   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
1826
1827   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1828   // flush the queue and render once
1829   application.SendNotification();
1830   application.Render();
1831   // Actor color is not clamped
1832   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
1833   // world color is clamped
1834   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
1835
1836   Stage::GetCurrent().Remove( actor );
1837   END_TEST;
1838 }
1839
1840 int UtcDaliActorSetColorIndividual(void)
1841 {
1842   TestApplication application;
1843
1844   Actor actor = Actor::New();
1845
1846   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1847   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1848
1849   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1850
1851   // flush the queue and render once
1852   application.SendNotification();
1853   application.Render();
1854
1855   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1856
1857   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1858
1859   // flush the queue and render once
1860   application.SendNotification();
1861   application.Render();
1862
1863   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1864
1865   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1866
1867   // flush the queue and render once
1868   application.SendNotification();
1869   application.Render();
1870
1871   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1872
1873   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1874
1875   // flush the queue and render once
1876   application.SendNotification();
1877   application.Render();
1878
1879   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1880
1881   END_TEST;
1882 }
1883
1884
1885 int UtcDaliActorGetCurrentColor(void)
1886 {
1887   TestApplication application;
1888   Actor actor = Actor::New();
1889   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1890
1891   actor.SetColor(color);
1892   // flush the queue and render once
1893   application.SendNotification();
1894   application.Render();
1895   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1896   END_TEST;
1897 }
1898
1899 int UtcDaliActorGetCurrentWorldColor(void)
1900 {
1901   tet_infoline("Actor::GetCurrentWorldColor");
1902   TestApplication application;
1903
1904   Actor parent = Actor::New();
1905   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1906   parent.SetColor( parentColor );
1907   Stage::GetCurrent().Add( parent );
1908
1909   Actor child = Actor::New();
1910   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1911   child.SetColor( childColor );
1912   parent.Add( child );
1913
1914   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1915   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1916
1917   // verify the default color mode
1918   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1919
1920   // The actors should not have a world color yet
1921   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1922   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1923
1924   application.SendNotification();
1925   application.Render(0);
1926
1927   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1928   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1929
1930   // The actors should have a world color now
1931   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1932   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1933
1934   // use own color
1935   child.SetColorMode( USE_OWN_COLOR );
1936   application.SendNotification();
1937   application.Render(0);
1938   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1939
1940   // use parent color
1941   child.SetColorMode( USE_PARENT_COLOR );
1942   application.SendNotification();
1943   application.Render(0);
1944   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1945   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1946
1947   // use parent alpha
1948   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1949   application.SendNotification();
1950   application.Render(0);
1951   Vector4 expectedColor( childColor );
1952   expectedColor.a *= parentColor.a;
1953   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1954   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1955   END_TEST;
1956 }
1957
1958 int UtcDaliActorSetColorMode(void)
1959 {
1960   tet_infoline("Actor::SetColorMode");
1961   TestApplication application;
1962   Actor actor = Actor::New();
1963   Actor child = Actor::New();
1964   actor.Add( child );
1965
1966   actor.SetColorMode( USE_OWN_COLOR );
1967   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1968
1969   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1970   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1971
1972   actor.SetColorMode( USE_PARENT_COLOR );
1973   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1974
1975   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1976   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1977   END_TEST;
1978 }
1979
1980 int UtcDaliActorScreenToLocal(void)
1981 {
1982   TestApplication application;
1983   Actor actor = Actor::New();
1984   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1985   actor.SetSize(100.0f, 100.0f);
1986   actor.SetPosition(10.0f, 10.0f);
1987   Stage::GetCurrent().Add(actor);
1988
1989   // flush the queue and render once
1990   application.SendNotification();
1991   application.Render();
1992
1993   float localX;
1994   float localY;
1995
1996   application.SendNotification();
1997   application.Render();
1998
1999   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2000
2001   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2002   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2003   END_TEST;
2004 }
2005
2006 int UtcDaliActorSetLeaveRequired(void)
2007 {
2008   TestApplication application;
2009
2010   Actor actor = Actor::New();
2011
2012   actor.SetLeaveRequired(false);
2013   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2014
2015   actor.SetLeaveRequired(true);
2016   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2017   END_TEST;
2018 }
2019
2020 int UtcDaliActorGetLeaveRequired(void)
2021 {
2022   TestApplication application;
2023
2024   Actor actor = Actor::New();
2025
2026   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2027   END_TEST;
2028 }
2029
2030 int UtcDaliActorSetKeyboardFocusable(void)
2031 {
2032   TestApplication application;
2033
2034   Actor actor = Actor::New();
2035
2036   actor.SetKeyboardFocusable(true);
2037   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2038
2039   actor.SetKeyboardFocusable(false);
2040   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2041   END_TEST;
2042 }
2043
2044 int UtcDaliActorIsKeyboardFocusable(void)
2045 {
2046   TestApplication application;
2047
2048   Actor actor = Actor::New();
2049
2050   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2051   END_TEST;
2052 }
2053
2054 int UtcDaliActorRemoveConstraints(void)
2055 {
2056   tet_infoline(" UtcDaliActorRemoveConstraints");
2057   TestApplication application;
2058
2059   gTestConstraintCalled = false;
2060
2061   Actor actor = Actor::New();
2062
2063   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2064   constraint.Apply();
2065   actor.RemoveConstraints();
2066
2067   DALI_TEST_CHECK( gTestConstraintCalled == false );
2068
2069   Stage::GetCurrent().Add( actor );
2070   constraint.Apply();
2071
2072   // flush the queue and render once
2073   application.SendNotification();
2074   application.Render();
2075
2076   actor.RemoveConstraints();
2077
2078   DALI_TEST_CHECK( gTestConstraintCalled == true );
2079   END_TEST;
2080 }
2081
2082 int UtcDaliActorRemoveConstraintTag(void)
2083 {
2084   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2085   TestApplication application;
2086
2087   Actor actor = Actor::New();
2088
2089   // 1. Apply Constraint1 and Constraint2, and test...
2090   unsigned int result1 = 0u;
2091   unsigned int result2 = 0u;
2092
2093   unsigned constraint1Tag = 1u;
2094   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2095   constraint1.SetTag( constraint1Tag );
2096   constraint1.Apply();
2097
2098   unsigned constraint2Tag = 2u;
2099   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2100   constraint2.SetTag( constraint2Tag );
2101   constraint2.Apply();
2102
2103   Stage::GetCurrent().Add( actor );
2104   // flush the queue and render once
2105   application.SendNotification();
2106   application.Render();
2107
2108   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2109   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2110
2111   // 2. Remove Constraint1 and test...
2112   result1 = 0;
2113   result2 = 0;
2114   actor.RemoveConstraints(constraint1Tag);
2115   // make color property dirty, which will trigger constraints to be reapplied.
2116   actor.SetColor( Color::WHITE );
2117   // flush the queue and render once
2118   application.SendNotification();
2119   application.Render();
2120
2121   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2122   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2123
2124   // 3. Re-Apply Constraint1 and test...
2125   result1 = 0;
2126   result2 = 0;
2127   constraint1.Apply();
2128   // make color property dirty, which will trigger constraints to be reapplied.
2129   actor.SetColor( Color::WHITE );
2130   // flush the queue and render once
2131   application.SendNotification();
2132   application.Render();
2133
2134   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2135   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2136
2137   // 2. Remove Constraint2 and test...
2138   result1 = 0;
2139   result2 = 0;
2140   actor.RemoveConstraints(constraint2Tag);
2141   // make color property dirty, which will trigger constraints to be reapplied.
2142   actor.SetColor( Color::WHITE );
2143   // flush the queue and render once
2144   application.SendNotification();
2145   application.Render();
2146
2147   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2148   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2149
2150   // 2. Remove Constraint1 as well and test...
2151   result1 = 0;
2152   result2 = 0;
2153   actor.RemoveConstraints(constraint1Tag);
2154   // make color property dirty, which will trigger constraints to be reapplied.
2155   actor.SetColor( Color::WHITE );
2156   // flush the queue and render once
2157   application.SendNotification();
2158   application.Render();
2159
2160   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2161   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2162   END_TEST;
2163 }
2164
2165 int UtcDaliActorTouchedSignal(void)
2166 {
2167   TestApplication application;
2168
2169   gTouchCallBackCalled = false;
2170
2171   // get the root layer
2172   Actor actor = Stage::GetCurrent().GetRootLayer();
2173   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2174
2175   application.SendNotification();
2176   application.Render();
2177
2178   // connect to its touch signal
2179   actor.TouchedSignal().Connect( TestCallback );
2180
2181   // simulate a touch event in the middle of the screen
2182   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2183   Dali::Integration::Point point;
2184   point.SetDeviceId( 1 );
2185   point.SetState( PointState::DOWN );
2186   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2187   Dali::Integration::TouchEvent event;
2188   event.AddPoint( point );
2189   application.ProcessEvent( event );
2190
2191   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2192   END_TEST;
2193 }
2194
2195 int UtcDaliActorHoveredSignal(void)
2196 {
2197   TestApplication application;
2198
2199   gHoverCallBackCalled = false;
2200
2201   // get the root layer
2202   Actor actor = Stage::GetCurrent().GetRootLayer();
2203   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2204
2205   application.SendNotification();
2206   application.Render();
2207
2208   // connect to its hover signal
2209   actor.HoveredSignal().Connect( TestCallback3 );
2210
2211   // simulate a hover event in the middle of the screen
2212   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2213   Dali::Integration::Point point;
2214   point.SetDeviceId( 1 );
2215   point.SetState( PointState::MOTION );
2216   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2217   Dali::Integration::HoverEvent event;
2218   event.AddPoint( point );
2219   application.ProcessEvent( event );
2220
2221   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2222   END_TEST;
2223 }
2224
2225 int UtcDaliActorOnOffStageSignal(void)
2226 {
2227   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2228
2229   TestApplication application;
2230
2231   // clean test data
2232   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2233   gActorNamesOnOffStage.clear();
2234
2235   Actor parent = Actor::New();
2236   parent.SetName( "parent" );
2237   parent.OnStageSignal().Connect( OnStageCallback );
2238   parent.OffStageSignal().Connect( OffStageCallback );
2239   // sanity check
2240   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2241   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2242
2243   // add parent to stage
2244   Stage::GetCurrent().Add( parent );
2245   // onstage emitted, offstage not
2246   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2247   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2248   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2249
2250   // test adding a child, should get onstage emitted
2251   // clean test data
2252   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2253   gActorNamesOnOffStage.clear();
2254
2255   Actor child = Actor::New();
2256   child.SetName( "child" );
2257   child.OnStageSignal().Connect( OnStageCallback );
2258   child.OffStageSignal().Connect( OffStageCallback );
2259   parent.Add( child ); // add child
2260   // onstage emitted, offstage not
2261   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2262   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2263   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2264
2265   // test removing parent from stage
2266   // clean test data
2267   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2268   gActorNamesOnOffStage.clear();
2269
2270   Stage::GetCurrent().Remove( parent );
2271   // onstage not emitted, offstage is
2272   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2273   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2274   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2275   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2276
2277   // test adding parent back to stage
2278   // clean test data
2279   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2280   gActorNamesOnOffStage.clear();
2281
2282   Stage::GetCurrent().Add( parent );
2283   // onstage emitted, offstage not
2284   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2285   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2286   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2287   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2288
2289   // test removing child
2290   // clean test data
2291   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2292   gActorNamesOnOffStage.clear();
2293
2294   parent.Remove( child );
2295   // onstage not emitted, offstage is
2296   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2297   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2298   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2299
2300   // test removing parent
2301   // clean test data
2302   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2303   gActorNamesOnOffStage.clear();
2304
2305   Stage::GetCurrent().Remove( parent );
2306   // onstage not emitted, offstage is
2307   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2308   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2309   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2310   END_TEST;
2311 }
2312
2313 int UtcDaliActorFindChildByName(void)
2314 {
2315   tet_infoline("Testing Dali::Actor::FindChildByName()");
2316   TestApplication application;
2317
2318   Actor parent = Actor::New();
2319   parent.SetName( "parent" );
2320   Actor first  = Actor::New();
2321   first .SetName( "first" );
2322   Actor second = Actor::New();
2323   second.SetName( "second" );
2324
2325   parent.Add(first);
2326   first.Add(second);
2327
2328   Actor found = parent.FindChildByName( "foo" );
2329   DALI_TEST_CHECK( !found );
2330
2331   found = parent.FindChildByName( "parent" );
2332   DALI_TEST_CHECK( found == parent );
2333
2334   found = parent.FindChildByName( "first" );
2335   DALI_TEST_CHECK( found == first );
2336
2337   found = parent.FindChildByName( "second" );
2338   DALI_TEST_CHECK( found == second );
2339   END_TEST;
2340 }
2341
2342 int UtcDaliActorFindChildById(void)
2343 {
2344   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2345   TestApplication application;
2346
2347   Actor parent = Actor::New();
2348   Actor first  = Actor::New();
2349   Actor second = Actor::New();
2350
2351   parent.Add(first);
2352   first.Add(second);
2353
2354   Actor found = parent.FindChildById( 100000 );
2355   DALI_TEST_CHECK( !found );
2356
2357   found = parent.FindChildById( parent.GetId() );
2358   DALI_TEST_CHECK( found == parent );
2359
2360   found = parent.FindChildById( first.GetId() );
2361   DALI_TEST_CHECK( found == first );
2362
2363   found = parent.FindChildById( second.GetId() );
2364   DALI_TEST_CHECK( found == second );
2365   END_TEST;
2366 }
2367
2368 int UtcDaliActorHitTest(void)
2369 {
2370   struct HitTestData
2371   {
2372   public:
2373     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2374     : mScale( scale ),
2375       mTouchPoint( touchPoint ),
2376       mResult( result )
2377     {}
2378
2379     Vector3 mScale;
2380     Vector2 mTouchPoint;
2381     bool mResult;
2382   };
2383
2384   TestApplication application;
2385   tet_infoline(" UtcDaliActorHitTest");
2386
2387   // Fill a vector with different hit tests.
2388   struct HitTestData* hitTestData[] = {
2389     //                    scale                     touch point           result
2390     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2391     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2392     new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ),  // same point as above with a wider scale. Should be inside.
2393     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2394     new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ),  // same point as above with a wider scale. Should be inside.
2395     NULL,
2396   };
2397
2398   // get the root layer
2399   Actor actor = Actor::New();
2400   actor.SetAnchorPoint( AnchorPoint::CENTER );
2401   actor.SetParentOrigin( ParentOrigin::CENTER );
2402
2403   Stage::GetCurrent().Add( actor );
2404
2405   gTouchCallBackCalled = false;
2406
2407   unsigned int index = 0;
2408   while( NULL != hitTestData[index] )
2409   {
2410     actor.SetSize( 1.f, 1.f );
2411     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2412
2413     // flush the queue and render once
2414     application.SendNotification();
2415     application.Render();
2416
2417     DALI_TEST_CHECK( !gTouchCallBackCalled );
2418
2419     // connect to its touch signal
2420     actor.TouchedSignal().Connect(TestCallback);
2421
2422     Dali::Integration::Point point;
2423     point.SetState( PointState::DOWN );
2424     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2425     Dali::Integration::TouchEvent event;
2426     event.AddPoint( point );
2427
2428     // flush the queue and render once
2429     application.SendNotification();
2430     application.Render();
2431     application.ProcessEvent( event );
2432
2433     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2434
2435     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2436       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2437                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2438                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2439                  hitTestData[index]->mResult );
2440
2441     gTouchCallBackCalled = false;
2442     ++index;
2443   }
2444   END_TEST;
2445 }
2446
2447 int UtcDaliActorSetDrawMode(void)
2448 {
2449   TestApplication app;
2450   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2451
2452   Actor a = Actor::New();
2453
2454   Stage::GetCurrent().Add(a);
2455   app.SendNotification();
2456   app.Render(0);
2457   app.SendNotification();
2458   app.Render(1);
2459
2460   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2461
2462   a.SetDrawMode( DrawMode::OVERLAY_2D );
2463   app.SendNotification();
2464   app.Render(1);
2465
2466   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2467
2468   a.SetDrawMode( DrawMode::NORMAL );
2469   app.SendNotification();
2470   app.Render(1);
2471
2472   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2473   END_TEST;
2474 }
2475
2476 int UtcDaliActorSetDrawModeOverlayRender(void)
2477 {
2478   TestApplication app;
2479   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2480
2481   app.SendNotification();
2482   app.Render(1);
2483
2484   std::vector<GLuint> ids;
2485   ids.push_back( 8 );   // first rendered actor
2486   ids.push_back( 9 );   // second rendered actor
2487   ids.push_back( 10 );  // third rendered actor
2488   app.GetGlAbstraction().SetNextTextureIds( ids );
2489
2490   BufferImage imageA = BufferImage::New(16, 16);
2491   BufferImage imageB = BufferImage::New(16, 16);
2492   BufferImage imageC = BufferImage::New(16, 16);
2493   Actor a = CreateRenderableActor( imageA );
2494   Actor b = CreateRenderableActor( imageB );
2495   Actor c = CreateRenderableActor( imageC );
2496
2497   // Render a,b,c as regular non-overlays. so order will be:
2498   // a (8)
2499   // b (9)
2500   // c (10)
2501   Stage::GetCurrent().Add(a);
2502   Stage::GetCurrent().Add(b);
2503   Stage::GetCurrent().Add(c);
2504
2505   app.SendNotification();
2506   app.Render(1);
2507
2508   // Should be 3 textures changes.
2509   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2510   typedef std::vector<GLuint>::size_type TextureSize;
2511   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2512   if( boundTextures.size() == 3 )
2513   {
2514     DALI_TEST_CHECK( boundTextures[0] == 8u );
2515     DALI_TEST_CHECK( boundTextures[1] == 9u );
2516     DALI_TEST_CHECK( boundTextures[2] == 10u );
2517   }
2518
2519   // Now texture ids have been set, we can monitor their render order.
2520   // render a as an overlay (last), so order will be:
2521   // b (9)
2522   // c (10)
2523   // a (8)
2524   a.SetDrawMode( DrawMode::OVERLAY_2D );
2525   app.GetGlAbstraction().ClearBoundTextures();
2526
2527   app.SendNotification();
2528   app.Render(1);
2529
2530   // Should be 3 texture changes.
2531   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2532   if( boundTextures.size() == 3 )
2533   {
2534     DALI_TEST_CHECK( boundTextures[0] == 9u );
2535     DALI_TEST_CHECK( boundTextures[1] == 10u );
2536     DALI_TEST_CHECK( boundTextures[2] == 8u );
2537   }
2538   END_TEST;
2539 }
2540
2541 int UtcDaliActorGetCurrentWorldMatrix(void)
2542 {
2543   TestApplication app;
2544   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2545
2546   Actor parent = Actor::New();
2547   parent.SetParentOrigin(ParentOrigin::CENTER);
2548   parent.SetAnchorPoint(AnchorPoint::CENTER);
2549   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2550   Radian rotationAngle(Degree(85.0f));
2551   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2552   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2553   parent.SetPosition( parentPosition );
2554   parent.SetOrientation( parentRotation );
2555   parent.SetScale( parentScale );
2556   Stage::GetCurrent().Add( parent );
2557
2558   Actor child = Actor::New();
2559   child.SetParentOrigin(ParentOrigin::CENTER);
2560   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2561   Radian childRotationAngle(Degree(23.0f));
2562   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2563   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2564   child.SetPosition( childPosition );
2565   child.SetOrientation( childRotation );
2566   child.SetScale( childScale );
2567   parent.Add( child );
2568
2569   app.SendNotification();
2570   app.Render(0);
2571   app.Render();
2572   app.SendNotification();
2573
2574   Matrix parentMatrix(false);
2575   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2576
2577   Matrix childMatrix(false);
2578   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2579
2580   //Child matrix should be the composition of child and parent
2581   Matrix childWorldMatrix(false);
2582   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2583
2584   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2585   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2586   END_TEST;
2587 }
2588
2589
2590
2591 int UtcDaliActorConstrainedToWorldMatrix(void)
2592 {
2593   TestApplication app;
2594   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2595
2596   Actor parent = Actor::New();
2597   parent.SetParentOrigin(ParentOrigin::CENTER);
2598   parent.SetAnchorPoint(AnchorPoint::CENTER);
2599   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2600   Radian rotationAngle(Degree(85.0f));
2601   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2602   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2603   parent.SetPosition( parentPosition );
2604   parent.SetOrientation( parentRotation );
2605   parent.SetScale( parentScale );
2606   Stage::GetCurrent().Add( parent );
2607
2608   Actor child = Actor::New();
2609   child.SetParentOrigin(ParentOrigin::CENTER);
2610   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2611   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2612   posConstraint.Apply();
2613
2614   Stage::GetCurrent().Add( child );
2615
2616   app.SendNotification();
2617   app.Render(0);
2618   app.Render();
2619   app.SendNotification();
2620
2621   Matrix parentMatrix(false);
2622   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2623
2624   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2625   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2626   END_TEST;
2627 }
2628
2629 int UtcDaliActorConstrainedToOrientation(void)
2630 {
2631   TestApplication app;
2632   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2633
2634   Actor parent = Actor::New();
2635   parent.SetParentOrigin(ParentOrigin::CENTER);
2636   parent.SetAnchorPoint(AnchorPoint::CENTER);
2637   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2638   Radian rotationAngle(Degree(85.0f));
2639   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2640   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2641   parent.SetPosition( parentPosition );
2642   parent.SetOrientation( parentRotation );
2643   parent.SetScale( parentScale );
2644   Stage::GetCurrent().Add( parent );
2645
2646   Actor child = Actor::New();
2647   child.SetParentOrigin(ParentOrigin::CENTER);
2648   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2649   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2650   posConstraint.Apply();
2651
2652   Stage::GetCurrent().Add( child );
2653
2654   app.SendNotification();
2655   app.Render(0);
2656   app.Render();
2657   app.SendNotification();
2658
2659   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2660   END_TEST;
2661 }
2662
2663 int UtcDaliActorUnparent(void)
2664 {
2665   TestApplication app;
2666   tet_infoline(" UtcDaliActorUnparent");
2667
2668   Actor parent = Actor::New();
2669   Stage::GetCurrent().Add( parent );
2670
2671   Actor child = Actor::New();
2672
2673   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2674   DALI_TEST_CHECK( !child.GetParent() );
2675
2676   // Test that calling Unparent with no parent is a NOOP
2677   child.Unparent();
2678
2679   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2680   DALI_TEST_CHECK( !child.GetParent() );
2681
2682   // Test that Unparent works
2683   parent.Add( child );
2684
2685   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2686   DALI_TEST_CHECK( parent == child.GetParent() );
2687
2688   child.Unparent();
2689
2690   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2691   DALI_TEST_CHECK( !child.GetParent() );
2692
2693   // Test that UnparentAndReset works
2694   parent.Add( child );
2695
2696   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2697   DALI_TEST_CHECK( parent == child.GetParent() );
2698
2699   UnparentAndReset( child );
2700
2701   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2702   DALI_TEST_CHECK( !child );
2703
2704   // Test that UnparentAndReset is a NOOP with empty handle
2705   UnparentAndReset( child );
2706
2707   DALI_TEST_CHECK( !child );
2708   END_TEST;
2709 }
2710
2711 int UtcDaliActorGetChildAt(void)
2712 {
2713   TestApplication app;
2714   tet_infoline(" UtcDaliActorGetChildAt");
2715
2716   Actor parent = Actor::New();
2717   Stage::GetCurrent().Add( parent );
2718
2719   Actor child0 = Actor::New();
2720   parent.Add( child0 );
2721
2722   Actor child1 = Actor::New();
2723   parent.Add( child1 );
2724
2725   Actor child2 = Actor::New();
2726   parent.Add( child2 );
2727
2728   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2729   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2730   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2731   END_TEST;
2732 }
2733
2734 int UtcDaliActorSetGetOverlay(void)
2735 {
2736   TestApplication app;
2737   tet_infoline(" UtcDaliActorSetGetOverlay");
2738
2739   Actor parent = Actor::New();
2740   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2741   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2742   END_TEST;
2743 }
2744
2745
2746 int UtcDaliActorCreateDestroy(void)
2747 {
2748   Actor* actor = new Actor;
2749   DALI_TEST_CHECK( actor );
2750   delete actor;
2751   END_TEST;
2752 }
2753
2754 namespace
2755 {
2756 struct PropertyStringIndex
2757 {
2758   const char * const name;
2759   const Property::Index index;
2760   const Property::Type type;
2761 };
2762
2763 const PropertyStringIndex PROPERTY_TABLE[] =
2764 {
2765   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2766   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2767   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2768   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2769   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2770   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2771   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2772   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2773   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2774   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2775   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2776   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2777   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2778   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2779   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2780   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2781   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2782   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2783   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2784   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2785   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2786   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2787   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2788   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2789   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2790   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2791   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2792   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2793   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2794   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2795   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2796   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2797   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2798   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2799   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2800   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2801   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2802   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2803   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2804   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2805   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2806   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
2807   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
2808   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
2809   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
2810   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
2811   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
2812   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
2813   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
2814   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
2815   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
2816   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
2817   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
2818   { "batchParent",              DevelActor::Property::BATCH_PARENT,        Property::BOOLEAN     },
2819   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
2820 };
2821 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2822 } // unnamed namespace
2823
2824 int UtcDaliActorProperties(void)
2825 {
2826   TestApplication app;
2827
2828   Actor actor = Actor::New();
2829
2830   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2831   {
2832     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2833     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2834     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2835     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2836   }
2837   END_TEST;
2838 }
2839
2840 int UtcDaliRelayoutProperties_ResizePolicies(void)
2841 {
2842   TestApplication app;
2843
2844   Actor actor = Actor::New();
2845
2846   // Defaults
2847   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2848   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2849
2850   // Set resize policy for all dimensions
2851   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2852   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2853   {
2854     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2855   }
2856
2857   // Set individual dimensions
2858   const char* const widthPolicy = "FILL_TO_PARENT";
2859   const char* const heightPolicy = "FIXED";
2860
2861   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2862   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2863
2864   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2865   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2866
2867   END_TEST;
2868 }
2869
2870 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2871 {
2872   TestApplication app;
2873
2874   Actor actor = Actor::New();
2875
2876   // Defaults
2877   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2878   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2879
2880   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2881   actor.SetSizeScalePolicy( policy );
2882   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2883
2884   // Set
2885   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2886   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2887
2888   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2889   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2890
2891   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2892   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2893
2894   END_TEST;
2895 }
2896
2897 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2898 {
2899   TestApplication app;
2900
2901   Actor actor = Actor::New();
2902
2903   // Defaults
2904   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2905   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2906
2907   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2908   actor.SetSizeModeFactor( sizeMode );
2909   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2910
2911   // Set
2912   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2913
2914   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2915   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2916
2917   END_TEST;
2918 }
2919
2920 int UtcDaliRelayoutProperties_DimensionDependency(void)
2921 {
2922   TestApplication app;
2923
2924   Actor actor = Actor::New();
2925
2926   // Defaults
2927   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2928   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2929
2930   // Set
2931   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2932   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2933
2934   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2935   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2936
2937   // Test setting another resize policy
2938   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2939   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2940
2941   END_TEST;
2942 }
2943
2944 int UtcDaliRelayoutProperties_Padding(void)
2945 {
2946   TestApplication app;
2947
2948   Actor actor = Actor::New();
2949
2950   // Data
2951   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2952
2953   // PADDING
2954   actor.SetProperty( Actor::Property::PADDING, padding );
2955   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2956
2957   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2958
2959   END_TEST;
2960 }
2961
2962 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2963 {
2964   TestApplication app;
2965
2966   Actor actor = Actor::New();
2967
2968   // Data
2969   Vector2 minSize( 1.0f, 2.0f );
2970
2971   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2972   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2973
2974   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2975
2976   Vector2 maxSize( 3.0f, 4.0f );
2977
2978   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2979   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2980
2981   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2982
2983   END_TEST;
2984 }
2985
2986 int UtcDaliActorGetHeightForWidth(void)
2987 {
2988   TestApplication app;
2989
2990   Actor actor = Actor::New();
2991
2992   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2993
2994   END_TEST;
2995 }
2996
2997 int UtcDaliActorGetWidthForHeight(void)
2998 {
2999   TestApplication app;
3000
3001   Actor actor = Actor::New();
3002
3003   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3004
3005   END_TEST;
3006 }
3007
3008 int UtcDaliActorGetRelayoutSize(void)
3009 {
3010   TestApplication app;
3011
3012   Actor actor = Actor::New();
3013
3014   // Add actor to stage
3015   Stage::GetCurrent().Add( actor );
3016
3017   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3018
3019   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3020   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3021
3022   // Flush the queue and render once
3023   app.SendNotification();
3024   app.Render();
3025
3026   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3027
3028   END_TEST;
3029 }
3030
3031 int UtcDaliActorSetPadding(void)
3032 {
3033   TestApplication app;
3034
3035   Actor actor = Actor::New();
3036
3037   Padding padding;
3038   actor.GetPadding( padding );
3039
3040   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3041   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3042   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3043   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3044
3045   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3046   actor.SetPadding( padding2 );
3047
3048   actor.GetPadding( padding );
3049
3050   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3051   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3052   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3053   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3054
3055   END_TEST;
3056 }
3057
3058 int UtcDaliActorSetMinimumSize(void)
3059 {
3060   TestApplication app;
3061
3062   Actor actor = Actor::New();
3063
3064   Vector2 size = actor.GetMinimumSize();
3065
3066   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3067   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3068
3069   Vector2 size2( 1.0f, 2.0f );
3070   actor.SetMinimumSize( size2 );
3071
3072   size = actor.GetMinimumSize();
3073
3074   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3075   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3076
3077   END_TEST;
3078 }
3079
3080 int UtcDaliActorSetMaximumSize(void)
3081 {
3082   TestApplication app;
3083
3084   Actor actor = Actor::New();
3085
3086   Vector2 size = actor.GetMaximumSize();
3087
3088   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3089   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3090
3091   Vector2 size2( 1.0f, 2.0f );
3092   actor.SetMaximumSize( size2 );
3093
3094   size = actor.GetMaximumSize();
3095
3096   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3097   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3098
3099   END_TEST;
3100 }
3101
3102 int UtcDaliActorOnRelayoutSignal(void)
3103 {
3104   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3105
3106   TestApplication application;
3107
3108   // Clean test data
3109   gOnRelayoutCallBackCalled = false;
3110   gActorNamesRelayout.clear();
3111
3112   Actor actor = Actor::New();
3113   actor.SetName( "actor" );
3114   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3115
3116   // Sanity check
3117   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3118
3119   // Add actor to stage
3120   Stage::GetCurrent().Add( actor );
3121
3122   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3123   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3124
3125   // Flush the queue and render once
3126   application.SendNotification();
3127   application.Render();
3128
3129   // OnRelayout emitted
3130   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3131   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3132
3133   END_TEST;
3134 }
3135
3136 int UtcDaliActorGetHierachyDepth(void)
3137 {
3138   TestApplication application;
3139   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3140
3141
3142   /* Build tree of actors:
3143    *
3144    *                      Depth
3145    *
3146    *       A (parent)       1
3147    *      / \
3148    *     B   C              2`
3149    *    / \   \
3150    *   D   E   F            3
3151    *
3152    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3153    */
3154   Stage stage( Stage::GetCurrent() );
3155
3156   Actor actorA = Actor::New();
3157   Actor actorB = Actor::New();
3158   Actor actorC = Actor::New();
3159   Actor actorD = Actor::New();
3160   Actor actorE = Actor::New();
3161   Actor actorF = Actor::New();
3162
3163   //Test that root actor has depth equal 0
3164   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3165
3166   //Test actors return depth -1 when not connected to the tree
3167   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3168   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3169   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3170   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3171   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3172   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3173
3174   //Create the hierarchy
3175   stage.Add( actorA );
3176   actorA.Add( actorB );
3177   actorA.Add( actorC );
3178   actorB.Add( actorD );
3179   actorB.Add( actorE );
3180   actorC.Add( actorF );
3181
3182   //Test actors return correct depth
3183   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3184   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3185   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3186   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3187   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3188   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3189
3190   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3191   actorA.Remove( actorB );
3192
3193   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3194   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3195   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3196
3197   //Removing actorA from the stage. All actors should have depth equal -1
3198   stage.Remove( actorA );
3199
3200   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3201   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3202   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3203   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3204   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3205   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3206
3207   END_TEST;
3208 }
3209
3210 int UtcDaliActorAnchorPointPropertyAsString(void)
3211 {
3212   TestApplication application;
3213
3214   Actor actor = Actor::New();
3215
3216   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3217   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3218
3219   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3220   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3221
3222   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3223   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3224
3225   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3226   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3227
3228   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3229   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3230
3231   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3232   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3233
3234   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3235   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3236
3237   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3238   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3239
3240   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3241   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3242
3243   // Invalid should not change anything
3244   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3245   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3246
3247   END_TEST;
3248 }
3249
3250 int UtcDaliActorParentOriginPropertyAsString(void)
3251 {
3252   TestApplication application;
3253
3254   Actor actor = Actor::New();
3255
3256   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3257   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3258
3259   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3260   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3261
3262   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3263   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3264
3265   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3266   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3267
3268   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3269   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3270
3271   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3272   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3273
3274   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3275   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3276
3277   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3278   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3279
3280   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3281   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3282
3283   // Invalid should not change anything
3284   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3285   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3286
3287   END_TEST;
3288 }
3289
3290 int UtcDaliActorColorModePropertyAsString(void)
3291 {
3292   TestApplication application;
3293
3294   Actor actor = Actor::New();
3295
3296   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3297   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3298
3299   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3300   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3301
3302   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3303   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3304
3305   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3306   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3307
3308   // Invalid should not change anything
3309   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3310   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3311
3312   END_TEST;
3313 }
3314
3315 int UtcDaliActorPositionInheritancePropertyAsString(void)
3316 {
3317   TestApplication application;
3318
3319   Actor actor = Actor::New();
3320
3321   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3322   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3323
3324   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3325   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3326
3327   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3328   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3329
3330   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3331   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3332
3333   // Invalid should not change anything
3334   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3335   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3336
3337   END_TEST;
3338 }
3339
3340 int UtcDaliActorDrawModePropertyAsString(void)
3341 {
3342   TestApplication application;
3343
3344   Actor actor = Actor::New();
3345
3346   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3347   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3348
3349   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3350   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3351
3352   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3353   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3354
3355   // Invalid should not change anything
3356   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3357   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3358
3359   END_TEST;
3360 }
3361
3362 int UtcDaliActorAddRendererP(void)
3363 {
3364   tet_infoline("Testing Actor::AddRenderer");
3365   TestApplication application;
3366
3367   Actor actor = Actor::New();
3368
3369   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3370
3371   Geometry geometry = CreateQuadGeometry();
3372   Shader shader = CreateShader();
3373   Renderer renderer = Renderer::New(geometry, shader);
3374
3375   actor.AddRenderer( renderer );
3376   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3377   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3378
3379   END_TEST;
3380 }
3381
3382 int UtcDaliActorAddRendererN(void)
3383 {
3384   tet_infoline("Testing Actor::AddRenderer");
3385   TestApplication application;
3386
3387   Actor actor = Actor::New();
3388   Renderer renderer;
3389
3390   // try illegal Add
3391   try
3392   {
3393     actor.AddRenderer( renderer );
3394     tet_printf("Assertion test failed - no Exception\n" );
3395     tet_result(TET_FAIL);
3396   }
3397   catch(Dali::DaliException& e)
3398   {
3399     DALI_TEST_PRINT_ASSERT( e );
3400     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3401     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3402   }
3403   catch(...)
3404   {
3405     tet_printf("Assertion test failed - wrong Exception\n" );
3406     tet_result(TET_FAIL);
3407   }
3408
3409   END_TEST;
3410 }
3411
3412 int UtcDaliActorAddRendererOnStage(void)
3413 {
3414   tet_infoline("Testing Actor::AddRenderer");
3415   TestApplication application;
3416
3417   Actor actor = Actor::New();
3418   Stage::GetCurrent().Add(actor);
3419
3420   application.SendNotification();
3421   application.Render(0);
3422
3423   Geometry geometry = CreateQuadGeometry();
3424   Shader shader = CreateShader();
3425   Renderer renderer = Renderer::New(geometry, shader);
3426
3427   application.SendNotification();
3428   application.Render(0);
3429
3430   try
3431   {
3432     actor.AddRenderer( renderer );
3433     tet_result(TET_PASS);
3434   }
3435   catch(...)
3436   {
3437     tet_result(TET_FAIL);
3438   }
3439
3440   END_TEST;
3441 }
3442
3443 int UtcDaliActorRemoveRendererP1(void)
3444 {
3445   tet_infoline("Testing Actor::RemoveRenderer");
3446   TestApplication application;
3447
3448   Actor actor = Actor::New();
3449
3450   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3451
3452   Geometry geometry = CreateQuadGeometry();
3453   Shader shader = CreateShader();
3454   Renderer renderer = Renderer::New(geometry, shader);
3455
3456   actor.AddRenderer( renderer );
3457   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3458   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3459
3460   actor.RemoveRenderer(renderer);
3461   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3462
3463
3464   END_TEST;
3465 }
3466
3467 int UtcDaliActorRemoveRendererP2(void)
3468 {
3469   tet_infoline("Testing Actor::RemoveRenderer");
3470   TestApplication application;
3471
3472   Actor actor = Actor::New();
3473
3474   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3475
3476   Geometry geometry = CreateQuadGeometry();
3477   Shader shader = CreateShader();
3478   Renderer renderer = Renderer::New(geometry, shader);
3479
3480   actor.AddRenderer( renderer );
3481   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3482   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3483
3484   actor.RemoveRenderer(0);
3485   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3486
3487
3488   END_TEST;
3489 }
3490
3491
3492 int UtcDaliActorRemoveRendererN(void)
3493 {
3494   tet_infoline("Testing Actor::RemoveRenderer");
3495   TestApplication application;
3496
3497   Actor actor = Actor::New();
3498
3499   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3500
3501   Geometry geometry = CreateQuadGeometry();
3502   Shader shader = CreateShader();
3503   Renderer renderer = Renderer::New(geometry, shader);
3504
3505   actor.AddRenderer( renderer );
3506   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3507   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3508
3509   actor.RemoveRenderer(10);
3510   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3511   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3512
3513   END_TEST;
3514 }
3515
3516 // Clipping test helper functions:
3517 Actor CreateActorWithContent()
3518 {
3519   BufferImage image = BufferImage::New( 16u, 16u );
3520   Actor actor = CreateRenderableActor( image );
3521
3522   // Setup dimensions and position so actor is not skipped by culling.
3523   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3524   actor.SetSize( 16.0f, 16.0f );
3525   actor.SetParentOrigin( ParentOrigin::CENTER );
3526   actor.SetAnchorPoint( AnchorPoint::CENTER );
3527
3528   return actor;
3529 }
3530
3531 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3532 {
3533   enabledDisableTrace.Reset();
3534   stencilTrace.Reset();
3535   enabledDisableTrace.Enable( true );
3536   stencilTrace.Enable( true );
3537
3538   application.SendNotification();
3539   application.Render();
3540
3541   enabledDisableTrace.Enable( false );
3542   stencilTrace.Enable( false );
3543 }
3544
3545 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3546 {
3547   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3548
3549   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3550   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3551   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3552   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3553 }
3554
3555 int UtcDaliActorPropertyClippingP(void)
3556 {
3557   // This test checks the clippingMode property.
3558   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3559   TestApplication application;
3560
3561   Actor actor = Actor::New();
3562
3563   // Check default clippingEnabled value.
3564   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3565
3566   int value = 0;
3567   bool getValueResult = getValue.Get( value );
3568   DALI_TEST_CHECK( getValueResult );
3569
3570   if( getValueResult )
3571   {
3572     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3573   }
3574
3575   // Check setting the property.
3576   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3577
3578   // Check the new value was set.
3579   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3580   getValueResult = getValue.Get( value );
3581   DALI_TEST_CHECK( getValueResult );
3582
3583   if( getValueResult )
3584   {
3585     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3586   }
3587
3588   END_TEST;
3589 }
3590
3591 int UtcDaliActorPropertyClippingN(void)
3592 {
3593   // Negative test case for Clipping.
3594   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3595   TestApplication application;
3596
3597   Actor actor = Actor::New();
3598
3599   // Check default clippingEnabled value.
3600   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3601
3602   int value = 0;
3603   bool getValueResult = getValue.Get( value );
3604   DALI_TEST_CHECK( getValueResult );
3605
3606   if( getValueResult )
3607   {
3608     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3609   }
3610
3611   // Check setting an invalid property value won't change the current property value.
3612   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3613
3614   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3615   getValueResult = getValue.Get( value );
3616   DALI_TEST_CHECK( getValueResult );
3617
3618   if( getValueResult )
3619   {
3620     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3621   }
3622
3623   END_TEST;
3624 }
3625
3626 int UtcDaliActorPropertyClippingActor(void)
3627 {
3628   // This test checks that an actor is correctly setup for clipping.
3629   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3630   TestApplication application;
3631
3632   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3633   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3634   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3635   size_t startIndex = 0u;
3636
3637   // Create a clipping actor.
3638   Actor actorDepth1Clip = CreateActorWithContent();
3639   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3640   Stage::GetCurrent().Add( actorDepth1Clip );
3641
3642   // Gather the call trace.
3643   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3644
3645   // Check we are writing to the color buffer.
3646   CheckColorMask( glAbstraction, true );
3647
3648   // Check the stencil buffer was enabled.
3649   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3650
3651   // Check the stencil buffer was cleared.
3652   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3653
3654   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3655   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3656   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3657   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3658
3659   END_TEST;
3660 }
3661
3662 int UtcDaliActorPropertyClippingNestedChildren(void)
3663 {
3664   // This test checks that a hierarchy of actors are clipped correctly by
3665   // writing to and reading from the correct bit-planes of the stencil buffer.
3666   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3667   TestApplication application;
3668   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3669   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3670   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3671
3672   // Create a clipping actor.
3673   Actor actorDepth1Clip = CreateActorWithContent();
3674   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3675   Stage::GetCurrent().Add( actorDepth1Clip );
3676
3677   // Create a child actor.
3678   Actor childDepth2 = CreateActorWithContent();
3679   actorDepth1Clip.Add( childDepth2 );
3680
3681   // Create another clipping actor.
3682   Actor childDepth2Clip = CreateActorWithContent();
3683   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3684   childDepth2.Add( childDepth2Clip );
3685
3686   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3687   // This tests the sort algorithm.
3688   Actor childDepth3 = CreateActorWithContent();
3689   childDepth2Clip.Add( childDepth3 );
3690   Actor childDepth4 = CreateActorWithContent();
3691   childDepth3.Add( childDepth4 );
3692
3693   // Gather the call trace.
3694   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3695
3696   // Check we are writing to the color buffer.
3697   CheckColorMask( glAbstraction, true );
3698
3699   // Check the stencil buffer was enabled.
3700   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
3701
3702   // Perform the test twice, once for 2D layer, and once for 3D.
3703   for( unsigned int i = 0u ; i < 2u; ++i )
3704   {
3705     size_t startIndex = 0u;
3706
3707     // Check the stencil buffer was cleared.
3708     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3709
3710     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3711     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3712     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
3713     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3714
3715     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3716     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
3717     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3718
3719     // Check we are set up to write to the second bitplane of the stencil buffer (only).
3720     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3721     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
3722     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3723
3724     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
3725     // (Both must be set to pass the check).
3726     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3727     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3728
3729     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
3730     if( i == 0u )
3731     {
3732       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
3733       GenerateTrace( application, enabledDisableTrace, stencilTrace );
3734     }
3735   }
3736
3737   END_TEST;
3738 }
3739
3740 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
3741 {
3742   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
3743   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
3744   TestApplication application;
3745
3746   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3747   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3748   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3749
3750   // Create a clipping actor.
3751   Actor actorDepth1Clip = CreateActorWithContent();
3752   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3753   Stage::GetCurrent().Add( actorDepth1Clip );
3754
3755   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
3756   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
3757
3758   // Gather the call trace.
3759   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3760
3761   // Check we are writing to the color buffer.
3762   CheckColorMask( glAbstraction, true );
3763
3764   // Check the stencil buffer was not enabled.
3765   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
3766
3767   // Check stencil functions are not called.
3768   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
3769   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
3770   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
3771
3772   END_TEST;
3773 }
3774
3775 int UtcDaliGetPropertyN(void)
3776 {
3777   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
3778   TestApplication app;
3779
3780   Actor actor = Actor::New();
3781
3782   unsigned int propertyCount = actor.GetPropertyCount();
3783   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
3784   END_TEST;
3785 }