Merge "Removed redundant resource loading & rendering code" 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   actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
1995
1996   // flush the queue and render once
1997   application.SendNotification();
1998   application.Render();
1999
2000   DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2001
2002   END_TEST;
2003 }
2004
2005
2006 int UtcDaliActorGetCurrentColor(void)
2007 {
2008   TestApplication application;
2009   Actor actor = Actor::New();
2010   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2011
2012   actor.SetColor(color);
2013   // flush the queue and render once
2014   application.SendNotification();
2015   application.Render();
2016   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2017   END_TEST;
2018 }
2019
2020 int UtcDaliActorGetCurrentWorldColor(void)
2021 {
2022   tet_infoline("Actor::GetCurrentWorldColor");
2023   TestApplication application;
2024
2025   Actor parent = Actor::New();
2026   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2027   parent.SetColor( parentColor );
2028   Stage::GetCurrent().Add( parent );
2029
2030   Actor child = Actor::New();
2031   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2032   child.SetColor( childColor );
2033   parent.Add( child );
2034
2035   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2036   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2037
2038   // verify the default color mode
2039   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2040
2041   // The actors should not have a world color yet
2042   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2043   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2044
2045   application.SendNotification();
2046   application.Render(0);
2047
2048   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2049   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2050
2051   // The actors should have a world color now
2052   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2053   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2054
2055   // use own color
2056   child.SetColorMode( USE_OWN_COLOR );
2057   application.SendNotification();
2058   application.Render(0);
2059   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2060
2061   // use parent color
2062   child.SetColorMode( USE_PARENT_COLOR );
2063   application.SendNotification();
2064   application.Render(0);
2065   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2066   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2067
2068   // use parent alpha
2069   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2070   application.SendNotification();
2071   application.Render(0);
2072   Vector4 expectedColor( childColor );
2073   expectedColor.a *= parentColor.a;
2074   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2075   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2076   END_TEST;
2077 }
2078
2079 int UtcDaliActorSetColorMode(void)
2080 {
2081   tet_infoline("Actor::SetColorMode");
2082   TestApplication application;
2083   Actor actor = Actor::New();
2084   Actor child = Actor::New();
2085   actor.Add( child );
2086
2087   actor.SetColorMode( USE_OWN_COLOR );
2088   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2089
2090   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2091   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2092
2093   actor.SetColorMode( USE_PARENT_COLOR );
2094   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2095
2096   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2097   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2098   END_TEST;
2099 }
2100
2101 int UtcDaliActorScreenToLocal(void)
2102 {
2103   TestApplication application;
2104   Actor actor = Actor::New();
2105   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2106   actor.SetSize(100.0f, 100.0f);
2107   actor.SetPosition(10.0f, 10.0f);
2108   Stage::GetCurrent().Add(actor);
2109
2110   // flush the queue and render once
2111   application.SendNotification();
2112   application.Render();
2113
2114   float localX;
2115   float localY;
2116
2117   application.SendNotification();
2118   application.Render();
2119
2120   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2121
2122   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2123   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2124   END_TEST;
2125 }
2126
2127 int UtcDaliActorSetLeaveRequired(void)
2128 {
2129   TestApplication application;
2130
2131   Actor actor = Actor::New();
2132
2133   actor.SetLeaveRequired(false);
2134   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2135
2136   actor.SetLeaveRequired(true);
2137   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2138   END_TEST;
2139 }
2140
2141 int UtcDaliActorGetLeaveRequired(void)
2142 {
2143   TestApplication application;
2144
2145   Actor actor = Actor::New();
2146
2147   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2148   END_TEST;
2149 }
2150
2151 int UtcDaliActorSetKeyboardFocusable(void)
2152 {
2153   TestApplication application;
2154
2155   Actor actor = Actor::New();
2156
2157   actor.SetKeyboardFocusable(true);
2158   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2159
2160   actor.SetKeyboardFocusable(false);
2161   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2162   END_TEST;
2163 }
2164
2165 int UtcDaliActorIsKeyboardFocusable(void)
2166 {
2167   TestApplication application;
2168
2169   Actor actor = Actor::New();
2170
2171   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2172   END_TEST;
2173 }
2174
2175 int UtcDaliActorRemoveConstraints(void)
2176 {
2177   tet_infoline(" UtcDaliActorRemoveConstraints");
2178   TestApplication application;
2179
2180   gTestConstraintCalled = false;
2181
2182   Actor actor = Actor::New();
2183
2184   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2185   constraint.Apply();
2186   actor.RemoveConstraints();
2187
2188   DALI_TEST_CHECK( gTestConstraintCalled == false );
2189
2190   Stage::GetCurrent().Add( actor );
2191   constraint.Apply();
2192
2193   // flush the queue and render once
2194   application.SendNotification();
2195   application.Render();
2196
2197   actor.RemoveConstraints();
2198
2199   DALI_TEST_CHECK( gTestConstraintCalled == true );
2200   END_TEST;
2201 }
2202
2203 int UtcDaliActorRemoveConstraintTag(void)
2204 {
2205   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2206   TestApplication application;
2207
2208   Actor actor = Actor::New();
2209
2210   // 1. Apply Constraint1 and Constraint2, and test...
2211   unsigned int result1 = 0u;
2212   unsigned int result2 = 0u;
2213
2214   unsigned constraint1Tag = 1u;
2215   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2216   constraint1.SetTag( constraint1Tag );
2217   constraint1.Apply();
2218
2219   unsigned constraint2Tag = 2u;
2220   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2221   constraint2.SetTag( constraint2Tag );
2222   constraint2.Apply();
2223
2224   Stage::GetCurrent().Add( actor );
2225   // flush the queue and render once
2226   application.SendNotification();
2227   application.Render();
2228
2229   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2230   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2231
2232   // 2. Remove Constraint1 and test...
2233   result1 = 0;
2234   result2 = 0;
2235   actor.RemoveConstraints(constraint1Tag);
2236   // make color property dirty, which will trigger constraints to be reapplied.
2237   actor.SetColor( Color::WHITE );
2238   // flush the queue and render once
2239   application.SendNotification();
2240   application.Render();
2241
2242   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2243   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2244
2245   // 3. Re-Apply Constraint1 and test...
2246   result1 = 0;
2247   result2 = 0;
2248   constraint1.Apply();
2249   // make color property dirty, which will trigger constraints to be reapplied.
2250   actor.SetColor( Color::WHITE );
2251   // flush the queue and render once
2252   application.SendNotification();
2253   application.Render();
2254
2255   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2256   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2257
2258   // 2. Remove Constraint2 and test...
2259   result1 = 0;
2260   result2 = 0;
2261   actor.RemoveConstraints(constraint2Tag);
2262   // make color property dirty, which will trigger constraints to be reapplied.
2263   actor.SetColor( Color::WHITE );
2264   // flush the queue and render once
2265   application.SendNotification();
2266   application.Render();
2267
2268   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2269   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2270
2271   // 2. Remove Constraint1 as well and test...
2272   result1 = 0;
2273   result2 = 0;
2274   actor.RemoveConstraints(constraint1Tag);
2275   // make color property dirty, which will trigger constraints to be reapplied.
2276   actor.SetColor( Color::WHITE );
2277   // flush the queue and render once
2278   application.SendNotification();
2279   application.Render();
2280
2281   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2282   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2283   END_TEST;
2284 }
2285
2286 int UtcDaliActorTouchedSignal(void)
2287 {
2288   TestApplication application;
2289
2290   gTouchCallBackCalled = false;
2291
2292   // get the root layer
2293   Actor actor = Stage::GetCurrent().GetRootLayer();
2294   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2295
2296   application.SendNotification();
2297   application.Render();
2298
2299   // connect to its touch signal
2300   actor.TouchedSignal().Connect( TestCallback );
2301
2302   // simulate a touch event in the middle of the screen
2303   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2304   Dali::Integration::Point point;
2305   point.SetDeviceId( 1 );
2306   point.SetState( PointState::DOWN );
2307   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2308   Dali::Integration::TouchEvent event;
2309   event.AddPoint( point );
2310   application.ProcessEvent( event );
2311
2312   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2313   END_TEST;
2314 }
2315
2316 int UtcDaliActorHoveredSignal(void)
2317 {
2318   TestApplication application;
2319
2320   gHoverCallBackCalled = false;
2321
2322   // get the root layer
2323   Actor actor = Stage::GetCurrent().GetRootLayer();
2324   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2325
2326   application.SendNotification();
2327   application.Render();
2328
2329   // connect to its hover signal
2330   actor.HoveredSignal().Connect( TestCallback3 );
2331
2332   // simulate a hover event in the middle of the screen
2333   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2334   Dali::Integration::Point point;
2335   point.SetDeviceId( 1 );
2336   point.SetState( PointState::MOTION );
2337   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2338   Dali::Integration::HoverEvent event;
2339   event.AddPoint( point );
2340   application.ProcessEvent( event );
2341
2342   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2343   END_TEST;
2344 }
2345
2346 int UtcDaliActorOnOffStageSignal(void)
2347 {
2348   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2349
2350   TestApplication application;
2351
2352   // clean test data
2353   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2354   gActorNamesOnOffStage.clear();
2355
2356   Actor parent = Actor::New();
2357   parent.SetName( "parent" );
2358   parent.OnStageSignal().Connect( OnStageCallback );
2359   parent.OffStageSignal().Connect( OffStageCallback );
2360   // sanity check
2361   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2362   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2363
2364   // add parent to stage
2365   Stage::GetCurrent().Add( parent );
2366   // onstage emitted, offstage not
2367   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2368   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2369   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2370
2371   // test adding a child, should get onstage emitted
2372   // clean test data
2373   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2374   gActorNamesOnOffStage.clear();
2375
2376   Actor child = Actor::New();
2377   child.SetName( "child" );
2378   child.OnStageSignal().Connect( OnStageCallback );
2379   child.OffStageSignal().Connect( OffStageCallback );
2380   parent.Add( child ); // add child
2381   // onstage emitted, offstage not
2382   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2383   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2384   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2385
2386   // test removing parent from stage
2387   // clean test data
2388   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2389   gActorNamesOnOffStage.clear();
2390
2391   Stage::GetCurrent().Remove( parent );
2392   // onstage not emitted, offstage is
2393   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2394   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2395   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2396   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2397
2398   // test adding parent back to stage
2399   // clean test data
2400   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2401   gActorNamesOnOffStage.clear();
2402
2403   Stage::GetCurrent().Add( parent );
2404   // onstage emitted, offstage not
2405   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2406   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2407   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2408   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2409
2410   // test removing child
2411   // clean test data
2412   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2413   gActorNamesOnOffStage.clear();
2414
2415   parent.Remove( child );
2416   // onstage not emitted, offstage is
2417   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2418   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2419   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2420
2421   // test removing parent
2422   // clean test data
2423   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2424   gActorNamesOnOffStage.clear();
2425
2426   Stage::GetCurrent().Remove( parent );
2427   // onstage not emitted, offstage is
2428   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2429   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2430   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2431   END_TEST;
2432 }
2433
2434 int UtcDaliActorFindChildByName(void)
2435 {
2436   tet_infoline("Testing Dali::Actor::FindChildByName()");
2437   TestApplication application;
2438
2439   Actor parent = Actor::New();
2440   parent.SetName( "parent" );
2441   Actor first  = Actor::New();
2442   first .SetName( "first" );
2443   Actor second = Actor::New();
2444   second.SetName( "second" );
2445
2446   parent.Add(first);
2447   first.Add(second);
2448
2449   Actor found = parent.FindChildByName( "foo" );
2450   DALI_TEST_CHECK( !found );
2451
2452   found = parent.FindChildByName( "parent" );
2453   DALI_TEST_CHECK( found == parent );
2454
2455   found = parent.FindChildByName( "first" );
2456   DALI_TEST_CHECK( found == first );
2457
2458   found = parent.FindChildByName( "second" );
2459   DALI_TEST_CHECK( found == second );
2460   END_TEST;
2461 }
2462
2463 int UtcDaliActorFindChildById(void)
2464 {
2465   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2466   TestApplication application;
2467
2468   Actor parent = Actor::New();
2469   Actor first  = Actor::New();
2470   Actor second = Actor::New();
2471
2472   parent.Add(first);
2473   first.Add(second);
2474
2475   Actor found = parent.FindChildById( 100000 );
2476   DALI_TEST_CHECK( !found );
2477
2478   found = parent.FindChildById( parent.GetId() );
2479   DALI_TEST_CHECK( found == parent );
2480
2481   found = parent.FindChildById( first.GetId() );
2482   DALI_TEST_CHECK( found == first );
2483
2484   found = parent.FindChildById( second.GetId() );
2485   DALI_TEST_CHECK( found == second );
2486   END_TEST;
2487 }
2488
2489 int UtcDaliActorHitTest(void)
2490 {
2491   struct HitTestData
2492   {
2493   public:
2494     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2495     : mScale( scale ),
2496       mTouchPoint( touchPoint ),
2497       mResult( result )
2498     {}
2499
2500     Vector3 mScale;
2501     Vector2 mTouchPoint;
2502     bool mResult;
2503   };
2504
2505   TestApplication application;
2506   tet_infoline(" UtcDaliActorHitTest");
2507
2508   // Fill a vector with different hit tests.
2509   struct HitTestData* hitTestData[] = {
2510     //                    scale                     touch point           result
2511     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2512     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2513     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.
2514     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2515     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.
2516     NULL,
2517   };
2518
2519   // get the root layer
2520   Actor actor = Actor::New();
2521   actor.SetAnchorPoint( AnchorPoint::CENTER );
2522   actor.SetParentOrigin( ParentOrigin::CENTER );
2523
2524   Stage::GetCurrent().Add( actor );
2525
2526   gTouchCallBackCalled = false;
2527
2528   unsigned int index = 0;
2529   while( NULL != hitTestData[index] )
2530   {
2531     actor.SetSize( 1.f, 1.f );
2532     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2533
2534     // flush the queue and render once
2535     application.SendNotification();
2536     application.Render();
2537
2538     DALI_TEST_CHECK( !gTouchCallBackCalled );
2539
2540     // connect to its touch signal
2541     actor.TouchedSignal().Connect(TestCallback);
2542
2543     Dali::Integration::Point point;
2544     point.SetState( PointState::DOWN );
2545     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2546     Dali::Integration::TouchEvent event;
2547     event.AddPoint( point );
2548
2549     // flush the queue and render once
2550     application.SendNotification();
2551     application.Render();
2552     application.ProcessEvent( event );
2553
2554     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2555
2556     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2557       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2558                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2559                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2560                  hitTestData[index]->mResult );
2561
2562     gTouchCallBackCalled = false;
2563     ++index;
2564   }
2565   END_TEST;
2566 }
2567
2568 int UtcDaliActorSetDrawMode(void)
2569 {
2570   TestApplication app;
2571   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2572
2573   Actor a = Actor::New();
2574
2575   Stage::GetCurrent().Add(a);
2576   app.SendNotification();
2577   app.Render(0);
2578   app.SendNotification();
2579   app.Render(1);
2580
2581   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2582
2583   a.SetDrawMode( DrawMode::OVERLAY_2D );
2584   app.SendNotification();
2585   app.Render(1);
2586
2587   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2588
2589   a.SetDrawMode( DrawMode::NORMAL );
2590   app.SendNotification();
2591   app.Render(1);
2592
2593   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2594   END_TEST;
2595 }
2596
2597 int UtcDaliActorSetDrawModeOverlayRender(void)
2598 {
2599   TestApplication app;
2600   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2601
2602   app.SendNotification();
2603   app.Render(1);
2604
2605   std::vector<GLuint> ids;
2606   ids.push_back( 8 );   // first rendered actor
2607   ids.push_back( 9 );   // second rendered actor
2608   ids.push_back( 10 );  // third rendered actor
2609   app.GetGlAbstraction().SetNextTextureIds( ids );
2610
2611   BufferImage imageA = BufferImage::New(16, 16);
2612   BufferImage imageB = BufferImage::New(16, 16);
2613   BufferImage imageC = BufferImage::New(16, 16);
2614   Actor a = CreateRenderableActor( imageA );
2615   Actor b = CreateRenderableActor( imageB );
2616   Actor c = CreateRenderableActor( imageC );
2617
2618   app.SendNotification();
2619   app.Render(1);
2620
2621   //Textures are bound when first created. Clear bound textures vector
2622   app.GetGlAbstraction().ClearBoundTextures();
2623
2624   // Render a,b,c as regular non-overlays. so order will be:
2625   // a (8)
2626   // b (9)
2627   // c (10)
2628   Stage::GetCurrent().Add(a);
2629   Stage::GetCurrent().Add(b);
2630   Stage::GetCurrent().Add(c);
2631
2632   app.SendNotification();
2633   app.Render(1);
2634
2635   // Should be 3 textures changes.
2636   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2637   typedef std::vector<GLuint>::size_type TextureSize;
2638   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2639   if( boundTextures.size() == 3 )
2640   {
2641     DALI_TEST_CHECK( boundTextures[0] == 8u );
2642     DALI_TEST_CHECK( boundTextures[1] == 9u );
2643     DALI_TEST_CHECK( boundTextures[2] == 10u );
2644   }
2645
2646   // Now texture ids have been set, we can monitor their render order.
2647   // render a as an overlay (last), so order will be:
2648   // b (9)
2649   // c (10)
2650   // a (8)
2651   a.SetDrawMode( DrawMode::OVERLAY_2D );
2652   app.GetGlAbstraction().ClearBoundTextures();
2653
2654   app.SendNotification();
2655   app.Render(1);
2656
2657   // Should be 3 texture changes.
2658   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2659   if( boundTextures.size() == 3 )
2660   {
2661     DALI_TEST_CHECK( boundTextures[0] == 9u );
2662     DALI_TEST_CHECK( boundTextures[1] == 10u );
2663     DALI_TEST_CHECK( boundTextures[2] == 8u );
2664   }
2665   END_TEST;
2666 }
2667
2668 int UtcDaliActorGetCurrentWorldMatrix(void)
2669 {
2670   TestApplication app;
2671   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2672
2673   Actor parent = Actor::New();
2674   parent.SetParentOrigin(ParentOrigin::CENTER);
2675   parent.SetAnchorPoint(AnchorPoint::CENTER);
2676   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2677   Radian rotationAngle(Degree(85.0f));
2678   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2679   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2680   parent.SetPosition( parentPosition );
2681   parent.SetOrientation( parentRotation );
2682   parent.SetScale( parentScale );
2683   Stage::GetCurrent().Add( parent );
2684
2685   Actor child = Actor::New();
2686   child.SetParentOrigin(ParentOrigin::CENTER);
2687   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2688   Radian childRotationAngle(Degree(23.0f));
2689   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2690   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2691   child.SetPosition( childPosition );
2692   child.SetOrientation( childRotation );
2693   child.SetScale( childScale );
2694   parent.Add( child );
2695
2696   app.SendNotification();
2697   app.Render(0);
2698   app.Render();
2699   app.SendNotification();
2700
2701   Matrix parentMatrix(false);
2702   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2703
2704   Matrix childMatrix(false);
2705   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2706
2707   //Child matrix should be the composition of child and parent
2708   Matrix childWorldMatrix(false);
2709   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2710
2711   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2712   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2713   END_TEST;
2714 }
2715
2716
2717
2718 int UtcDaliActorConstrainedToWorldMatrix(void)
2719 {
2720   TestApplication app;
2721   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2722
2723   Actor parent = Actor::New();
2724   parent.SetParentOrigin(ParentOrigin::CENTER);
2725   parent.SetAnchorPoint(AnchorPoint::CENTER);
2726   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2727   Radian rotationAngle(Degree(85.0f));
2728   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2729   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2730   parent.SetPosition( parentPosition );
2731   parent.SetOrientation( parentRotation );
2732   parent.SetScale( parentScale );
2733   Stage::GetCurrent().Add( parent );
2734
2735   Actor child = Actor::New();
2736   child.SetParentOrigin(ParentOrigin::CENTER);
2737   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2738   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2739   posConstraint.Apply();
2740
2741   Stage::GetCurrent().Add( child );
2742
2743   app.SendNotification();
2744   app.Render(0);
2745   app.Render();
2746   app.SendNotification();
2747
2748   Matrix parentMatrix(false);
2749   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2750
2751   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2752   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2753   END_TEST;
2754 }
2755
2756 int UtcDaliActorConstrainedToOrientation(void)
2757 {
2758   TestApplication app;
2759   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2760
2761   Actor parent = Actor::New();
2762   parent.SetParentOrigin(ParentOrigin::CENTER);
2763   parent.SetAnchorPoint(AnchorPoint::CENTER);
2764   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2765   Radian rotationAngle(Degree(85.0f));
2766   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2767   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2768   parent.SetPosition( parentPosition );
2769   parent.SetOrientation( parentRotation );
2770   parent.SetScale( parentScale );
2771   Stage::GetCurrent().Add( parent );
2772
2773   Actor child = Actor::New();
2774   child.SetParentOrigin(ParentOrigin::CENTER);
2775   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2776   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2777   posConstraint.Apply();
2778
2779   Stage::GetCurrent().Add( child );
2780
2781   app.SendNotification();
2782   app.Render(0);
2783   app.Render();
2784   app.SendNotification();
2785
2786   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2787   END_TEST;
2788 }
2789
2790 int UtcDaliActorConstrainedToOpacity(void)
2791 {
2792   TestApplication app;
2793   tet_infoline(" UtcDaliActorConstrainedToOpacity");
2794
2795   Actor parent = Actor::New();
2796   parent.SetOpacity( 0.7f );
2797   Stage::GetCurrent().Add( parent );
2798
2799   Actor child = Actor::New();
2800   Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2801   opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2802   opacityConstraint.Apply();
2803
2804   Stage::GetCurrent().Add( child );
2805
2806   app.SendNotification();
2807   app.Render(0);
2808   app.Render();
2809   app.SendNotification();
2810
2811   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2812
2813   parent.SetOpacity( 0.3f );
2814
2815   app.SendNotification();
2816   app.Render(0);
2817   app.Render();
2818   app.SendNotification();
2819
2820   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2821
2822   END_TEST;
2823 }
2824
2825 int UtcDaliActorUnparent(void)
2826 {
2827   TestApplication app;
2828   tet_infoline(" UtcDaliActorUnparent");
2829
2830   Actor parent = Actor::New();
2831   Stage::GetCurrent().Add( parent );
2832
2833   Actor child = Actor::New();
2834
2835   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2836   DALI_TEST_CHECK( !child.GetParent() );
2837
2838   // Test that calling Unparent with no parent is a NOOP
2839   child.Unparent();
2840
2841   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2842   DALI_TEST_CHECK( !child.GetParent() );
2843
2844   // Test that Unparent works
2845   parent.Add( child );
2846
2847   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2848   DALI_TEST_CHECK( parent == child.GetParent() );
2849
2850   child.Unparent();
2851
2852   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2853   DALI_TEST_CHECK( !child.GetParent() );
2854
2855   // Test that UnparentAndReset works
2856   parent.Add( child );
2857
2858   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2859   DALI_TEST_CHECK( parent == child.GetParent() );
2860
2861   UnparentAndReset( child );
2862
2863   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2864   DALI_TEST_CHECK( !child );
2865
2866   // Test that UnparentAndReset is a NOOP with empty handle
2867   UnparentAndReset( child );
2868
2869   DALI_TEST_CHECK( !child );
2870   END_TEST;
2871 }
2872
2873 int UtcDaliActorGetChildAt(void)
2874 {
2875   TestApplication app;
2876   tet_infoline(" UtcDaliActorGetChildAt");
2877
2878   Actor parent = Actor::New();
2879   Stage::GetCurrent().Add( parent );
2880
2881   Actor child0 = Actor::New();
2882   parent.Add( child0 );
2883
2884   Actor child1 = Actor::New();
2885   parent.Add( child1 );
2886
2887   Actor child2 = Actor::New();
2888   parent.Add( child2 );
2889
2890   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2891   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2892   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2893   END_TEST;
2894 }
2895
2896 int UtcDaliActorSetGetOverlay(void)
2897 {
2898   TestApplication app;
2899   tet_infoline(" UtcDaliActorSetGetOverlay");
2900
2901   Actor parent = Actor::New();
2902   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2903   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2904   END_TEST;
2905 }
2906
2907
2908 int UtcDaliActorCreateDestroy(void)
2909 {
2910   Actor* actor = new Actor;
2911   DALI_TEST_CHECK( actor );
2912   delete actor;
2913   END_TEST;
2914 }
2915
2916 namespace
2917 {
2918 struct PropertyStringIndex
2919 {
2920   const char * const name;
2921   const Property::Index index;
2922   const Property::Type type;
2923 };
2924
2925 const PropertyStringIndex PROPERTY_TABLE[] =
2926 {
2927   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2928   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2929   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2930   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2931   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2932   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2933   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2934   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2935   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2936   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2937   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2938   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2939   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2940   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2941   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2942   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2943   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2944   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2945   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2946   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2947   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2948   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2949   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2950   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2951   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2952   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2953   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2954   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2955   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2956   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2957   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2958   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2959   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2960   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2961   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2962   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2963   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2964   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2965   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2966   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2967   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2968   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
2969   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
2970   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
2971   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
2972   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
2973   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
2974   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
2975   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
2976   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
2977   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
2978   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
2979   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
2980   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
2981   { "opacity",                  DevelActor::Property::OPACITY,             Property::FLOAT       },
2982 };
2983 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2984 } // unnamed namespace
2985
2986 int UtcDaliActorProperties(void)
2987 {
2988   TestApplication app;
2989
2990   Actor actor = Actor::New();
2991
2992   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2993   {
2994     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2995     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2996     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2997     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2998   }
2999   END_TEST;
3000 }
3001
3002 int UtcDaliRelayoutProperties_ResizePolicies(void)
3003 {
3004   TestApplication app;
3005
3006   Actor actor = Actor::New();
3007
3008   // Defaults
3009   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3010   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3011
3012   // Set resize policy for all dimensions
3013   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3014   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3015   {
3016     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3017   }
3018
3019   // Set individual dimensions
3020   const char* const widthPolicy = "FILL_TO_PARENT";
3021   const char* const heightPolicy = "FIXED";
3022
3023   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3024   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3025
3026   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3027   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3028
3029   // Set individual dimensions using enums
3030   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3031   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3032
3033   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3034   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3035
3036   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3037   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3038
3039   END_TEST;
3040 }
3041
3042 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3043 {
3044   TestApplication app;
3045
3046   Actor actor = Actor::New();
3047
3048   // Defaults
3049   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3050   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3051
3052   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3053   actor.SetSizeScalePolicy( policy );
3054   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3055
3056   // Set
3057   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3058   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3059
3060   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3061   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3062
3063   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3064   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3065
3066   END_TEST;
3067 }
3068
3069 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3070 {
3071   TestApplication app;
3072
3073   Actor actor = Actor::New();
3074
3075   // Defaults
3076   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3077   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3078
3079   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3080   actor.SetSizeModeFactor( sizeMode );
3081   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3082
3083   // Set
3084   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3085
3086   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3087   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3088
3089   END_TEST;
3090 }
3091
3092 int UtcDaliRelayoutProperties_DimensionDependency(void)
3093 {
3094   TestApplication app;
3095
3096   Actor actor = Actor::New();
3097
3098   // Defaults
3099   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3100   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3101
3102   // Set
3103   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3104   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3105
3106   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3107   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3108
3109   // Test setting another resize policy
3110   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3111   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3112
3113   END_TEST;
3114 }
3115
3116 int UtcDaliRelayoutProperties_Padding(void)
3117 {
3118   TestApplication app;
3119
3120   Actor actor = Actor::New();
3121
3122   // Data
3123   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3124
3125   // PADDING
3126   actor.SetProperty( Actor::Property::PADDING, padding );
3127   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3128
3129   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3130
3131   END_TEST;
3132 }
3133
3134 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3135 {
3136   TestApplication app;
3137
3138   Actor actor = Actor::New();
3139
3140   // Data
3141   Vector2 minSize( 1.0f, 2.0f );
3142
3143   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3144   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3145
3146   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3147
3148   Vector2 maxSize( 3.0f, 4.0f );
3149
3150   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3151   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3152
3153   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3154
3155   END_TEST;
3156 }
3157
3158 int UtcDaliActorGetHeightForWidth(void)
3159 {
3160   TestApplication app;
3161
3162   Actor actor = Actor::New();
3163
3164   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3165
3166   END_TEST;
3167 }
3168
3169 int UtcDaliActorGetWidthForHeight(void)
3170 {
3171   TestApplication app;
3172
3173   Actor actor = Actor::New();
3174
3175   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3176
3177   END_TEST;
3178 }
3179
3180 int UtcDaliActorGetRelayoutSize(void)
3181 {
3182   TestApplication app;
3183
3184   Actor actor = Actor::New();
3185
3186   // Add actor to stage
3187   Stage::GetCurrent().Add( actor );
3188
3189   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3190
3191   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3192   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3193
3194   // Flush the queue and render once
3195   app.SendNotification();
3196   app.Render();
3197
3198   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3199
3200   END_TEST;
3201 }
3202
3203 int UtcDaliActorSetPadding(void)
3204 {
3205   TestApplication app;
3206
3207   Actor actor = Actor::New();
3208
3209   Padding padding;
3210   actor.GetPadding( padding );
3211
3212   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3213   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3214   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3215   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3216
3217   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3218   actor.SetPadding( padding2 );
3219
3220   actor.GetPadding( padding );
3221
3222   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3223   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3224   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3225   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3226
3227   END_TEST;
3228 }
3229
3230 int UtcDaliActorSetMinimumSize(void)
3231 {
3232   TestApplication app;
3233
3234   Actor actor = Actor::New();
3235
3236   Vector2 size = actor.GetMinimumSize();
3237
3238   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3239   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3240
3241   Vector2 size2( 1.0f, 2.0f );
3242   actor.SetMinimumSize( size2 );
3243
3244   size = actor.GetMinimumSize();
3245
3246   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3247   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3248
3249   END_TEST;
3250 }
3251
3252 int UtcDaliActorSetMaximumSize(void)
3253 {
3254   TestApplication app;
3255
3256   Actor actor = Actor::New();
3257
3258   Vector2 size = actor.GetMaximumSize();
3259
3260   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3261   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3262
3263   Vector2 size2( 1.0f, 2.0f );
3264   actor.SetMaximumSize( size2 );
3265
3266   size = actor.GetMaximumSize();
3267
3268   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3269   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3270
3271   END_TEST;
3272 }
3273
3274 int UtcDaliActorOnRelayoutSignal(void)
3275 {
3276   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3277
3278   TestApplication application;
3279
3280   // Clean test data
3281   gOnRelayoutCallBackCalled = false;
3282   gActorNamesRelayout.clear();
3283
3284   Actor actor = Actor::New();
3285   actor.SetName( "actor" );
3286   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3287
3288   // Sanity check
3289   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3290
3291   // Add actor to stage
3292   Stage::GetCurrent().Add( actor );
3293
3294   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3295   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3296
3297   // Flush the queue and render once
3298   application.SendNotification();
3299   application.Render();
3300
3301   // OnRelayout emitted
3302   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3303   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3304
3305   END_TEST;
3306 }
3307
3308 int UtcDaliActorGetHierachyDepth(void)
3309 {
3310   TestApplication application;
3311   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3312
3313
3314   /* Build tree of actors:
3315    *
3316    *                      Depth
3317    *
3318    *       A (parent)       1
3319    *      / \
3320    *     B   C              2`
3321    *    / \   \
3322    *   D   E   F            3
3323    *
3324    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3325    */
3326   Stage stage( Stage::GetCurrent() );
3327
3328   Actor actorA = Actor::New();
3329   Actor actorB = Actor::New();
3330   Actor actorC = Actor::New();
3331   Actor actorD = Actor::New();
3332   Actor actorE = Actor::New();
3333   Actor actorF = Actor::New();
3334
3335   //Test that root actor has depth equal 0
3336   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3337
3338   //Test actors return depth -1 when not connected to the tree
3339   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3340   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3341   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3342   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3343   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3344   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3345
3346   //Create the hierarchy
3347   stage.Add( actorA );
3348   actorA.Add( actorB );
3349   actorA.Add( actorC );
3350   actorB.Add( actorD );
3351   actorB.Add( actorE );
3352   actorC.Add( actorF );
3353
3354   //Test actors return correct depth
3355   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3356   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3357   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3358   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3359   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3360   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3361
3362   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3363   actorA.Remove( actorB );
3364
3365   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3366   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3367   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3368
3369   //Removing actorA from the stage. All actors should have depth equal -1
3370   stage.Remove( actorA );
3371
3372   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3373   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3374   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3375   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3376   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3377   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3378
3379   END_TEST;
3380 }
3381
3382 int UtcDaliActorAnchorPointPropertyAsString(void)
3383 {
3384   TestApplication application;
3385
3386   Actor actor = Actor::New();
3387
3388   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3389   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3390
3391   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3392   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3393
3394   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3395   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3396
3397   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3398   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3399
3400   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3401   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3402
3403   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3404   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3405
3406   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3407   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3408
3409   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3410   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3411
3412   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3413   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3414
3415   // Invalid should not change anything
3416   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3417   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3418
3419   END_TEST;
3420 }
3421
3422 int UtcDaliActorParentOriginPropertyAsString(void)
3423 {
3424   TestApplication application;
3425
3426   Actor actor = Actor::New();
3427
3428   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3429   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3430
3431   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3432   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3433
3434   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3435   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3436
3437   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3438   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3439
3440   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3441   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3442
3443   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3444   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3445
3446   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3447   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3448
3449   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3450   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3451
3452   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3453   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3454
3455   // Invalid should not change anything
3456   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3457   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3458
3459   END_TEST;
3460 }
3461
3462 int UtcDaliActorColorModePropertyAsString(void)
3463 {
3464   TestApplication application;
3465
3466   Actor actor = Actor::New();
3467
3468   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3469   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3470
3471   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3472   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3473
3474   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3475   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3476
3477   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3478   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3479
3480   // Invalid should not change anything
3481   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3482   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3483
3484   END_TEST;
3485 }
3486
3487 int UtcDaliActorPositionInheritancePropertyAsString(void)
3488 {
3489   TestApplication application;
3490
3491   Actor actor = Actor::New();
3492
3493   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3494   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3495
3496   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3497   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3498
3499   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3500   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3501
3502   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3503   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3504
3505   // Invalid should not change anything
3506   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3507   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3508
3509   END_TEST;
3510 }
3511
3512 int UtcDaliActorDrawModePropertyAsString(void)
3513 {
3514   TestApplication application;
3515
3516   Actor actor = Actor::New();
3517
3518   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3519   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3520
3521   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3522   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3523
3524   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3525   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3526
3527   // Invalid should not change anything
3528   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3529   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3530
3531   END_TEST;
3532 }
3533
3534 int UtcDaliActorColorModePropertyAsEnum(void)
3535 {
3536   TestApplication application;
3537
3538   Actor actor = Actor::New();
3539
3540   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3541   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3542
3543   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3544   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3545
3546   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3547   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3548
3549   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3550   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3551
3552   END_TEST;
3553 }
3554
3555 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3556 {
3557   TestApplication application;
3558
3559   Actor actor = Actor::New();
3560
3561   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3562   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3563
3564   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3565   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3566
3567   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3568   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3569
3570   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3571   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3572
3573   END_TEST;
3574 }
3575
3576 int UtcDaliActorDrawModePropertyAsEnum(void)
3577 {
3578   TestApplication application;
3579
3580   Actor actor = Actor::New();
3581
3582   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3583   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3584
3585   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3586   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3587
3588   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3589   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3590
3591   END_TEST;
3592 }
3593
3594 int UtcDaliActorAddRendererP(void)
3595 {
3596   tet_infoline("Testing Actor::AddRenderer");
3597   TestApplication application;
3598
3599   Actor actor = Actor::New();
3600
3601   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3602
3603   Geometry geometry = CreateQuadGeometry();
3604   Shader shader = CreateShader();
3605   Renderer renderer = Renderer::New(geometry, shader);
3606
3607   actor.AddRenderer( renderer );
3608   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3609   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3610
3611   END_TEST;
3612 }
3613
3614 int UtcDaliActorAddRendererN(void)
3615 {
3616   tet_infoline("Testing Actor::AddRenderer");
3617   TestApplication application;
3618
3619   Actor actor = Actor::New();
3620   Renderer renderer;
3621
3622   // try illegal Add
3623   try
3624   {
3625     actor.AddRenderer( renderer );
3626     tet_printf("Assertion test failed - no Exception\n" );
3627     tet_result(TET_FAIL);
3628   }
3629   catch(Dali::DaliException& e)
3630   {
3631     DALI_TEST_PRINT_ASSERT( e );
3632     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3633     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3634   }
3635   catch(...)
3636   {
3637     tet_printf("Assertion test failed - wrong Exception\n" );
3638     tet_result(TET_FAIL);
3639   }
3640
3641   END_TEST;
3642 }
3643
3644 int UtcDaliActorAddRendererOnStage(void)
3645 {
3646   tet_infoline("Testing Actor::AddRenderer");
3647   TestApplication application;
3648
3649   Actor actor = Actor::New();
3650   Stage::GetCurrent().Add(actor);
3651
3652   application.SendNotification();
3653   application.Render(0);
3654
3655   Geometry geometry = CreateQuadGeometry();
3656   Shader shader = CreateShader();
3657   Renderer renderer = Renderer::New(geometry, shader);
3658
3659   application.SendNotification();
3660   application.Render(0);
3661
3662   try
3663   {
3664     actor.AddRenderer( renderer );
3665     tet_result(TET_PASS);
3666   }
3667   catch(...)
3668   {
3669     tet_result(TET_FAIL);
3670   }
3671
3672   END_TEST;
3673 }
3674
3675 int UtcDaliActorRemoveRendererP1(void)
3676 {
3677   tet_infoline("Testing Actor::RemoveRenderer");
3678   TestApplication application;
3679
3680   Actor actor = Actor::New();
3681
3682   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3683
3684   Geometry geometry = CreateQuadGeometry();
3685   Shader shader = CreateShader();
3686   Renderer renderer = Renderer::New(geometry, shader);
3687
3688   actor.AddRenderer( renderer );
3689   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3690   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3691
3692   actor.RemoveRenderer(renderer);
3693   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3694
3695
3696   END_TEST;
3697 }
3698
3699 int UtcDaliActorRemoveRendererP2(void)
3700 {
3701   tet_infoline("Testing Actor::RemoveRenderer");
3702   TestApplication application;
3703
3704   Actor actor = Actor::New();
3705
3706   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3707
3708   Geometry geometry = CreateQuadGeometry();
3709   Shader shader = CreateShader();
3710   Renderer renderer = Renderer::New(geometry, shader);
3711
3712   actor.AddRenderer( renderer );
3713   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3714   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3715
3716   actor.RemoveRenderer(0);
3717   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3718
3719
3720   END_TEST;
3721 }
3722
3723
3724 int UtcDaliActorRemoveRendererN(void)
3725 {
3726   tet_infoline("Testing Actor::RemoveRenderer");
3727   TestApplication application;
3728
3729   Actor actor = Actor::New();
3730
3731   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3732
3733   Geometry geometry = CreateQuadGeometry();
3734   Shader shader = CreateShader();
3735   Renderer renderer = Renderer::New(geometry, shader);
3736
3737   actor.AddRenderer( renderer );
3738   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3739   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3740
3741   actor.RemoveRenderer(10);
3742   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3743   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3744
3745   END_TEST;
3746 }
3747
3748 // Clipping test helper functions:
3749 Actor CreateActorWithContent()
3750 {
3751   BufferImage image = BufferImage::New( 16u, 16u );
3752   Actor actor = CreateRenderableActor( image );
3753
3754   // Setup dimensions and position so actor is not skipped by culling.
3755   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3756   actor.SetSize( 16.0f, 16.0f );
3757   actor.SetParentOrigin( ParentOrigin::CENTER );
3758   actor.SetAnchorPoint( AnchorPoint::CENTER );
3759
3760   return actor;
3761 }
3762
3763 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3764 {
3765   enabledDisableTrace.Reset();
3766   stencilTrace.Reset();
3767   enabledDisableTrace.Enable( true );
3768   stencilTrace.Enable( true );
3769
3770   application.SendNotification();
3771   application.Render();
3772
3773   enabledDisableTrace.Enable( false );
3774   stencilTrace.Enable( false );
3775 }
3776
3777 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3778 {
3779   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3780
3781   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3782   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3783   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3784   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3785 }
3786
3787 int UtcDaliActorPropertyClippingP(void)
3788 {
3789   // This test checks the clippingMode property.
3790   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3791   TestApplication application;
3792
3793   Actor actor = Actor::New();
3794
3795   // Check default clippingEnabled value.
3796   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3797
3798   int value = 0;
3799   bool getValueResult = getValue.Get( value );
3800   DALI_TEST_CHECK( getValueResult );
3801
3802   if( getValueResult )
3803   {
3804     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3805   }
3806
3807   // Check setting the property.
3808   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3809
3810   // Check the new value was set.
3811   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3812   getValueResult = getValue.Get( value );
3813   DALI_TEST_CHECK( getValueResult );
3814
3815   if( getValueResult )
3816   {
3817     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3818   }
3819
3820   END_TEST;
3821 }
3822
3823 int UtcDaliActorPropertyClippingN(void)
3824 {
3825   // Negative test case for Clipping.
3826   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3827   TestApplication application;
3828
3829   Actor actor = Actor::New();
3830
3831   // Check default clippingEnabled value.
3832   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3833
3834   int value = 0;
3835   bool getValueResult = getValue.Get( value );
3836   DALI_TEST_CHECK( getValueResult );
3837
3838   if( getValueResult )
3839   {
3840     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3841   }
3842
3843   // Check setting an invalid property value won't change the current property value.
3844   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3845
3846   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3847   getValueResult = getValue.Get( value );
3848   DALI_TEST_CHECK( getValueResult );
3849
3850   if( getValueResult )
3851   {
3852     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3853   }
3854
3855   END_TEST;
3856 }
3857
3858 int UtcDaliActorPropertyClippingActor(void)
3859 {
3860   // This test checks that an actor is correctly setup for clipping.
3861   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3862   TestApplication application;
3863
3864   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3865   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3866   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3867   size_t startIndex = 0u;
3868
3869   // Create a clipping actor.
3870   Actor actorDepth1Clip = CreateActorWithContent();
3871   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3872   Stage::GetCurrent().Add( actorDepth1Clip );
3873
3874   // Gather the call trace.
3875   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3876
3877   // Check we are writing to the color buffer.
3878   CheckColorMask( glAbstraction, true );
3879
3880   // Check the stencil buffer was enabled.
3881   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3882
3883   // Check the stencil buffer was cleared.
3884   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3885
3886   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3887   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3888   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3889   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3890
3891   END_TEST;
3892 }
3893
3894 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3895 {
3896   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3897   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3898   TestApplication application;
3899
3900   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3901   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3902   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3903   size_t startIndex = 0u;
3904
3905   // Create a clipping actor.
3906   Actor actorDepth1Clip = CreateActorWithContent();
3907   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3908   Stage::GetCurrent().Add( actorDepth1Clip );
3909
3910   // Gather the call trace.
3911   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3912
3913   // Check we are writing to the color buffer.
3914   CheckColorMask( glAbstraction, true );
3915
3916   // Check the stencil buffer was enabled.
3917   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3918
3919   // Check the stencil buffer was cleared.
3920   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3921
3922   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3923   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3924   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3925   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3926
3927   // Now disable the clipping
3928   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3929
3930   // Gather the call trace.
3931   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3932
3933   // Check the stencil buffer was disabled.
3934   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3935
3936   // Ensure all values in stencil-mask are set to 1.
3937   startIndex = 0u;
3938   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3939
3940   END_TEST;
3941 }
3942
3943
3944 int UtcDaliActorPropertyClippingNestedChildren(void)
3945 {
3946   // This test checks that a hierarchy of actors are clipped correctly by
3947   // writing to and reading from the correct bit-planes of the stencil buffer.
3948   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3949   TestApplication application;
3950   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3951   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3952   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3953
3954   // Create a clipping actor.
3955   Actor actorDepth1Clip = CreateActorWithContent();
3956   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3957   Stage::GetCurrent().Add( actorDepth1Clip );
3958
3959   // Create a child actor.
3960   Actor childDepth2 = CreateActorWithContent();
3961   actorDepth1Clip.Add( childDepth2 );
3962
3963   // Create another clipping actor.
3964   Actor childDepth2Clip = CreateActorWithContent();
3965   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3966   childDepth2.Add( childDepth2Clip );
3967
3968   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3969   // This tests the sort algorithm.
3970   Actor childDepth3 = CreateActorWithContent();
3971   childDepth2Clip.Add( childDepth3 );
3972   Actor childDepth4 = CreateActorWithContent();
3973   childDepth3.Add( childDepth4 );
3974
3975   // Gather the call trace.
3976   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3977
3978   // Check we are writing to the color buffer.
3979   CheckColorMask( glAbstraction, true );
3980
3981   // Check the stencil buffer was enabled.
3982   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
3983
3984   // Perform the test twice, once for 2D layer, and once for 3D.
3985   for( unsigned int i = 0u ; i < 2u; ++i )
3986   {
3987     size_t startIndex = 0u;
3988
3989     // Check the stencil buffer was cleared.
3990     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3991
3992     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3993     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3994     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
3995     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3996
3997     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3998     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
3999     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4000
4001     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4002     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4003     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4004     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4005
4006     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4007     // (Both must be set to pass the check).
4008     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4009     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4010
4011     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4012     if( i == 0u )
4013     {
4014       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4015       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4016     }
4017   }
4018
4019   END_TEST;
4020 }
4021
4022 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4023 {
4024   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4025   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4026   TestApplication application;
4027
4028   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4029   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4030   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4031
4032   // Create a clipping actor.
4033   Actor actorDepth1Clip = CreateActorWithContent();
4034   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4035   Stage::GetCurrent().Add( actorDepth1Clip );
4036
4037   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4038   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4039
4040   // Gather the call trace.
4041   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4042
4043   // Check we are writing to the color buffer.
4044   CheckColorMask( glAbstraction, true );
4045
4046   // Check the stencil buffer was not enabled.
4047   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4048
4049   // Check stencil functions are not called.
4050   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4051   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4052   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4053
4054   END_TEST;
4055 }
4056
4057 int UtcDaliGetPropertyN(void)
4058 {
4059   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4060   TestApplication app;
4061
4062   Actor actor = Actor::New();
4063
4064   unsigned int propertyCount = actor.GetPropertyCount();
4065   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4066   END_TEST;
4067 }