Make NodePropertyFlags typesafe by using enum class
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2018 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 gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
49
50 bool gHoverCallBackCalled=false;
51
52 static bool gTestConstraintCalled;
53
54 LayoutDirection::Type gLayoutDirectionType;
55
56 struct TestConstraint
57 {
58   void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
59   {
60     gTestConstraintCalled = true;
61   }
62 };
63
64 /**
65  * TestConstraint reference.
66  * When constraint is called, the resultRef is updated
67  * with the value supplied.
68  */
69 template<typename T>
70 struct TestConstraintRef
71 {
72   TestConstraintRef(unsigned int& resultRef, unsigned int value)
73   : mResultRef(resultRef),
74     mValue(value)
75   {
76   }
77
78   void operator()( T& current, const PropertyInputContainer& /* inputs */ )
79   {
80     mResultRef = mValue;
81   }
82
83   unsigned int& mResultRef;
84   unsigned int mValue;
85 };
86
87 static bool TestCallback(Actor actor, const TouchEvent& event)
88 {
89   gTouchCallBackCalled = true;
90   return false;
91   END_TEST;
92 }
93
94 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
95 {
96   gTouchCallBackCalled = true;
97   return true;
98   END_TEST;
99 }
100
101 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
102 {
103   gTouchCallBackCalled2 = true;
104   return true;
105   END_TEST;
106 }
107
108 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
109 {
110   gTouchCallBackCalled3 = true;
111   return true;
112   END_TEST;
113 }
114
115 static void ResetTouchCallbacks()
116 {
117   gTouchCallBackCalled = false;
118   gTouchCallBackCalled2 = false;
119   gTouchCallBackCalled3 = false;
120 }
121
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
123 {
124   gHoverCallBackCalled = true;
125   return false;
126   END_TEST;
127 }
128
129 // validation stuff for onstage & offstage signals
130 static std::vector< std::string > gActorNamesOnOffStage;
131 static int gOnStageCallBackCalled;
132 void OnStageCallback( Actor actor )
133 {
134   ++gOnStageCallBackCalled;
135   gActorNamesOnOffStage.push_back( actor.GetName() );
136   DALI_TEST_CHECK( actor.OnStage() == true );
137 }
138 static int gOffStageCallBackCalled;
139 void OffStageCallback( Actor actor )
140 {
141   ++gOffStageCallBackCalled;
142   gActorNamesOnOffStage.push_back( actor.GetName() );
143   DALI_TEST_CHECK( actor.OnStage() == false );
144 }
145
146 struct PositionComponentConstraint
147 {
148   PositionComponentConstraint(){}
149
150   void operator()( Vector3& pos, const PropertyInputContainer& inputs )
151   {
152     const Matrix& m = inputs[0]->GetMatrix();
153     Vector3 scale;
154     Quaternion rot;
155     m.GetTransformComponents(pos, rot, scale);
156   }
157 };
158
159 struct OrientationComponentConstraint
160 {
161   OrientationComponentConstraint(){}
162
163   void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
164   {
165     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
166     Vector3 pos, scale;
167     Quaternion rot;
168     orientation = parentOrientation;
169   }
170 };
171 // OnRelayout
172
173 static bool gOnRelayoutCallBackCalled = false;
174 static std::vector< std::string > gActorNamesRelayout;
175
176 void OnRelayoutCallback( Actor actor )
177 {
178   gOnRelayoutCallBackCalled = true;
179   gActorNamesRelayout.push_back( actor.GetName() );
180 }
181
182 struct VisibilityChangedFunctorData
183 {
184   VisibilityChangedFunctorData()
185   : actor(),
186     visible( false ),
187     type( DevelActor::VisibilityChange::SELF ),
188     called( false )
189   {
190   }
191
192   void Reset()
193   {
194     actor.Reset();
195     visible = false;
196     type = DevelActor::VisibilityChange::SELF;
197     called = false;
198   }
199
200   void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
201   {
202     DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
203     DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
204     DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
205     DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
206   }
207
208   void Check( bool compareCalled, const std::string& location )
209   {
210     DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
211   }
212
213   Actor actor;
214   bool visible;
215   DevelActor::VisibilityChange::Type type;
216   bool called;
217 };
218
219 struct VisibilityChangedFunctor
220 {
221   VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
222
223   void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
224   {
225     data.actor = actor;
226     data.visible = visible;
227     data.type = type;
228     data.called = true;
229   }
230
231   VisibilityChangedFunctorData& data;
232 };
233
234
235 struct VisibilityChangedVoidFunctor
236 {
237   VisibilityChangedVoidFunctor(bool& signalCalled)
238   : mSignalCalled( signalCalled )
239   { }
240
241   void operator()()
242   {
243     mSignalCalled  = true;
244   }
245
246   bool& mSignalCalled;
247 };
248
249 struct ChildOrderChangedFunctor
250 {
251   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
252   : mSignalCalled( signalCalled ),
253     mActor( actor )
254   { }
255
256   void operator()( Actor actor )
257   {
258     mSignalCalled  = true;
259     mActor = actor;
260   }
261
262   bool& mSignalCalled;
263   Actor& mActor;
264 };
265
266 struct CulledPropertyNotificationFunctor
267 {
268   CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification )
269   : mSignalCalled( signalCalled ),
270     mPropertyNotification( propertyNotification )
271   { }
272
273   void operator()( PropertyNotification& source )
274   {
275     mSignalCalled  = true;
276     mPropertyNotification = source;
277   }
278
279   bool& mSignalCalled;
280   PropertyNotification& mPropertyNotification;
281 };
282
283 } // anonymous namespace
284
285
286 //& purpose: Testing New API
287 int UtcDaliActorNew(void)
288 {
289   TestApplication application;
290
291   Actor actor = Actor::New();
292
293   DALI_TEST_CHECK(actor);
294   END_TEST;
295 }
296
297 //& purpose: Testing Dali::Actor::DownCast()
298 int UtcDaliActorDownCastP(void)
299 {
300   TestApplication application;
301   tet_infoline("Testing Dali::Actor::DownCast()");
302
303   Actor actor = Actor::New();
304   BaseHandle object(actor);
305   Actor actor2 = Actor::DownCast(object);
306   DALI_TEST_CHECK(actor2);
307   END_TEST;
308 }
309
310 //& purpose: Testing Dali::Actor::DownCast()
311 int UtcDaliActorDownCastN(void)
312 {
313   TestApplication application;
314   tet_infoline("Testing Dali::Actor::DownCast()");
315
316   BaseHandle unInitializedObject;
317   Actor actor = Actor::DownCast(unInitializedObject);
318   DALI_TEST_CHECK(!actor);
319   END_TEST;
320 }
321
322 //& purpose: Testing Dali::Actor::GetName()
323 int UtcDaliActorGetName(void)
324 {
325   TestApplication application;
326
327   Actor actor = Actor::New();
328
329   DALI_TEST_CHECK(actor.GetName().empty());
330   END_TEST;
331 }
332
333 //& purpose: Testing Dali::Actor::SetName()
334 int UtcDaliActorSetName(void)
335 {
336   TestApplication application;
337
338   string str("ActorName");
339   Actor actor = Actor::New();
340
341   actor.SetName(str);
342   DALI_TEST_CHECK(actor.GetName() == str);
343   END_TEST;
344 }
345
346 int UtcDaliActorGetId(void)
347 {
348   tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
349   TestApplication application;
350
351   Actor first = Actor::New();
352   Actor second = Actor::New();
353   Actor third = Actor::New();
354
355   DALI_TEST_CHECK(first.GetId() != second.GetId());
356   DALI_TEST_CHECK(second.GetId() != third.GetId());
357   END_TEST;
358 }
359
360 int UtcDaliActorIsRoot(void)
361 {
362   TestApplication application;
363
364   Actor actor = Actor::New();
365   DALI_TEST_CHECK(!actor.IsRoot());
366
367   // get the root layer
368   actor = Stage::GetCurrent().GetLayer( 0 );
369   DALI_TEST_CHECK( actor.IsRoot() );
370   END_TEST;
371 }
372
373 int UtcDaliActorOnStage(void)
374 {
375   TestApplication application;
376
377   Actor actor = Actor::New();
378   DALI_TEST_CHECK( !actor.OnStage() );
379
380   // get the root layer
381   actor = Stage::GetCurrent().GetLayer( 0 );
382   DALI_TEST_CHECK( actor.OnStage() );
383   END_TEST;
384 }
385
386 int UtcDaliActorIsLayer(void)
387 {
388   TestApplication application;
389
390   Actor actor = Actor::New();
391   DALI_TEST_CHECK( !actor.IsLayer() );
392
393   // get the root layer
394   actor = Stage::GetCurrent().GetLayer( 0 );
395   DALI_TEST_CHECK( actor.IsLayer() );
396   END_TEST;
397 }
398
399 int UtcDaliActorGetLayer(void)
400 {
401   TestApplication application;
402
403   Actor actor = Actor::New();
404   Stage::GetCurrent().Add(actor);
405   Layer layer = actor.GetLayer();
406
407   DALI_TEST_CHECK(layer);
408
409   // get the root layers layer
410   actor = Stage::GetCurrent().GetLayer( 0 );
411   DALI_TEST_CHECK( actor.GetLayer() );
412   END_TEST;
413 }
414
415 int UtcDaliActorAddP(void)
416 {
417   tet_infoline("Testing Actor::Add");
418   TestApplication application;
419
420   Actor parent = Actor::New();
421   Actor child = Actor::New();
422
423   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
424
425   parent.Add(child);
426
427   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
428
429   Actor parent2 = Actor::New();
430   parent2.Add( child );
431
432   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
433   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
434
435   // try Adding to same parent again, works
436   parent2.Add( child );
437   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
438
439   // try reparenting an orphaned child
440   {
441     Actor temporaryParent = Actor::New();
442     temporaryParent.Add( child );
443     DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
444   }
445   // temporaryParent has now died, reparent the orphaned child
446   parent2.Add( child );
447   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
448
449   END_TEST;
450 }
451
452 int UtcDaliActorAddN(void)
453 {
454   tet_infoline("Testing Actor::Add");
455   TestApplication application;
456
457   Actor child = Actor::New();
458
459   Actor parent2 = Actor::New();
460   parent2.Add( child );
461
462   // try illegal Add
463   try
464   {
465     parent2.Add( parent2 );
466     tet_printf("Assertion test failed - no Exception\n" );
467     tet_result(TET_FAIL);
468   }
469   catch(Dali::DaliException& e)
470   {
471     DALI_TEST_PRINT_ASSERT( e );
472     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
473     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
474   }
475   catch(...)
476   {
477     tet_printf("Assertion test failed - wrong Exception\n" );
478     tet_result(TET_FAIL);
479   }
480
481   // try reparenting root
482   try
483   {
484     parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
485     tet_printf("Assertion test failed - no Exception\n" );
486     tet_result(TET_FAIL);
487   }
488   catch(Dali::DaliException& e)
489   {
490     DALI_TEST_PRINT_ASSERT( e );
491     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
492     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
493   }
494   catch(...)
495   {
496     tet_printf("Assertion test failed - wrong Exception\n" );
497     tet_result(TET_FAIL);
498   }
499
500   // try Add empty
501   try
502   {
503     Actor empty;
504     parent2.Add( empty );
505     tet_printf("Assertion test failed - no Exception\n" );
506     tet_result(TET_FAIL);
507   }
508   catch(Dali::DaliException& e)
509   {
510     DALI_TEST_PRINT_ASSERT( e );
511     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
512     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
513   }
514   catch(...)
515   {
516     tet_printf("Assertion test failed - wrong Exception\n" );
517     tet_result(TET_FAIL);
518   }
519
520   END_TEST;
521 }
522
523 int UtcDaliActorRemoveN(void)
524 {
525   tet_infoline("Testing Actor::Remove");
526   TestApplication application;
527
528   Actor parent = Actor::New();
529   Actor child = Actor::New();
530   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
531
532   parent.Add(child);
533   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
534
535   parent.Remove(child);
536   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
537
538   // remove again, no problem
539   parent.Remove(child);
540   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
541
542   // add child back
543   parent.Add(child);
544   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
545   // try Remove self, its a no-op
546   parent.Remove( parent );
547   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
548
549   // try Remove empty
550   try
551   {
552     Actor empty;
553     parent.Remove( empty );
554     tet_printf("Assertion test failed - no Exception\n" );
555     tet_result(TET_FAIL);
556   }
557   catch(Dali::DaliException& e)
558   {
559     DALI_TEST_PRINT_ASSERT( e );
560     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
561     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
562   }
563   catch(...)
564   {
565     tet_printf("Assertion test failed - wrong Exception\n" );
566     tet_result(TET_FAIL);
567   }
568   END_TEST;
569 }
570
571 int UtcDaliActorRemoveP(void)
572 {
573   TestApplication application;
574
575   Actor parent = Actor::New();
576   Actor child = Actor::New();
577   Actor random = Actor::New();
578
579   Stage::GetCurrent().Add( parent );
580
581   DALI_TEST_CHECK(parent.GetChildCount() == 0);
582
583   parent.Add(child);
584
585   DALI_TEST_CHECK(parent.GetChildCount() == 1);
586
587   parent.Remove(random);
588
589   DALI_TEST_CHECK(parent.GetChildCount() == 1);
590
591   Stage::GetCurrent().Remove( parent );
592
593   DALI_TEST_CHECK(parent.GetChildCount() == 1);
594   END_TEST;
595 }
596
597 int UtcDaliActorGetChildCount(void)
598 {
599   TestApplication application;
600
601   Actor parent = Actor::New();
602   Actor child = Actor::New();
603
604   DALI_TEST_CHECK(parent.GetChildCount() == 0);
605
606   parent.Add(child);
607
608   DALI_TEST_CHECK(parent.GetChildCount() == 1);
609   END_TEST;
610 }
611
612 int UtcDaliActorGetChildren01(void)
613 {
614   TestApplication application;
615
616   Actor parent = Actor::New();
617   Actor first  = Actor::New();
618   Actor second = Actor::New();
619   Actor third  = Actor::New();
620
621   parent.Add(first);
622   parent.Add(second);
623   parent.Add(third);
624
625   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
626   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
627   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
628   END_TEST;
629 }
630
631 int UtcDaliActorGetChildren02(void)
632 {
633   TestApplication application;
634
635   Actor parent = Actor::New();
636   Actor first  = Actor::New();
637   Actor second = Actor::New();
638   Actor third  = Actor::New();
639
640   parent.Add(first);
641   parent.Add(second);
642   parent.Add(third);
643
644   const Actor& constParent = parent;
645
646   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
647   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
648   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
649   END_TEST;
650 }
651
652 int UtcDaliActorGetParent01(void)
653 {
654   TestApplication application;
655
656   Actor parent = Actor::New();
657   Actor child = Actor::New();
658
659   parent.Add(child);
660
661   DALI_TEST_CHECK(child.GetParent() == parent);
662   END_TEST;
663 }
664
665 int UtcDaliActorGetParent02(void)
666 {
667   TestApplication application;
668
669   Actor actor = Actor::New();
670
671   DALI_TEST_CHECK(!actor.GetParent());
672   END_TEST;
673 }
674
675 int UtcDaliActorCustomProperty(void)
676 {
677   TestApplication application;
678
679   Actor actor = Actor::New();
680   Stage::GetCurrent().Add( actor );
681
682   float startValue(1.0f);
683   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
684   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
685
686   application.SendNotification();
687   application.Render(0);
688   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
689
690   actor.SetProperty( index, 5.0f );
691
692   application.SendNotification();
693   application.Render(0);
694   DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
695   END_TEST;
696 }
697
698 int UtcDaliActorCustomPropertyIntToFloat(void)
699 {
700   TestApplication application;
701
702   Actor actor = Actor::New();
703   Stage::GetCurrent().Add( actor );
704
705   float startValue(5.0f);
706   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
707   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
708
709   application.SendNotification();
710   application.Render(0);
711   DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
712
713   actor.SetProperty( index, int(1) );
714
715   application.SendNotification();
716   application.Render(0);
717   DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
718   END_TEST;
719 }
720
721 int UtcDaliActorCustomPropertyFloatToInt(void)
722 {
723   TestApplication application;
724
725   Actor actor = Actor::New();
726   Stage::GetCurrent().Add( actor );
727
728   int startValue(5);
729   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
730   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
731
732   application.SendNotification();
733   application.Render(0);
734   DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
735
736   actor.SetProperty( index, float(1.5) );
737
738   application.SendNotification();
739   application.Render(0);
740   DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
741   END_TEST;
742 }
743
744 int UtcDaliActorSetParentOrigin(void)
745 {
746   TestApplication application;
747
748   Actor actor = Actor::New();
749
750   Vector3 vector(0.7f, 0.8f, 0.9f);
751   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
752
753   actor.SetParentOrigin(vector);
754
755   // flush the queue and render once
756   application.SendNotification();
757   application.Render();
758
759   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
760
761   Stage::GetCurrent().Add( actor );
762
763   actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
764
765   // flush the queue and render once
766   application.SendNotification();
767   application.Render();
768
769   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
770
771   Stage::GetCurrent().Remove( actor );
772   END_TEST;
773 }
774
775 int UtcDaliActorSetParentOriginIndividual(void)
776 {
777   TestApplication application;
778
779   Actor actor = Actor::New();
780
781   Vector3 vector(0.7f, 0.8f, 0.9f);
782   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
783
784   actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
785
786   // flush the queue and render once
787   application.SendNotification();
788   application.Render();
789
790   DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
791
792   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
793
794   // flush the queue and render once
795   application.SendNotification();
796   application.Render();
797
798   DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
799
800   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
801
802   // flush the queue and render once
803   application.SendNotification();
804   application.Render();
805
806   DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
807
808   END_TEST;
809 }
810
811 int UtcDaliActorGetCurrentParentOrigin(void)
812 {
813   TestApplication application;
814
815   Actor actor = Actor::New();
816
817   Vector3 vector(0.7f, 0.8f, 0.9f);
818   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
819
820   actor.SetParentOrigin(vector);
821
822   // flush the queue and render once
823   application.SendNotification();
824   application.Render();
825
826   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
827   END_TEST;
828 }
829
830 int UtcDaliActorSetAnchorPoint(void)
831 {
832   TestApplication application;
833
834   Actor actor = Actor::New();
835
836   Vector3 vector(0.7f, 0.8f, 0.9f);
837   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
838
839   actor.SetAnchorPoint(vector);
840
841   // flush the queue and render once
842   application.SendNotification();
843   application.Render();
844
845   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
846
847   Stage::GetCurrent().Add( actor );
848
849   actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
850   // flush the queue and render once
851   application.SendNotification();
852   application.Render();
853
854   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
855
856   Stage::GetCurrent().Remove( actor );
857   END_TEST;
858 }
859
860 int UtcDaliActorSetAnchorPointIndividual(void)
861 {
862   TestApplication application;
863
864   Actor actor = Actor::New();
865
866   Vector3 vector(0.7f, 0.8f, 0.9f);
867   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
868
869   actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
870
871   // flush the queue and render once
872   application.SendNotification();
873   application.Render();
874
875   DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
876
877   actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
878
879   // flush the queue and render once
880   application.SendNotification();
881   application.Render();
882
883   DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
884
885   actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
886
887   // flush the queue and render once
888   application.SendNotification();
889   application.Render();
890
891   DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
892
893   END_TEST;
894 }
895
896 int UtcDaliActorGetCurrentAnchorPoint(void)
897 {
898   TestApplication application;
899
900   Actor actor = Actor::New();
901
902   Vector3 vector(0.7f, 0.8f, 0.9f);
903   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
904
905   actor.SetAnchorPoint(vector);
906
907   // flush the queue and render once
908   application.SendNotification();
909   application.Render();
910
911   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
912   END_TEST;
913 }
914
915 // SetSize(float width, float height)
916 int UtcDaliActorSetSize01(void)
917 {
918   TestApplication application;
919
920   Actor actor = Actor::New();
921   Vector3 vector(100.0f, 100.0f, 0.0f);
922
923   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
924
925   actor.SetSize(vector.x, vector.y);
926
927   // Immediately retrieve the size after setting
928   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
929   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
930   DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
931   DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
932   DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
933
934   // Flush the queue and render once
935   application.SendNotification();
936   application.Render();
937
938   // Check the size in the new frame
939   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
940
941   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
942   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
943   DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
944   DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
945   DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
946
947   // Check async behaviour
948   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
949   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
950   DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
951   DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
952   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
953
954   // Change the resize policy and check whether the size stays the same
955   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
956
957   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
958   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
959
960   // Set a new size after resize policy is changed and check the new size
961   actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
962
963   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
964   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
965
966   // Change the resize policy again and check whether the new size stays the same
967   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
968
969   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
970   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
971
972   // Set another new size after resize policy is changed and check the new size
973   actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
974
975   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
976   DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
977
978   END_TEST;
979 }
980
981 // SetSize(float width, float height, float depth)
982 int UtcDaliActorSetSize02(void)
983 {
984   TestApplication application;
985
986   Actor actor = Actor::New();
987   Vector3 vector(100.0f, 100.0f, 100.0f);
988
989   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
990
991   actor.SetSize(vector.x, vector.y, vector.z);
992
993   // Immediately check the size after setting
994   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
995   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996
997   // flush the queue and render once
998   application.SendNotification();
999   application.Render();
1000
1001   // Check the size in the new frame
1002   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1003
1004   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1005   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1006
1007   END_TEST;
1008 }
1009
1010 // SetSize(Vector2 size)
1011 int UtcDaliActorSetSize03(void)
1012 {
1013   TestApplication application;
1014
1015   Actor actor = Actor::New();
1016   Vector3 vector(100.0f, 100.0f, 0.0f);
1017
1018   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1019
1020   actor.SetSize(Vector2(vector.x, vector.y));
1021
1022   // Immediately check the size after setting
1023   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1024   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1025
1026   // flush the queue and render once
1027   application.SendNotification();
1028   application.Render();
1029
1030   // Check the size in the new frame
1031   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1032
1033   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1034   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1035
1036   END_TEST;
1037 }
1038
1039 // SetSize(Vector3 size)
1040 int UtcDaliActorSetSize04(void)
1041 {
1042   TestApplication application;
1043
1044   Actor actor = Actor::New();
1045   Vector3 vector(100.0f, 100.0f, 100.0f);
1046
1047   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1048
1049   actor.SetSize(vector);
1050
1051   // Immediately check the size after setting
1052   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1053   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1054
1055   // flush the queue and render once
1056   application.SendNotification();
1057   application.Render();
1058
1059   // Check the size in the new frame
1060   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1061
1062   Stage::GetCurrent().Add( actor );
1063   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1064
1065   // Immediately check the size after setting
1066   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1067   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1068
1069   // flush the queue and render once
1070   application.SendNotification();
1071   application.Render();
1072
1073   // Check the size in the new frame
1074   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1075
1076   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1077   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1078
1079   Stage::GetCurrent().Remove( actor );
1080   END_TEST;
1081 }
1082
1083 int UtcDaliActorSetSizeIndividual(void)
1084 {
1085   TestApplication application;
1086
1087   Actor actor = Actor::New();
1088
1089   Vector3 vector(0.7f, 0.8f, 0.9f);
1090   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1091
1092   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1093
1094   // Immediately check the width after setting
1095   float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1096   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1097
1098   // flush the queue and render once
1099   application.SendNotification();
1100   application.Render();
1101
1102   // Check the width in the new frame
1103   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1104
1105   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1106   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1107
1108   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1109
1110   // Immediately check the height after setting
1111   float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1112   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1113
1114   // flush the queue and render once
1115   application.SendNotification();
1116   application.Render();
1117
1118   // Check the height in the new frame
1119   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1120
1121   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1122   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1123
1124   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1125
1126   // Immediately check the depth after setting
1127   float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1128   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1129
1130   // flush the queue and render once
1131   application.SendNotification();
1132   application.Render();
1133
1134   // Check the depth in the new frame
1135   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1136
1137   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1138   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1139
1140   // Change the resize policy and check whether the size stays the same
1141   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1142
1143   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1144   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1145
1146   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1147   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1148
1149   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1150   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1151
1152   // Change the resize policy again and check whether the size stays the same
1153   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1154
1155   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1156   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1157
1158   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1159   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1160
1161   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1162   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1163
1164   END_TEST;
1165 }
1166
1167 int UtcDaliActorSetSizeIndividual02(void)
1168 {
1169   TestApplication application;
1170
1171   Actor actor = Actor::New();
1172   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1173   Stage::GetCurrent().Add( actor );
1174
1175   Vector3 vector( 100.0f, 200.0f, 400.0f );
1176   DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1177
1178   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1179   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1180
1181   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1182   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1183
1184   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1185   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1186
1187   // flush the queue and render once
1188   application.SendNotification();
1189   application.Render();
1190
1191   // Check the width in the new frame
1192   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1193   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1194
1195   END_TEST;
1196 }
1197
1198
1199 int UtcDaliActorGetCurrentSize(void)
1200 {
1201   TestApplication application;
1202
1203   Actor actor = Actor::New();
1204   Vector3 vector(100.0f, 100.0f, 20.0f);
1205
1206   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1207
1208   actor.SetSize(vector);
1209
1210   // flush the queue and render once
1211   application.SendNotification();
1212   application.Render();
1213
1214   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1215   END_TEST;
1216 }
1217
1218 int UtcDaliActorGetNaturalSize(void)
1219 {
1220   TestApplication application;
1221
1222   Actor actor = Actor::New();
1223   Vector3 vector( 0.0f, 0.0f, 0.0f );
1224
1225   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1226
1227   END_TEST;
1228 }
1229
1230 int UtcDaliActorGetCurrentSizeImmediate(void)
1231 {
1232   TestApplication application;
1233
1234   Actor actor = Actor::New();
1235   Vector3 vector(100.0f, 100.0f, 20.0f);
1236
1237   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1238   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1239
1240   actor.SetSize(vector);
1241
1242   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1243   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1244
1245   // flush the queue and render once
1246   application.SendNotification();
1247   application.Render();
1248
1249   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1250   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1251
1252   // Animation
1253   // Build the animation
1254   const float durationSeconds = 2.0f;
1255   Animation animation = Animation::New( durationSeconds );
1256   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1257   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1258
1259   DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1260
1261   // Start the animation
1262   animation.Play();
1263
1264   application.SendNotification();
1265   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1266
1267   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1268
1269   END_TEST;
1270 }
1271
1272 // SetPosition(float x, float y)
1273 int UtcDaliActorSetPosition01(void)
1274 {
1275   TestApplication application;
1276
1277   Actor actor = Actor::New();
1278
1279   // Set to random to start off with
1280   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1281
1282   Vector3 vector(100.0f, 100.0f, 0.0f);
1283
1284   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1285
1286   actor.SetPosition(vector.x, vector.y);
1287   // flush the queue and render once
1288   application.SendNotification();
1289   application.Render();
1290   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1291
1292   Stage::GetCurrent().Add( actor );
1293   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1294   // flush the queue and render once
1295   application.SendNotification();
1296   application.Render();
1297   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1298
1299   actor.SetX( 1.0f );
1300   actor.SetY( 1.1f );
1301   actor.SetZ( 1.2f );
1302   // flush the queue and render once
1303   application.SendNotification();
1304   application.Render();
1305   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1306
1307   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1308   // flush the queue and render once
1309   application.SendNotification();
1310   application.Render();
1311   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1312
1313   Stage::GetCurrent().Remove( actor );
1314   END_TEST;
1315 }
1316
1317 // SetPosition(float x, float y, float z)
1318 int UtcDaliActorSetPosition02(void)
1319 {
1320   TestApplication application;
1321
1322   Actor actor = Actor::New();
1323
1324   // Set to random to start off with
1325   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1326
1327   Vector3 vector(100.0f, 100.0f, 100.0f);
1328
1329   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1330
1331   actor.SetPosition(vector.x, vector.y, vector.z);
1332
1333   // flush the queue and render once
1334   application.SendNotification();
1335   application.Render();
1336
1337   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1338   END_TEST;
1339 }
1340
1341 // SetPosition(Vector3 position)
1342 int UtcDaliActorSetPosition03(void)
1343 {
1344   TestApplication application;
1345
1346   Actor actor = Actor::New();
1347
1348   // Set to random to start off with
1349   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1350
1351   Vector3 vector(100.0f, 100.0f, 100.0f);
1352
1353   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1354
1355   actor.SetPosition(vector);
1356
1357   // flush the queue and render once
1358   application.SendNotification();
1359   application.Render();
1360
1361   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1362   END_TEST;
1363 }
1364
1365 int UtcDaliActorSetX(void)
1366 {
1367   TestApplication application;
1368
1369   Actor actor = Actor::New();
1370
1371   Vector3 vector(100.0f, 0.0f, 0.0f);
1372
1373   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1374
1375   actor.SetX(100.0f);
1376
1377   // flush the queue and render once
1378   application.SendNotification();
1379   application.Render();
1380
1381   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1382   END_TEST;
1383 }
1384
1385 int UtcDaliActorSetY(void)
1386 {
1387   TestApplication application;
1388
1389   Actor actor = Actor::New();
1390
1391   Vector3 vector(0.0f, 100.0f, 0.0f);
1392
1393   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1394
1395   actor.SetY(100.0f);
1396
1397   // flush the queue and render once
1398   application.SendNotification();
1399   application.Render();
1400
1401   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1402   END_TEST;
1403 }
1404
1405 int UtcDaliActorSetZ(void)
1406 {
1407   TestApplication application;
1408
1409   Actor actor = Actor::New();
1410
1411   Vector3 vector(0.0f, 0.0f, 100.0f);
1412
1413   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1414
1415   actor.SetZ(100.0f);
1416
1417   // flush the queue and render once
1418   application.SendNotification();
1419   application.Render();
1420
1421   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1422   END_TEST;
1423 }
1424
1425 int UtcDaliActorSetPositionProperties(void)
1426 {
1427   TestApplication application;
1428
1429   Actor actor = Actor::New();
1430
1431   Vector3 vector(0.7f, 0.8f, 0.9f);
1432   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1433
1434   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1435   DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1436   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1437
1438   // flush the queue and render once
1439   application.SendNotification();
1440   application.Render();
1441
1442   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1443   DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1444   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1445   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1446   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1447
1448   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1449   DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1450   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1451
1452   // flush the queue and render once
1453   application.SendNotification();
1454   application.Render();
1455
1456   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1457   DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1458   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1459   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1460   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1461
1462   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1463   DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1464   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1465
1466   // flush the queue and render once
1467   application.SendNotification();
1468   application.Render();
1469
1470   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1471   DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1472   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1473   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1474   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1475
1476   END_TEST;
1477 }
1478
1479 int UtcDaliActorTranslateBy(void)
1480 {
1481   TestApplication application;
1482
1483   Actor actor = Actor::New();
1484   Vector3 vector(100.0f, 100.0f, 100.0f);
1485
1486   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1487
1488   actor.SetPosition(vector);
1489
1490   // flush the queue and render once
1491   application.SendNotification();
1492   application.Render();
1493
1494   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1495
1496   actor.TranslateBy(vector);
1497
1498   // flush the queue and render once
1499   application.SendNotification();
1500   application.Render();
1501
1502   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1503   END_TEST;
1504 }
1505
1506 int UtcDaliActorGetCurrentPosition(void)
1507 {
1508   TestApplication application;
1509
1510   Actor actor = Actor::New();
1511   Vector3 setVector(100.0f, 100.0f, 0.0f);
1512   actor.SetPosition(setVector);
1513
1514   // flush the queue and render once
1515   application.SendNotification();
1516   application.Render();
1517
1518   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1519   END_TEST;
1520 }
1521
1522 int UtcDaliActorGetCurrentWorldPosition(void)
1523 {
1524   TestApplication application;
1525
1526   Actor parent = Actor::New();
1527   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1528   parent.SetPosition( parentPosition );
1529   parent.SetParentOrigin( ParentOrigin::CENTER );
1530   parent.SetAnchorPoint( AnchorPoint::CENTER );
1531   Stage::GetCurrent().Add( parent );
1532
1533   Actor child = Actor::New();
1534   child.SetParentOrigin( ParentOrigin::CENTER );
1535   child.SetAnchorPoint( AnchorPoint::CENTER );
1536   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1537   child.SetPosition( childPosition );
1538   parent.Add( child );
1539
1540   // The actors should not have a world position yet
1541   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1542   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1543
1544   application.SendNotification();
1545   application.Render(0);
1546
1547   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1548   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1549
1550   // The actors should have a world position now
1551   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1552   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1553   END_TEST;
1554 }
1555
1556 int UtcDaliActorInheritPosition(void)
1557 {
1558   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1559   TestApplication application;
1560
1561   Actor parent = Actor::New();
1562   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1563   parent.SetPosition( parentPosition );
1564   parent.SetParentOrigin( ParentOrigin::CENTER );
1565   parent.SetAnchorPoint( AnchorPoint::CENTER );
1566   Stage::GetCurrent().Add( parent );
1567
1568   Actor child = Actor::New();
1569   child.SetParentOrigin( ParentOrigin::CENTER );
1570   child.SetAnchorPoint( AnchorPoint::CENTER );
1571   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1572   child.SetPosition( childPosition );
1573   parent.Add( child );
1574
1575   // The actors should not have a world position yet
1576   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1577   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1578
1579   // first test default, which is to inherit position
1580   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1581   application.SendNotification();
1582   application.Render(0); // should only really call Update as Render is not required to update scene
1583   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1584   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1585   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1586   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1587
1588
1589   //Change child position
1590   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1591   child.SetPosition( childOffset );
1592
1593   // Change inheritance mode to not inherit
1594   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1595   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1596   application.SendNotification();
1597   application.Render(0); // should only really call Update as Render is not required to update scene
1598   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1599   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1600   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1601   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1602   END_TEST;
1603 }
1604
1605 int UtcDaliActorSetInheritPosition(void)
1606 {
1607   tet_infoline("Testing Actor::SetInheritPosition");
1608   TestApplication application;
1609
1610   Actor parent = Actor::New();
1611   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1612   parent.SetPosition( parentPosition );
1613   parent.SetParentOrigin( ParentOrigin::CENTER );
1614   parent.SetAnchorPoint( AnchorPoint::CENTER );
1615   Stage::GetCurrent().Add( parent );
1616
1617   Actor child = Actor::New();
1618   child.SetParentOrigin( ParentOrigin::CENTER );
1619   child.SetAnchorPoint( AnchorPoint::CENTER );
1620   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1621   child.SetPosition( childPosition );
1622   parent.Add( child );
1623
1624   // The actors should not have a world position yet
1625   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1626   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1627
1628   // first test default, which is to inherit position
1629   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1630   application.SendNotification();
1631   application.Render(0); // should only really call Update as Render is not required to update scene
1632   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1633   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1634   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1635   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1636
1637   //Change child position
1638   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1639   child.SetPosition( childOffset );
1640
1641   // Use local position as world postion
1642   child.SetInheritPosition( false );
1643   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1644   application.SendNotification();
1645   application.Render(0); // should only really call Update as Render is not required to update scene
1646   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1647   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1648   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1649   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1650
1651   //Change back to inherit position from parent
1652   child.SetInheritPosition( true );
1653   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1654   application.SendNotification();
1655   application.Render(0); // should only really call Update as Render is not required to update scene
1656   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1657   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1658   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1659   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1660   END_TEST;
1661 }
1662
1663 int UtcDaliActorInheritOpacity(void)
1664 {
1665   tet_infoline("Testing Actor::Inherit Opacity");
1666   TestApplication application;
1667
1668   Actor parent = Actor::New();
1669   Actor child = Actor::New();
1670   parent.Add( child );
1671   Stage::GetCurrent().Add( parent );
1672
1673   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1674   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1675
1676   // flush the queue and render once
1677   application.SendNotification();
1678   application.Render();
1679
1680   parent.SetOpacity( 0.1f );
1681
1682   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1683   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1684
1685   application.SendNotification();
1686   application.Render();
1687
1688   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1689   DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1690   DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1691   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1692   DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1693   DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1694
1695   END_TEST;
1696 }
1697
1698 // SetOrientation(float angleRadians, Vector3 axis)
1699 int UtcDaliActorSetOrientation01(void)
1700 {
1701   TestApplication application;
1702
1703   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1704   Actor actor = Actor::New();
1705
1706   actor.SetOrientation(rotation);
1707
1708   // flush the queue and render once
1709   application.SendNotification();
1710   application.Render();
1711
1712   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1713   END_TEST;
1714 }
1715
1716 int UtcDaliActorSetOrientation02(void)
1717 {
1718   TestApplication application;
1719
1720   Actor actor = Actor::New();
1721
1722   Radian angle( 0.785f );
1723   Vector3 axis(1.0f, 1.0f, 0.0f);
1724
1725   actor.SetOrientation( angle, axis);
1726   Quaternion rotation( angle, axis );
1727   // flush the queue and render once
1728   application.SendNotification();
1729   application.Render();
1730   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1731
1732   Stage::GetCurrent().Add( actor );
1733   actor.RotateBy( Degree( 360 ), axis);
1734   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1735
1736   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1737   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1738   // flush the queue and render once
1739   application.SendNotification();
1740   application.Render();
1741   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1742
1743   actor.SetOrientation( angle, axis);
1744   // flush the queue and render once
1745   application.SendNotification();
1746   application.Render();
1747   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1748
1749   Stage::GetCurrent().Remove( actor );
1750   END_TEST;
1751 }
1752
1753 // SetOrientation(float angleRadians, Vector3 axis)
1754 int UtcDaliActorSetOrientationProperty(void)
1755 {
1756   TestApplication application;
1757
1758   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1759   Actor actor = Actor::New();
1760
1761   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1762   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1763
1764   // flush the queue and render once
1765   application.SendNotification();
1766   application.Render();
1767
1768   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1769   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1770   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1771   END_TEST;
1772 }
1773
1774 // RotateBy(float angleRadians, Vector3 axis)
1775 int UtcDaliActorRotateBy01(void)
1776 {
1777   TestApplication application;
1778
1779   Actor actor = Actor::New();
1780
1781   Radian angle( M_PI * 0.25f );
1782   actor.RotateBy(( angle ), Vector3::ZAXIS);
1783   // flush the queue and render once
1784   application.SendNotification();
1785   application.Render();
1786   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1787
1788   Stage::GetCurrent().Add( actor );
1789
1790   actor.RotateBy( angle, Vector3::ZAXIS);
1791   // flush the queue and render once
1792   application.SendNotification();
1793   application.Render();
1794   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1795
1796   Stage::GetCurrent().Remove( actor );
1797   END_TEST;
1798 }
1799
1800 // RotateBy(Quaternion relativeRotation)
1801 int UtcDaliActorRotateBy02(void)
1802 {
1803   TestApplication application;
1804
1805   Actor actor = Actor::New();
1806
1807   Radian angle( M_PI * 0.25f );
1808   Quaternion rotation(angle, Vector3::ZAXIS);
1809   actor.RotateBy(rotation);
1810   // flush the queue and render once
1811   application.SendNotification();
1812   application.Render();
1813   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1814
1815   actor.RotateBy(rotation);
1816   // flush the queue and render once
1817   application.SendNotification();
1818   application.Render();
1819   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1820   END_TEST;
1821 }
1822
1823 int UtcDaliActorGetCurrentOrientation(void)
1824 {
1825   TestApplication application;
1826   Actor actor = Actor::New();
1827
1828   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1829   actor.SetOrientation(rotation);
1830   // flush the queue and render once
1831   application.SendNotification();
1832   application.Render();
1833   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1834   END_TEST;
1835 }
1836
1837 int UtcDaliActorGetCurrentWorldOrientation(void)
1838 {
1839   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1840   TestApplication application;
1841
1842   Actor parent = Actor::New();
1843   Radian rotationAngle( Degree(90.0f) );
1844   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1845   parent.SetOrientation( rotation );
1846   Stage::GetCurrent().Add( parent );
1847
1848   Actor child = Actor::New();
1849   child.SetOrientation( rotation );
1850   parent.Add( child );
1851
1852   // The actors should not have a world rotation yet
1853   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1854   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1855
1856   application.SendNotification();
1857   application.Render(0);
1858
1859   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1860   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1861
1862   // The actors should have a world rotation now
1863   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1864   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1865
1866   // turn off child rotation inheritance
1867   child.SetInheritOrientation( false );
1868   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1869   application.SendNotification();
1870   application.Render(0);
1871
1872   // The actors should have a world rotation now
1873   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1874   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1875   END_TEST;
1876 }
1877
1878 // SetScale(float scale)
1879 int UtcDaliActorSetScale01(void)
1880 {
1881   TestApplication application;
1882
1883   Actor actor = Actor::New();
1884
1885   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1886   actor.SetScale(0.25f);
1887
1888   Vector3 scale(10.0f, 10.0f, 10.0f);
1889   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1890
1891   actor.SetScale(scale.x);
1892
1893   // flush the queue and render once
1894   application.SendNotification();
1895   application.Render();
1896
1897   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1898   END_TEST;
1899 }
1900
1901 // SetScale(float scaleX, float scaleY, float scaleZ)
1902 int UtcDaliActorSetScale02(void)
1903 {
1904   TestApplication application;
1905   Vector3 scale(10.0f, 10.0f, 10.0f);
1906
1907   Actor actor = Actor::New();
1908
1909   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1910   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1911
1912   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1913
1914   actor.SetScale(scale.x, scale.y, scale.z);
1915   // flush the queue and render once
1916   application.SendNotification();
1917   application.Render();
1918   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1919
1920   // add to stage and test
1921   Stage::GetCurrent().Add( actor );
1922   actor.SetScale( 2.0f, 2.0f, 2.0f );
1923   // flush the queue and render once
1924   application.SendNotification();
1925   application.Render();
1926   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1927
1928   Stage::GetCurrent().Remove( actor );
1929
1930   END_TEST;
1931 }
1932
1933 // SetScale(Vector3 scale)
1934 int UtcDaliActorSetScale03(void)
1935 {
1936   TestApplication application;
1937   Vector3 scale(10.0f, 10.0f, 10.0f);
1938
1939   Actor actor = Actor::New();
1940
1941   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1942   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1943
1944   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1945
1946   actor.SetScale(scale);
1947
1948   // flush the queue and render once
1949   application.SendNotification();
1950   application.Render();
1951
1952   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1953   END_TEST;
1954 }
1955
1956 int UtcDaliActorSetScaleIndividual(void)
1957 {
1958   TestApplication application;
1959
1960   Actor actor = Actor::New();
1961
1962   Vector3 vector(0.7f, 0.8f, 0.9f);
1963   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1964
1965   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1966   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1967
1968   // flush the queue and render once
1969   application.SendNotification();
1970   application.Render();
1971
1972   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1973   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1974   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1975
1976   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1977   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1978
1979   // flush the queue and render once
1980   application.SendNotification();
1981   application.Render();
1982
1983   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1984   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1985   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1986
1987   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1988   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1989
1990   // flush the queue and render once
1991   application.SendNotification();
1992   application.Render();
1993
1994   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1995   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1996   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1997
1998   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1999   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2000
2001   END_TEST;
2002 }
2003
2004 int UtcDaliActorScaleBy(void)
2005 {
2006   TestApplication application;
2007   Actor actor = Actor::New();
2008   Vector3 vector(100.0f, 100.0f, 100.0f);
2009
2010   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
2011
2012   actor.SetScale(vector);
2013
2014   // flush the queue and render once
2015   application.SendNotification();
2016   application.Render();
2017
2018   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
2019
2020   actor.ScaleBy(vector);
2021
2022   // flush the queue and render once
2023   application.SendNotification();
2024   application.Render();
2025
2026   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
2027   END_TEST;
2028 }
2029
2030 int UtcDaliActorGetCurrentScale(void)
2031 {
2032   TestApplication application;
2033   Vector3 scale(12.0f, 1.0f, 2.0f);
2034
2035   Actor actor = Actor::New();
2036
2037   actor.SetScale(scale);
2038
2039   // flush the queue and render once
2040   application.SendNotification();
2041   application.Render();
2042
2043   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
2044   END_TEST;
2045 }
2046
2047 int UtcDaliActorGetCurrentWorldScale(void)
2048 {
2049   TestApplication application;
2050
2051   Actor parent = Actor::New();
2052   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2053   parent.SetScale( parentScale );
2054   Stage::GetCurrent().Add( parent );
2055
2056   Actor child = Actor::New();
2057   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2058   child.SetScale( childScale );
2059   parent.Add( child );
2060
2061   // The actors should not have a scale yet
2062   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2063   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2064
2065   // The actors should not have a world scale yet
2066   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2067   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2068
2069   application.SendNotification();
2070   application.Render(0);
2071
2072   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2073   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2074
2075   // The actors should have a world scale now
2076   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2077   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2078   END_TEST;
2079 }
2080
2081 int UtcDaliActorInheritScale(void)
2082 {
2083   tet_infoline("Testing Actor::SetInheritScale");
2084   TestApplication application;
2085
2086   Actor parent = Actor::New();
2087   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2088   parent.SetScale( parentScale );
2089   Stage::GetCurrent().Add( parent );
2090
2091   Actor child = Actor::New();
2092   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2093   child.SetScale( childScale );
2094   parent.Add( child );
2095
2096   application.SendNotification();
2097   application.Render(0);
2098
2099   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2100   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2101
2102   child.SetInheritScale( false );
2103   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2104
2105   application.SendNotification();
2106   application.Render(0);
2107
2108   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2109   END_TEST;
2110 }
2111
2112 int UtcDaliActorSetVisible(void)
2113 {
2114   TestApplication application;
2115
2116   Actor actor = Actor::New();
2117   actor.SetVisible(false);
2118   // flush the queue and render once
2119   application.SendNotification();
2120   application.Render();
2121   DALI_TEST_CHECK(actor.IsVisible() == false);
2122
2123   actor.SetVisible(true);
2124   // flush the queue and render once
2125   application.SendNotification();
2126   application.Render();
2127   DALI_TEST_CHECK(actor.IsVisible() == true);
2128
2129   // put actor on stage
2130   Stage::GetCurrent().Add( actor );
2131   actor.SetVisible(false);
2132   // flush the queue and render once
2133   application.SendNotification();
2134   application.Render();
2135   DALI_TEST_CHECK(actor.IsVisible() == false);
2136   END_TEST;
2137 }
2138
2139 int UtcDaliActorIsVisible(void)
2140 {
2141   TestApplication application;
2142
2143   Actor actor = Actor::New();
2144
2145   DALI_TEST_CHECK(actor.IsVisible() == true);
2146   END_TEST;
2147 }
2148
2149 int UtcDaliActorSetOpacity(void)
2150 {
2151   TestApplication application;
2152
2153   Actor actor = Actor::New();
2154   // initial opacity is 1
2155   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2156
2157   actor.SetOpacity( 0.4f);
2158   // flush the queue and render once
2159   application.SendNotification();
2160   application.Render();
2161   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2162
2163   // change opacity, actor is on stage to change is not immediate
2164   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2165   // flush the queue and render once
2166   application.SendNotification();
2167   application.Render();
2168   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2169
2170   // put actor on stage
2171   Stage::GetCurrent().Add( actor );
2172
2173   // change opacity, actor is on stage to change is not immediate
2174   actor.SetOpacity( 0.9f );
2175   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2176   // flush the queue and render once
2177   application.SendNotification();
2178   application.Render();
2179   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2180
2181   // change opacity, actor is on stage to change is not immediate
2182   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2183   // flush the queue and render once
2184   application.SendNotification();
2185   application.Render();
2186   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2187   END_TEST;
2188 }
2189
2190 int UtcDaliActorGetCurrentOpacity(void)
2191 {
2192   TestApplication application;
2193
2194   Actor actor = Actor::New();
2195   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2196
2197   actor.SetOpacity(0.5f);
2198   // flush the queue and render once
2199   application.SendNotification();
2200   application.Render();
2201   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2202   END_TEST;
2203 }
2204
2205 int UtcDaliActorSetSensitive(void)
2206 {
2207   TestApplication application;
2208   Actor actor = Actor::New();
2209
2210   bool sensitive = !actor.IsSensitive();
2211
2212   actor.SetSensitive(sensitive);
2213
2214   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2215   END_TEST;
2216 }
2217
2218 int UtcDaliActorIsSensitive(void)
2219 {
2220   TestApplication application;
2221   Actor actor = Actor::New();
2222   actor.SetSensitive(false);
2223
2224   DALI_TEST_CHECK(false == actor.IsSensitive());
2225   END_TEST;
2226 }
2227
2228 int UtcDaliActorSetColor(void)
2229 {
2230   TestApplication application;
2231   Actor actor = Actor::New();
2232   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2233
2234   DALI_TEST_CHECK(color != actor.GetCurrentColor());
2235
2236   actor.SetColor(color);
2237   // flush the queue and render once
2238   application.SendNotification();
2239   application.Render();
2240   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2241
2242   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2243   // flush the queue and render once
2244   application.SendNotification();
2245   application.Render();
2246   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
2247
2248   Stage::GetCurrent().Add( actor );
2249   actor.SetColor( color );
2250   // flush the queue and render once
2251   application.SendNotification();
2252   application.Render();
2253   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
2254
2255   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2256   // flush the queue and render once
2257   application.SendNotification();
2258   application.Render();
2259   // Actor color is not clamped
2260   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
2261   // world color is clamped
2262   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
2263
2264   Stage::GetCurrent().Remove( actor );
2265   END_TEST;
2266 }
2267
2268 int UtcDaliActorSetColorIndividual(void)
2269 {
2270   TestApplication application;
2271
2272   Actor actor = Actor::New();
2273
2274   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2275   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2276
2277   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2278   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2279
2280   // flush the queue and render once
2281   application.SendNotification();
2282   application.Render();
2283
2284   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2285   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2286   DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2287
2288   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2289   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2290
2291   // flush the queue and render once
2292   application.SendNotification();
2293   application.Render();
2294
2295   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2296   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2297   DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2298
2299   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2300   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2301
2302   // flush the queue and render once
2303   application.SendNotification();
2304   application.Render();
2305
2306   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2307   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2308   DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2309
2310
2311   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2312   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2313
2314   // flush the queue and render once
2315   application.SendNotification();
2316   application.Render();
2317
2318   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2319   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2320   DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2321
2322   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2323   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2324
2325   actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2326
2327
2328   // flush the queue and render once
2329   application.SendNotification();
2330   application.Render();
2331
2332   DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2333
2334   END_TEST;
2335 }
2336
2337
2338 int UtcDaliActorGetCurrentColor(void)
2339 {
2340   TestApplication application;
2341   Actor actor = Actor::New();
2342   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2343
2344   actor.SetColor(color);
2345   // flush the queue and render once
2346   application.SendNotification();
2347   application.Render();
2348   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2349   END_TEST;
2350 }
2351
2352 int UtcDaliActorGetCurrentWorldColor(void)
2353 {
2354   tet_infoline("Actor::GetCurrentWorldColor");
2355   TestApplication application;
2356
2357   Actor parent = Actor::New();
2358   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2359   parent.SetColor( parentColor );
2360   Stage::GetCurrent().Add( parent );
2361
2362   Actor child = Actor::New();
2363   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2364   child.SetColor( childColor );
2365   parent.Add( child );
2366
2367   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2368   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2369
2370   // verify the default color mode
2371   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2372
2373   // The actors should not have a world color yet
2374   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2375   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2376
2377   application.SendNotification();
2378   application.Render(0);
2379
2380   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2381   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2382
2383   // The actors should have a world color now
2384   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2385   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2386
2387   // use own color
2388   child.SetColorMode( USE_OWN_COLOR );
2389   application.SendNotification();
2390   application.Render(0);
2391   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2392
2393   // use parent color
2394   child.SetColorMode( USE_PARENT_COLOR );
2395   application.SendNotification();
2396   application.Render(0);
2397   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2398   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2399
2400   // use parent alpha
2401   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2402   application.SendNotification();
2403   application.Render(0);
2404   Vector4 expectedColor( childColor );
2405   expectedColor.a *= parentColor.a;
2406   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2407   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2408   END_TEST;
2409 }
2410
2411 int UtcDaliActorSetColorMode(void)
2412 {
2413   tet_infoline("Actor::SetColorMode");
2414   TestApplication application;
2415   Actor actor = Actor::New();
2416   Actor child = Actor::New();
2417   actor.Add( child );
2418
2419   actor.SetColorMode( USE_OWN_COLOR );
2420   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2421
2422   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2423   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2424
2425   actor.SetColorMode( USE_PARENT_COLOR );
2426   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2427
2428   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2429   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2430   END_TEST;
2431 }
2432
2433 int UtcDaliActorScreenToLocal(void)
2434 {
2435   TestApplication application;
2436   Actor actor = Actor::New();
2437   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2438   actor.SetSize(100.0f, 100.0f);
2439   actor.SetPosition(10.0f, 10.0f);
2440   Stage::GetCurrent().Add(actor);
2441
2442   // flush the queue and render once
2443   application.SendNotification();
2444   application.Render();
2445
2446   float localX;
2447   float localY;
2448
2449   application.SendNotification();
2450   application.Render();
2451
2452   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2453
2454   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2455   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2456   END_TEST;
2457 }
2458
2459 int UtcDaliActorSetLeaveRequired(void)
2460 {
2461   TestApplication application;
2462
2463   Actor actor = Actor::New();
2464
2465   actor.SetLeaveRequired(false);
2466   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2467
2468   actor.SetLeaveRequired(true);
2469   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2470   END_TEST;
2471 }
2472
2473 int UtcDaliActorGetLeaveRequired(void)
2474 {
2475   TestApplication application;
2476
2477   Actor actor = Actor::New();
2478
2479   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2480   END_TEST;
2481 }
2482
2483 int UtcDaliActorSetKeyboardFocusable(void)
2484 {
2485   TestApplication application;
2486
2487   Actor actor = Actor::New();
2488
2489   actor.SetKeyboardFocusable(true);
2490   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2491
2492   actor.SetKeyboardFocusable(false);
2493   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2494   END_TEST;
2495 }
2496
2497 int UtcDaliActorIsKeyboardFocusable(void)
2498 {
2499   TestApplication application;
2500
2501   Actor actor = Actor::New();
2502
2503   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2504   END_TEST;
2505 }
2506
2507 int UtcDaliActorRemoveConstraints(void)
2508 {
2509   tet_infoline(" UtcDaliActorRemoveConstraints");
2510   TestApplication application;
2511
2512   gTestConstraintCalled = false;
2513
2514   Actor actor = Actor::New();
2515
2516   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2517   constraint.Apply();
2518   actor.RemoveConstraints();
2519
2520   DALI_TEST_CHECK( gTestConstraintCalled == false );
2521
2522   Stage::GetCurrent().Add( actor );
2523   constraint.Apply();
2524
2525   // flush the queue and render once
2526   application.SendNotification();
2527   application.Render();
2528
2529   actor.RemoveConstraints();
2530
2531   DALI_TEST_CHECK( gTestConstraintCalled == true );
2532   END_TEST;
2533 }
2534
2535 int UtcDaliActorRemoveConstraintTag(void)
2536 {
2537   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2538   TestApplication application;
2539
2540   Actor actor = Actor::New();
2541
2542   // 1. Apply Constraint1 and Constraint2, and test...
2543   unsigned int result1 = 0u;
2544   unsigned int result2 = 0u;
2545
2546   unsigned constraint1Tag = 1u;
2547   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2548   constraint1.SetTag( constraint1Tag );
2549   constraint1.Apply();
2550
2551   unsigned constraint2Tag = 2u;
2552   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2553   constraint2.SetTag( constraint2Tag );
2554   constraint2.Apply();
2555
2556   Stage::GetCurrent().Add( actor );
2557   // flush the queue and render once
2558   application.SendNotification();
2559   application.Render();
2560
2561   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2562   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2563
2564   // 2. Remove Constraint1 and test...
2565   result1 = 0;
2566   result2 = 0;
2567   actor.RemoveConstraints(constraint1Tag);
2568   // make color property dirty, which will trigger constraints to be reapplied.
2569   actor.SetColor( Color::WHITE );
2570   // flush the queue and render once
2571   application.SendNotification();
2572   application.Render();
2573
2574   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2575   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2576
2577   // 3. Re-Apply Constraint1 and test...
2578   result1 = 0;
2579   result2 = 0;
2580   constraint1.Apply();
2581   // make color property dirty, which will trigger constraints to be reapplied.
2582   actor.SetColor( Color::WHITE );
2583   // flush the queue and render once
2584   application.SendNotification();
2585   application.Render();
2586
2587   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2588   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2589
2590   // 2. Remove Constraint2 and test...
2591   result1 = 0;
2592   result2 = 0;
2593   actor.RemoveConstraints(constraint2Tag);
2594   // make color property dirty, which will trigger constraints to be reapplied.
2595   actor.SetColor( Color::WHITE );
2596   // flush the queue and render once
2597   application.SendNotification();
2598   application.Render();
2599
2600   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2601   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2602
2603   // 2. Remove Constraint1 as well and test...
2604   result1 = 0;
2605   result2 = 0;
2606   actor.RemoveConstraints(constraint1Tag);
2607   // make color property dirty, which will trigger constraints to be reapplied.
2608   actor.SetColor( Color::WHITE );
2609   // flush the queue and render once
2610   application.SendNotification();
2611   application.Render();
2612
2613   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2614   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2615   END_TEST;
2616 }
2617
2618 int UtcDaliActorTouchedSignal(void)
2619 {
2620   TestApplication application;
2621
2622   ResetTouchCallbacks();
2623
2624   // get the root layer
2625   Actor actor = Stage::GetCurrent().GetRootLayer();
2626   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2627
2628   application.SendNotification();
2629   application.Render();
2630
2631   // connect to its touch signal
2632   actor.TouchedSignal().Connect( TestCallback );
2633
2634   // simulate a touch event in the middle of the screen
2635   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2636   Dali::Integration::Point point;
2637   point.SetDeviceId( 1 );
2638   point.SetState( PointState::DOWN );
2639   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2640   Dali::Integration::TouchEvent touchEvent;
2641   touchEvent.AddPoint( point );
2642   application.ProcessEvent( touchEvent );
2643
2644   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2645   END_TEST;
2646 }
2647
2648 int UtcDaliActorHoveredSignal(void)
2649 {
2650   TestApplication application;
2651
2652   gHoverCallBackCalled = false;
2653
2654   // get the root layer
2655   Actor actor = Stage::GetCurrent().GetRootLayer();
2656   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2657
2658   application.SendNotification();
2659   application.Render();
2660
2661   // connect to its hover signal
2662   actor.HoveredSignal().Connect( TestCallback3 );
2663
2664   // simulate a hover event in the middle of the screen
2665   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2666   Dali::Integration::Point point;
2667   point.SetDeviceId( 1 );
2668   point.SetState( PointState::MOTION );
2669   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2670   Dali::Integration::HoverEvent hoverEvent;
2671   hoverEvent.AddPoint( point );
2672   application.ProcessEvent( hoverEvent );
2673
2674   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2675   END_TEST;
2676 }
2677
2678 int UtcDaliActorOnOffStageSignal(void)
2679 {
2680   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2681
2682   TestApplication application;
2683
2684   // clean test data
2685   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2686   gActorNamesOnOffStage.clear();
2687
2688   Actor parent = Actor::New();
2689   parent.SetName( "parent" );
2690   parent.OnStageSignal().Connect( OnStageCallback );
2691   parent.OffStageSignal().Connect( OffStageCallback );
2692   // sanity check
2693   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2694   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2695
2696   // add parent to stage
2697   Stage::GetCurrent().Add( parent );
2698   // onstage emitted, offstage not
2699   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2700   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2701   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2702
2703   // test adding a child, should get onstage emitted
2704   // clean test data
2705   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2706   gActorNamesOnOffStage.clear();
2707
2708   Actor child = Actor::New();
2709   child.SetName( "child" );
2710   child.OnStageSignal().Connect( OnStageCallback );
2711   child.OffStageSignal().Connect( OffStageCallback );
2712   parent.Add( child ); // add child
2713   // onstage emitted, offstage not
2714   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2715   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2716   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2717
2718   // test removing parent from stage
2719   // clean test data
2720   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2721   gActorNamesOnOffStage.clear();
2722
2723   Stage::GetCurrent().Remove( parent );
2724   // onstage not emitted, offstage is
2725   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2726   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2727   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2728   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2729
2730   // test adding parent back to stage
2731   // clean test data
2732   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2733   gActorNamesOnOffStage.clear();
2734
2735   Stage::GetCurrent().Add( parent );
2736   // onstage emitted, offstage not
2737   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2738   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2739   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2740   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2741
2742   // test removing child
2743   // clean test data
2744   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2745   gActorNamesOnOffStage.clear();
2746
2747   parent.Remove( child );
2748   // onstage not emitted, offstage is
2749   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2750   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2751   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2752
2753   // test removing parent
2754   // clean test data
2755   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2756   gActorNamesOnOffStage.clear();
2757
2758   Stage::GetCurrent().Remove( parent );
2759   // onstage not emitted, offstage is
2760   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2761   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2762   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2763   END_TEST;
2764 }
2765
2766 int UtcDaliActorFindChildByName(void)
2767 {
2768   tet_infoline("Testing Dali::Actor::FindChildByName()");
2769   TestApplication application;
2770
2771   Actor parent = Actor::New();
2772   parent.SetName( "parent" );
2773   Actor first  = Actor::New();
2774   first .SetName( "first" );
2775   Actor second = Actor::New();
2776   second.SetName( "second" );
2777
2778   parent.Add(first);
2779   first.Add(second);
2780
2781   Actor found = parent.FindChildByName( "foo" );
2782   DALI_TEST_CHECK( !found );
2783
2784   found = parent.FindChildByName( "parent" );
2785   DALI_TEST_CHECK( found == parent );
2786
2787   found = parent.FindChildByName( "first" );
2788   DALI_TEST_CHECK( found == first );
2789
2790   found = parent.FindChildByName( "second" );
2791   DALI_TEST_CHECK( found == second );
2792   END_TEST;
2793 }
2794
2795 int UtcDaliActorFindChildById(void)
2796 {
2797   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2798   TestApplication application;
2799
2800   Actor parent = Actor::New();
2801   Actor first  = Actor::New();
2802   Actor second = Actor::New();
2803
2804   parent.Add(first);
2805   first.Add(second);
2806
2807   Actor found = parent.FindChildById( 100000 );
2808   DALI_TEST_CHECK( !found );
2809
2810   found = parent.FindChildById( parent.GetId() );
2811   DALI_TEST_CHECK( found == parent );
2812
2813   found = parent.FindChildById( first.GetId() );
2814   DALI_TEST_CHECK( found == first );
2815
2816   found = parent.FindChildById( second.GetId() );
2817   DALI_TEST_CHECK( found == second );
2818   END_TEST;
2819 }
2820
2821 int UtcDaliActorHitTest(void)
2822 {
2823   struct HitTestData
2824   {
2825   public:
2826     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2827     : mScale( scale ),
2828       mTouchPoint( touchPoint ),
2829       mResult( result )
2830     {}
2831
2832     Vector3 mScale;
2833     Vector2 mTouchPoint;
2834     bool mResult;
2835   };
2836
2837   TestApplication application;
2838   tet_infoline(" UtcDaliActorHitTest");
2839
2840   // Fill a vector with different hit tests.
2841   struct HitTestData* hitTestData[] = {
2842     //                    scale                     touch point           result
2843     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2844     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2845     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.
2846     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2847     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.
2848     NULL,
2849   };
2850
2851   // get the root layer
2852   Actor actor = Actor::New();
2853   actor.SetAnchorPoint( AnchorPoint::CENTER );
2854   actor.SetParentOrigin( ParentOrigin::CENTER );
2855
2856   Stage::GetCurrent().Add( actor );
2857
2858   ResetTouchCallbacks();
2859
2860   unsigned int index = 0;
2861   while( NULL != hitTestData[index] )
2862   {
2863     actor.SetSize( 1.f, 1.f );
2864     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2865
2866     // flush the queue and render once
2867     application.SendNotification();
2868     application.Render();
2869
2870     DALI_TEST_CHECK( !gTouchCallBackCalled );
2871
2872     // connect to its touch signal
2873     actor.TouchedSignal().Connect(TestCallback);
2874
2875     Dali::Integration::Point point;
2876     point.SetState( PointState::DOWN );
2877     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2878     Dali::Integration::TouchEvent event;
2879     event.AddPoint( point );
2880
2881     // flush the queue and render once
2882     application.SendNotification();
2883     application.Render();
2884     application.ProcessEvent( event );
2885
2886     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2887
2888     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2889       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2890                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2891                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2892                  hitTestData[index]->mResult );
2893
2894     ResetTouchCallbacks();
2895     ++index;
2896   }
2897   END_TEST;
2898 }
2899
2900 int UtcDaliActorSetDrawMode(void)
2901 {
2902   TestApplication app;
2903   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2904
2905   Actor a = Actor::New();
2906
2907   Stage::GetCurrent().Add(a);
2908   app.SendNotification();
2909   app.Render(0);
2910   app.SendNotification();
2911   app.Render(1);
2912
2913   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2914
2915   a.SetDrawMode( DrawMode::OVERLAY_2D );
2916   app.SendNotification();
2917   app.Render(1);
2918
2919   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2920
2921   a.SetDrawMode( DrawMode::NORMAL );
2922   app.SendNotification();
2923   app.Render(1);
2924
2925   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2926   END_TEST;
2927 }
2928
2929 int UtcDaliActorSetDrawModeOverlayRender(void)
2930 {
2931   TestApplication app;
2932   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2933
2934   app.SendNotification();
2935   app.Render(1);
2936
2937   std::vector<GLuint> ids;
2938   ids.push_back( 8 );   // first rendered actor
2939   ids.push_back( 9 );   // second rendered actor
2940   ids.push_back( 10 );  // third rendered actor
2941   app.GetGlAbstraction().SetNextTextureIds( ids );
2942
2943   BufferImage imageA = BufferImage::New(16, 16);
2944   BufferImage imageB = BufferImage::New(16, 16);
2945   BufferImage imageC = BufferImage::New(16, 16);
2946   Actor a = CreateRenderableActor( imageA );
2947   Actor b = CreateRenderableActor( imageB );
2948   Actor c = CreateRenderableActor( imageC );
2949
2950   app.SendNotification();
2951   app.Render(1);
2952
2953   //Textures are bound when first created. Clear bound textures vector
2954   app.GetGlAbstraction().ClearBoundTextures();
2955
2956   // Render a,b,c as regular non-overlays. so order will be:
2957   // a (8)
2958   // b (9)
2959   // c (10)
2960   Stage::GetCurrent().Add(a);
2961   Stage::GetCurrent().Add(b);
2962   Stage::GetCurrent().Add(c);
2963
2964   app.SendNotification();
2965   app.Render(1);
2966
2967   // Should be 3 textures changes.
2968   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2969   typedef std::vector<GLuint>::size_type TextureSize;
2970   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2971   if( boundTextures.size() == 3 )
2972   {
2973     DALI_TEST_CHECK( boundTextures[0] == 8u );
2974     DALI_TEST_CHECK( boundTextures[1] == 9u );
2975     DALI_TEST_CHECK( boundTextures[2] == 10u );
2976   }
2977
2978   // Now texture ids have been set, we can monitor their render order.
2979   // render a as an overlay (last), so order will be:
2980   // b (9)
2981   // c (10)
2982   // a (8)
2983   a.SetDrawMode( DrawMode::OVERLAY_2D );
2984   app.GetGlAbstraction().ClearBoundTextures();
2985
2986   app.SendNotification();
2987   app.Render(1);
2988
2989   // Should be 3 texture changes.
2990   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2991   if( boundTextures.size() == 3 )
2992   {
2993     DALI_TEST_CHECK( boundTextures[0] == 9u );
2994     DALI_TEST_CHECK( boundTextures[1] == 10u );
2995     DALI_TEST_CHECK( boundTextures[2] == 8u );
2996   }
2997   END_TEST;
2998 }
2999
3000 int UtcDaliActorGetCurrentWorldMatrix(void)
3001 {
3002   TestApplication app;
3003   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3004
3005   Actor parent = Actor::New();
3006   parent.SetParentOrigin(ParentOrigin::CENTER);
3007   parent.SetAnchorPoint(AnchorPoint::CENTER);
3008   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3009   Radian rotationAngle(Degree(85.0f));
3010   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3011   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3012   parent.SetPosition( parentPosition );
3013   parent.SetOrientation( parentRotation );
3014   parent.SetScale( parentScale );
3015   Stage::GetCurrent().Add( parent );
3016
3017   Actor child = Actor::New();
3018   child.SetParentOrigin(ParentOrigin::CENTER);
3019   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3020   Radian childRotationAngle(Degree(23.0f));
3021   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3022   Vector3 childScale( 2.0f, 2.0f, 2.0f );
3023   child.SetPosition( childPosition );
3024   child.SetOrientation( childRotation );
3025   child.SetScale( childScale );
3026   parent.Add( child );
3027
3028   app.SendNotification();
3029   app.Render(0);
3030   app.Render();
3031   app.SendNotification();
3032
3033   Matrix parentMatrix(false);
3034   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3035
3036   Matrix childMatrix(false);
3037   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3038
3039   //Child matrix should be the composition of child and parent
3040   Matrix childWorldMatrix(false);
3041   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3042
3043   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3044   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
3045   END_TEST;
3046 }
3047
3048
3049
3050 int UtcDaliActorConstrainedToWorldMatrix(void)
3051 {
3052   TestApplication app;
3053   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3054
3055   Actor parent = Actor::New();
3056   parent.SetParentOrigin(ParentOrigin::CENTER);
3057   parent.SetAnchorPoint(AnchorPoint::CENTER);
3058   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3059   Radian rotationAngle(Degree(85.0f));
3060   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3061   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3062   parent.SetPosition( parentPosition );
3063   parent.SetOrientation( parentRotation );
3064   parent.SetScale( parentScale );
3065   Stage::GetCurrent().Add( parent );
3066
3067   Actor child = Actor::New();
3068   child.SetParentOrigin(ParentOrigin::CENTER);
3069   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3070   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3071   posConstraint.Apply();
3072
3073   Stage::GetCurrent().Add( child );
3074
3075   app.SendNotification();
3076   app.Render(0);
3077   app.Render();
3078   app.SendNotification();
3079
3080   Matrix parentMatrix(false);
3081   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3082
3083   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3084   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3085   END_TEST;
3086 }
3087
3088 int UtcDaliActorConstrainedToOrientation(void)
3089 {
3090   TestApplication app;
3091   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3092
3093   Actor parent = Actor::New();
3094   parent.SetParentOrigin(ParentOrigin::CENTER);
3095   parent.SetAnchorPoint(AnchorPoint::CENTER);
3096   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3097   Radian rotationAngle(Degree(85.0f));
3098   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3099   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3100   parent.SetPosition( parentPosition );
3101   parent.SetOrientation( parentRotation );
3102   parent.SetScale( parentScale );
3103   Stage::GetCurrent().Add( parent );
3104
3105   Actor child = Actor::New();
3106   child.SetParentOrigin(ParentOrigin::CENTER);
3107   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3108   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3109   posConstraint.Apply();
3110
3111   Stage::GetCurrent().Add( child );
3112
3113   app.SendNotification();
3114   app.Render(0);
3115   app.Render();
3116   app.SendNotification();
3117
3118   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3119   END_TEST;
3120 }
3121
3122 int UtcDaliActorConstrainedToOpacity(void)
3123 {
3124   TestApplication app;
3125   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3126
3127   Actor parent = Actor::New();
3128   parent.SetOpacity( 0.7f );
3129   Stage::GetCurrent().Add( parent );
3130
3131   Actor child = Actor::New();
3132   Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3133   opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3134   opacityConstraint.Apply();
3135
3136   Stage::GetCurrent().Add( child );
3137
3138   app.SendNotification();
3139   app.Render(0);
3140   app.Render();
3141   app.SendNotification();
3142
3143   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3144
3145   parent.SetOpacity( 0.3f );
3146
3147   app.SendNotification();
3148   app.Render(0);
3149   app.Render();
3150   app.SendNotification();
3151
3152   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3153
3154   END_TEST;
3155 }
3156
3157 int UtcDaliActorUnparent(void)
3158 {
3159   TestApplication app;
3160   tet_infoline(" UtcDaliActorUnparent");
3161
3162   Actor parent = Actor::New();
3163   Stage::GetCurrent().Add( parent );
3164
3165   Actor child = Actor::New();
3166
3167   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3168   DALI_TEST_CHECK( !child.GetParent() );
3169
3170   // Test that calling Unparent with no parent is a NOOP
3171   child.Unparent();
3172
3173   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3174   DALI_TEST_CHECK( !child.GetParent() );
3175
3176   // Test that Unparent works
3177   parent.Add( child );
3178
3179   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3180   DALI_TEST_CHECK( parent == child.GetParent() );
3181
3182   child.Unparent();
3183
3184   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3185   DALI_TEST_CHECK( !child.GetParent() );
3186
3187   // Test that UnparentAndReset works
3188   parent.Add( child );
3189
3190   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3191   DALI_TEST_CHECK( parent == child.GetParent() );
3192
3193   UnparentAndReset( child );
3194
3195   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3196   DALI_TEST_CHECK( !child );
3197
3198   // Test that UnparentAndReset is a NOOP with empty handle
3199   UnparentAndReset( child );
3200
3201   DALI_TEST_CHECK( !child );
3202   END_TEST;
3203 }
3204
3205 int UtcDaliActorGetChildAt(void)
3206 {
3207   TestApplication app;
3208   tet_infoline(" UtcDaliActorGetChildAt");
3209
3210   Actor parent = Actor::New();
3211   Stage::GetCurrent().Add( parent );
3212
3213   Actor child0 = Actor::New();
3214   parent.Add( child0 );
3215
3216   Actor child1 = Actor::New();
3217   parent.Add( child1 );
3218
3219   Actor child2 = Actor::New();
3220   parent.Add( child2 );
3221
3222   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3223   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3224   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3225   END_TEST;
3226 }
3227
3228 int UtcDaliActorSetGetOverlay(void)
3229 {
3230   TestApplication app;
3231   tet_infoline(" UtcDaliActorSetGetOverlay");
3232
3233   Actor parent = Actor::New();
3234   parent.SetDrawMode(DrawMode::OVERLAY_2D );
3235   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3236   END_TEST;
3237 }
3238
3239
3240 int UtcDaliActorCreateDestroy(void)
3241 {
3242   Actor* actor = new Actor;
3243   DALI_TEST_CHECK( actor );
3244   delete actor;
3245   END_TEST;
3246 }
3247
3248 namespace
3249 {
3250 struct PropertyStringIndex
3251 {
3252   const char * const name;
3253   const Property::Index index;
3254   const Property::Type type;
3255 };
3256
3257 const PropertyStringIndex PROPERTY_TABLE[] =
3258 {
3259   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
3260   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
3261   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
3262   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
3263   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
3264   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
3265   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
3266   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
3267   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
3268   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
3269   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
3270   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
3271   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
3272   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
3273   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
3274   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
3275   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
3276   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
3277   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
3278   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
3279   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
3280   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
3281   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
3282   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
3283   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
3284   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
3285   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
3286   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
3287   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
3288   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
3289   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
3290   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
3291   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
3292   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
3293   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
3294   { "name",                     Actor::Property::NAME,                     Property::STRING      },
3295   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
3296   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
3297   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
3298   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
3299   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
3300   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
3301   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
3302   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
3303   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
3304   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
3305   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
3306   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
3307   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
3308   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
3309   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
3310   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
3311   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
3312   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
3313   { "opacity",                  DevelActor::Property::OPACITY,             Property::FLOAT       },
3314 };
3315 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3316 } // unnamed namespace
3317
3318 int UtcDaliActorProperties(void)
3319 {
3320   TestApplication app;
3321
3322   Actor actor = Actor::New();
3323
3324   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3325   {
3326     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3327     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3328     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3329     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3330   }
3331   END_TEST;
3332 }
3333
3334 int UtcDaliRelayoutProperties_ResizePolicies(void)
3335 {
3336   TestApplication app;
3337
3338   Actor actor = Actor::New();
3339
3340   // Defaults
3341   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3342   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3343
3344   // Set resize policy for all dimensions
3345   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3346   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3347   {
3348     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3349   }
3350
3351   // Set individual dimensions
3352   const char* const widthPolicy = "FILL_TO_PARENT";
3353   const char* const heightPolicy = "FIXED";
3354
3355   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3356   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3357
3358   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3359   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3360
3361   // Set individual dimensions using enums
3362   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3363   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3364
3365   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3366   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3367
3368   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3369   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3370
3371   END_TEST;
3372 }
3373
3374 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3375 {
3376   TestApplication app;
3377
3378   Actor actor = Actor::New();
3379
3380   // Defaults
3381   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3382   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3383
3384   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3385   actor.SetSizeScalePolicy( policy );
3386   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3387
3388   // Set
3389   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3390   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3391
3392   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3393   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3394
3395   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3396   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3397
3398   END_TEST;
3399 }
3400
3401 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3402 {
3403   TestApplication app;
3404
3405   Actor actor = Actor::New();
3406
3407   // Defaults
3408   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3409   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3410
3411   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3412   actor.SetSizeModeFactor( sizeMode );
3413   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3414
3415   // Set
3416   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3417
3418   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3419   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3420
3421   END_TEST;
3422 }
3423
3424 int UtcDaliRelayoutProperties_DimensionDependency(void)
3425 {
3426   TestApplication app;
3427
3428   Actor actor = Actor::New();
3429
3430   // Defaults
3431   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3432   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3433
3434   // Set
3435   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3436   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3437
3438   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3439   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3440
3441   // Test setting another resize policy
3442   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3443   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3444
3445   END_TEST;
3446 }
3447
3448 int UtcDaliRelayoutProperties_Padding(void)
3449 {
3450   TestApplication app;
3451
3452   Actor actor = Actor::New();
3453
3454   // Data
3455   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3456
3457   // PADDING
3458   actor.SetProperty( Actor::Property::PADDING, padding );
3459   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3460
3461   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3462
3463   END_TEST;
3464 }
3465
3466 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3467 {
3468   TestApplication app;
3469
3470   Actor actor = Actor::New();
3471
3472   // Data
3473   Vector2 minSize( 1.0f, 2.0f );
3474
3475   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3476   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3477
3478   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3479
3480   Vector2 maxSize( 3.0f, 4.0f );
3481
3482   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3483   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3484
3485   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3486
3487   END_TEST;
3488 }
3489
3490 int UtcDaliActorGetHeightForWidth(void)
3491 {
3492   TestApplication app;
3493
3494   Actor actor = Actor::New();
3495
3496   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3497
3498   END_TEST;
3499 }
3500
3501 int UtcDaliActorGetWidthForHeight(void)
3502 {
3503   TestApplication app;
3504
3505   Actor actor = Actor::New();
3506
3507   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3508
3509   END_TEST;
3510 }
3511
3512 int UtcDaliActorGetRelayoutSize(void)
3513 {
3514   TestApplication app;
3515
3516   Actor actor = Actor::New();
3517
3518   // Add actor to stage
3519   Stage::GetCurrent().Add( actor );
3520
3521   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3522
3523   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3524   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3525
3526   // Flush the queue and render once
3527   app.SendNotification();
3528   app.Render();
3529
3530   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3531
3532   END_TEST;
3533 }
3534
3535 int UtcDaliActorSetPadding(void)
3536 {
3537   TestApplication app;
3538
3539   Actor actor = Actor::New();
3540
3541   Padding padding;
3542   actor.GetPadding( padding );
3543
3544   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3545   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3546   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3547   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3548
3549   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3550   actor.SetPadding( padding2 );
3551
3552   actor.GetPadding( padding );
3553
3554   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3555   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3556   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3557   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3558
3559   END_TEST;
3560 }
3561
3562 int UtcDaliActorSetMinimumSize(void)
3563 {
3564   TestApplication app;
3565
3566   Actor actor = Actor::New();
3567
3568   Vector2 size = actor.GetMinimumSize();
3569
3570   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3571   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3572
3573   Vector2 size2( 1.0f, 2.0f );
3574   actor.SetMinimumSize( size2 );
3575
3576   size = actor.GetMinimumSize();
3577
3578   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3579   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3580
3581   END_TEST;
3582 }
3583
3584 int UtcDaliActorSetMaximumSize(void)
3585 {
3586   TestApplication app;
3587
3588   Actor actor = Actor::New();
3589
3590   Vector2 size = actor.GetMaximumSize();
3591
3592   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3593   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3594
3595   Vector2 size2( 1.0f, 2.0f );
3596   actor.SetMaximumSize( size2 );
3597
3598   size = actor.GetMaximumSize();
3599
3600   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3601   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3602
3603   END_TEST;
3604 }
3605
3606 int UtcDaliActorOnRelayoutSignal(void)
3607 {
3608   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3609
3610   TestApplication application;
3611
3612   // Clean test data
3613   gOnRelayoutCallBackCalled = false;
3614   gActorNamesRelayout.clear();
3615
3616   Actor actor = Actor::New();
3617   actor.SetName( "actor" );
3618   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3619
3620   // Sanity check
3621   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3622
3623   // Add actor to stage
3624   Stage::GetCurrent().Add( actor );
3625
3626   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3627   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3628
3629   // Flush the queue and render once
3630   application.SendNotification();
3631   application.Render();
3632
3633   // OnRelayout emitted
3634   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3635   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3636
3637   END_TEST;
3638 }
3639
3640 int UtcDaliActorGetHierachyDepth(void)
3641 {
3642   TestApplication application;
3643   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3644
3645
3646   /* Build tree of actors:
3647    *
3648    *                      Depth
3649    *
3650    *       A (parent)       1
3651    *      / \
3652    *     B   C              2`
3653    *    / \   \
3654    *   D   E   F            3
3655    *
3656    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3657    */
3658   Stage stage( Stage::GetCurrent() );
3659
3660   Actor actorA = Actor::New();
3661   Actor actorB = Actor::New();
3662   Actor actorC = Actor::New();
3663   Actor actorD = Actor::New();
3664   Actor actorE = Actor::New();
3665   Actor actorF = Actor::New();
3666
3667   //Test that root actor has depth equal 0
3668   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3669
3670   //Test actors return depth -1 when not connected to the tree
3671   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3672   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3673   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3674   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3675   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3676   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3677
3678   //Create the hierarchy
3679   stage.Add( actorA );
3680   actorA.Add( actorB );
3681   actorA.Add( actorC );
3682   actorB.Add( actorD );
3683   actorB.Add( actorE );
3684   actorC.Add( actorF );
3685
3686   //Test actors return correct depth
3687   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3688   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3689   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3690   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3691   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3692   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3693
3694   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3695   actorA.Remove( actorB );
3696
3697   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3698   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3699   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3700
3701   //Removing actorA from the stage. All actors should have depth equal -1
3702   stage.Remove( actorA );
3703
3704   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3705   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3706   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3707   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3708   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3709   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3710
3711   END_TEST;
3712 }
3713
3714 int UtcDaliActorAnchorPointPropertyAsString(void)
3715 {
3716   TestApplication application;
3717
3718   Actor actor = Actor::New();
3719
3720   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3721   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3722
3723   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3724   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3725
3726   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3727   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3728
3729   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3730   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3731
3732   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3733   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3734
3735   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3736   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3737
3738   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3739   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3740
3741   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3742   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3743
3744   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3745   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3746
3747   // Invalid should not change anything
3748   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3749   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3750
3751   END_TEST;
3752 }
3753
3754 int UtcDaliActorParentOriginPropertyAsString(void)
3755 {
3756   TestApplication application;
3757
3758   Actor actor = Actor::New();
3759
3760   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3761   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3762
3763   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3764   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3765
3766   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3767   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3768
3769   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3770   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3771
3772   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3773   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3774
3775   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3776   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3777
3778   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3779   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3780
3781   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3782   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3783
3784   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3785   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3786
3787   // Invalid should not change anything
3788   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3789   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3790
3791   END_TEST;
3792 }
3793
3794 int UtcDaliActorColorModePropertyAsString(void)
3795 {
3796   TestApplication application;
3797
3798   Actor actor = Actor::New();
3799
3800   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3801   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3802
3803   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3804   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3805
3806   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3807   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3808
3809   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3810   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3811
3812   // Invalid should not change anything
3813   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3814   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3815
3816   END_TEST;
3817 }
3818
3819 int UtcDaliActorPositionInheritancePropertyAsString(void)
3820 {
3821   TestApplication application;
3822
3823   Actor actor = Actor::New();
3824
3825   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3826   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3827
3828   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3829   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3830
3831   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3832   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3833
3834   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3835   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3836
3837   // Invalid should not change anything
3838   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3839   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3840
3841   END_TEST;
3842 }
3843
3844 int UtcDaliActorDrawModePropertyAsString(void)
3845 {
3846   TestApplication application;
3847
3848   Actor actor = Actor::New();
3849
3850   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3851   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3852
3853   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3854   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3855
3856   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3857   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3858
3859   // Invalid should not change anything
3860   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3861   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3862
3863   END_TEST;
3864 }
3865
3866 int UtcDaliActorColorModePropertyAsEnum(void)
3867 {
3868   TestApplication application;
3869
3870   Actor actor = Actor::New();
3871
3872   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3873   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3874
3875   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3876   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3877
3878   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3879   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3880
3881   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3882   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3883
3884   END_TEST;
3885 }
3886
3887 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3888 {
3889   TestApplication application;
3890
3891   Actor actor = Actor::New();
3892
3893   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3894   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3895
3896   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3897   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3898
3899   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3900   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3901
3902   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3903   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3904
3905   END_TEST;
3906 }
3907
3908 int UtcDaliActorDrawModePropertyAsEnum(void)
3909 {
3910   TestApplication application;
3911
3912   Actor actor = Actor::New();
3913
3914   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3915   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3916
3917   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3918   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3919
3920   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3921   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3922
3923   END_TEST;
3924 }
3925
3926 int UtcDaliActorAddRendererP(void)
3927 {
3928   tet_infoline("Testing Actor::AddRenderer");
3929   TestApplication application;
3930
3931   Actor actor = Actor::New();
3932
3933   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3934
3935   Geometry geometry = CreateQuadGeometry();
3936   Shader shader = CreateShader();
3937   Renderer renderer = Renderer::New(geometry, shader);
3938
3939   actor.AddRenderer( renderer );
3940   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3941   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3942
3943   END_TEST;
3944 }
3945
3946 int UtcDaliActorAddRendererN(void)
3947 {
3948   tet_infoline("Testing Actor::AddRenderer");
3949   TestApplication application;
3950
3951   Actor actor = Actor::New();
3952   Renderer renderer;
3953
3954   // try illegal Add
3955   try
3956   {
3957     actor.AddRenderer( renderer );
3958     tet_printf("Assertion test failed - no Exception\n" );
3959     tet_result(TET_FAIL);
3960   }
3961   catch(Dali::DaliException& e)
3962   {
3963     DALI_TEST_PRINT_ASSERT( e );
3964     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3965     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3966   }
3967   catch(...)
3968   {
3969     tet_printf("Assertion test failed - wrong Exception\n" );
3970     tet_result(TET_FAIL);
3971   }
3972
3973   END_TEST;
3974 }
3975
3976 int UtcDaliActorAddRendererOnStage(void)
3977 {
3978   tet_infoline("Testing Actor::AddRenderer");
3979   TestApplication application;
3980
3981   Actor actor = Actor::New();
3982   Stage::GetCurrent().Add(actor);
3983
3984   application.SendNotification();
3985   application.Render(0);
3986
3987   Geometry geometry = CreateQuadGeometry();
3988   Shader shader = CreateShader();
3989   Renderer renderer = Renderer::New(geometry, shader);
3990
3991   application.SendNotification();
3992   application.Render(0);
3993
3994   try
3995   {
3996     actor.AddRenderer( renderer );
3997     tet_result(TET_PASS);
3998   }
3999   catch(...)
4000   {
4001     tet_result(TET_FAIL);
4002   }
4003
4004   END_TEST;
4005 }
4006
4007 int UtcDaliActorRemoveRendererP1(void)
4008 {
4009   tet_infoline("Testing Actor::RemoveRenderer");
4010   TestApplication application;
4011
4012   Actor actor = Actor::New();
4013
4014   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4015
4016   {
4017     Geometry geometry = CreateQuadGeometry();
4018     Shader shader = CreateShader();
4019     Renderer renderer = Renderer::New(geometry, shader);
4020
4021     actor.AddRenderer( renderer );
4022     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4023     DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4024
4025     application.SendNotification();
4026     application.Render();
4027   }
4028
4029   {
4030     Renderer renderer = actor.GetRendererAt(0);
4031     actor.RemoveRenderer(renderer);
4032     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4033
4034     application.SendNotification();
4035     application.Render();
4036   }
4037
4038   // Call one final time to ensure that the renderer is actually removed after
4039   // the handle goes out of scope, and excercises the deletion code path in
4040   // scene graph and render.
4041   application.SendNotification();
4042   application.Render();
4043
4044   END_TEST;
4045 }
4046
4047 int UtcDaliActorRemoveRendererP2(void)
4048 {
4049   tet_infoline("Testing Actor::RemoveRenderer");
4050   TestApplication application;
4051
4052   Actor actor = Actor::New();
4053
4054   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4055
4056   Geometry geometry = CreateQuadGeometry();
4057   Shader shader = CreateShader();
4058   Renderer renderer = Renderer::New(geometry, shader);
4059
4060   actor.AddRenderer( renderer );
4061   application.SendNotification();
4062   application.Render();
4063
4064   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4065   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4066
4067   actor.RemoveRenderer(0);
4068   application.SendNotification();
4069   application.Render();
4070
4071   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4072
4073   // Shut down whilst holding onto the renderer handle.
4074   END_TEST;
4075 }
4076
4077
4078 int UtcDaliActorRemoveRendererN(void)
4079 {
4080   tet_infoline("Testing Actor::RemoveRenderer");
4081   TestApplication application;
4082
4083   Actor actor = Actor::New();
4084
4085   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4086
4087   Geometry geometry = CreateQuadGeometry();
4088   Shader shader = CreateShader();
4089   Renderer renderer = Renderer::New(geometry, shader);
4090
4091   actor.AddRenderer( renderer );
4092   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4093   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4094
4095   actor.RemoveRenderer(10);
4096   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4097   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4098
4099   END_TEST;
4100 }
4101
4102 // Clipping test helper functions:
4103 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4104 {
4105   BufferImage image = BufferImage::New( width, height );
4106   Actor actor = CreateRenderableActor( image );
4107
4108   // Setup dimensions and position so actor is not skipped by culling.
4109   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4110   actor.SetSize( width, height );
4111   actor.SetParentOrigin( ParentOrigin::CENTER );
4112   actor.SetAnchorPoint( AnchorPoint::CENTER );
4113
4114   return actor;
4115 }
4116
4117 Actor CreateActorWithContent16x16()
4118 {
4119   return CreateActorWithContent( 16, 16 );
4120 }
4121
4122 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4123 {
4124   enabledDisableTrace.Reset();
4125   stencilTrace.Reset();
4126   enabledDisableTrace.Enable( true );
4127   stencilTrace.Enable( true );
4128
4129   application.SendNotification();
4130   application.Render();
4131
4132   enabledDisableTrace.Enable( false );
4133   stencilTrace.Enable( false );
4134 }
4135
4136 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4137 {
4138   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4139
4140   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
4141   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4142   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
4143   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4144 }
4145
4146 int UtcDaliActorPropertyClippingP(void)
4147 {
4148   // This test checks the clippingMode property.
4149   tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4150   TestApplication application;
4151
4152   Actor actor = Actor::New();
4153
4154   // Check default clippingEnabled value.
4155   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4156
4157   int value = 0;
4158   bool getValueResult = getValue.Get( value );
4159   DALI_TEST_CHECK( getValueResult );
4160
4161   if( getValueResult )
4162   {
4163     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4164   }
4165
4166   // Check setting the property to the stencil mode.
4167   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4168
4169   // Check the new value was set.
4170   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4171   getValueResult = getValue.Get( value );
4172   DALI_TEST_CHECK( getValueResult );
4173
4174   if( getValueResult )
4175   {
4176     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4177   }
4178
4179   // Check setting the property to the scissor mode.
4180   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4181
4182   // Check the new value was set.
4183   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4184   getValueResult = getValue.Get( value );
4185   DALI_TEST_CHECK( getValueResult );
4186
4187   if( getValueResult )
4188   {
4189     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4190   }
4191   END_TEST;
4192 }
4193
4194 int UtcDaliActorPropertyClippingN(void)
4195 {
4196   // Negative test case for Clipping.
4197   tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4198   TestApplication application;
4199
4200   Actor actor = Actor::New();
4201
4202   // Check default clippingEnabled value.
4203   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4204
4205   int value = 0;
4206   bool getValueResult = getValue.Get( value );
4207   DALI_TEST_CHECK( getValueResult );
4208
4209   if( getValueResult )
4210   {
4211     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4212   }
4213
4214   // Check setting an invalid property value won't change the current property value.
4215   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4216
4217   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4218   getValueResult = getValue.Get( value );
4219   DALI_TEST_CHECK( getValueResult );
4220
4221   if( getValueResult )
4222   {
4223     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4224   }
4225
4226   END_TEST;
4227 }
4228
4229 int UtcDaliActorPropertyClippingActor(void)
4230 {
4231   // This test checks that an actor is correctly setup for clipping.
4232   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4233   TestApplication application;
4234
4235   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4236   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4237   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4238   size_t startIndex = 0u;
4239
4240   // Create a clipping actor.
4241   Actor actorDepth1Clip = CreateActorWithContent16x16();
4242   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4243   Stage::GetCurrent().Add( actorDepth1Clip );
4244
4245   // Gather the call trace.
4246   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4247
4248   // Check we are writing to the color buffer.
4249   CheckColorMask( glAbstraction, true );
4250
4251   // Check the stencil buffer was enabled.
4252   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4253
4254   // Check the stencil buffer was cleared.
4255   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4256
4257   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4258   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4259   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4260   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4261
4262   END_TEST;
4263 }
4264
4265 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4266 {
4267   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4268   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4269   TestApplication application;
4270
4271   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4272   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4273   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4274   size_t startIndex = 0u;
4275
4276   // Create a clipping actor.
4277   Actor actorDepth1Clip = CreateActorWithContent16x16();
4278   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4279   Stage::GetCurrent().Add( actorDepth1Clip );
4280
4281   // Gather the call trace.
4282   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4283
4284   // Check we are writing to the color buffer.
4285   CheckColorMask( glAbstraction, true );
4286
4287   // Check the stencil buffer was enabled.
4288   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4289
4290   // Check the stencil buffer was cleared.
4291   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4292
4293   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4294   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4295   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4296   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4297
4298   // Now disable the clipping
4299   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4300
4301   // Gather the call trace.
4302   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4303
4304   // Check the stencil buffer was disabled.
4305   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4306
4307   // Ensure all values in stencil-mask are set to 1.
4308   startIndex = 0u;
4309   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4310
4311   END_TEST;
4312 }
4313
4314 int UtcDaliActorPropertyClippingNestedChildren(void)
4315 {
4316   // This test checks that a hierarchy of actors are clipped correctly by
4317   // writing to and reading from the correct bit-planes of the stencil buffer.
4318   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4319   TestApplication application;
4320   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4321   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4322   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4323
4324   // Create a clipping actor.
4325   Actor actorDepth1Clip = CreateActorWithContent16x16();
4326   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4327   Stage::GetCurrent().Add( actorDepth1Clip );
4328
4329   // Create a child actor.
4330   Actor childDepth2 = CreateActorWithContent16x16();
4331   actorDepth1Clip.Add( childDepth2 );
4332
4333   // Create another clipping actor.
4334   Actor childDepth2Clip = CreateActorWithContent16x16();
4335   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4336   childDepth2.Add( childDepth2Clip );
4337
4338   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4339   // This tests the sort algorithm.
4340   Actor childDepth3 = CreateActorWithContent16x16();
4341   childDepth2Clip.Add( childDepth3 );
4342   Actor childDepth4 = CreateActorWithContent16x16();
4343   childDepth3.Add( childDepth4 );
4344
4345   // Gather the call trace.
4346   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4347
4348   // Check we are writing to the color buffer.
4349   CheckColorMask( glAbstraction, true );
4350
4351   // Check the stencil buffer was enabled.
4352   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4353
4354   // Perform the test twice, once for 2D layer, and once for 3D.
4355   for( unsigned int i = 0u ; i < 2u; ++i )
4356   {
4357     size_t startIndex = 0u;
4358
4359     // Check the stencil buffer was cleared.
4360     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4361
4362     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4363     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4364     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4365     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4366
4367     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4368     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4369     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4370
4371     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4372     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4373     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4374     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4375
4376     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4377     // (Both must be set to pass the check).
4378     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4379     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4380
4381     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4382     if( i == 0u )
4383     {
4384       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4385       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4386     }
4387   }
4388
4389   END_TEST;
4390 }
4391
4392 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4393 {
4394   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4395   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4396   TestApplication application;
4397   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4398   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4399
4400   /* We create a small tree of actors as follows:
4401
4402                            A
4403                           / \
4404      Clipping enabled -> B   D
4405                          |   |
4406                          C   E
4407
4408      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4409   */
4410   Actor actors[5];
4411   for( int i = 0; i < 5; ++i )
4412   {
4413     BufferImage image = BufferImage::New( 16u, 16u );
4414     Actor actor = CreateRenderableActor( image );
4415
4416     // Setup dimensions and position so actor is not skipped by culling.
4417     actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4418     actor.SetSize( 16.0f, 16.0f );
4419
4420     if( i == 0 )
4421     {
4422       actor.SetParentOrigin( ParentOrigin::CENTER );
4423     }
4424     else
4425     {
4426       float b = i > 2 ? 1.0f : -1.0f;
4427       actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4428     }
4429
4430     actors[i] = actor;
4431   }
4432
4433   // Enable clipping on the actor at the top of the left branch.
4434   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4435
4436   // Build the scene graph.
4437   Stage::GetCurrent().Add( actors[0] );
4438
4439   // Left branch:
4440   actors[0].Add( actors[1] );
4441   actors[1].Add( actors[2] );
4442
4443   // Right branch:
4444   actors[0].Add( actors[3] );
4445   actors[3].Add( actors[4] );
4446
4447   // Gather the call trace.
4448   enabledDisableTrace.Reset();
4449   enabledDisableTrace.Enable( true );
4450   application.SendNotification();
4451   application.Render();
4452   enabledDisableTrace.Enable( false );
4453
4454   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4455
4456      Note: Correct enable call trace:    StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4457            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4458   */
4459   size_t startIndex = 0u;
4460   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "3042", startIndex ) );
4461   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4462   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4463
4464   // Swap the clipping actor from top of left branch to top of right branch.
4465   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4466   actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4467
4468   // Gather the call trace.
4469   enabledDisableTrace.Reset();
4470   enabledDisableTrace.Enable( true );
4471   application.SendNotification();
4472   application.Render();
4473   enabledDisableTrace.Enable( false );
4474
4475   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4476   // This proves the draw order has remained the same.
4477   startIndex = 0u;
4478   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex(  "Enable",  "2960", startIndex ) );
4479   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4480
4481   END_TEST;
4482 }
4483
4484 int UtcDaliActorPropertyScissorClippingActor(void)
4485 {
4486   // This test checks that an actor is correctly setup for clipping.
4487   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4488   TestApplication application;
4489
4490   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4491   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4492   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4493
4494   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4495   const Vector2 imageSize( 16.0f, 16.0f );
4496
4497   // Create a clipping actor.
4498   Actor clippingActorA = CreateActorWithContent16x16();
4499   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4500   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4501   clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4502   clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4503   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4504   Stage::GetCurrent().Add( clippingActorA );
4505
4506   // Gather the call trace.
4507   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4508
4509   // Check we are writing to the color buffer.
4510   CheckColorMask( glAbstraction, true );
4511
4512   // Check scissor test was enabled.
4513   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4514
4515   // Check the scissor was set, and the coordinates are correct.
4516   std::stringstream compareParametersString;
4517   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4518   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 0, 0, 16, 16
4519
4520   clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4521   clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4522
4523   // Gather the call trace.
4524   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4525
4526   // Check the scissor was set, and the coordinates are correct.
4527   compareParametersString.str( std::string() );
4528   compareParametersString.clear();
4529   compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4530   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 464, 784, 16, 16
4531
4532   END_TEST;
4533 }
4534
4535 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4536 {
4537   // This test checks that an actor is correctly setup for clipping.
4538   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4539   TestApplication application;
4540
4541
4542   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4543   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4544   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4545
4546   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4547   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4548   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4549
4550   // Create a clipping actors.
4551   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4552   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4553
4554   clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4555   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4556   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4557
4558   clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4559   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4560   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4561
4562   clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4563   clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4564
4565   Stage::GetCurrent().Add( clippingActorA );
4566   Stage::GetCurrent().Add( clippingActorB );
4567
4568   // Gather the call trace.
4569   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4570
4571   // Check we are writing to the color buffer.
4572   CheckColorMask( glAbstraction, true );
4573
4574   // Check scissor test was enabled.
4575   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4576
4577   // Check the scissor was set, and the coordinates are correct.
4578   std::stringstream compareParametersString;
4579
4580   std::string clipA( "0, 500, 480, 200" );
4581   std::string clipB( "0, 380, 480, 40" );
4582
4583   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4584   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4585
4586   END_TEST;
4587 }
4588
4589 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4590 {
4591   // This test checks that an actor is correctly setup for clipping.
4592   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4593   TestApplication application;
4594
4595   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4596   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4597   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4598
4599   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4600   const Vector2 imageSize( 16.0f, 16.0f );
4601
4602   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4603
4604      A is drawn first - with scissor clipping on
4605      B is drawn second - also with scissor clipping on
4606      C is the generated clipping region, the intersection ( A ∩ B )
4607
4608            ┏━━━━━━━┓                   ┌───────┐
4609            ┃     B ┃                   │     B │
4610        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4611        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4612        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4613        │ A     │                   ┊ A     ┊
4614        └───────┘                   └┄┄┄┄┄┄┄┘
4615
4616      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4617   */
4618
4619   // Create a clipping actor.
4620   Actor clippingActorA = CreateActorWithContent16x16();
4621   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4622   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4623   clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4624   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4625   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4626   Stage::GetCurrent().Add( clippingActorA );
4627
4628   // Create a child clipping actor.
4629   Actor clippingActorB = CreateActorWithContent16x16();
4630   clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4631   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4632   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4633   clippingActorA.Add( clippingActorB );
4634
4635   // positionModifiers is an array of positions to position B around.
4636   // expect is an array of expected scissor clip coordinate results.
4637   const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ),     Vector2( -1.0f, 1.0f ),    Vector2( -1.0f, -1.0f ),   Vector2( 1.0f, -1.0f )    };
4638   const Vector4 expect[4] =            { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4639
4640   // Loop through each overlap combination.
4641   for( unsigned int test = 0u; test < 4u; ++test )
4642   {
4643     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4644     const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4645     clippingActorB.SetPosition( position.x, position.y );
4646
4647     // Gather the call trace.
4648     GenerateTrace( application, enabledDisableTrace, scissorTrace );
4649
4650     // Check we are writing to the color buffer.
4651     CheckColorMask( glAbstraction, true );
4652
4653     // Check scissor test was enabled.
4654     DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4655
4656     // Check the scissor was set, and the coordinates are correct.
4657     const Vector4& expectResults( expect[test] );
4658     std::stringstream compareParametersString;
4659     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4660     DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with the expected result
4661   }
4662
4663   END_TEST;
4664 }
4665
4666 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4667 {
4668   // This test checks that an actor is correctly setup for clipping.
4669   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4670   TestApplication application;
4671
4672   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4673   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4674   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4675
4676   /* Create a nest of 2 scissors and siblings of the parent.
4677
4678             stage
4679               |
4680         ┌─────┐─────┐
4681         A     C     D
4682         |           |
4683         B           E
4684   */
4685
4686   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4687   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4688   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4689   const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4690   const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4691   const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4692
4693   // Create a clipping actors.
4694   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4695   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4696   Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4697   Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4698   Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4699
4700   clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4701   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4702   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4703
4704   clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4705   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4706   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4707
4708   clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4709   clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4710   clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4711
4712   clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4713   clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4714   clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4715
4716   clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4717   clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4718
4719   clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4720   clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4721   clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4722   clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4723   clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4724
4725   Stage::GetCurrent().Add( clippingActorA );
4726   clippingActorA.Add( clippingActorB );
4727   Stage::GetCurrent().Add( clippingActorC );
4728   Stage::GetCurrent().Add( clippingActorD );
4729   clippingActorD.Add( clippingActorE );
4730
4731   // Gather the call trace.
4732   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4733
4734   // Check we are writing to the color buffer.
4735   CheckColorMask( glAbstraction, true );
4736
4737   // Check scissor test was enabled.
4738   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4739
4740   // Check the scissor was set, and the coordinates are correct.
4741   std::string clipA( "0, 500, 480, 200" );
4742   std::string clipB( "0, 580, 480, 40" );
4743   std::string clipC( "0, 200, 480, 200" );
4744   std::string clipD( "0, 300, 480, 200" );
4745
4746   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4747   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4748   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4749   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4750   DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 );    // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4751
4752   END_TEST;
4753 }
4754
4755 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4756 {
4757   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4758   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4759   TestApplication application;
4760
4761   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4762   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4763   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4764
4765   // Create a clipping actor.
4766   Actor actorDepth1Clip = CreateActorWithContent16x16();
4767   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4768   Stage::GetCurrent().Add( actorDepth1Clip );
4769
4770   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4771   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4772
4773   // Gather the call trace.
4774   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4775
4776   // Check we are writing to the color buffer.
4777   CheckColorMask( glAbstraction, true );
4778
4779   // Check the stencil buffer was not enabled.
4780   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4781
4782   // Check stencil functions are not called.
4783   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4784   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4785   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4786
4787   // Check that scissor clipping is overriden by the renderer properties.
4788   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4789
4790   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4791
4792   // Gather the call trace.
4793   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4794
4795   // Check the stencil buffer was not enabled.
4796   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );    // 3089 = 0xC11 (GL_SCISSOR_TEST)
4797
4798   DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4799
4800   END_TEST;
4801 }
4802
4803 int UtcDaliGetPropertyN(void)
4804 {
4805   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4806   TestApplication app;
4807
4808   Actor actor = Actor::New();
4809
4810   unsigned int propertyCount = actor.GetPropertyCount();
4811   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4812   END_TEST;
4813 }
4814
4815 int UtcDaliActorRaiseLower(void)
4816 {
4817   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4818
4819   TestApplication application;
4820
4821   Stage stage( Stage::GetCurrent() );
4822
4823   Actor actorA = Actor::New();
4824   Actor actorB = Actor::New();
4825   Actor actorC = Actor::New();
4826
4827   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4828   actorA.SetParentOrigin( ParentOrigin::CENTER );
4829
4830   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4831   actorB.SetParentOrigin( ParentOrigin::CENTER );
4832
4833   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4834   actorC.SetParentOrigin( ParentOrigin::CENTER );
4835
4836   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4837   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4838
4839   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4840   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4841
4842   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4843   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4844
4845   stage.Add( actorA );
4846   stage.Add( actorB );
4847   stage.Add( actorC );
4848
4849   ResetTouchCallbacks();
4850
4851   application.SendNotification();
4852   application.Render();
4853
4854   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4855   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4856   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4857
4858   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4859   // Only top actor will get touched.
4860   actorA.TouchSignal().Connect( TestTouchCallback );
4861   actorB.TouchSignal().Connect( TestTouchCallback2 );
4862   actorC.TouchSignal().Connect( TestTouchCallback3 );
4863
4864   // Connect ChildOrderChangedSignal
4865   bool orderChangedSignal( false );
4866   Actor orderChangedActor;
4867   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4868   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4869
4870   Dali::Integration::Point point;
4871   point.SetDeviceId( 1 );
4872   point.SetState( PointState::DOWN );
4873   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4874   Dali::Integration::TouchEvent touchEvent;
4875   touchEvent.AddPoint( point );
4876
4877   application.ProcessEvent( touchEvent );
4878
4879   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4880   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4881   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4882
4883   ResetTouchCallbacks();
4884
4885   tet_printf( "Testing Raising of Actor\n" );
4886
4887   int preActorOrder( 0 );
4888   int postActorOrder( 0 );
4889
4890   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4891   value.Get( preActorOrder );
4892
4893   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4894   actorB.Raise();
4895   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4896   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4897
4898   // Ensure sort order is calculated before next touch event
4899   application.SendNotification();
4900
4901   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4902   value.Get( postActorOrder );
4903
4904   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4905
4906   application.ProcessEvent( touchEvent );
4907
4908   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4909   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4910   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4911
4912   ResetTouchCallbacks();
4913
4914   tet_printf( "Testing Lowering of Actor\n" );
4915
4916   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4917   value.Get( preActorOrder );
4918
4919   orderChangedSignal = false;
4920
4921   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4922   actorB.Lower();
4923   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4924   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4925
4926   application.SendNotification(); // ensure sort order calculated before next touch event
4927
4928   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4929   value.Get( postActorOrder );
4930
4931   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4932
4933   application.ProcessEvent( touchEvent );
4934
4935   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4936   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4937   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4938
4939   ResetTouchCallbacks();
4940
4941   END_TEST;
4942 }
4943
4944 int UtcDaliActorRaiseToTopLowerToBottom(void)
4945 {
4946   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4947
4948   TestApplication application;
4949
4950   Stage stage( Stage::GetCurrent() );
4951
4952   Actor actorA = Actor::New();
4953   Actor actorB = Actor::New();
4954   Actor actorC = Actor::New();
4955
4956   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4957   // enables checking of which actor the uniform is assigned too
4958   Shader shaderA = CreateShader();
4959   shaderA.RegisterProperty( "uRendererColor",1.f);
4960
4961   Shader shaderB = CreateShader();
4962   shaderB.RegisterProperty( "uRendererColor", 2.f );
4963
4964   Shader shaderC = CreateShader();
4965   shaderC.RegisterProperty( "uRendererColor", 3.f );
4966
4967   Geometry geometry = CreateQuadGeometry();
4968
4969   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4970   Renderer rendererA = Renderer::New(geometry, shaderA);
4971   actorA.AddRenderer(rendererA);
4972
4973   Renderer rendererB = Renderer::New(geometry, shaderB);
4974   actorB.AddRenderer(rendererB);
4975
4976   Renderer rendererC = Renderer::New(geometry, shaderC);
4977   actorC.AddRenderer(rendererC);
4978
4979   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4980   actorA.SetParentOrigin( ParentOrigin::CENTER );
4981
4982   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4983   actorB.SetParentOrigin( ParentOrigin::CENTER );
4984
4985   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4986   actorC.SetParentOrigin( ParentOrigin::CENTER );
4987
4988   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4989   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4990
4991   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4992   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4993
4994   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4995   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4996
4997   stage.Add( actorA );
4998   stage.Add( actorB );
4999   stage.Add( actorC );
5000
5001   ResetTouchCallbacks();
5002
5003   // Connect ChildOrderChangedSignal
5004   bool orderChangedSignal( false );
5005   Actor orderChangedActor;
5006   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5007   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5008
5009   // Set up gl abstraction trace so can query the set uniform order
5010   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5011   glAbstraction.EnableSetUniformCallTrace(true);
5012   glAbstraction.ResetSetUniformCallStack();
5013
5014   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5015
5016   application.SendNotification();
5017   application.Render();
5018
5019   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
5020
5021
5022   // Test order of uniforms in stack
5023   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5024   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5025   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5026
5027   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
5028
5029   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5030
5031   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5032   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5033   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5034
5035   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5036   // Only top actor will get touched.
5037   actorA.TouchSignal().Connect( TestTouchCallback );
5038   actorB.TouchSignal().Connect( TestTouchCallback2 );
5039   actorC.TouchSignal().Connect( TestTouchCallback3 );
5040
5041   Dali::Integration::Point point;
5042   point.SetDeviceId( 1 );
5043   point.SetState( PointState::DOWN );
5044   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5045   Dali::Integration::TouchEvent touchEvent;
5046   touchEvent.AddPoint( point );
5047
5048   application.ProcessEvent( touchEvent );
5049
5050   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5051   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5052   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5053
5054   ResetTouchCallbacks();
5055
5056   tet_printf( "RaiseToTop ActorA\n" );
5057
5058   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5059   actorA.RaiseToTop();
5060   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5061   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5062
5063   application.SendNotification(); // ensure sorting order is calculated before next touch event
5064
5065   application.ProcessEvent( touchEvent );
5066
5067   glAbstraction.ResetSetUniformCallStack();
5068   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5069
5070   application.SendNotification();
5071   application.Render();
5072
5073   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5074
5075   // Test order of uniforms in stack
5076   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5077   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5078   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5079
5080   tet_infoline( "Testing A above C and B at bottom\n" );
5081   bool ACB = ( indexA > indexC) && ( indexC > indexB );
5082
5083   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5084
5085   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5086   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5087   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5088
5089   ResetTouchCallbacks();
5090
5091   tet_printf( "RaiseToTop ActorB\n" );
5092
5093   orderChangedSignal = false;
5094
5095   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5096   actorB.RaiseToTop();
5097   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5098   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5099
5100   application.SendNotification(); // Ensure sort order is calculated before next touch event
5101
5102   application.ProcessEvent( touchEvent );
5103
5104   glAbstraction.ResetSetUniformCallStack();
5105   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5106
5107   application.SendNotification();
5108   application.Render();
5109
5110   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5111
5112   // Test order of uniforms in stack
5113   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5114   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5115   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5116
5117   tet_infoline( "Testing B above A and C at bottom\n" );
5118   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5119
5120   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5121
5122   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5123   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5124   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5125
5126   ResetTouchCallbacks();
5127
5128   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5129
5130   orderChangedSignal = false;
5131
5132   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5133   actorA.LowerToBottom();
5134   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5135   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5136
5137   application.SendNotification();
5138   application.Render();
5139
5140   orderChangedSignal = false;
5141
5142   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5143   actorB.LowerToBottom();
5144   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5145   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5146
5147   application.SendNotification();
5148   application.Render();
5149
5150   application.ProcessEvent( touchEvent );
5151
5152   glAbstraction.ResetSetUniformCallStack();
5153   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5154
5155   application.SendNotification();
5156   application.Render();
5157
5158   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5159
5160   // Test order of uniforms in stack
5161   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5162   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5163   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5164
5165   tet_infoline( "Testing C above A and B at bottom\n" );
5166   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5167
5168   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5169
5170   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5171   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5172   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5173
5174   ResetTouchCallbacks();
5175
5176   END_TEST;
5177 }
5178
5179 int UtcDaliActorRaiseAbove(void)
5180 {
5181   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5182
5183   TestApplication application;
5184
5185   Stage stage( Stage::GetCurrent() );
5186
5187   Actor actorA = Actor::New();
5188   Actor actorB = Actor::New();
5189   Actor actorC = Actor::New();
5190
5191   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5192   actorA.SetParentOrigin( ParentOrigin::CENTER );
5193
5194   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5195   actorB.SetParentOrigin( ParentOrigin::CENTER );
5196
5197   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5198   actorC.SetParentOrigin( ParentOrigin::CENTER );
5199
5200   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5201   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5202
5203   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5204   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5205
5206   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5207   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5208
5209   stage.Add( actorA );
5210   stage.Add( actorB );
5211   stage.Add( actorC );
5212
5213   ResetTouchCallbacks();
5214
5215   application.SendNotification();
5216   application.Render();
5217
5218   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5219   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5220   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5221
5222   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5223   // Only top actor will get touched.
5224   actorA.TouchSignal().Connect( TestTouchCallback );
5225   actorB.TouchSignal().Connect( TestTouchCallback2 );
5226   actorC.TouchSignal().Connect( TestTouchCallback3 );
5227
5228   bool orderChangedSignal( false );
5229   Actor orderChangedActor;
5230   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5231   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5232
5233   Dali::Integration::Point point;
5234   point.SetDeviceId( 1 );
5235   point.SetState( PointState::DOWN );
5236   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5237   Dali::Integration::TouchEvent touchEvent;
5238   touchEvent.AddPoint( point );
5239
5240   application.ProcessEvent( touchEvent );
5241
5242   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5243   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5244   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5245
5246   ResetTouchCallbacks();
5247
5248   tet_printf( "Raise actor B Above Actor C\n" );
5249
5250   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5251   actorB.RaiseAbove( actorC );
5252   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5253   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5254
5255   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5256   application.SendNotification();
5257   application.ProcessEvent( touchEvent );
5258
5259   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5260   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5261   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5262
5263   ResetTouchCallbacks();
5264
5265   tet_printf( "Raise actor A Above Actor B\n" );
5266
5267   orderChangedSignal = false;
5268
5269   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5270   actorA.RaiseAbove( actorB );
5271   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5272   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5273
5274   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5275   application.SendNotification();
5276
5277   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5278
5279   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5280   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5281   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5282
5283   ResetTouchCallbacks();
5284
5285   END_TEST;
5286 }
5287
5288 int UtcDaliActorLowerBelow(void)
5289 {
5290   tet_infoline( "UtcDaliActor LowerBelow test \n" );
5291
5292   TestApplication application;
5293
5294   Stage stage( Stage::GetCurrent() );
5295
5296   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5297   // enables checking of which actor the uniform is assigned too
5298   Shader shaderA = CreateShader();
5299   shaderA.RegisterProperty( "uRendererColor",1.f);
5300
5301   Shader shaderB = CreateShader();
5302   shaderB.RegisterProperty( "uRendererColor", 2.f );
5303
5304   Shader shaderC = CreateShader();
5305   shaderC.RegisterProperty( "uRendererColor", 3.f );
5306
5307   Actor actorA = Actor::New();
5308   Actor actorB = Actor::New();
5309   Actor actorC = Actor::New();
5310
5311   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5312   Geometry geometry = CreateQuadGeometry();
5313
5314   Renderer rendererA = Renderer::New(geometry, shaderA);
5315   actorA.AddRenderer(rendererA);
5316
5317   Renderer rendererB = Renderer::New(geometry, shaderB);
5318   actorB.AddRenderer(rendererB);
5319
5320   Renderer rendererC = Renderer::New(geometry, shaderC);
5321   actorC.AddRenderer(rendererC);
5322
5323   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5324   actorA.SetParentOrigin( ParentOrigin::CENTER );
5325
5326   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5327   actorB.SetParentOrigin( ParentOrigin::CENTER );
5328
5329   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5330   actorC.SetParentOrigin( ParentOrigin::CENTER );
5331
5332   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5333   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5334
5335   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5336   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5337
5338   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5339   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5340
5341   Actor container = Actor::New();
5342   container.SetParentOrigin( ParentOrigin::CENTER );
5343   container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5344   stage.Add( container );
5345
5346   container.Add( actorA );
5347   container.Add( actorB );
5348   container.Add( actorC );
5349
5350   ResetTouchCallbacks();
5351
5352   // Connect ChildOrderChangedSignal
5353   bool orderChangedSignal( false );
5354   Actor orderChangedActor;
5355   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5356   DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5357
5358   // Set up gl abstraction trace so can query the set uniform order
5359   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5360   glAbstraction.EnableSetUniformCallTrace(true);
5361   glAbstraction.ResetSetUniformCallStack();
5362   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5363
5364   glAbstraction.ResetSetUniformCallStack();
5365
5366   application.SendNotification();
5367   application.Render();
5368
5369   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5370
5371   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5372
5373   // Test order of uniforms in stack
5374   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5375   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5376   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5377
5378   tet_infoline( "Testing C above B and A at bottom\n" );
5379   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
5380
5381   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5382
5383   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5384   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5385   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5386
5387   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5388   // Only top actor will get touched.
5389   actorA.TouchSignal().Connect( TestTouchCallback );
5390   actorB.TouchSignal().Connect( TestTouchCallback2 );
5391   actorC.TouchSignal().Connect( TestTouchCallback3 );
5392
5393   Dali::Integration::Point point;
5394   point.SetDeviceId( 1 );
5395   point.SetState( PointState::DOWN );
5396   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5397   Dali::Integration::TouchEvent touchEvent;
5398   touchEvent.AddPoint( point );
5399
5400   tet_infoline( "UtcDaliActor Test Set up completed \n" );
5401
5402   application.ProcessEvent( touchEvent );
5403
5404   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5405   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5406   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5407
5408   ResetTouchCallbacks();
5409
5410   tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" );
5411
5412   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5413   actorC.LowerBelow( actorB );
5414   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5415   DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5416
5417   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5418   application.SendNotification();
5419   application.Render();
5420
5421   application.ProcessEvent( touchEvent ); // touch event
5422
5423   glAbstraction.ResetSetUniformCallStack();
5424   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5425
5426   application.SendNotification();
5427   application.Render();
5428
5429   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5430
5431   // Test order of uniforms in stack
5432   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5433   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5434   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5435
5436   tet_infoline( "Testing render order is A, C, B" );
5437   DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5438   DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5439
5440   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5441   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5442   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5443
5444   ResetTouchCallbacks();
5445
5446   tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5447
5448   orderChangedSignal = false;
5449
5450   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5451   actorC.LowerBelow( actorA );
5452   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5453   DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5454
5455   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5456   application.SendNotification();
5457   application.Render();
5458
5459   application.ProcessEvent( touchEvent );
5460
5461   glAbstraction.ResetSetUniformCallStack();
5462   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5463
5464   application.Render();
5465   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5466
5467   // Test order of uniforms in stack
5468   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5469   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5470   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5471
5472   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5473   DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5474
5475   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5477   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5478
5479   ResetTouchCallbacks();
5480
5481   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5482
5483   orderChangedSignal = false;
5484
5485   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5486   actorB.LowerBelow( actorC );
5487   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5488   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5489
5490   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5491   application.SendNotification();
5492   application.Render();
5493
5494   application.ProcessEvent( touchEvent );
5495
5496   glAbstraction.ResetSetUniformCallStack();
5497   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5498
5499   application.Render();
5500   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5501
5502   // Test order of uniforms in stack
5503   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5504   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5505   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5506
5507   DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5508   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5509
5510   END_TEST;
5511 }
5512
5513
5514 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5515 {
5516   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5517
5518   TestApplication application;
5519
5520   Stage stage( Stage::GetCurrent() );
5521
5522   Actor parentA = Actor::New();
5523   Actor parentB = Actor::New();
5524   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5525   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5526   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5527   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5528
5529   parentA.SetAnchorPoint( AnchorPoint::CENTER );
5530   parentA.SetParentOrigin( ParentOrigin::CENTER );
5531
5532   parentB.SetAnchorPoint( AnchorPoint::CENTER );
5533   parentB.SetParentOrigin( ParentOrigin::CENTER );
5534
5535   stage.Add( parentA );
5536   stage.Add( parentB );
5537
5538   Actor actorA = Actor::New();
5539   Actor actorB = Actor::New();
5540   Actor actorC = Actor::New();
5541
5542   parentA.Add( actorA );
5543   parentA.Add( actorB );
5544
5545   tet_printf( "Actor C added to different parent from A and B \n" );
5546   parentB.Add( actorC );
5547
5548   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5549   actorA.SetParentOrigin( ParentOrigin::CENTER );
5550
5551   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5552   actorB.SetParentOrigin( ParentOrigin::CENTER );
5553
5554   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5555   actorC.SetParentOrigin( ParentOrigin::CENTER );
5556
5557   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5558   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5559
5560   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5561   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5562
5563   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5564   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5565
5566   ResetTouchCallbacks();
5567
5568   // Connect ChildOrderChangedSignal
5569   bool orderChangedSignal( false );
5570   Actor orderChangedActor;
5571   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5572   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5573
5574   application.SendNotification();
5575   application.Render();
5576
5577   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5578   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5579   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5580
5581   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5582   // Only top actor will get touched.
5583   actorA.TouchSignal().Connect( TestTouchCallback );
5584   actorB.TouchSignal().Connect( TestTouchCallback2 );
5585   actorC.TouchSignal().Connect( TestTouchCallback3 );
5586
5587   Dali::Integration::Point point;
5588   point.SetDeviceId( 1 );
5589   point.SetState( PointState::DOWN );
5590   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5591   Dali::Integration::TouchEvent touchEvent;
5592   touchEvent.AddPoint( point );
5593
5594   application.ProcessEvent( touchEvent );
5595
5596   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5597   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5598   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5599
5600   ResetTouchCallbacks();
5601
5602   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5603
5604   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5605   actorA.RaiseAbove( actorC );
5606   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5607
5608   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5609   application.SendNotification();
5610
5611   application.ProcessEvent( touchEvent ); // touch event
5612
5613   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5614   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5615   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5616
5617   ResetTouchCallbacks();
5618
5619   END_TEST;
5620 }
5621
5622 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5623 {
5624   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5625
5626   TestApplication application;
5627
5628   Stage stage( Stage::GetCurrent() );
5629
5630   Actor actorA = Actor::New();
5631   Actor actorB = Actor::New();
5632   Actor actorC = Actor::New();
5633
5634   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5635   actorA.SetParentOrigin( ParentOrigin::CENTER );
5636
5637   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5638   actorB.SetParentOrigin( ParentOrigin::CENTER );
5639
5640   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5641   actorC.SetParentOrigin( ParentOrigin::CENTER );
5642
5643   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5644   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5645
5646   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5647   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5648
5649   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5650   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5651
5652   ResetTouchCallbacks();
5653
5654   // Connect ChildOrderChangedSignal
5655   bool orderChangedSignal( false );
5656   Actor orderChangedActor;
5657   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5658   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5659
5660   application.SendNotification();
5661   application.Render();
5662
5663   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5664   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5665   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5666
5667   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5668   // Only top actor will get touched.
5669   actorA.TouchSignal().Connect( TestTouchCallback );
5670   actorB.TouchSignal().Connect( TestTouchCallback2 );
5671   actorC.TouchSignal().Connect( TestTouchCallback3 );
5672
5673   Dali::Integration::Point point;
5674   point.SetDeviceId( 1 );
5675   point.SetState( PointState::DOWN );
5676   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5677   Dali::Integration::TouchEvent touchEvent;
5678   touchEvent.AddPoint( point );
5679
5680   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5681
5682   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5683   actorA.RaiseAbove( actorC );
5684   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5685
5686   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5687   application.SendNotification();
5688
5689   application.ProcessEvent( touchEvent );
5690
5691   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5692
5693   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5694   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5695   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5696
5697   ResetTouchCallbacks();
5698
5699   orderChangedSignal = false;
5700
5701   stage.Add ( actorB );
5702   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5703
5704   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5705   actorA.LowerBelow( actorC );
5706   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5707
5708   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5709   application.SendNotification();
5710   application.Render();
5711
5712   application.ProcessEvent( touchEvent );
5713
5714   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5715   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5716   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5717   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5718
5719   ResetTouchCallbacks();
5720
5721   orderChangedSignal = false;
5722
5723   tet_printf( "Adding Actor A to stage, will be on top\n" );
5724
5725   stage.Add ( actorA );
5726   application.SendNotification();
5727   application.Render();
5728
5729   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5730
5731   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5732   actorB.RaiseAbove( actorC );
5733   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5734
5735   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5736   application.SendNotification();
5737
5738   application.ProcessEvent( touchEvent );
5739
5740   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5741   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5742   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5743   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5744
5745   ResetTouchCallbacks();
5746
5747   orderChangedSignal = false;
5748
5749   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5750
5751   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5752   actorA.LowerBelow( actorC );
5753   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5754
5755   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5756   application.SendNotification();
5757
5758   application.ProcessEvent( touchEvent );
5759
5760   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5761   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5762   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5763   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5764
5765   ResetTouchCallbacks();
5766
5767   orderChangedSignal = false;
5768
5769   stage.Add ( actorC );
5770
5771   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5772   actorA.RaiseAbove( actorC );
5773   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5774   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5775
5776   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5777   application.SendNotification();
5778   application.Render();
5779
5780   application.ProcessEvent( touchEvent );
5781
5782   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5783   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5784   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5785   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5786
5787   END_TEST;
5788 }
5789
5790 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5791 {
5792   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5793
5794   TestApplication application;
5795
5796   Stage stage( Stage::GetCurrent() );
5797
5798   Actor actorA = Actor::New();
5799   Actor actorB = Actor::New();
5800   Actor actorC = Actor::New();
5801
5802   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5803   actorA.SetParentOrigin( ParentOrigin::CENTER );
5804
5805   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5806   actorB.SetParentOrigin( ParentOrigin::CENTER );
5807
5808   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5809   actorC.SetParentOrigin( ParentOrigin::CENTER );
5810
5811   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5812   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5813
5814   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5815   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5816
5817   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5818   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5819
5820   ResetTouchCallbacks();
5821
5822   // Connect ChildOrderChangedSignal
5823   bool orderChangedSignal( false );
5824   Actor orderChangedActor;
5825   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5826   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5827
5828   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5829   // Only top actor will get touched.
5830   actorA.TouchSignal().Connect( TestTouchCallback );
5831   actorB.TouchSignal().Connect( TestTouchCallback2 );
5832   actorC.TouchSignal().Connect( TestTouchCallback3 );
5833
5834   Dali::Integration::Point point;
5835   point.SetDeviceId( 1 );
5836   point.SetState( PointState::DOWN );
5837   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5838   Dali::Integration::TouchEvent touchEvent;
5839   touchEvent.AddPoint( point );
5840
5841   stage.Add ( actorA );
5842   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5843
5844   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5845   actorB.Raise();
5846   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5847
5848   application.SendNotification();
5849   application.Render();
5850
5851   application.ProcessEvent( touchEvent );
5852
5853   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5854
5855   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5856   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5857   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5858
5859   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5860   ResetTouchCallbacks();
5861
5862   orderChangedSignal = false;
5863
5864   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5865   actorC.Lower();
5866   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5867
5868   // Sort actor tree before next touch event
5869   application.SendNotification();
5870   application.Render();
5871
5872   application.ProcessEvent( touchEvent );
5873
5874   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5875
5876   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5877   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5878   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5879   ResetTouchCallbacks();
5880
5881   orderChangedSignal = false;
5882
5883   tet_printf( "Lower actor C below B but C not parented\n" );
5884
5885   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5886   actorB.Lower();
5887   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5888
5889   // Sort actor tree before next touch event
5890   application.SendNotification();
5891   application.Render();
5892
5893   application.ProcessEvent( touchEvent );
5894
5895   tet_printf( "Not parented so Lower should show no effect\n" );
5896
5897   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5898   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5899   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5900   ResetTouchCallbacks();
5901
5902   orderChangedSignal = false;
5903
5904   tet_printf( "Raise actor B to top\n" );
5905
5906   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5907   actorB.RaiseToTop();
5908   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5909
5910   // Sort actor tree before next touch event
5911   application.SendNotification();
5912   application.Render();
5913
5914   application.ProcessEvent( touchEvent );
5915
5916   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5917
5918   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5919   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5920   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5921   ResetTouchCallbacks();
5922
5923   orderChangedSignal = false;
5924
5925   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5926
5927   stage.Add ( actorB );
5928
5929   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5930
5931   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5932   actorC.LowerToBottom();
5933   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5934
5935   application.SendNotification();
5936   application.Render();
5937
5938   application.ProcessEvent( touchEvent );
5939
5940   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5941
5942   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5943   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5944   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5945   ResetTouchCallbacks();
5946
5947   END_TEST;
5948 }
5949
5950
5951 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5952 {
5953   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5954
5955   TestApplication application;
5956
5957   Stage stage( Stage::GetCurrent() );
5958
5959   Actor actorA = Actor::New();
5960   Actor actorB = Actor::New();
5961   Actor actorC = Actor::New();
5962
5963   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5964   actorA.SetParentOrigin( ParentOrigin::CENTER );
5965
5966   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5967   actorB.SetParentOrigin( ParentOrigin::CENTER );
5968
5969   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5970   actorC.SetParentOrigin( ParentOrigin::CENTER );
5971
5972   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5973   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5974
5975   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5976   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5977
5978   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5979   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5980
5981   stage.Add( actorA );
5982   stage.Add( actorB );
5983   stage.Add( actorC );
5984
5985   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5986   // Only top actor will get touched.
5987   actorA.TouchSignal().Connect( TestTouchCallback );
5988   actorB.TouchSignal().Connect( TestTouchCallback2 );
5989   actorC.TouchSignal().Connect( TestTouchCallback3 );
5990
5991   ResetTouchCallbacks();
5992
5993   // Connect ChildOrderChangedSignal
5994   bool orderChangedSignal( false );
5995   Actor orderChangedActor;
5996   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5997   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5998
5999   application.SendNotification();
6000   application.Render();
6001
6002   Dali::Integration::Point point;
6003   point.SetDeviceId( 1 );
6004   point.SetState( PointState::DOWN );
6005   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
6006   Dali::Integration::TouchEvent touchEvent;
6007   touchEvent.AddPoint( point );
6008
6009   application.ProcessEvent( touchEvent );
6010
6011   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6012   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6013   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
6014
6015   ResetTouchCallbacks();
6016
6017   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
6018
6019   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6020   actorA.RaiseAbove( actorA );
6021   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6022   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6023
6024   application.SendNotification();
6025   application.Render();
6026
6027   application.ProcessEvent( touchEvent );
6028
6029   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6030
6031   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
6032   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
6033   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
6034
6035   ResetTouchCallbacks();
6036
6037   orderChangedSignal = false;
6038
6039   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6040   actorA.RaiseAbove( actorC );
6041   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6042   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6043
6044   application.SendNotification();
6045   application.Render();
6046
6047   application.ProcessEvent( touchEvent );
6048
6049   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6050   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
6051   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
6052   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
6053
6054   END_TEST;
6055 }
6056
6057 int UtcDaliActorGetScreenPosition(void)
6058 {
6059   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6060
6061   TestApplication application;
6062
6063   Stage stage( Stage::GetCurrent() );
6064
6065   Actor actorA = Actor::New();
6066   actorA.SetAnchorPoint( AnchorPoint::CENTER );
6067
6068   Vector2 size2( 10.0f, 20.0f );
6069   actorA.SetSize( size2 );
6070
6071   actorA.SetPosition( 0.f, 0.f );
6072
6073   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6074
6075   stage.Add( actorA );
6076
6077   application.SendNotification();
6078   application.Render();
6079
6080   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6081   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6082
6083   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
6084   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6085
6086   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6087   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6088
6089   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6090
6091   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6092
6093   application.SendNotification();
6094   application.Render();
6095
6096   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6097   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6098
6099   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
6100   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6101
6102   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6103   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6104
6105   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6106
6107   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6108
6109   application.SendNotification();
6110   application.Render();
6111
6112   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6113   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6114
6115   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
6116   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
6117
6118   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6119   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6120
6121   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6122
6123   actorA.SetPosition( 30.0, 0.0 );
6124
6125   application.SendNotification();
6126   application.Render();
6127
6128   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6129   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6130
6131   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
6132   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
6133
6134   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6135   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6136
6137   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6138
6139   actorA.SetPosition( 30.0, 420.0 );
6140
6141   application.SendNotification();
6142   application.Render();
6143
6144   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6145   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6146
6147   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6148   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
6149
6150   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
6151   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6152
6153   tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6154
6155   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6156   actorA.SetPosition( 30.0, 30.0 );
6157
6158   Actor actorB = Actor::New();
6159   actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6160   actorB.SetSize( size2 );
6161   actorB.SetPosition( 10.f, 10.f );
6162   actorA.Add( actorB );
6163
6164   actorA.SetScale( 2.0f );
6165
6166   application.SendNotification();
6167   application.Render();
6168
6169   actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6170
6171   DALI_TEST_EQUALS( actorScreenPosition.x,  50lu , TEST_LOCATION );
6172   DALI_TEST_EQUALS( actorScreenPosition.y,  50lu , TEST_LOCATION );
6173
6174   END_TEST;
6175 }
6176
6177 int UtcDaliActorGetScreenPositionAfterScaling(void)
6178 {
6179   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6180
6181   TestApplication application;
6182
6183   Stage stage( Stage::GetCurrent() );
6184
6185   Actor actorA = Actor::New();
6186   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6187
6188   Vector2 size2( 10.0f, 20.0f );
6189   actorA.SetSize( size2 );
6190   actorA.SetScale( 1.5f );
6191   actorA.SetPosition( 0.f, 0.f );
6192
6193   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6194
6195   stage.Add( actorA );
6196
6197   application.SendNotification();
6198   application.Render();
6199
6200   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6201   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6202
6203   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6204   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6205
6206   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6207   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6208
6209   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6210
6211   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6212
6213   application.SendNotification();
6214   application.Render();
6215
6216   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6217   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6218
6219   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6220   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6221
6222   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
6223   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6224
6225   END_TEST;
6226 }
6227
6228 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6229 {
6230   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6231
6232   TestApplication application;
6233
6234   Stage stage( Stage::GetCurrent() );
6235
6236   Actor actorA = Actor::New();
6237   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6238   actorA.SetParentOrigin( ParentOrigin::CENTER );
6239   Vector2 size2( 10.0f, 20.0f );
6240   actorA.SetSize( size2 );
6241   actorA.SetPosition( 0.f, 0.f );
6242
6243   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6244
6245   stage.Add( actorA );
6246
6247   application.SendNotification();
6248   application.Render();
6249
6250   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6251   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6252
6253   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6254   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6255
6256   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
6257   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
6258
6259   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6260
6261   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6262   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6263
6264   application.SendNotification();
6265   application.Render();
6266
6267   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6268   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6269
6270   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6271   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6272
6273   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6274   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6275
6276   END_TEST;
6277   END_TEST;
6278 }
6279
6280 int UtcDaliActorGetScreenPositionWithChildActors(void)
6281 {
6282   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6283
6284   TestApplication application;
6285
6286   Stage stage( Stage::GetCurrent() );
6287
6288   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6289
6290   Actor actorA = Actor::New();
6291   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6292   actorA.SetParentOrigin( ParentOrigin::CENTER );
6293   Vector2 size1( 10.0f, 20.0f );
6294   actorA.SetSize( size1 );
6295   actorA.SetPosition( 0.f, 0.f );
6296
6297   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6298
6299   Actor parentActorA = Actor::New();
6300   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6301   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6302   Vector2 size2( 30.0f, 60.0f );
6303   parentActorA.SetSize( size2 );
6304   parentActorA.SetPosition( 0.f, 0.f );
6305
6306   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6307
6308   stage.Add( parentActorA );
6309   parentActorA.Add ( actorA );
6310
6311   application.SendNotification();
6312   application.Render();
6313
6314   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6315   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6316
6317   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6318   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6319
6320   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
6321   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
6322
6323   tet_infoline( "Test 2\n");
6324
6325   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6326
6327   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6328   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6329
6330   application.SendNotification();
6331   application.Render();
6332
6333   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6334   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6335
6336   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6337   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6338
6339   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
6340   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
6341
6342   END_TEST;
6343 }
6344
6345 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6346 {
6347   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6348
6349   TestApplication application;
6350
6351   Stage stage( Stage::GetCurrent() );
6352
6353   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6354
6355   Actor actorA = Actor::New();
6356   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6357   actorA.SetParentOrigin( ParentOrigin::CENTER );
6358   Vector2 size1( 10.0f, 20.0f );
6359   actorA.SetSize( size1 );
6360   actorA.SetPosition( 0.f, 0.f );
6361
6362   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6363
6364   Actor parentActorA = Actor::New();
6365   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6366   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6367   Vector2 size2( 30.0f, 60.0f );
6368   parentActorA.SetSize( size2 );
6369   parentActorA.SetPosition( 0.f, 0.f );
6370
6371   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6372
6373   Actor grandParentActorA = Actor::New();
6374   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6375   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6376   Vector2 size3( 60.0f, 120.0f );
6377   grandParentActorA.SetSize( size3 );
6378   grandParentActorA.SetPosition( 0.f, 0.f );
6379
6380   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6381
6382   stage.Add( grandParentActorA );
6383   grandParentActorA.Add ( parentActorA );
6384
6385   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6386
6387   parentActorA.Add ( actorA );
6388
6389   application.SendNotification();
6390   application.Render();
6391
6392   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6393   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6394
6395   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6396   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6397
6398   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
6399   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
6400
6401   END_TEST;
6402 }
6403
6404 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6405 {
6406   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6407
6408   TestApplication application;
6409
6410   Stage stage( Stage::GetCurrent() );
6411
6412   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6413
6414   Actor actorA = Actor::New();
6415   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6416   actorA.SetParentOrigin( ParentOrigin::CENTER );
6417   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6418   actorA.SetSize( 10.0f, 20.0f );
6419   stage.Add( actorA );
6420
6421   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6422
6423   Actor actorB = Actor::New();
6424   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6425   actorB.SetParentOrigin( ParentOrigin::CENTER );
6426   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6427   Vector2 actorBSize( 30.0f, 60.0f );
6428   actorB.SetSize( actorBSize );
6429   stage.Add( actorB );
6430
6431   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6432
6433   Actor actorC = Actor::New();
6434   actorC.SetAnchorPoint( AnchorPoint::CENTER );
6435   actorC.SetParentOrigin( ParentOrigin::CENTER );
6436   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6437   Vector2 actorCSize( 60.0f, 120.0f );
6438   actorC.SetSize( actorCSize );
6439   stage.Add( actorC );
6440
6441   application.SendNotification();
6442   application.Render();
6443
6444   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6445
6446   Vector2 center( stage.GetSize() * 0.5f );
6447
6448   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6449   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6450   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6451
6452   tet_infoline( "Add scale to all actors" );
6453
6454   actorA.SetScale( 2.0f );
6455   actorB.SetScale( 2.0f );
6456   actorC.SetScale( 2.0f );
6457
6458   application.SendNotification();
6459   application.Render();
6460
6461   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6462   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6463   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6464
6465   END_TEST;
6466 }
6467
6468 int utcDaliActorPositionUsesAnchorPoint(void)
6469 {
6470   TestApplication application;
6471   tet_infoline( "Check default behaviour\n" );
6472
6473   Actor actor = Actor::New();
6474   actor.SetParentOrigin( ParentOrigin::CENTER );
6475   actor.SetAnchorPoint( AnchorPoint::CENTER );
6476   actor.SetSize( 100.0f, 100.0f );
6477   Stage::GetCurrent().Add( actor );
6478
6479   application.SendNotification();
6480   application.Render();
6481
6482   tet_infoline( "Check that the world position is in the center\n" );
6483   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6484
6485   tet_infoline( "Set the position uses anchor point property to false\n" );
6486   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6487
6488   application.SendNotification();
6489   application.Render();
6490
6491   tet_infoline( "Check that the world position has changed appropriately\n" );
6492   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6493
6494   END_TEST;
6495 }
6496
6497 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6498 {
6499   TestApplication application;
6500   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6501
6502   Actor actor = Actor::New();
6503   actor.SetParentOrigin( ParentOrigin::CENTER );
6504   actor.SetAnchorPoint( AnchorPoint::CENTER );
6505   actor.SetSize( 100.0f, 100.0f );
6506   actor.SetScale( 2.0f );
6507   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6508   Stage::GetCurrent().Add( actor );
6509
6510   application.SendNotification();
6511   application.Render();
6512
6513   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6514   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6515
6516   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6517   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6518   application.SendNotification();
6519   application.Render();
6520   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6521
6522   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6523   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6524   application.SendNotification();
6525   application.Render();
6526   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6527
6528   END_TEST;
6529 }
6530
6531 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6532 {
6533   TestApplication application;
6534   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6535
6536   Actor actor = Actor::New();
6537   actor.SetParentOrigin( ParentOrigin::CENTER );
6538   actor.SetAnchorPoint( AnchorPoint::CENTER );
6539   actor.SetSize( 100.0f, 100.0f );
6540   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6541   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6542   Stage::GetCurrent().Add( actor );
6543
6544   application.SendNotification();
6545   application.Render();
6546
6547   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6548   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6549
6550   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6551   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6552   application.SendNotification();
6553   application.Render();
6554   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6555
6556   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6557   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6558   application.SendNotification();
6559   application.Render();
6560   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6561
6562   END_TEST;
6563 }
6564
6565 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6566 {
6567   TestApplication application;
6568   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6569
6570   Actor actor = Actor::New();
6571   actor.SetParentOrigin( ParentOrigin::CENTER );
6572   actor.SetAnchorPoint( AnchorPoint::CENTER );
6573   actor.SetSize( 100.0f, 100.0f );
6574   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6575   actor.SetScale( 2.0f );
6576   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6577   Stage::GetCurrent().Add( actor );
6578
6579   application.SendNotification();
6580   application.Render();
6581
6582   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6583   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6584
6585   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6586   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6587   application.SendNotification();
6588   application.Render();
6589   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6590
6591   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6592   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6593   application.SendNotification();
6594   application.Render();
6595   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6596
6597   END_TEST;
6598 }
6599
6600 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6601 {
6602   TestApplication application;
6603   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6604
6605   Actor parent = Actor::New();
6606
6607   Stage::GetCurrent().Add( parent );
6608   Vector2 stageSize( Stage::GetCurrent().GetSize() );
6609
6610   Actor actor = Actor::New();
6611   actor.SetParentOrigin( ParentOrigin::CENTER );
6612   actor.SetAnchorPoint( AnchorPoint::CENTER );
6613   actor.SetSize( 100.0f, 100.0f );
6614   actor.SetInheritScale( false );
6615   actor.SetInheritOrientation( false );
6616   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6617   parent.Add( actor );
6618
6619   application.SendNotification();
6620   application.Render();
6621
6622   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6623
6624   tet_infoline( "Check the world position is in the right place\n" );
6625   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6626
6627   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6628   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6629   application.SendNotification();
6630   application.Render();
6631   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6632
6633   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6634   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6635   application.SendNotification();
6636   application.Render();
6637   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6638
6639   END_TEST;
6640 }
6641
6642 int utcDaliActorVisibilityChangeSignalSelf(void)
6643 {
6644   TestApplication application;
6645   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6646
6647   Actor actor = Actor::New();
6648
6649   VisibilityChangedFunctorData data;
6650   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6651
6652   actor.SetVisible( false );
6653
6654   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6655
6656   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6657   data.Reset();
6658
6659   actor.SetVisible( false );
6660   data.Check( false /* not called */, TEST_LOCATION );
6661
6662   tet_infoline( "Change the visibility using properties, ensure called" );
6663   data.Reset();
6664
6665   actor.SetProperty( Actor::Property::VISIBLE, true );
6666   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6667
6668   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6669   data.Reset();
6670
6671   actor.SetProperty( Actor::Property::VISIBLE, true );
6672   data.Check( false /* not called */, TEST_LOCATION );
6673
6674   END_TEST;
6675 }
6676
6677 int utcDaliActorVisibilityChangeSignalChildren(void)
6678 {
6679   TestApplication application;
6680   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6681
6682   Actor parent = Actor::New();
6683   Actor child = Actor::New();
6684   parent.Add( child );
6685
6686   Actor grandChild = Actor::New();
6687   child.Add( grandChild );
6688
6689   VisibilityChangedFunctorData parentData;
6690   VisibilityChangedFunctorData childData;
6691   VisibilityChangedFunctorData grandChildData;
6692
6693   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6694   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6695   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6696
6697   parent.SetVisible( false );
6698   parentData.Check( false /* not called */, TEST_LOCATION );
6699   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6700   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6701
6702   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6703   parentData.Reset();
6704   childData.Reset();
6705   grandChildData.Reset();
6706
6707   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6708
6709   parent.SetVisible( true );
6710   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6711   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6712   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6713
6714   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6715   parentData.Reset();
6716   childData.Reset();
6717   grandChildData.Reset();
6718
6719   parent.SetVisible( true );
6720   parentData.Check( false /* not called */, TEST_LOCATION );
6721   childData.Check( false /* not called */, TEST_LOCATION );
6722   grandChildData.Check( false /* not called */, TEST_LOCATION );
6723
6724   END_TEST;
6725 }
6726
6727 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6728 {
6729   TestApplication application;
6730   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6731
6732   Actor actor = Actor::New();
6733   Stage::GetCurrent().Add( actor );
6734
6735   application.SendNotification();
6736   application.Render();
6737
6738   VisibilityChangedFunctorData data;
6739   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6740
6741   Animation animation = Animation::New( 1.0f );
6742   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6743
6744   data.Check( false, TEST_LOCATION );
6745   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6746   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6747
6748   tet_infoline( "Play the animation and check the property value" );
6749   animation.Play();
6750
6751   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6752   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6753
6754   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6755   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6756
6757   application.SendNotification();
6758   application.Render( 1100 ); // After the animation
6759
6760   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6761
6762   END_TEST;
6763 }
6764
6765
6766 int utcDaliActorVisibilityChangeSignalByName(void)
6767 {
6768   TestApplication application;
6769   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6770
6771   Actor actor = Actor::New();
6772
6773   bool signalCalled=false;
6774   actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6775   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6776   actor.SetVisible( false );
6777   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6778
6779   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6780   signalCalled = false;
6781   actor.SetVisible( false );
6782   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6783
6784   tet_infoline( "Change the visibility using properties, ensure called" );
6785   actor.SetProperty( Actor::Property::VISIBLE, true );
6786   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6787
6788   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6789   signalCalled = false;
6790
6791   actor.SetProperty( Actor::Property::VISIBLE, true );
6792   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6793
6794   END_TEST;
6795 }
6796
6797
6798 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6799 {
6800   gLayoutDirectionType = type;
6801 }
6802
6803 int UtcDaliActorLayoutDirectionProperty(void)
6804 {
6805   TestApplication application;
6806   tet_infoline( "Check layout direction property" );
6807
6808   Actor actor0 = Actor::New();
6809   DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6810   Stage::GetCurrent().Add( actor0 );
6811
6812   application.SendNotification();
6813   application.Render();
6814
6815   Actor actor1 = Actor::New();
6816   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6817   Actor actor2 = Actor::New();
6818   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6819   Actor actor3 = Actor::New();
6820   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821   Actor actor4 = Actor::New();
6822   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6823   Actor actor5 = Actor::New();
6824   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6825   Actor actor6 = Actor::New();
6826   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6827   Actor actor7 = Actor::New();
6828   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6829   Actor actor8 = Actor::New();
6830   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6831   Actor actor9 = Actor::New();
6832   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6833
6834   actor1.Add( actor2 );
6835   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6836   actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6837
6838   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6839   actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6840   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6841
6842   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6843   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6844   DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6845
6846   actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6847   actor0.Add( actor1 );
6848   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6849   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6850
6851   Stage::GetCurrent().Add( actor3 );
6852   actor3.Add( actor4 );
6853   actor4.Add( actor5 );
6854   actor5.Add( actor6 );
6855   actor5.Add( actor7 );
6856   actor7.Add( actor8 );
6857   actor8.Add( actor9 );
6858   actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6859   actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6860
6861   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6862   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6863   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6864
6865   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6866
6867   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6868   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6869   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6870   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6871   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6872   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6873   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6874
6875   actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6876   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6877   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6878
6879   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6880   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6881   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6882   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6883
6884   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6885   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6886   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6887
6888   END_TEST;
6889 }
6890
6891
6892 struct LayoutDirectionFunctor
6893 {
6894   LayoutDirectionFunctor(bool& signalCalled)
6895   : mSignalCalled( signalCalled )
6896   {
6897   }
6898
6899   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6900   : mSignalCalled( rhs.mSignalCalled )
6901   {
6902   }
6903
6904   void operator()()
6905   {
6906     mSignalCalled = true;
6907   }
6908
6909   bool& mSignalCalled;
6910 };
6911
6912 int UtcDaliActorLayoutDirectionSignal(void)
6913 {
6914   TestApplication application;
6915   tet_infoline( "Check changing layout direction property sends a signal" );
6916
6917   Actor actor = Actor::New();
6918   DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6919   Stage::GetCurrent().Add( actor );
6920   bool signalCalled = false;
6921   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6922
6923   actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6924   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6925
6926   // Test that writing the same value doesn't send a signal
6927   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6928   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6929
6930   // Test that writing a different value sends the signal
6931   signalCalled = false;
6932   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6933   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6934
6935   signalCalled = false;
6936   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6937   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6938
6939   END_TEST;
6940 }
6941
6942 struct ChildAddedSignalCheck
6943 {
6944   ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6945   : mSignalReceived( signalReceived ),
6946     mChildHandle( childHandle )
6947   {
6948   }
6949
6950   void operator() ( Actor childHandle )
6951   {
6952     mSignalReceived = true;
6953     mChildHandle = childHandle;
6954   }
6955   void operator() ()
6956   {
6957     mSignalReceived = true;
6958     mChildHandle = Actor();
6959   }
6960
6961   bool& mSignalReceived;
6962   Actor& mChildHandle;
6963 };
6964
6965 int UtcDaliChildAddedSignalP1(void)
6966 {
6967   TestApplication application;
6968   auto stage = Stage::GetCurrent();
6969
6970   bool signalReceived=false;
6971   Actor childActor;
6972
6973   ChildAddedSignalCheck signal( signalReceived, childActor );
6974   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6975   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6976
6977   auto actorA = Actor::New();
6978   stage.Add( actorA );
6979   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6980   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6981   signalReceived = false;
6982
6983   auto actorB = Actor::New();
6984   stage.Add( actorB );
6985   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6986   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6987
6988   END_TEST;
6989 }
6990
6991
6992 int UtcDaliChildAddedSignalP2(void)
6993 {
6994   TestApplication application;
6995   auto stage = Stage::GetCurrent();
6996
6997   bool signalReceived=false;
6998   Actor childActor;
6999
7000   ChildAddedSignalCheck signal( signalReceived, childActor );
7001   tet_infoline( "Connect to childAdded signal by name" );
7002
7003   stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
7004   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7005
7006   auto actorA = Actor::New();
7007   stage.Add( actorA );
7008   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7009
7010   // Can't test which actor was added; signal signature is void() when connecting via name.
7011   signalReceived = false;
7012
7013   auto actorB = Actor::New();
7014   stage.Add( actorB );
7015   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7016
7017   END_TEST;
7018 }
7019
7020 int UtcDaliChildAddedSignalN(void)
7021 {
7022   TestApplication application;
7023   auto stage = Stage::GetCurrent();
7024
7025   bool signalReceived=false;
7026   Actor childActor;
7027
7028   ChildAddedSignalCheck signal( signalReceived, childActor );
7029   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7030   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7031
7032   auto actorA = Actor::New();
7033   stage.Add( actorA );
7034   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7035   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7036   signalReceived = false;
7037
7038   auto actorB = Actor::New();
7039   actorA.Add( actorB );
7040   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7041   END_TEST;
7042 }
7043
7044
7045 struct ChildRemovedSignalCheck
7046 {
7047   ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7048   : mSignalReceived( signalReceived ),
7049     mChildHandle( childHandle )
7050   {
7051   }
7052
7053   void operator() ( Actor childHandle )
7054   {
7055     mSignalReceived = true;
7056     mChildHandle = childHandle;
7057   }
7058
7059   void operator() ()
7060   {
7061     mSignalReceived = true;
7062   }
7063
7064   bool& mSignalReceived;
7065   Actor& mChildHandle;
7066 };
7067
7068 int UtcDaliChildRemovedSignalP1(void)
7069 {
7070   TestApplication application;
7071   auto stage = Stage::GetCurrent();
7072
7073   bool signalReceived=false;
7074   Actor childActor;
7075
7076   ChildRemovedSignalCheck signal( signalReceived, childActor );
7077   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7078   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7079
7080   auto actorA = Actor::New();
7081   stage.Add( actorA );
7082   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7083   DALI_TEST_CHECK( !childActor );
7084
7085   stage.Remove( actorA );
7086   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7087   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7088
7089   signalReceived = false;
7090   auto actorB = Actor::New();
7091   stage.Add( actorB );
7092   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7093
7094   stage.Remove( actorB );
7095   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7096   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7097
7098   END_TEST;
7099 }
7100
7101 int UtcDaliChildRemovedSignalP2(void)
7102 {
7103   TestApplication application;
7104   auto stage = Stage::GetCurrent();
7105
7106   bool signalReceived=false;
7107   Actor childActor;
7108
7109   ChildAddedSignalCheck signal( signalReceived, childActor );
7110   tet_infoline( "Connect to childRemoved signal by name" );
7111
7112   stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7113   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7114
7115   auto actorA = Actor::New();
7116   stage.Add( actorA );
7117   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7118
7119   stage.Remove( actorA );
7120   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7121
7122   signalReceived = false;
7123   auto actorB = Actor::New();
7124   stage.Add( actorB );
7125   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7126
7127   stage.Remove( actorB );
7128   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7129
7130   END_TEST;
7131 }
7132
7133
7134 int UtcDaliChildRemovedSignalN(void)
7135 {
7136   TestApplication application;
7137   auto stage = Stage::GetCurrent();
7138
7139   bool signalReceived=false;
7140   Actor childActor;
7141
7142   ChildRemovedSignalCheck signal( signalReceived, childActor );
7143   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7144   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7145
7146   auto actorA = Actor::New();
7147   stage.Add( actorA );
7148
7149   auto actorB = Actor::New();
7150   actorA.Add( actorB );
7151
7152   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7153   DALI_TEST_CHECK( ! childActor );
7154
7155   actorA.Remove( actorB );
7156   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7157   END_TEST;
7158 }
7159
7160
7161 int UtcDaliChildMovedSignalP(void)
7162 {
7163   TestApplication application;
7164   auto stage = Stage::GetCurrent();
7165
7166   bool addedASignalReceived   = false;
7167   bool removedASignalReceived = false;
7168   bool addedBSignalReceived   = false;
7169   bool removedBSignalReceived = false;
7170   Actor childActor;
7171
7172   auto actorA = Actor::New();
7173   auto actorB = Actor::New();
7174   stage.Add( actorA );
7175   stage.Add( actorB );
7176
7177   ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7178   ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7179   ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7180   ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7181
7182   DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7183   DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7184   DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7185   DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7186
7187   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7188   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7189   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7190   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7191
7192   // Create a child of A
7193
7194   auto child = Actor::New();
7195   actorA.Add( child );
7196
7197   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7198   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7199   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7200   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7201   DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7202
7203   // Move child to B:
7204   addedASignalReceived   = false;
7205   addedBSignalReceived   = false;
7206   removedASignalReceived = false;
7207   removedBSignalReceived = false;
7208
7209   actorB.Add( child ); // Expect this child to be re-parented
7210   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7211   DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7212   DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7213   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7214
7215   // Move child back to A:
7216   addedASignalReceived   = false;
7217   addedBSignalReceived   = false;
7218   removedASignalReceived = false;
7219   removedBSignalReceived = false;
7220
7221   actorA.Add( child ); // Expect this child to be re-parented
7222   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7223   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7224   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7225   DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7226
7227
7228   END_TEST;
7229 }
7230
7231 int utcDaliActorCulled(void)
7232 {
7233   TestApplication application;
7234   auto stage = Stage::GetCurrent();
7235
7236   tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7237
7238   Actor actor = Actor::New();
7239   actor.SetSize( 10.0f, 10.0f );
7240
7241   Geometry geometry = CreateQuadGeometry();
7242   Shader shader = CreateShader();
7243   Renderer renderer = Renderer::New(geometry, shader);
7244   actor.AddRenderer( renderer );
7245
7246   stage.Add( actor );
7247
7248   application.SendNotification();
7249   application.Render( 0 );
7250
7251   DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7252
7253   PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7254   notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7255
7256   // Connect NotifySignal
7257   bool propertyNotificationSignal( false );
7258   PropertyNotification source;
7259   CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7260   notification.NotifySignal().Connect( &application, f ) ;
7261
7262   actor.SetPosition( 1000.0f, 1000.0f );
7263
7264   application.SendNotification();
7265   application.Render();
7266
7267   application.SendNotification();
7268
7269   DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7270
7271   DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7272   DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7273   DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7274
7275   END_TEST;
7276 }