Merge "Update doxygen comments" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2017 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   // Immediately retrieve the size after setting
725   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
726   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
727
728   // Flush the queue and render once
729   application.SendNotification();
730   application.Render();
731
732   // Check the size in the new frame
733   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
734
735   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
736   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
737
738   // Change the resize policy and check whether the size stays the same
739   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
740
741   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
742   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
743
744   // Set a new size after resize policy is changed and check the new size
745   actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
746
747   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
748   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
749
750   // Change the resize policy again and check whether the new size stays the same
751   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
752
753   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
754   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
755
756   // Set another new size after resize policy is changed and check the new size
757   actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
758
759   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
760   DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
761
762   END_TEST;
763 }
764
765 // SetSize(float width, float height, float depth)
766 int UtcDaliActorSetSize02(void)
767 {
768   TestApplication application;
769
770   Actor actor = Actor::New();
771   Vector3 vector(100.0f, 100.0f, 100.0f);
772
773   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
774
775   actor.SetSize(vector.x, vector.y, vector.z);
776
777   // Immediately check the size after setting
778   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
779   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
780
781   // flush the queue and render once
782   application.SendNotification();
783   application.Render();
784
785   // Check the size in the new frame
786   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
787
788   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
789   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
790
791   END_TEST;
792 }
793
794 // SetSize(Vector2 size)
795 int UtcDaliActorSetSize03(void)
796 {
797   TestApplication application;
798
799   Actor actor = Actor::New();
800   Vector3 vector(100.0f, 100.0f, 0.0f);
801
802   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
803
804   actor.SetSize(Vector2(vector.x, vector.y));
805
806   // Immediately check the size after setting
807   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
808   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
809
810   // flush the queue and render once
811   application.SendNotification();
812   application.Render();
813
814   // Check the size in the new frame
815   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
816
817   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
818   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
819
820   END_TEST;
821 }
822
823 // SetSize(Vector3 size)
824 int UtcDaliActorSetSize04(void)
825 {
826   TestApplication application;
827
828   Actor actor = Actor::New();
829   Vector3 vector(100.0f, 100.0f, 100.0f);
830
831   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
832
833   actor.SetSize(vector);
834
835   // Immediately check the size after setting
836   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
837   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
838
839   // flush the queue and render once
840   application.SendNotification();
841   application.Render();
842
843   // Check the size in the new frame
844   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
845
846   Stage::GetCurrent().Add( actor );
847   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
848
849   // Immediately check the size after setting
850   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
851   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
852
853   // flush the queue and render once
854   application.SendNotification();
855   application.Render();
856
857   // Check the size in the new frame
858   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
859
860   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
861   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
862
863   Stage::GetCurrent().Remove( actor );
864   END_TEST;
865 }
866
867 int UtcDaliActorSetSizeIndividual(void)
868 {
869   TestApplication application;
870
871   Actor actor = Actor::New();
872
873   Vector3 vector(0.7f, 0.8f, 0.9f);
874   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
875
876   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
877
878   // Immediately check the width after setting
879   float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
880   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
881
882   // flush the queue and render once
883   application.SendNotification();
884   application.Render();
885
886   // Check the width in the new frame
887   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
888
889   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
890   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
891
892   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
893
894   // Immediately check the height after setting
895   float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
896   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
897
898   // flush the queue and render once
899   application.SendNotification();
900   application.Render();
901
902   // Check the height in the new frame
903   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
904
905   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
906   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
907
908   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
909
910   // Immediately check the depth after setting
911   float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
912   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
913
914   // flush the queue and render once
915   application.SendNotification();
916   application.Render();
917
918   // Check the depth in the new frame
919   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
920
921   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
922   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
923
924   // Change the resize policy and check whether the size stays the same
925   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
926
927   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
928   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
929
930   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
931   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
932
933   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
934   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
935
936   // Change the resize policy again and check whether the size stays the same
937   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
938
939   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
940   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
941
942   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
943   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
944
945   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
946   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
947
948   END_TEST;
949 }
950
951
952 int UtcDaliActorGetCurrentSize(void)
953 {
954   TestApplication application;
955
956   Actor actor = Actor::New();
957   Vector3 vector(100.0f, 100.0f, 20.0f);
958
959   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
960
961   actor.SetSize(vector);
962
963   // flush the queue and render once
964   application.SendNotification();
965   application.Render();
966
967   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
968   END_TEST;
969 }
970
971 int UtcDaliActorGetNaturalSize(void)
972 {
973   TestApplication application;
974
975   Actor actor = Actor::New();
976   Vector3 vector( 0.0f, 0.0f, 0.0f );
977
978   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
979
980   END_TEST;
981 }
982
983 int UtcDaliActorGetCurrentSizeImmediate(void)
984 {
985   TestApplication application;
986
987   Actor actor = Actor::New();
988   Vector3 vector(100.0f, 100.0f, 20.0f);
989
990   DALI_TEST_CHECK(vector != actor.GetTargetSize());
991   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
992
993   actor.SetSize(vector);
994
995   DALI_TEST_CHECK(vector == actor.GetTargetSize());
996   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
997
998   // flush the queue and render once
999   application.SendNotification();
1000   application.Render();
1001
1002   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1003   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1004
1005   // Animation
1006   // Build the animation
1007   const float durationSeconds = 2.0f;
1008   Animation animation = Animation::New( durationSeconds );
1009   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1010   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1011
1012   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1013
1014   // Start the animation
1015   animation.Play();
1016
1017   application.SendNotification();
1018   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1019
1020   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1021
1022   END_TEST;
1023 }
1024
1025 // SetPosition(float x, float y)
1026 int UtcDaliActorSetPosition01(void)
1027 {
1028   TestApplication application;
1029
1030   Actor actor = Actor::New();
1031
1032   // Set to random to start off with
1033   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1034
1035   Vector3 vector(100.0f, 100.0f, 0.0f);
1036
1037   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1038
1039   actor.SetPosition(vector.x, vector.y);
1040   // flush the queue and render once
1041   application.SendNotification();
1042   application.Render();
1043   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1044
1045   Stage::GetCurrent().Add( actor );
1046   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1047   // flush the queue and render once
1048   application.SendNotification();
1049   application.Render();
1050   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1051
1052   actor.SetX( 1.0f );
1053   actor.SetY( 1.1f );
1054   actor.SetZ( 1.2f );
1055   // flush the queue and render once
1056   application.SendNotification();
1057   application.Render();
1058   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1059
1060   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1061   // flush the queue and render once
1062   application.SendNotification();
1063   application.Render();
1064   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1065
1066   Stage::GetCurrent().Remove( actor );
1067   END_TEST;
1068 }
1069
1070 // SetPosition(float x, float y, float z)
1071 int UtcDaliActorSetPosition02(void)
1072 {
1073   TestApplication application;
1074
1075   Actor actor = Actor::New();
1076
1077   // Set to random to start off with
1078   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1079
1080   Vector3 vector(100.0f, 100.0f, 100.0f);
1081
1082   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1083
1084   actor.SetPosition(vector.x, vector.y, vector.z);
1085
1086   // flush the queue and render once
1087   application.SendNotification();
1088   application.Render();
1089
1090   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1091   END_TEST;
1092 }
1093
1094 // SetPosition(Vector3 position)
1095 int UtcDaliActorSetPosition03(void)
1096 {
1097   TestApplication application;
1098
1099   Actor actor = Actor::New();
1100
1101   // Set to random to start off with
1102   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1103
1104   Vector3 vector(100.0f, 100.0f, 100.0f);
1105
1106   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1107
1108   actor.SetPosition(vector);
1109
1110   // flush the queue and render once
1111   application.SendNotification();
1112   application.Render();
1113
1114   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1115   END_TEST;
1116 }
1117
1118 int UtcDaliActorSetX(void)
1119 {
1120   TestApplication application;
1121
1122   Actor actor = Actor::New();
1123
1124   Vector3 vector(100.0f, 0.0f, 0.0f);
1125
1126   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1127
1128   actor.SetX(100.0f);
1129
1130   // flush the queue and render once
1131   application.SendNotification();
1132   application.Render();
1133
1134   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1135   END_TEST;
1136 }
1137
1138 int UtcDaliActorSetY(void)
1139 {
1140   TestApplication application;
1141
1142   Actor actor = Actor::New();
1143
1144   Vector3 vector(0.0f, 100.0f, 0.0f);
1145
1146   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1147
1148   actor.SetY(100.0f);
1149
1150   // flush the queue and render once
1151   application.SendNotification();
1152   application.Render();
1153
1154   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1155   END_TEST;
1156 }
1157
1158 int UtcDaliActorSetZ(void)
1159 {
1160   TestApplication application;
1161
1162   Actor actor = Actor::New();
1163
1164   Vector3 vector(0.0f, 0.0f, 100.0f);
1165
1166   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1167
1168   actor.SetZ(100.0f);
1169
1170   // flush the queue and render once
1171   application.SendNotification();
1172   application.Render();
1173
1174   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1175   END_TEST;
1176 }
1177
1178 int UtcDaliActorSetPositionProperties(void)
1179 {
1180   TestApplication application;
1181
1182   Actor actor = Actor::New();
1183
1184   Vector3 vector(0.7f, 0.8f, 0.9f);
1185   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1186
1187   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1188
1189   // flush the queue and render once
1190   application.SendNotification();
1191   application.Render();
1192
1193   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1194
1195   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1196
1197   // flush the queue and render once
1198   application.SendNotification();
1199   application.Render();
1200
1201   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1202
1203   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1204
1205   // flush the queue and render once
1206   application.SendNotification();
1207   application.Render();
1208
1209   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1210
1211   END_TEST;
1212 }
1213
1214 int UtcDaliActorTranslateBy(void)
1215 {
1216   TestApplication application;
1217
1218   Actor actor = Actor::New();
1219   Vector3 vector(100.0f, 100.0f, 100.0f);
1220
1221   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1222
1223   actor.SetPosition(vector);
1224
1225   // flush the queue and render once
1226   application.SendNotification();
1227   application.Render();
1228
1229   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1230
1231   actor.TranslateBy(vector);
1232
1233   // flush the queue and render once
1234   application.SendNotification();
1235   application.Render();
1236
1237   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1238   END_TEST;
1239 }
1240
1241 int UtcDaliActorGetCurrentPosition(void)
1242 {
1243   TestApplication application;
1244
1245   Actor actor = Actor::New();
1246   Vector3 setVector(100.0f, 100.0f, 0.0f);
1247   actor.SetPosition(setVector);
1248
1249   // flush the queue and render once
1250   application.SendNotification();
1251   application.Render();
1252
1253   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1254   END_TEST;
1255 }
1256
1257 int UtcDaliActorGetCurrentWorldPosition(void)
1258 {
1259   TestApplication application;
1260
1261   Actor parent = Actor::New();
1262   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1263   parent.SetPosition( parentPosition );
1264   parent.SetParentOrigin( ParentOrigin::CENTER );
1265   parent.SetAnchorPoint( AnchorPoint::CENTER );
1266   Stage::GetCurrent().Add( parent );
1267
1268   Actor child = Actor::New();
1269   child.SetParentOrigin( ParentOrigin::CENTER );
1270   child.SetAnchorPoint( AnchorPoint::CENTER );
1271   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1272   child.SetPosition( childPosition );
1273   parent.Add( child );
1274
1275   // The actors should not have a world position yet
1276   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1277   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1278
1279   application.SendNotification();
1280   application.Render(0);
1281
1282   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1283   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1284
1285   // The actors should have a world position now
1286   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1287   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1288   END_TEST;
1289 }
1290
1291 int UtcDaliActorInheritPosition(void)
1292 {
1293   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1294   TestApplication application;
1295
1296   Actor parent = Actor::New();
1297   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1298   parent.SetPosition( parentPosition );
1299   parent.SetParentOrigin( ParentOrigin::CENTER );
1300   parent.SetAnchorPoint( AnchorPoint::CENTER );
1301   Stage::GetCurrent().Add( parent );
1302
1303   Actor child = Actor::New();
1304   child.SetParentOrigin( ParentOrigin::CENTER );
1305   child.SetAnchorPoint( AnchorPoint::CENTER );
1306   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1307   child.SetPosition( childPosition );
1308   parent.Add( child );
1309
1310   // The actors should not have a world position yet
1311   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1312   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1313
1314   // first test default, which is to inherit position
1315   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1316   application.SendNotification();
1317   application.Render(0); // should only really call Update as Render is not required to update scene
1318   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1319   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1320   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1321   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1322
1323
1324   //Change child position
1325   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1326   child.SetPosition( childOffset );
1327
1328   // Change inheritance mode to not inherit
1329   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1330   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1331   application.SendNotification();
1332   application.Render(0); // should only really call Update as Render is not required to update scene
1333   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1334   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1335   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1336   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1337   END_TEST;
1338 }
1339
1340 int UtcDaliActorSetInheritPosition(void)
1341 {
1342   tet_infoline("Testing Actor::SetInheritPosition");
1343   TestApplication application;
1344
1345   Actor parent = Actor::New();
1346   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1347   parent.SetPosition( parentPosition );
1348   parent.SetParentOrigin( ParentOrigin::CENTER );
1349   parent.SetAnchorPoint( AnchorPoint::CENTER );
1350   Stage::GetCurrent().Add( parent );
1351
1352   Actor child = Actor::New();
1353   child.SetParentOrigin( ParentOrigin::CENTER );
1354   child.SetAnchorPoint( AnchorPoint::CENTER );
1355   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1356   child.SetPosition( childPosition );
1357   parent.Add( child );
1358
1359   // The actors should not have a world position yet
1360   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1361   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1362
1363   // first test default, which is to inherit position
1364   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1365   application.SendNotification();
1366   application.Render(0); // should only really call Update as Render is not required to update scene
1367   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1368   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1369   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1370   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1371
1372   //Change child position
1373   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1374   child.SetPosition( childOffset );
1375
1376   // Use local position as world postion
1377   child.SetInheritPosition( false );
1378   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1379   application.SendNotification();
1380   application.Render(0); // should only really call Update as Render is not required to update scene
1381   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1382   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1383   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1384   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1385
1386   //Change back to inherit position from parent
1387   child.SetInheritPosition( true );
1388   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1389   application.SendNotification();
1390   application.Render(0); // should only really call Update as Render is not required to update scene
1391   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1392   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1393   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1394   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1395   END_TEST;
1396 }
1397
1398 // SetOrientation(float angleRadians, Vector3 axis)
1399 int UtcDaliActorSetOrientation01(void)
1400 {
1401   TestApplication application;
1402
1403   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1404   Actor actor = Actor::New();
1405
1406   actor.SetOrientation(rotation);
1407
1408   // flush the queue and render once
1409   application.SendNotification();
1410   application.Render();
1411
1412   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1413   END_TEST;
1414 }
1415
1416 int UtcDaliActorSetOrientation02(void)
1417 {
1418   TestApplication application;
1419
1420   Actor actor = Actor::New();
1421
1422   Radian angle( 0.785f );
1423   Vector3 axis(1.0f, 1.0f, 0.0f);
1424
1425   actor.SetOrientation( angle, axis);
1426   Quaternion rotation( angle, axis );
1427   // flush the queue and render once
1428   application.SendNotification();
1429   application.Render();
1430   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1431
1432   Stage::GetCurrent().Add( actor );
1433   actor.RotateBy( Degree( 360 ), axis);
1434   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1435
1436   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1437   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1438   // flush the queue and render once
1439   application.SendNotification();
1440   application.Render();
1441   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1442
1443   actor.SetOrientation( angle, axis);
1444   // flush the queue and render once
1445   application.SendNotification();
1446   application.Render();
1447   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1448
1449   Stage::GetCurrent().Remove( actor );
1450   END_TEST;
1451 }
1452
1453 // SetOrientation(float angleRadians, Vector3 axis)
1454 int UtcDaliActorSetOrientationProperty(void)
1455 {
1456   TestApplication application;
1457
1458   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1459   Actor actor = Actor::New();
1460
1461   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1462
1463   // flush the queue and render once
1464   application.SendNotification();
1465   application.Render();
1466
1467   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1468   END_TEST;
1469 }
1470
1471 // RotateBy(float angleRadians, Vector3 axis)
1472 int UtcDaliActorRotateBy01(void)
1473 {
1474   TestApplication application;
1475
1476   Actor actor = Actor::New();
1477
1478   Radian angle( M_PI * 0.25f );
1479   actor.RotateBy(( angle ), Vector3::ZAXIS);
1480   // flush the queue and render once
1481   application.SendNotification();
1482   application.Render();
1483   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1484
1485   Stage::GetCurrent().Add( actor );
1486
1487   actor.RotateBy( angle, Vector3::ZAXIS);
1488   // flush the queue and render once
1489   application.SendNotification();
1490   application.Render();
1491   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1492
1493   Stage::GetCurrent().Remove( actor );
1494   END_TEST;
1495 }
1496
1497 // RotateBy(Quaternion relativeRotation)
1498 int UtcDaliActorRotateBy02(void)
1499 {
1500   TestApplication application;
1501
1502   Actor actor = Actor::New();
1503
1504   Radian angle( M_PI * 0.25f );
1505   Quaternion rotation(angle, Vector3::ZAXIS);
1506   actor.RotateBy(rotation);
1507   // flush the queue and render once
1508   application.SendNotification();
1509   application.Render();
1510   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1511
1512   actor.RotateBy(rotation);
1513   // flush the queue and render once
1514   application.SendNotification();
1515   application.Render();
1516   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1517   END_TEST;
1518 }
1519
1520 int UtcDaliActorGetCurrentOrientation(void)
1521 {
1522   TestApplication application;
1523   Actor actor = Actor::New();
1524
1525   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1526   actor.SetOrientation(rotation);
1527   // flush the queue and render once
1528   application.SendNotification();
1529   application.Render();
1530   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1531   END_TEST;
1532 }
1533
1534 int UtcDaliActorGetCurrentWorldOrientation(void)
1535 {
1536   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1537   TestApplication application;
1538
1539   Actor parent = Actor::New();
1540   Radian rotationAngle( Degree(90.0f) );
1541   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1542   parent.SetOrientation( rotation );
1543   Stage::GetCurrent().Add( parent );
1544
1545   Actor child = Actor::New();
1546   child.SetOrientation( rotation );
1547   parent.Add( child );
1548
1549   // The actors should not have a world rotation yet
1550   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1551   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1552
1553   application.SendNotification();
1554   application.Render(0);
1555
1556   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1557   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1558
1559   // The actors should have a world rotation now
1560   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1561   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1562
1563   // turn off child rotation inheritance
1564   child.SetInheritOrientation( false );
1565   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1566   application.SendNotification();
1567   application.Render(0);
1568
1569   // The actors should have a world rotation now
1570   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1571   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1572   END_TEST;
1573 }
1574
1575 // SetScale(float scale)
1576 int UtcDaliActorSetScale01(void)
1577 {
1578   TestApplication application;
1579
1580   Actor actor = Actor::New();
1581
1582   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1583   actor.SetScale(0.25f);
1584
1585   Vector3 scale(10.0f, 10.0f, 10.0f);
1586   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1587
1588   actor.SetScale(scale.x);
1589
1590   // flush the queue and render once
1591   application.SendNotification();
1592   application.Render();
1593
1594   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1595   END_TEST;
1596 }
1597
1598 // SetScale(float scaleX, float scaleY, float scaleZ)
1599 int UtcDaliActorSetScale02(void)
1600 {
1601   TestApplication application;
1602   Vector3 scale(10.0f, 10.0f, 10.0f);
1603
1604   Actor actor = Actor::New();
1605
1606   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1607   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1608
1609   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1610
1611   actor.SetScale(scale.x, scale.y, scale.z);
1612   // flush the queue and render once
1613   application.SendNotification();
1614   application.Render();
1615   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1616
1617   // add to stage and test
1618   Stage::GetCurrent().Add( actor );
1619   actor.SetScale( 2.0f, 2.0f, 2.0f );
1620   // flush the queue and render once
1621   application.SendNotification();
1622   application.Render();
1623   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1624
1625   Stage::GetCurrent().Remove( actor );
1626
1627   END_TEST;
1628 }
1629
1630 // SetScale(Vector3 scale)
1631 int UtcDaliActorSetScale03(void)
1632 {
1633   TestApplication application;
1634   Vector3 scale(10.0f, 10.0f, 10.0f);
1635
1636   Actor actor = Actor::New();
1637
1638   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1639   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1640
1641   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1642
1643   actor.SetScale(scale);
1644
1645   // flush the queue and render once
1646   application.SendNotification();
1647   application.Render();
1648
1649   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1650   END_TEST;
1651 }
1652
1653 int UtcDaliActorSetScaleIndividual(void)
1654 {
1655   TestApplication application;
1656
1657   Actor actor = Actor::New();
1658
1659   Vector3 vector(0.7f, 0.8f, 0.9f);
1660   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1661
1662   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1663
1664   // flush the queue and render once
1665   application.SendNotification();
1666   application.Render();
1667
1668   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1669
1670   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1671
1672   // flush the queue and render once
1673   application.SendNotification();
1674   application.Render();
1675
1676   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1677
1678   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1679
1680   // flush the queue and render once
1681   application.SendNotification();
1682   application.Render();
1683
1684   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1685
1686   END_TEST;
1687 }
1688
1689 int UtcDaliActorScaleBy(void)
1690 {
1691   TestApplication application;
1692   Actor actor = Actor::New();
1693   Vector3 vector(100.0f, 100.0f, 100.0f);
1694
1695   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1696
1697   actor.SetScale(vector);
1698
1699   // flush the queue and render once
1700   application.SendNotification();
1701   application.Render();
1702
1703   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1704
1705   actor.ScaleBy(vector);
1706
1707   // flush the queue and render once
1708   application.SendNotification();
1709   application.Render();
1710
1711   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1712   END_TEST;
1713 }
1714
1715 int UtcDaliActorGetCurrentScale(void)
1716 {
1717   TestApplication application;
1718   Vector3 scale(12.0f, 1.0f, 2.0f);
1719
1720   Actor actor = Actor::New();
1721
1722   actor.SetScale(scale);
1723
1724   // flush the queue and render once
1725   application.SendNotification();
1726   application.Render();
1727
1728   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1729   END_TEST;
1730 }
1731
1732 int UtcDaliActorGetCurrentWorldScale(void)
1733 {
1734   TestApplication application;
1735
1736   Actor parent = Actor::New();
1737   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1738   parent.SetScale( parentScale );
1739   Stage::GetCurrent().Add( parent );
1740
1741   Actor child = Actor::New();
1742   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1743   child.SetScale( childScale );
1744   parent.Add( child );
1745
1746   // The actors should not have a scale yet
1747   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1748   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1749
1750   // The actors should not have a world scale yet
1751   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1752   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1753
1754   application.SendNotification();
1755   application.Render(0);
1756
1757   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1758   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1759
1760   // The actors should have a world scale now
1761   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1762   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1763   END_TEST;
1764 }
1765
1766 int UtcDaliActorInheritScale(void)
1767 {
1768   tet_infoline("Testing Actor::SetInheritScale");
1769   TestApplication application;
1770
1771   Actor parent = Actor::New();
1772   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1773   parent.SetScale( parentScale );
1774   Stage::GetCurrent().Add( parent );
1775
1776   Actor child = Actor::New();
1777   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1778   child.SetScale( childScale );
1779   parent.Add( child );
1780
1781   application.SendNotification();
1782   application.Render(0);
1783
1784   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1785   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1786
1787   child.SetInheritScale( false );
1788   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1789
1790   application.SendNotification();
1791   application.Render(0);
1792
1793   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1794   END_TEST;
1795 }
1796
1797 int UtcDaliActorSetVisible(void)
1798 {
1799   TestApplication application;
1800
1801   Actor actor = Actor::New();
1802   actor.SetVisible(false);
1803   // flush the queue and render once
1804   application.SendNotification();
1805   application.Render();
1806   DALI_TEST_CHECK(actor.IsVisible() == false);
1807
1808   actor.SetVisible(true);
1809   // flush the queue and render once
1810   application.SendNotification();
1811   application.Render();
1812   DALI_TEST_CHECK(actor.IsVisible() == true);
1813
1814   // put actor on stage
1815   Stage::GetCurrent().Add( actor );
1816   actor.SetVisible(false);
1817   // flush the queue and render once
1818   application.SendNotification();
1819   application.Render();
1820   DALI_TEST_CHECK(actor.IsVisible() == false);
1821   END_TEST;
1822 }
1823
1824 int UtcDaliActorIsVisible(void)
1825 {
1826   TestApplication application;
1827
1828   Actor actor = Actor::New();
1829
1830   DALI_TEST_CHECK(actor.IsVisible() == true);
1831   END_TEST;
1832 }
1833
1834 int UtcDaliActorSetOpacity(void)
1835 {
1836   TestApplication application;
1837
1838   Actor actor = Actor::New();
1839   // initial opacity is 1
1840   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1841
1842   actor.SetOpacity( 0.4f);
1843   // flush the queue and render once
1844   application.SendNotification();
1845   application.Render();
1846   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1847
1848   // change opacity, actor is on stage to change is not immediate
1849   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1850   // flush the queue and render once
1851   application.SendNotification();
1852   application.Render();
1853   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1854
1855   // put actor on stage
1856   Stage::GetCurrent().Add( actor );
1857
1858   // change opacity, actor is on stage to change is not immediate
1859   actor.SetOpacity( 0.9f );
1860   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1861   // flush the queue and render once
1862   application.SendNotification();
1863   application.Render();
1864   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1865
1866   // change opacity, actor is on stage to change is not immediate
1867   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1868   // flush the queue and render once
1869   application.SendNotification();
1870   application.Render();
1871   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1872   END_TEST;
1873 }
1874
1875 int UtcDaliActorGetCurrentOpacity(void)
1876 {
1877   TestApplication application;
1878
1879   Actor actor = Actor::New();
1880   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1881
1882   actor.SetOpacity(0.5f);
1883   // flush the queue and render once
1884   application.SendNotification();
1885   application.Render();
1886   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1887   END_TEST;
1888 }
1889
1890 int UtcDaliActorSetSensitive(void)
1891 {
1892   TestApplication application;
1893   Actor actor = Actor::New();
1894
1895   bool sensitive = !actor.IsSensitive();
1896
1897   actor.SetSensitive(sensitive);
1898
1899   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1900   END_TEST;
1901 }
1902
1903 int UtcDaliActorIsSensitive(void)
1904 {
1905   TestApplication application;
1906   Actor actor = Actor::New();
1907   actor.SetSensitive(false);
1908
1909   DALI_TEST_CHECK(false == actor.IsSensitive());
1910   END_TEST;
1911 }
1912
1913 int UtcDaliActorSetColor(void)
1914 {
1915   TestApplication application;
1916   Actor actor = Actor::New();
1917   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1918
1919   DALI_TEST_CHECK(color != actor.GetCurrentColor());
1920
1921   actor.SetColor(color);
1922   // flush the queue and render once
1923   application.SendNotification();
1924   application.Render();
1925   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1926
1927   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1928   // flush the queue and render once
1929   application.SendNotification();
1930   application.Render();
1931   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
1932
1933   Stage::GetCurrent().Add( actor );
1934   actor.SetColor( color );
1935   // flush the queue and render once
1936   application.SendNotification();
1937   application.Render();
1938   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
1939
1940   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1941   // flush the queue and render once
1942   application.SendNotification();
1943   application.Render();
1944   // Actor color is not clamped
1945   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
1946   // world color is clamped
1947   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
1948
1949   Stage::GetCurrent().Remove( actor );
1950   END_TEST;
1951 }
1952
1953 int UtcDaliActorSetColorIndividual(void)
1954 {
1955   TestApplication application;
1956
1957   Actor actor = Actor::New();
1958
1959   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1960   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1961
1962   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1963
1964   // flush the queue and render once
1965   application.SendNotification();
1966   application.Render();
1967
1968   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1969
1970   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1971
1972   // flush the queue and render once
1973   application.SendNotification();
1974   application.Render();
1975
1976   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1977
1978   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1979
1980   // flush the queue and render once
1981   application.SendNotification();
1982   application.Render();
1983
1984   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1985
1986   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1987
1988   // flush the queue and render once
1989   application.SendNotification();
1990   application.Render();
1991
1992   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1993
1994   END_TEST;
1995 }
1996
1997
1998 int UtcDaliActorGetCurrentColor(void)
1999 {
2000   TestApplication application;
2001   Actor actor = Actor::New();
2002   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2003
2004   actor.SetColor(color);
2005   // flush the queue and render once
2006   application.SendNotification();
2007   application.Render();
2008   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2009   END_TEST;
2010 }
2011
2012 int UtcDaliActorGetCurrentWorldColor(void)
2013 {
2014   tet_infoline("Actor::GetCurrentWorldColor");
2015   TestApplication application;
2016
2017   Actor parent = Actor::New();
2018   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2019   parent.SetColor( parentColor );
2020   Stage::GetCurrent().Add( parent );
2021
2022   Actor child = Actor::New();
2023   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2024   child.SetColor( childColor );
2025   parent.Add( child );
2026
2027   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2028   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2029
2030   // verify the default color mode
2031   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2032
2033   // The actors should not have a world color yet
2034   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2035   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2036
2037   application.SendNotification();
2038   application.Render(0);
2039
2040   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2041   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2042
2043   // The actors should have a world color now
2044   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2045   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2046
2047   // use own color
2048   child.SetColorMode( USE_OWN_COLOR );
2049   application.SendNotification();
2050   application.Render(0);
2051   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2052
2053   // use parent color
2054   child.SetColorMode( USE_PARENT_COLOR );
2055   application.SendNotification();
2056   application.Render(0);
2057   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2058   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2059
2060   // use parent alpha
2061   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2062   application.SendNotification();
2063   application.Render(0);
2064   Vector4 expectedColor( childColor );
2065   expectedColor.a *= parentColor.a;
2066   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2067   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2068   END_TEST;
2069 }
2070
2071 int UtcDaliActorSetColorMode(void)
2072 {
2073   tet_infoline("Actor::SetColorMode");
2074   TestApplication application;
2075   Actor actor = Actor::New();
2076   Actor child = Actor::New();
2077   actor.Add( child );
2078
2079   actor.SetColorMode( USE_OWN_COLOR );
2080   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2081
2082   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2083   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2084
2085   actor.SetColorMode( USE_PARENT_COLOR );
2086   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2087
2088   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2089   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2090   END_TEST;
2091 }
2092
2093 int UtcDaliActorScreenToLocal(void)
2094 {
2095   TestApplication application;
2096   Actor actor = Actor::New();
2097   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2098   actor.SetSize(100.0f, 100.0f);
2099   actor.SetPosition(10.0f, 10.0f);
2100   Stage::GetCurrent().Add(actor);
2101
2102   // flush the queue and render once
2103   application.SendNotification();
2104   application.Render();
2105
2106   float localX;
2107   float localY;
2108
2109   application.SendNotification();
2110   application.Render();
2111
2112   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2113
2114   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2115   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2116   END_TEST;
2117 }
2118
2119 int UtcDaliActorSetLeaveRequired(void)
2120 {
2121   TestApplication application;
2122
2123   Actor actor = Actor::New();
2124
2125   actor.SetLeaveRequired(false);
2126   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2127
2128   actor.SetLeaveRequired(true);
2129   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2130   END_TEST;
2131 }
2132
2133 int UtcDaliActorGetLeaveRequired(void)
2134 {
2135   TestApplication application;
2136
2137   Actor actor = Actor::New();
2138
2139   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2140   END_TEST;
2141 }
2142
2143 int UtcDaliActorSetKeyboardFocusable(void)
2144 {
2145   TestApplication application;
2146
2147   Actor actor = Actor::New();
2148
2149   actor.SetKeyboardFocusable(true);
2150   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2151
2152   actor.SetKeyboardFocusable(false);
2153   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2154   END_TEST;
2155 }
2156
2157 int UtcDaliActorIsKeyboardFocusable(void)
2158 {
2159   TestApplication application;
2160
2161   Actor actor = Actor::New();
2162
2163   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2164   END_TEST;
2165 }
2166
2167 int UtcDaliActorRemoveConstraints(void)
2168 {
2169   tet_infoline(" UtcDaliActorRemoveConstraints");
2170   TestApplication application;
2171
2172   gTestConstraintCalled = false;
2173
2174   Actor actor = Actor::New();
2175
2176   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2177   constraint.Apply();
2178   actor.RemoveConstraints();
2179
2180   DALI_TEST_CHECK( gTestConstraintCalled == false );
2181
2182   Stage::GetCurrent().Add( actor );
2183   constraint.Apply();
2184
2185   // flush the queue and render once
2186   application.SendNotification();
2187   application.Render();
2188
2189   actor.RemoveConstraints();
2190
2191   DALI_TEST_CHECK( gTestConstraintCalled == true );
2192   END_TEST;
2193 }
2194
2195 int UtcDaliActorRemoveConstraintTag(void)
2196 {
2197   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2198   TestApplication application;
2199
2200   Actor actor = Actor::New();
2201
2202   // 1. Apply Constraint1 and Constraint2, and test...
2203   unsigned int result1 = 0u;
2204   unsigned int result2 = 0u;
2205
2206   unsigned constraint1Tag = 1u;
2207   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2208   constraint1.SetTag( constraint1Tag );
2209   constraint1.Apply();
2210
2211   unsigned constraint2Tag = 2u;
2212   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2213   constraint2.SetTag( constraint2Tag );
2214   constraint2.Apply();
2215
2216   Stage::GetCurrent().Add( actor );
2217   // flush the queue and render once
2218   application.SendNotification();
2219   application.Render();
2220
2221   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2222   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2223
2224   // 2. Remove Constraint1 and test...
2225   result1 = 0;
2226   result2 = 0;
2227   actor.RemoveConstraints(constraint1Tag);
2228   // make color property dirty, which will trigger constraints to be reapplied.
2229   actor.SetColor( Color::WHITE );
2230   // flush the queue and render once
2231   application.SendNotification();
2232   application.Render();
2233
2234   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2235   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2236
2237   // 3. Re-Apply Constraint1 and test...
2238   result1 = 0;
2239   result2 = 0;
2240   constraint1.Apply();
2241   // make color property dirty, which will trigger constraints to be reapplied.
2242   actor.SetColor( Color::WHITE );
2243   // flush the queue and render once
2244   application.SendNotification();
2245   application.Render();
2246
2247   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2248   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2249
2250   // 2. Remove Constraint2 and test...
2251   result1 = 0;
2252   result2 = 0;
2253   actor.RemoveConstraints(constraint2Tag);
2254   // make color property dirty, which will trigger constraints to be reapplied.
2255   actor.SetColor( Color::WHITE );
2256   // flush the queue and render once
2257   application.SendNotification();
2258   application.Render();
2259
2260   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2261   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2262
2263   // 2. Remove Constraint1 as well and test...
2264   result1 = 0;
2265   result2 = 0;
2266   actor.RemoveConstraints(constraint1Tag);
2267   // make color property dirty, which will trigger constraints to be reapplied.
2268   actor.SetColor( Color::WHITE );
2269   // flush the queue and render once
2270   application.SendNotification();
2271   application.Render();
2272
2273   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2274   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2275   END_TEST;
2276 }
2277
2278 int UtcDaliActorTouchedSignal(void)
2279 {
2280   TestApplication application;
2281
2282   gTouchCallBackCalled = false;
2283
2284   // get the root layer
2285   Actor actor = Stage::GetCurrent().GetRootLayer();
2286   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2287
2288   application.SendNotification();
2289   application.Render();
2290
2291   // connect to its touch signal
2292   actor.TouchedSignal().Connect( TestCallback );
2293
2294   // simulate a touch event in the middle of the screen
2295   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2296   Dali::Integration::Point point;
2297   point.SetDeviceId( 1 );
2298   point.SetState( PointState::DOWN );
2299   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2300   Dali::Integration::TouchEvent event;
2301   event.AddPoint( point );
2302   application.ProcessEvent( event );
2303
2304   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2305   END_TEST;
2306 }
2307
2308 int UtcDaliActorHoveredSignal(void)
2309 {
2310   TestApplication application;
2311
2312   gHoverCallBackCalled = false;
2313
2314   // get the root layer
2315   Actor actor = Stage::GetCurrent().GetRootLayer();
2316   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2317
2318   application.SendNotification();
2319   application.Render();
2320
2321   // connect to its hover signal
2322   actor.HoveredSignal().Connect( TestCallback3 );
2323
2324   // simulate a hover event in the middle of the screen
2325   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2326   Dali::Integration::Point point;
2327   point.SetDeviceId( 1 );
2328   point.SetState( PointState::MOTION );
2329   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2330   Dali::Integration::HoverEvent event;
2331   event.AddPoint( point );
2332   application.ProcessEvent( event );
2333
2334   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2335   END_TEST;
2336 }
2337
2338 int UtcDaliActorOnOffStageSignal(void)
2339 {
2340   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2341
2342   TestApplication application;
2343
2344   // clean test data
2345   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2346   gActorNamesOnOffStage.clear();
2347
2348   Actor parent = Actor::New();
2349   parent.SetName( "parent" );
2350   parent.OnStageSignal().Connect( OnStageCallback );
2351   parent.OffStageSignal().Connect( OffStageCallback );
2352   // sanity check
2353   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2354   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2355
2356   // add parent to stage
2357   Stage::GetCurrent().Add( parent );
2358   // onstage emitted, offstage not
2359   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2360   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2361   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2362
2363   // test adding a child, should get onstage emitted
2364   // clean test data
2365   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2366   gActorNamesOnOffStage.clear();
2367
2368   Actor child = Actor::New();
2369   child.SetName( "child" );
2370   child.OnStageSignal().Connect( OnStageCallback );
2371   child.OffStageSignal().Connect( OffStageCallback );
2372   parent.Add( child ); // add child
2373   // onstage emitted, offstage not
2374   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2375   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2376   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2377
2378   // test removing parent from stage
2379   // clean test data
2380   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2381   gActorNamesOnOffStage.clear();
2382
2383   Stage::GetCurrent().Remove( parent );
2384   // onstage not emitted, offstage is
2385   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2386   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2387   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2388   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2389
2390   // test adding parent back to stage
2391   // clean test data
2392   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2393   gActorNamesOnOffStage.clear();
2394
2395   Stage::GetCurrent().Add( parent );
2396   // onstage emitted, offstage not
2397   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2398   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2399   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2400   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2401
2402   // test removing child
2403   // clean test data
2404   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2405   gActorNamesOnOffStage.clear();
2406
2407   parent.Remove( child );
2408   // onstage not emitted, offstage is
2409   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2410   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2411   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2412
2413   // test removing parent
2414   // clean test data
2415   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2416   gActorNamesOnOffStage.clear();
2417
2418   Stage::GetCurrent().Remove( parent );
2419   // onstage not emitted, offstage is
2420   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2421   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2422   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2423   END_TEST;
2424 }
2425
2426 int UtcDaliActorFindChildByName(void)
2427 {
2428   tet_infoline("Testing Dali::Actor::FindChildByName()");
2429   TestApplication application;
2430
2431   Actor parent = Actor::New();
2432   parent.SetName( "parent" );
2433   Actor first  = Actor::New();
2434   first .SetName( "first" );
2435   Actor second = Actor::New();
2436   second.SetName( "second" );
2437
2438   parent.Add(first);
2439   first.Add(second);
2440
2441   Actor found = parent.FindChildByName( "foo" );
2442   DALI_TEST_CHECK( !found );
2443
2444   found = parent.FindChildByName( "parent" );
2445   DALI_TEST_CHECK( found == parent );
2446
2447   found = parent.FindChildByName( "first" );
2448   DALI_TEST_CHECK( found == first );
2449
2450   found = parent.FindChildByName( "second" );
2451   DALI_TEST_CHECK( found == second );
2452   END_TEST;
2453 }
2454
2455 int UtcDaliActorFindChildById(void)
2456 {
2457   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2458   TestApplication application;
2459
2460   Actor parent = Actor::New();
2461   Actor first  = Actor::New();
2462   Actor second = Actor::New();
2463
2464   parent.Add(first);
2465   first.Add(second);
2466
2467   Actor found = parent.FindChildById( 100000 );
2468   DALI_TEST_CHECK( !found );
2469
2470   found = parent.FindChildById( parent.GetId() );
2471   DALI_TEST_CHECK( found == parent );
2472
2473   found = parent.FindChildById( first.GetId() );
2474   DALI_TEST_CHECK( found == first );
2475
2476   found = parent.FindChildById( second.GetId() );
2477   DALI_TEST_CHECK( found == second );
2478   END_TEST;
2479 }
2480
2481 int UtcDaliActorHitTest(void)
2482 {
2483   struct HitTestData
2484   {
2485   public:
2486     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2487     : mScale( scale ),
2488       mTouchPoint( touchPoint ),
2489       mResult( result )
2490     {}
2491
2492     Vector3 mScale;
2493     Vector2 mTouchPoint;
2494     bool mResult;
2495   };
2496
2497   TestApplication application;
2498   tet_infoline(" UtcDaliActorHitTest");
2499
2500   // Fill a vector with different hit tests.
2501   struct HitTestData* hitTestData[] = {
2502     //                    scale                     touch point           result
2503     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2504     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2505     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.
2506     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2507     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.
2508     NULL,
2509   };
2510
2511   // get the root layer
2512   Actor actor = Actor::New();
2513   actor.SetAnchorPoint( AnchorPoint::CENTER );
2514   actor.SetParentOrigin( ParentOrigin::CENTER );
2515
2516   Stage::GetCurrent().Add( actor );
2517
2518   gTouchCallBackCalled = false;
2519
2520   unsigned int index = 0;
2521   while( NULL != hitTestData[index] )
2522   {
2523     actor.SetSize( 1.f, 1.f );
2524     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2525
2526     // flush the queue and render once
2527     application.SendNotification();
2528     application.Render();
2529
2530     DALI_TEST_CHECK( !gTouchCallBackCalled );
2531
2532     // connect to its touch signal
2533     actor.TouchedSignal().Connect(TestCallback);
2534
2535     Dali::Integration::Point point;
2536     point.SetState( PointState::DOWN );
2537     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2538     Dali::Integration::TouchEvent event;
2539     event.AddPoint( point );
2540
2541     // flush the queue and render once
2542     application.SendNotification();
2543     application.Render();
2544     application.ProcessEvent( event );
2545
2546     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2547
2548     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2549       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2550                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2551                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2552                  hitTestData[index]->mResult );
2553
2554     gTouchCallBackCalled = false;
2555     ++index;
2556   }
2557   END_TEST;
2558 }
2559
2560 int UtcDaliActorSetDrawMode(void)
2561 {
2562   TestApplication app;
2563   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2564
2565   Actor a = Actor::New();
2566
2567   Stage::GetCurrent().Add(a);
2568   app.SendNotification();
2569   app.Render(0);
2570   app.SendNotification();
2571   app.Render(1);
2572
2573   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2574
2575   a.SetDrawMode( DrawMode::OVERLAY_2D );
2576   app.SendNotification();
2577   app.Render(1);
2578
2579   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2580
2581   a.SetDrawMode( DrawMode::NORMAL );
2582   app.SendNotification();
2583   app.Render(1);
2584
2585   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2586   END_TEST;
2587 }
2588
2589 int UtcDaliActorSetDrawModeOverlayRender(void)
2590 {
2591   TestApplication app;
2592   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2593
2594   app.SendNotification();
2595   app.Render(1);
2596
2597   std::vector<GLuint> ids;
2598   ids.push_back( 8 );   // first rendered actor
2599   ids.push_back( 9 );   // second rendered actor
2600   ids.push_back( 10 );  // third rendered actor
2601   app.GetGlAbstraction().SetNextTextureIds( ids );
2602
2603   BufferImage imageA = BufferImage::New(16, 16);
2604   BufferImage imageB = BufferImage::New(16, 16);
2605   BufferImage imageC = BufferImage::New(16, 16);
2606   Actor a = CreateRenderableActor( imageA );
2607   Actor b = CreateRenderableActor( imageB );
2608   Actor c = CreateRenderableActor( imageC );
2609
2610   app.SendNotification();
2611   app.Render(1);
2612
2613   //Textures are bound when first created. Clear bound textures vector
2614   app.GetGlAbstraction().ClearBoundTextures();
2615
2616   // Render a,b,c as regular non-overlays. so order will be:
2617   // a (8)
2618   // b (9)
2619   // c (10)
2620   Stage::GetCurrent().Add(a);
2621   Stage::GetCurrent().Add(b);
2622   Stage::GetCurrent().Add(c);
2623
2624   app.SendNotification();
2625   app.Render(1);
2626
2627   // Should be 3 textures changes.
2628   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2629   typedef std::vector<GLuint>::size_type TextureSize;
2630   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2631   if( boundTextures.size() == 3 )
2632   {
2633     DALI_TEST_CHECK( boundTextures[0] == 8u );
2634     DALI_TEST_CHECK( boundTextures[1] == 9u );
2635     DALI_TEST_CHECK( boundTextures[2] == 10u );
2636   }
2637
2638   // Now texture ids have been set, we can monitor their render order.
2639   // render a as an overlay (last), so order will be:
2640   // b (9)
2641   // c (10)
2642   // a (8)
2643   a.SetDrawMode( DrawMode::OVERLAY_2D );
2644   app.GetGlAbstraction().ClearBoundTextures();
2645
2646   app.SendNotification();
2647   app.Render(1);
2648
2649   // Should be 3 texture changes.
2650   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2651   if( boundTextures.size() == 3 )
2652   {
2653     DALI_TEST_CHECK( boundTextures[0] == 9u );
2654     DALI_TEST_CHECK( boundTextures[1] == 10u );
2655     DALI_TEST_CHECK( boundTextures[2] == 8u );
2656   }
2657   END_TEST;
2658 }
2659
2660 int UtcDaliActorGetCurrentWorldMatrix(void)
2661 {
2662   TestApplication app;
2663   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2664
2665   Actor parent = Actor::New();
2666   parent.SetParentOrigin(ParentOrigin::CENTER);
2667   parent.SetAnchorPoint(AnchorPoint::CENTER);
2668   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2669   Radian rotationAngle(Degree(85.0f));
2670   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2671   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2672   parent.SetPosition( parentPosition );
2673   parent.SetOrientation( parentRotation );
2674   parent.SetScale( parentScale );
2675   Stage::GetCurrent().Add( parent );
2676
2677   Actor child = Actor::New();
2678   child.SetParentOrigin(ParentOrigin::CENTER);
2679   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2680   Radian childRotationAngle(Degree(23.0f));
2681   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2682   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2683   child.SetPosition( childPosition );
2684   child.SetOrientation( childRotation );
2685   child.SetScale( childScale );
2686   parent.Add( child );
2687
2688   app.SendNotification();
2689   app.Render(0);
2690   app.Render();
2691   app.SendNotification();
2692
2693   Matrix parentMatrix(false);
2694   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2695
2696   Matrix childMatrix(false);
2697   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2698
2699   //Child matrix should be the composition of child and parent
2700   Matrix childWorldMatrix(false);
2701   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2702
2703   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2704   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2705   END_TEST;
2706 }
2707
2708
2709
2710 int UtcDaliActorConstrainedToWorldMatrix(void)
2711 {
2712   TestApplication app;
2713   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2714
2715   Actor parent = Actor::New();
2716   parent.SetParentOrigin(ParentOrigin::CENTER);
2717   parent.SetAnchorPoint(AnchorPoint::CENTER);
2718   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2719   Radian rotationAngle(Degree(85.0f));
2720   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2721   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2722   parent.SetPosition( parentPosition );
2723   parent.SetOrientation( parentRotation );
2724   parent.SetScale( parentScale );
2725   Stage::GetCurrent().Add( parent );
2726
2727   Actor child = Actor::New();
2728   child.SetParentOrigin(ParentOrigin::CENTER);
2729   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2730   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2731   posConstraint.Apply();
2732
2733   Stage::GetCurrent().Add( child );
2734
2735   app.SendNotification();
2736   app.Render(0);
2737   app.Render();
2738   app.SendNotification();
2739
2740   Matrix parentMatrix(false);
2741   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2742
2743   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2744   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2745   END_TEST;
2746 }
2747
2748 int UtcDaliActorConstrainedToOrientation(void)
2749 {
2750   TestApplication app;
2751   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2752
2753   Actor parent = Actor::New();
2754   parent.SetParentOrigin(ParentOrigin::CENTER);
2755   parent.SetAnchorPoint(AnchorPoint::CENTER);
2756   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2757   Radian rotationAngle(Degree(85.0f));
2758   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2759   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2760   parent.SetPosition( parentPosition );
2761   parent.SetOrientation( parentRotation );
2762   parent.SetScale( parentScale );
2763   Stage::GetCurrent().Add( parent );
2764
2765   Actor child = Actor::New();
2766   child.SetParentOrigin(ParentOrigin::CENTER);
2767   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2768   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2769   posConstraint.Apply();
2770
2771   Stage::GetCurrent().Add( child );
2772
2773   app.SendNotification();
2774   app.Render(0);
2775   app.Render();
2776   app.SendNotification();
2777
2778   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2779   END_TEST;
2780 }
2781
2782 int UtcDaliActorUnparent(void)
2783 {
2784   TestApplication app;
2785   tet_infoline(" UtcDaliActorUnparent");
2786
2787   Actor parent = Actor::New();
2788   Stage::GetCurrent().Add( parent );
2789
2790   Actor child = Actor::New();
2791
2792   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2793   DALI_TEST_CHECK( !child.GetParent() );
2794
2795   // Test that calling Unparent with no parent is a NOOP
2796   child.Unparent();
2797
2798   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2799   DALI_TEST_CHECK( !child.GetParent() );
2800
2801   // Test that Unparent works
2802   parent.Add( child );
2803
2804   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2805   DALI_TEST_CHECK( parent == child.GetParent() );
2806
2807   child.Unparent();
2808
2809   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2810   DALI_TEST_CHECK( !child.GetParent() );
2811
2812   // Test that UnparentAndReset works
2813   parent.Add( child );
2814
2815   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2816   DALI_TEST_CHECK( parent == child.GetParent() );
2817
2818   UnparentAndReset( child );
2819
2820   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2821   DALI_TEST_CHECK( !child );
2822
2823   // Test that UnparentAndReset is a NOOP with empty handle
2824   UnparentAndReset( child );
2825
2826   DALI_TEST_CHECK( !child );
2827   END_TEST;
2828 }
2829
2830 int UtcDaliActorGetChildAt(void)
2831 {
2832   TestApplication app;
2833   tet_infoline(" UtcDaliActorGetChildAt");
2834
2835   Actor parent = Actor::New();
2836   Stage::GetCurrent().Add( parent );
2837
2838   Actor child0 = Actor::New();
2839   parent.Add( child0 );
2840
2841   Actor child1 = Actor::New();
2842   parent.Add( child1 );
2843
2844   Actor child2 = Actor::New();
2845   parent.Add( child2 );
2846
2847   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2848   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2849   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2850   END_TEST;
2851 }
2852
2853 int UtcDaliActorSetGetOverlay(void)
2854 {
2855   TestApplication app;
2856   tet_infoline(" UtcDaliActorSetGetOverlay");
2857
2858   Actor parent = Actor::New();
2859   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2860   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2861   END_TEST;
2862 }
2863
2864
2865 int UtcDaliActorCreateDestroy(void)
2866 {
2867   Actor* actor = new Actor;
2868   DALI_TEST_CHECK( actor );
2869   delete actor;
2870   END_TEST;
2871 }
2872
2873 namespace
2874 {
2875 struct PropertyStringIndex
2876 {
2877   const char * const name;
2878   const Property::Index index;
2879   const Property::Type type;
2880 };
2881
2882 const PropertyStringIndex PROPERTY_TABLE[] =
2883 {
2884   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2885   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2886   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2887   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2888   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2889   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2890   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2891   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2892   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2893   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2894   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2895   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2896   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2897   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2898   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2899   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2900   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2901   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2902   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2903   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2904   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2905   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2906   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2907   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2908   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2909   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2910   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2911   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2912   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2913   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2914   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2915   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2916   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2917   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2918   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2919   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2920   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2921   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2922   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2923   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2924   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2925   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
2926   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
2927   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
2928   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
2929   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
2930   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
2931   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
2932   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
2933   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
2934   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
2935   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
2936   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
2937   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
2938 };
2939 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2940 } // unnamed namespace
2941
2942 int UtcDaliActorProperties(void)
2943 {
2944   TestApplication app;
2945
2946   Actor actor = Actor::New();
2947
2948   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2949   {
2950     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2951     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2952     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2953     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2954   }
2955   END_TEST;
2956 }
2957
2958 int UtcDaliRelayoutProperties_ResizePolicies(void)
2959 {
2960   TestApplication app;
2961
2962   Actor actor = Actor::New();
2963
2964   // Defaults
2965   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2966   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2967
2968   // Set resize policy for all dimensions
2969   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2970   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2971   {
2972     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2973   }
2974
2975   // Set individual dimensions
2976   const char* const widthPolicy = "FILL_TO_PARENT";
2977   const char* const heightPolicy = "FIXED";
2978
2979   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2980   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2981
2982   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2983   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2984
2985   // Set individual dimensions using enums
2986   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
2987   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
2988
2989   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
2990   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
2991
2992   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
2993   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
2994
2995   END_TEST;
2996 }
2997
2998 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2999 {
3000   TestApplication app;
3001
3002   Actor actor = Actor::New();
3003
3004   // Defaults
3005   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3006   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3007
3008   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3009   actor.SetSizeScalePolicy( policy );
3010   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3011
3012   // Set
3013   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3014   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3015
3016   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3017   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3018
3019   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3020   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3021
3022   END_TEST;
3023 }
3024
3025 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3026 {
3027   TestApplication app;
3028
3029   Actor actor = Actor::New();
3030
3031   // Defaults
3032   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3033   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3034
3035   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3036   actor.SetSizeModeFactor( sizeMode );
3037   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3038
3039   // Set
3040   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3041
3042   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3043   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3044
3045   END_TEST;
3046 }
3047
3048 int UtcDaliRelayoutProperties_DimensionDependency(void)
3049 {
3050   TestApplication app;
3051
3052   Actor actor = Actor::New();
3053
3054   // Defaults
3055   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3056   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3057
3058   // Set
3059   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3060   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3061
3062   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3063   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3064
3065   // Test setting another resize policy
3066   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3067   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3068
3069   END_TEST;
3070 }
3071
3072 int UtcDaliRelayoutProperties_Padding(void)
3073 {
3074   TestApplication app;
3075
3076   Actor actor = Actor::New();
3077
3078   // Data
3079   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3080
3081   // PADDING
3082   actor.SetProperty( Actor::Property::PADDING, padding );
3083   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3084
3085   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3086
3087   END_TEST;
3088 }
3089
3090 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3091 {
3092   TestApplication app;
3093
3094   Actor actor = Actor::New();
3095
3096   // Data
3097   Vector2 minSize( 1.0f, 2.0f );
3098
3099   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3100   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3101
3102   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3103
3104   Vector2 maxSize( 3.0f, 4.0f );
3105
3106   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3107   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3108
3109   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3110
3111   END_TEST;
3112 }
3113
3114 int UtcDaliActorGetHeightForWidth(void)
3115 {
3116   TestApplication app;
3117
3118   Actor actor = Actor::New();
3119
3120   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3121
3122   END_TEST;
3123 }
3124
3125 int UtcDaliActorGetWidthForHeight(void)
3126 {
3127   TestApplication app;
3128
3129   Actor actor = Actor::New();
3130
3131   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3132
3133   END_TEST;
3134 }
3135
3136 int UtcDaliActorGetRelayoutSize(void)
3137 {
3138   TestApplication app;
3139
3140   Actor actor = Actor::New();
3141
3142   // Add actor to stage
3143   Stage::GetCurrent().Add( actor );
3144
3145   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3146
3147   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3148   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3149
3150   // Flush the queue and render once
3151   app.SendNotification();
3152   app.Render();
3153
3154   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3155
3156   END_TEST;
3157 }
3158
3159 int UtcDaliActorSetPadding(void)
3160 {
3161   TestApplication app;
3162
3163   Actor actor = Actor::New();
3164
3165   Padding padding;
3166   actor.GetPadding( padding );
3167
3168   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3169   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3170   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3171   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3172
3173   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3174   actor.SetPadding( padding2 );
3175
3176   actor.GetPadding( padding );
3177
3178   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3179   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3180   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3181   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3182
3183   END_TEST;
3184 }
3185
3186 int UtcDaliActorSetMinimumSize(void)
3187 {
3188   TestApplication app;
3189
3190   Actor actor = Actor::New();
3191
3192   Vector2 size = actor.GetMinimumSize();
3193
3194   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3195   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3196
3197   Vector2 size2( 1.0f, 2.0f );
3198   actor.SetMinimumSize( size2 );
3199
3200   size = actor.GetMinimumSize();
3201
3202   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3203   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3204
3205   END_TEST;
3206 }
3207
3208 int UtcDaliActorSetMaximumSize(void)
3209 {
3210   TestApplication app;
3211
3212   Actor actor = Actor::New();
3213
3214   Vector2 size = actor.GetMaximumSize();
3215
3216   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3217   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3218
3219   Vector2 size2( 1.0f, 2.0f );
3220   actor.SetMaximumSize( size2 );
3221
3222   size = actor.GetMaximumSize();
3223
3224   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3225   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3226
3227   END_TEST;
3228 }
3229
3230 int UtcDaliActorOnRelayoutSignal(void)
3231 {
3232   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3233
3234   TestApplication application;
3235
3236   // Clean test data
3237   gOnRelayoutCallBackCalled = false;
3238   gActorNamesRelayout.clear();
3239
3240   Actor actor = Actor::New();
3241   actor.SetName( "actor" );
3242   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3243
3244   // Sanity check
3245   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3246
3247   // Add actor to stage
3248   Stage::GetCurrent().Add( actor );
3249
3250   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3251   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3252
3253   // Flush the queue and render once
3254   application.SendNotification();
3255   application.Render();
3256
3257   // OnRelayout emitted
3258   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3259   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3260
3261   END_TEST;
3262 }
3263
3264 int UtcDaliActorGetHierachyDepth(void)
3265 {
3266   TestApplication application;
3267   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3268
3269
3270   /* Build tree of actors:
3271    *
3272    *                      Depth
3273    *
3274    *       A (parent)       1
3275    *      / \
3276    *     B   C              2`
3277    *    / \   \
3278    *   D   E   F            3
3279    *
3280    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3281    */
3282   Stage stage( Stage::GetCurrent() );
3283
3284   Actor actorA = Actor::New();
3285   Actor actorB = Actor::New();
3286   Actor actorC = Actor::New();
3287   Actor actorD = Actor::New();
3288   Actor actorE = Actor::New();
3289   Actor actorF = Actor::New();
3290
3291   //Test that root actor has depth equal 0
3292   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3293
3294   //Test actors return depth -1 when not connected to the tree
3295   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3296   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3297   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3298   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3299   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3300   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3301
3302   //Create the hierarchy
3303   stage.Add( actorA );
3304   actorA.Add( actorB );
3305   actorA.Add( actorC );
3306   actorB.Add( actorD );
3307   actorB.Add( actorE );
3308   actorC.Add( actorF );
3309
3310   //Test actors return correct depth
3311   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3312   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3313   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3314   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3315   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3316   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3317
3318   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3319   actorA.Remove( actorB );
3320
3321   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3322   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3323   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3324
3325   //Removing actorA from the stage. All actors should have depth equal -1
3326   stage.Remove( actorA );
3327
3328   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3329   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3330   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3331   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3332   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3333   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3334
3335   END_TEST;
3336 }
3337
3338 int UtcDaliActorAnchorPointPropertyAsString(void)
3339 {
3340   TestApplication application;
3341
3342   Actor actor = Actor::New();
3343
3344   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3345   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3346
3347   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3348   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3349
3350   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3351   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3352
3353   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3354   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3355
3356   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3357   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3358
3359   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3360   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3361
3362   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3363   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3364
3365   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3366   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3367
3368   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3369   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3370
3371   // Invalid should not change anything
3372   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3373   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3374
3375   END_TEST;
3376 }
3377
3378 int UtcDaliActorParentOriginPropertyAsString(void)
3379 {
3380   TestApplication application;
3381
3382   Actor actor = Actor::New();
3383
3384   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3385   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3386
3387   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3388   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3389
3390   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3391   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3392
3393   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3394   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3395
3396   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3397   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3398
3399   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3400   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3401
3402   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3403   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3404
3405   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3406   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3407
3408   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3409   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3410
3411   // Invalid should not change anything
3412   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3413   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3414
3415   END_TEST;
3416 }
3417
3418 int UtcDaliActorColorModePropertyAsString(void)
3419 {
3420   TestApplication application;
3421
3422   Actor actor = Actor::New();
3423
3424   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3425   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3426
3427   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3428   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3429
3430   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3431   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3432
3433   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3434   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3435
3436   // Invalid should not change anything
3437   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3438   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3439
3440   END_TEST;
3441 }
3442
3443 int UtcDaliActorPositionInheritancePropertyAsString(void)
3444 {
3445   TestApplication application;
3446
3447   Actor actor = Actor::New();
3448
3449   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3450   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3451
3452   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3453   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3454
3455   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3456   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3457
3458   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3459   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3460
3461   // Invalid should not change anything
3462   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3463   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3464
3465   END_TEST;
3466 }
3467
3468 int UtcDaliActorDrawModePropertyAsString(void)
3469 {
3470   TestApplication application;
3471
3472   Actor actor = Actor::New();
3473
3474   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3475   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3476
3477   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3478   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3479
3480   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3481   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3482
3483   // Invalid should not change anything
3484   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3485   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3486
3487   END_TEST;
3488 }
3489
3490 int UtcDaliActorColorModePropertyAsEnum(void)
3491 {
3492   TestApplication application;
3493
3494   Actor actor = Actor::New();
3495
3496   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3497   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3498
3499   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3500   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3501
3502   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3503   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3504
3505   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3506   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3507
3508   END_TEST;
3509 }
3510
3511 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3512 {
3513   TestApplication application;
3514
3515   Actor actor = Actor::New();
3516
3517   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3518   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3519
3520   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3521   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3522
3523   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3524   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3525
3526   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3527   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3528
3529   END_TEST;
3530 }
3531
3532 int UtcDaliActorDrawModePropertyAsEnum(void)
3533 {
3534   TestApplication application;
3535
3536   Actor actor = Actor::New();
3537
3538   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3539   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3540
3541   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3542   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3543
3544   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3545   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3546
3547   END_TEST;
3548 }
3549
3550 int UtcDaliActorAddRendererP(void)
3551 {
3552   tet_infoline("Testing Actor::AddRenderer");
3553   TestApplication application;
3554
3555   Actor actor = Actor::New();
3556
3557   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3558
3559   Geometry geometry = CreateQuadGeometry();
3560   Shader shader = CreateShader();
3561   Renderer renderer = Renderer::New(geometry, shader);
3562
3563   actor.AddRenderer( renderer );
3564   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3565   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3566
3567   END_TEST;
3568 }
3569
3570 int UtcDaliActorAddRendererN(void)
3571 {
3572   tet_infoline("Testing Actor::AddRenderer");
3573   TestApplication application;
3574
3575   Actor actor = Actor::New();
3576   Renderer renderer;
3577
3578   // try illegal Add
3579   try
3580   {
3581     actor.AddRenderer( renderer );
3582     tet_printf("Assertion test failed - no Exception\n" );
3583     tet_result(TET_FAIL);
3584   }
3585   catch(Dali::DaliException& e)
3586   {
3587     DALI_TEST_PRINT_ASSERT( e );
3588     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3589     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3590   }
3591   catch(...)
3592   {
3593     tet_printf("Assertion test failed - wrong Exception\n" );
3594     tet_result(TET_FAIL);
3595   }
3596
3597   END_TEST;
3598 }
3599
3600 int UtcDaliActorAddRendererOnStage(void)
3601 {
3602   tet_infoline("Testing Actor::AddRenderer");
3603   TestApplication application;
3604
3605   Actor actor = Actor::New();
3606   Stage::GetCurrent().Add(actor);
3607
3608   application.SendNotification();
3609   application.Render(0);
3610
3611   Geometry geometry = CreateQuadGeometry();
3612   Shader shader = CreateShader();
3613   Renderer renderer = Renderer::New(geometry, shader);
3614
3615   application.SendNotification();
3616   application.Render(0);
3617
3618   try
3619   {
3620     actor.AddRenderer( renderer );
3621     tet_result(TET_PASS);
3622   }
3623   catch(...)
3624   {
3625     tet_result(TET_FAIL);
3626   }
3627
3628   END_TEST;
3629 }
3630
3631 int UtcDaliActorRemoveRendererP1(void)
3632 {
3633   tet_infoline("Testing Actor::RemoveRenderer");
3634   TestApplication application;
3635
3636   Actor actor = Actor::New();
3637
3638   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3639
3640   Geometry geometry = CreateQuadGeometry();
3641   Shader shader = CreateShader();
3642   Renderer renderer = Renderer::New(geometry, shader);
3643
3644   actor.AddRenderer( renderer );
3645   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3646   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3647
3648   actor.RemoveRenderer(renderer);
3649   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3650
3651
3652   END_TEST;
3653 }
3654
3655 int UtcDaliActorRemoveRendererP2(void)
3656 {
3657   tet_infoline("Testing Actor::RemoveRenderer");
3658   TestApplication application;
3659
3660   Actor actor = Actor::New();
3661
3662   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3663
3664   Geometry geometry = CreateQuadGeometry();
3665   Shader shader = CreateShader();
3666   Renderer renderer = Renderer::New(geometry, shader);
3667
3668   actor.AddRenderer( renderer );
3669   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3670   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3671
3672   actor.RemoveRenderer(0);
3673   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3674
3675
3676   END_TEST;
3677 }
3678
3679
3680 int UtcDaliActorRemoveRendererN(void)
3681 {
3682   tet_infoline("Testing Actor::RemoveRenderer");
3683   TestApplication application;
3684
3685   Actor actor = Actor::New();
3686
3687   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3688
3689   Geometry geometry = CreateQuadGeometry();
3690   Shader shader = CreateShader();
3691   Renderer renderer = Renderer::New(geometry, shader);
3692
3693   actor.AddRenderer( renderer );
3694   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3695   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3696
3697   actor.RemoveRenderer(10);
3698   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3699   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3700
3701   END_TEST;
3702 }
3703
3704 // Clipping test helper functions:
3705 Actor CreateActorWithContent()
3706 {
3707   BufferImage image = BufferImage::New( 16u, 16u );
3708   Actor actor = CreateRenderableActor( image );
3709
3710   // Setup dimensions and position so actor is not skipped by culling.
3711   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3712   actor.SetSize( 16.0f, 16.0f );
3713   actor.SetParentOrigin( ParentOrigin::CENTER );
3714   actor.SetAnchorPoint( AnchorPoint::CENTER );
3715
3716   return actor;
3717 }
3718
3719 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3720 {
3721   enabledDisableTrace.Reset();
3722   stencilTrace.Reset();
3723   enabledDisableTrace.Enable( true );
3724   stencilTrace.Enable( true );
3725
3726   application.SendNotification();
3727   application.Render();
3728
3729   enabledDisableTrace.Enable( false );
3730   stencilTrace.Enable( false );
3731 }
3732
3733 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3734 {
3735   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3736
3737   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3738   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3739   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3740   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3741 }
3742
3743 int UtcDaliActorPropertyClippingP(void)
3744 {
3745   // This test checks the clippingMode property.
3746   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3747   TestApplication application;
3748
3749   Actor actor = Actor::New();
3750
3751   // Check default clippingEnabled value.
3752   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3753
3754   int value = 0;
3755   bool getValueResult = getValue.Get( value );
3756   DALI_TEST_CHECK( getValueResult );
3757
3758   if( getValueResult )
3759   {
3760     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3761   }
3762
3763   // Check setting the property.
3764   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3765
3766   // Check the new value was set.
3767   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3768   getValueResult = getValue.Get( value );
3769   DALI_TEST_CHECK( getValueResult );
3770
3771   if( getValueResult )
3772   {
3773     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3774   }
3775
3776   END_TEST;
3777 }
3778
3779 int UtcDaliActorPropertyClippingN(void)
3780 {
3781   // Negative test case for Clipping.
3782   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3783   TestApplication application;
3784
3785   Actor actor = Actor::New();
3786
3787   // Check default clippingEnabled value.
3788   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3789
3790   int value = 0;
3791   bool getValueResult = getValue.Get( value );
3792   DALI_TEST_CHECK( getValueResult );
3793
3794   if( getValueResult )
3795   {
3796     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3797   }
3798
3799   // Check setting an invalid property value won't change the current property value.
3800   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3801
3802   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3803   getValueResult = getValue.Get( value );
3804   DALI_TEST_CHECK( getValueResult );
3805
3806   if( getValueResult )
3807   {
3808     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3809   }
3810
3811   END_TEST;
3812 }
3813
3814 int UtcDaliActorPropertyClippingActor(void)
3815 {
3816   // This test checks that an actor is correctly setup for clipping.
3817   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3818   TestApplication application;
3819
3820   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3821   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3822   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3823   size_t startIndex = 0u;
3824
3825   // Create a clipping actor.
3826   Actor actorDepth1Clip = CreateActorWithContent();
3827   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3828   Stage::GetCurrent().Add( actorDepth1Clip );
3829
3830   // Gather the call trace.
3831   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3832
3833   // Check we are writing to the color buffer.
3834   CheckColorMask( glAbstraction, true );
3835
3836   // Check the stencil buffer was enabled.
3837   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3838
3839   // Check the stencil buffer was cleared.
3840   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3841
3842   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3843   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3844   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3845   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3846
3847   END_TEST;
3848 }
3849
3850 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3851 {
3852   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3853   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3854   TestApplication application;
3855
3856   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3857   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3858   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3859   size_t startIndex = 0u;
3860
3861   // Create a clipping actor.
3862   Actor actorDepth1Clip = CreateActorWithContent();
3863   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3864   Stage::GetCurrent().Add( actorDepth1Clip );
3865
3866   // Gather the call trace.
3867   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3868
3869   // Check we are writing to the color buffer.
3870   CheckColorMask( glAbstraction, true );
3871
3872   // Check the stencil buffer was enabled.
3873   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3874
3875   // Check the stencil buffer was cleared.
3876   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3877
3878   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3879   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3880   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3881   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3882
3883   // Now disable the clipping
3884   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3885
3886   // Gather the call trace.
3887   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3888
3889   // Check the stencil buffer was disabled.
3890   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3891
3892   // Ensure all values in stencil-mask are set to 1.
3893   startIndex = 0u;
3894   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3895
3896   END_TEST;
3897 }
3898
3899
3900 int UtcDaliActorPropertyClippingNestedChildren(void)
3901 {
3902   // This test checks that a hierarchy of actors are clipped correctly by
3903   // writing to and reading from the correct bit-planes of the stencil buffer.
3904   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3905   TestApplication application;
3906   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3907   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3908   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3909
3910   // Create a clipping actor.
3911   Actor actorDepth1Clip = CreateActorWithContent();
3912   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3913   Stage::GetCurrent().Add( actorDepth1Clip );
3914
3915   // Create a child actor.
3916   Actor childDepth2 = CreateActorWithContent();
3917   actorDepth1Clip.Add( childDepth2 );
3918
3919   // Create another clipping actor.
3920   Actor childDepth2Clip = CreateActorWithContent();
3921   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3922   childDepth2.Add( childDepth2Clip );
3923
3924   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3925   // This tests the sort algorithm.
3926   Actor childDepth3 = CreateActorWithContent();
3927   childDepth2Clip.Add( childDepth3 );
3928   Actor childDepth4 = CreateActorWithContent();
3929   childDepth3.Add( childDepth4 );
3930
3931   // Gather the call trace.
3932   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3933
3934   // Check we are writing to the color buffer.
3935   CheckColorMask( glAbstraction, true );
3936
3937   // Check the stencil buffer was enabled.
3938   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
3939
3940   // Perform the test twice, once for 2D layer, and once for 3D.
3941   for( unsigned int i = 0u ; i < 2u; ++i )
3942   {
3943     size_t startIndex = 0u;
3944
3945     // Check the stencil buffer was cleared.
3946     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3947
3948     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3949     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3950     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
3951     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3952
3953     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3954     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
3955     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3956
3957     // Check we are set up to write to the second bitplane of the stencil buffer (only).
3958     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3959     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
3960     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3961
3962     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
3963     // (Both must be set to pass the check).
3964     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3965     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3966
3967     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
3968     if( i == 0u )
3969     {
3970       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
3971       GenerateTrace( application, enabledDisableTrace, stencilTrace );
3972     }
3973   }
3974
3975   END_TEST;
3976 }
3977
3978 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
3979 {
3980   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
3981   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
3982   TestApplication application;
3983
3984   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3985   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3986   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3987
3988   // Create a clipping actor.
3989   Actor actorDepth1Clip = CreateActorWithContent();
3990   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3991   Stage::GetCurrent().Add( actorDepth1Clip );
3992
3993   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
3994   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
3995
3996   // Gather the call trace.
3997   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3998
3999   // Check we are writing to the color buffer.
4000   CheckColorMask( glAbstraction, true );
4001
4002   // Check the stencil buffer was not enabled.
4003   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4004
4005   // Check stencil functions are not called.
4006   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4007   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4008   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4009
4010   END_TEST;
4011 }
4012
4013 int UtcDaliGetPropertyN(void)
4014 {
4015   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4016   TestApplication app;
4017
4018   Actor actor = Actor::New();
4019
4020   unsigned int propertyCount = actor.GetPropertyCount();
4021   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4022   END_TEST;
4023 }