Remove deprecated APIs in Tizen 3.0
[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 UtcDaliActorSetInheritPosition(void)
1557 {
1558   tet_infoline("Testing Actor::SetInheritPosition");
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.IsPositionInherited(), true, 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   //Change child position
1589   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1590   child.SetPosition( childOffset );
1591
1592   // Use local position as world postion
1593   child.SetInheritPosition( false );
1594   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1595   application.SendNotification();
1596   application.Render(0); // should only really call Update as Render is not required to update scene
1597   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1598   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1599   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1600   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1601
1602   //Change back to inherit position from parent
1603   child.SetInheritPosition( true );
1604   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1605   application.SendNotification();
1606   application.Render(0); // should only really call Update as Render is not required to update scene
1607   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1608   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1609   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1610   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1611   END_TEST;
1612 }
1613
1614 int UtcDaliActorInheritOpacity(void)
1615 {
1616   tet_infoline("Testing Actor::Inherit Opacity");
1617   TestApplication application;
1618
1619   Actor parent = Actor::New();
1620   Actor child = Actor::New();
1621   parent.Add( child );
1622   Stage::GetCurrent().Add( parent );
1623
1624   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1625   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1626
1627   // flush the queue and render once
1628   application.SendNotification();
1629   application.Render();
1630
1631   parent.SetOpacity( 0.1f );
1632
1633   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1634   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1635
1636   application.SendNotification();
1637   application.Render();
1638
1639   DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1640   DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1641   DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1642   DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1643   DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1644   DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1645
1646   END_TEST;
1647 }
1648
1649 // SetOrientation(float angleRadians, Vector3 axis)
1650 int UtcDaliActorSetOrientation01(void)
1651 {
1652   TestApplication application;
1653
1654   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1655   Actor actor = Actor::New();
1656
1657   actor.SetOrientation(rotation);
1658
1659   // flush the queue and render once
1660   application.SendNotification();
1661   application.Render();
1662
1663   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1664   END_TEST;
1665 }
1666
1667 int UtcDaliActorSetOrientation02(void)
1668 {
1669   TestApplication application;
1670
1671   Actor actor = Actor::New();
1672
1673   Radian angle( 0.785f );
1674   Vector3 axis(1.0f, 1.0f, 0.0f);
1675
1676   actor.SetOrientation( angle, axis);
1677   Quaternion rotation( angle, axis );
1678   // flush the queue and render once
1679   application.SendNotification();
1680   application.Render();
1681   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1682
1683   Stage::GetCurrent().Add( actor );
1684   actor.RotateBy( Degree( 360 ), axis);
1685   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1686
1687   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1688   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1689   // flush the queue and render once
1690   application.SendNotification();
1691   application.Render();
1692   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1693
1694   actor.SetOrientation( angle, axis);
1695   // flush the queue and render once
1696   application.SendNotification();
1697   application.Render();
1698   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1699
1700   Stage::GetCurrent().Remove( actor );
1701   END_TEST;
1702 }
1703
1704 // SetOrientation(float angleRadians, Vector3 axis)
1705 int UtcDaliActorSetOrientationProperty(void)
1706 {
1707   TestApplication application;
1708
1709   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1710   Actor actor = Actor::New();
1711
1712   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1713   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1714
1715   // flush the queue and render once
1716   application.SendNotification();
1717   application.Render();
1718
1719   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1720   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1721   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1722   END_TEST;
1723 }
1724
1725 // RotateBy(float angleRadians, Vector3 axis)
1726 int UtcDaliActorRotateBy01(void)
1727 {
1728   TestApplication application;
1729
1730   Actor actor = Actor::New();
1731
1732   Radian angle( M_PI * 0.25f );
1733   actor.RotateBy(( angle ), Vector3::ZAXIS);
1734   // flush the queue and render once
1735   application.SendNotification();
1736   application.Render();
1737   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1738
1739   Stage::GetCurrent().Add( actor );
1740
1741   actor.RotateBy( angle, Vector3::ZAXIS);
1742   // flush the queue and render once
1743   application.SendNotification();
1744   application.Render();
1745   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1746
1747   Stage::GetCurrent().Remove( actor );
1748   END_TEST;
1749 }
1750
1751 // RotateBy(Quaternion relativeRotation)
1752 int UtcDaliActorRotateBy02(void)
1753 {
1754   TestApplication application;
1755
1756   Actor actor = Actor::New();
1757
1758   Radian angle( M_PI * 0.25f );
1759   Quaternion rotation(angle, Vector3::ZAXIS);
1760   actor.RotateBy(rotation);
1761   // flush the queue and render once
1762   application.SendNotification();
1763   application.Render();
1764   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1765
1766   actor.RotateBy(rotation);
1767   // flush the queue and render once
1768   application.SendNotification();
1769   application.Render();
1770   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1771   END_TEST;
1772 }
1773
1774 int UtcDaliActorGetCurrentOrientation(void)
1775 {
1776   TestApplication application;
1777   Actor actor = Actor::New();
1778
1779   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1780   actor.SetOrientation(rotation);
1781   // flush the queue and render once
1782   application.SendNotification();
1783   application.Render();
1784   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1785   END_TEST;
1786 }
1787
1788 int UtcDaliActorGetCurrentWorldOrientation(void)
1789 {
1790   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1791   TestApplication application;
1792
1793   Actor parent = Actor::New();
1794   Radian rotationAngle( Degree(90.0f) );
1795   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1796   parent.SetOrientation( rotation );
1797   Stage::GetCurrent().Add( parent );
1798
1799   Actor child = Actor::New();
1800   child.SetOrientation( rotation );
1801   parent.Add( child );
1802
1803   // The actors should not have a world rotation yet
1804   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1805   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1806
1807   application.SendNotification();
1808   application.Render(0);
1809
1810   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1811   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1812
1813   // The actors should have a world rotation now
1814   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1815   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1816
1817   // turn off child rotation inheritance
1818   child.SetInheritOrientation( false );
1819   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1820   application.SendNotification();
1821   application.Render(0);
1822
1823   // The actors should have a world rotation now
1824   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1825   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1826   END_TEST;
1827 }
1828
1829 // SetScale(float scale)
1830 int UtcDaliActorSetScale01(void)
1831 {
1832   TestApplication application;
1833
1834   Actor actor = Actor::New();
1835
1836   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1837   actor.SetScale(0.25f);
1838
1839   Vector3 scale(10.0f, 10.0f, 10.0f);
1840   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1841
1842   actor.SetScale(scale.x);
1843
1844   // flush the queue and render once
1845   application.SendNotification();
1846   application.Render();
1847
1848   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1849   END_TEST;
1850 }
1851
1852 // SetScale(float scaleX, float scaleY, float scaleZ)
1853 int UtcDaliActorSetScale02(void)
1854 {
1855   TestApplication application;
1856   Vector3 scale(10.0f, 10.0f, 10.0f);
1857
1858   Actor actor = Actor::New();
1859
1860   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1861   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1862
1863   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1864
1865   actor.SetScale(scale.x, scale.y, scale.z);
1866   // flush the queue and render once
1867   application.SendNotification();
1868   application.Render();
1869   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1870
1871   // add to stage and test
1872   Stage::GetCurrent().Add( actor );
1873   actor.SetScale( 2.0f, 2.0f, 2.0f );
1874   // flush the queue and render once
1875   application.SendNotification();
1876   application.Render();
1877   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1878
1879   Stage::GetCurrent().Remove( actor );
1880
1881   END_TEST;
1882 }
1883
1884 // SetScale(Vector3 scale)
1885 int UtcDaliActorSetScale03(void)
1886 {
1887   TestApplication application;
1888   Vector3 scale(10.0f, 10.0f, 10.0f);
1889
1890   Actor actor = Actor::New();
1891
1892   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1893   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1894
1895   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1896
1897   actor.SetScale(scale);
1898
1899   // flush the queue and render once
1900   application.SendNotification();
1901   application.Render();
1902
1903   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1904   END_TEST;
1905 }
1906
1907 int UtcDaliActorSetScaleIndividual(void)
1908 {
1909   TestApplication application;
1910
1911   Actor actor = Actor::New();
1912
1913   Vector3 vector(0.7f, 0.8f, 0.9f);
1914   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1915
1916   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1917   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1918
1919   // flush the queue and render once
1920   application.SendNotification();
1921   application.Render();
1922
1923   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1924   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1925   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1926
1927   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1928   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1929
1930   // flush the queue and render once
1931   application.SendNotification();
1932   application.Render();
1933
1934   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1935   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1936   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1937
1938   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1939   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1940
1941   // flush the queue and render once
1942   application.SendNotification();
1943   application.Render();
1944
1945   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1946   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1947   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1948
1949   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1950   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1951
1952   END_TEST;
1953 }
1954
1955 int UtcDaliActorScaleBy(void)
1956 {
1957   TestApplication application;
1958   Actor actor = Actor::New();
1959   Vector3 vector(100.0f, 100.0f, 100.0f);
1960
1961   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1962
1963   actor.SetScale(vector);
1964
1965   // flush the queue and render once
1966   application.SendNotification();
1967   application.Render();
1968
1969   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1970
1971   actor.ScaleBy(vector);
1972
1973   // flush the queue and render once
1974   application.SendNotification();
1975   application.Render();
1976
1977   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1978   END_TEST;
1979 }
1980
1981 int UtcDaliActorGetCurrentScale(void)
1982 {
1983   TestApplication application;
1984   Vector3 scale(12.0f, 1.0f, 2.0f);
1985
1986   Actor actor = Actor::New();
1987
1988   actor.SetScale(scale);
1989
1990   // flush the queue and render once
1991   application.SendNotification();
1992   application.Render();
1993
1994   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1995   END_TEST;
1996 }
1997
1998 int UtcDaliActorGetCurrentWorldScale(void)
1999 {
2000   TestApplication application;
2001
2002   Actor parent = Actor::New();
2003   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2004   parent.SetScale( parentScale );
2005   Stage::GetCurrent().Add( parent );
2006
2007   Actor child = Actor::New();
2008   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2009   child.SetScale( childScale );
2010   parent.Add( child );
2011
2012   // The actors should not have a scale yet
2013   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2014   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2015
2016   // The actors should not have a world scale yet
2017   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2018   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2019
2020   application.SendNotification();
2021   application.Render(0);
2022
2023   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2024   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2025
2026   // The actors should have a world scale now
2027   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2028   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2029   END_TEST;
2030 }
2031
2032 int UtcDaliActorInheritScale(void)
2033 {
2034   tet_infoline("Testing Actor::SetInheritScale");
2035   TestApplication application;
2036
2037   Actor parent = Actor::New();
2038   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2039   parent.SetScale( parentScale );
2040   Stage::GetCurrent().Add( parent );
2041
2042   Actor child = Actor::New();
2043   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2044   child.SetScale( childScale );
2045   parent.Add( child );
2046
2047   application.SendNotification();
2048   application.Render(0);
2049
2050   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2051   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2052
2053   child.SetInheritScale( false );
2054   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2055
2056   application.SendNotification();
2057   application.Render(0);
2058
2059   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2060   END_TEST;
2061 }
2062
2063 int UtcDaliActorSetVisible(void)
2064 {
2065   TestApplication application;
2066
2067   Actor actor = Actor::New();
2068   actor.SetVisible(false);
2069   // flush the queue and render once
2070   application.SendNotification();
2071   application.Render();
2072   DALI_TEST_CHECK(actor.IsVisible() == false);
2073
2074   actor.SetVisible(true);
2075   // flush the queue and render once
2076   application.SendNotification();
2077   application.Render();
2078   DALI_TEST_CHECK(actor.IsVisible() == true);
2079
2080   // put actor on stage
2081   Stage::GetCurrent().Add( actor );
2082   actor.SetVisible(false);
2083   // flush the queue and render once
2084   application.SendNotification();
2085   application.Render();
2086   DALI_TEST_CHECK(actor.IsVisible() == false);
2087   END_TEST;
2088 }
2089
2090 int UtcDaliActorIsVisible(void)
2091 {
2092   TestApplication application;
2093
2094   Actor actor = Actor::New();
2095
2096   DALI_TEST_CHECK(actor.IsVisible() == true);
2097   END_TEST;
2098 }
2099
2100 int UtcDaliActorSetOpacity(void)
2101 {
2102   TestApplication application;
2103
2104   Actor actor = Actor::New();
2105   // initial opacity is 1
2106   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2107
2108   actor.SetOpacity( 0.4f);
2109   // flush the queue and render once
2110   application.SendNotification();
2111   application.Render();
2112   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2113
2114   // change opacity, actor is on stage to change is not immediate
2115   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2116   // flush the queue and render once
2117   application.SendNotification();
2118   application.Render();
2119   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2120
2121   // put actor on stage
2122   Stage::GetCurrent().Add( actor );
2123
2124   // change opacity, actor is on stage to change is not immediate
2125   actor.SetOpacity( 0.9f );
2126   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2127   // flush the queue and render once
2128   application.SendNotification();
2129   application.Render();
2130   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2131
2132   // change opacity, actor is on stage to change is not immediate
2133   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2134   // flush the queue and render once
2135   application.SendNotification();
2136   application.Render();
2137   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2138   END_TEST;
2139 }
2140
2141 int UtcDaliActorGetCurrentOpacity(void)
2142 {
2143   TestApplication application;
2144
2145   Actor actor = Actor::New();
2146   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2147
2148   actor.SetOpacity(0.5f);
2149   // flush the queue and render once
2150   application.SendNotification();
2151   application.Render();
2152   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2153   END_TEST;
2154 }
2155
2156 int UtcDaliActorSetSensitive(void)
2157 {
2158   TestApplication application;
2159   Actor actor = Actor::New();
2160
2161   bool sensitive = !actor.IsSensitive();
2162
2163   actor.SetSensitive(sensitive);
2164
2165   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2166   END_TEST;
2167 }
2168
2169 int UtcDaliActorIsSensitive(void)
2170 {
2171   TestApplication application;
2172   Actor actor = Actor::New();
2173   actor.SetSensitive(false);
2174
2175   DALI_TEST_CHECK(false == actor.IsSensitive());
2176   END_TEST;
2177 }
2178
2179 int UtcDaliActorSetColor(void)
2180 {
2181   TestApplication application;
2182   Actor actor = Actor::New();
2183   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2184
2185   DALI_TEST_CHECK(color != actor.GetCurrentColor());
2186
2187   actor.SetColor(color);
2188   // flush the queue and render once
2189   application.SendNotification();
2190   application.Render();
2191   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2192
2193   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2194   // flush the queue and render once
2195   application.SendNotification();
2196   application.Render();
2197   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
2198
2199   Stage::GetCurrent().Add( actor );
2200   actor.SetColor( color );
2201   // flush the queue and render once
2202   application.SendNotification();
2203   application.Render();
2204   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
2205
2206   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2207   // flush the queue and render once
2208   application.SendNotification();
2209   application.Render();
2210   // Actor color is not clamped
2211   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
2212   // world color is clamped
2213   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
2214
2215   Stage::GetCurrent().Remove( actor );
2216   END_TEST;
2217 }
2218
2219 int UtcDaliActorSetColorIndividual(void)
2220 {
2221   TestApplication application;
2222
2223   Actor actor = Actor::New();
2224
2225   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2226   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2227
2228   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2229   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2230
2231   // flush the queue and render once
2232   application.SendNotification();
2233   application.Render();
2234
2235   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2236   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2237   DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2238
2239   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2240   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2241
2242   // flush the queue and render once
2243   application.SendNotification();
2244   application.Render();
2245
2246   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2247   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2248   DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2249
2250   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2251   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2252
2253   // flush the queue and render once
2254   application.SendNotification();
2255   application.Render();
2256
2257   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2258   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2259   DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2260
2261
2262   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2263   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2264
2265   // flush the queue and render once
2266   application.SendNotification();
2267   application.Render();
2268
2269   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2270   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2271   DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2272
2273   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2274   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2275
2276   actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2277
2278
2279   // flush the queue and render once
2280   application.SendNotification();
2281   application.Render();
2282
2283   DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2284
2285   END_TEST;
2286 }
2287
2288
2289 int UtcDaliActorGetCurrentColor(void)
2290 {
2291   TestApplication application;
2292   Actor actor = Actor::New();
2293   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2294
2295   actor.SetColor(color);
2296   // flush the queue and render once
2297   application.SendNotification();
2298   application.Render();
2299   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2300   END_TEST;
2301 }
2302
2303 int UtcDaliActorGetCurrentWorldColor(void)
2304 {
2305   tet_infoline("Actor::GetCurrentWorldColor");
2306   TestApplication application;
2307
2308   Actor parent = Actor::New();
2309   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2310   parent.SetColor( parentColor );
2311   Stage::GetCurrent().Add( parent );
2312
2313   Actor child = Actor::New();
2314   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2315   child.SetColor( childColor );
2316   parent.Add( child );
2317
2318   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2319   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2320
2321   // verify the default color mode
2322   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2323
2324   // The actors should not have a world color yet
2325   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2326   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2327
2328   application.SendNotification();
2329   application.Render(0);
2330
2331   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2332   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2333
2334   // The actors should have a world color now
2335   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2336   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2337
2338   // use own color
2339   child.SetColorMode( USE_OWN_COLOR );
2340   application.SendNotification();
2341   application.Render(0);
2342   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2343
2344   // use parent color
2345   child.SetColorMode( USE_PARENT_COLOR );
2346   application.SendNotification();
2347   application.Render(0);
2348   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2349   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2350
2351   // use parent alpha
2352   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2353   application.SendNotification();
2354   application.Render(0);
2355   Vector4 expectedColor( childColor );
2356   expectedColor.a *= parentColor.a;
2357   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2358   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2359   END_TEST;
2360 }
2361
2362 int UtcDaliActorSetColorMode(void)
2363 {
2364   tet_infoline("Actor::SetColorMode");
2365   TestApplication application;
2366   Actor actor = Actor::New();
2367   Actor child = Actor::New();
2368   actor.Add( child );
2369
2370   actor.SetColorMode( USE_OWN_COLOR );
2371   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2372
2373   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2374   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2375
2376   actor.SetColorMode( USE_PARENT_COLOR );
2377   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2378
2379   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2380   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2381   END_TEST;
2382 }
2383
2384 int UtcDaliActorScreenToLocal(void)
2385 {
2386   TestApplication application;
2387   Actor actor = Actor::New();
2388   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2389   actor.SetSize(100.0f, 100.0f);
2390   actor.SetPosition(10.0f, 10.0f);
2391   Stage::GetCurrent().Add(actor);
2392
2393   // flush the queue and render once
2394   application.SendNotification();
2395   application.Render();
2396
2397   float localX;
2398   float localY;
2399
2400   application.SendNotification();
2401   application.Render();
2402
2403   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2404
2405   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2406   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2407   END_TEST;
2408 }
2409
2410 int UtcDaliActorSetLeaveRequired(void)
2411 {
2412   TestApplication application;
2413
2414   Actor actor = Actor::New();
2415
2416   actor.SetLeaveRequired(false);
2417   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2418
2419   actor.SetLeaveRequired(true);
2420   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2421   END_TEST;
2422 }
2423
2424 int UtcDaliActorGetLeaveRequired(void)
2425 {
2426   TestApplication application;
2427
2428   Actor actor = Actor::New();
2429
2430   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2431   END_TEST;
2432 }
2433
2434 int UtcDaliActorSetKeyboardFocusable(void)
2435 {
2436   TestApplication application;
2437
2438   Actor actor = Actor::New();
2439
2440   actor.SetKeyboardFocusable(true);
2441   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2442
2443   actor.SetKeyboardFocusable(false);
2444   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2445   END_TEST;
2446 }
2447
2448 int UtcDaliActorIsKeyboardFocusable(void)
2449 {
2450   TestApplication application;
2451
2452   Actor actor = Actor::New();
2453
2454   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2455   END_TEST;
2456 }
2457
2458 int UtcDaliActorRemoveConstraints(void)
2459 {
2460   tet_infoline(" UtcDaliActorRemoveConstraints");
2461   TestApplication application;
2462
2463   gTestConstraintCalled = false;
2464
2465   Actor actor = Actor::New();
2466
2467   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2468   constraint.Apply();
2469   actor.RemoveConstraints();
2470
2471   DALI_TEST_CHECK( gTestConstraintCalled == false );
2472
2473   Stage::GetCurrent().Add( actor );
2474   constraint.Apply();
2475
2476   // flush the queue and render once
2477   application.SendNotification();
2478   application.Render();
2479
2480   actor.RemoveConstraints();
2481
2482   DALI_TEST_CHECK( gTestConstraintCalled == true );
2483   END_TEST;
2484 }
2485
2486 int UtcDaliActorRemoveConstraintTag(void)
2487 {
2488   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2489   TestApplication application;
2490
2491   Actor actor = Actor::New();
2492
2493   // 1. Apply Constraint1 and Constraint2, and test...
2494   unsigned int result1 = 0u;
2495   unsigned int result2 = 0u;
2496
2497   unsigned constraint1Tag = 1u;
2498   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2499   constraint1.SetTag( constraint1Tag );
2500   constraint1.Apply();
2501
2502   unsigned constraint2Tag = 2u;
2503   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2504   constraint2.SetTag( constraint2Tag );
2505   constraint2.Apply();
2506
2507   Stage::GetCurrent().Add( actor );
2508   // flush the queue and render once
2509   application.SendNotification();
2510   application.Render();
2511
2512   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2513   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2514
2515   // 2. Remove Constraint1 and test...
2516   result1 = 0;
2517   result2 = 0;
2518   actor.RemoveConstraints(constraint1Tag);
2519   // make color property dirty, which will trigger constraints to be reapplied.
2520   actor.SetColor( Color::WHITE );
2521   // flush the queue and render once
2522   application.SendNotification();
2523   application.Render();
2524
2525   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2526   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2527
2528   // 3. Re-Apply Constraint1 and test...
2529   result1 = 0;
2530   result2 = 0;
2531   constraint1.Apply();
2532   // make color property dirty, which will trigger constraints to be reapplied.
2533   actor.SetColor( Color::WHITE );
2534   // flush the queue and render once
2535   application.SendNotification();
2536   application.Render();
2537
2538   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2539   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2540
2541   // 2. Remove Constraint2 and test...
2542   result1 = 0;
2543   result2 = 0;
2544   actor.RemoveConstraints(constraint2Tag);
2545   // make color property dirty, which will trigger constraints to be reapplied.
2546   actor.SetColor( Color::WHITE );
2547   // flush the queue and render once
2548   application.SendNotification();
2549   application.Render();
2550
2551   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2552   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2553
2554   // 2. Remove Constraint1 as well and test...
2555   result1 = 0;
2556   result2 = 0;
2557   actor.RemoveConstraints(constraint1Tag);
2558   // make color property dirty, which will trigger constraints to be reapplied.
2559   actor.SetColor( Color::WHITE );
2560   // flush the queue and render once
2561   application.SendNotification();
2562   application.Render();
2563
2564   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2565   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2566   END_TEST;
2567 }
2568
2569 int UtcDaliActorTouchedSignal(void)
2570 {
2571   TestApplication application;
2572
2573   ResetTouchCallbacks();
2574
2575   // get the root layer
2576   Actor actor = Stage::GetCurrent().GetRootLayer();
2577   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2578
2579   application.SendNotification();
2580   application.Render();
2581
2582   // connect to its touch signal
2583   actor.TouchedSignal().Connect( TestCallback );
2584
2585   // simulate a touch event in the middle of the screen
2586   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2587   Dali::Integration::Point point;
2588   point.SetDeviceId( 1 );
2589   point.SetState( PointState::DOWN );
2590   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2591   Dali::Integration::TouchEvent touchEvent;
2592   touchEvent.AddPoint( point );
2593   application.ProcessEvent( touchEvent );
2594
2595   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2596   END_TEST;
2597 }
2598
2599 int UtcDaliActorHoveredSignal(void)
2600 {
2601   TestApplication application;
2602
2603   gHoverCallBackCalled = false;
2604
2605   // get the root layer
2606   Actor actor = Stage::GetCurrent().GetRootLayer();
2607   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2608
2609   application.SendNotification();
2610   application.Render();
2611
2612   // connect to its hover signal
2613   actor.HoveredSignal().Connect( TestCallback3 );
2614
2615   // simulate a hover event in the middle of the screen
2616   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2617   Dali::Integration::Point point;
2618   point.SetDeviceId( 1 );
2619   point.SetState( PointState::MOTION );
2620   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2621   Dali::Integration::HoverEvent hoverEvent;
2622   hoverEvent.AddPoint( point );
2623   application.ProcessEvent( hoverEvent );
2624
2625   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2626   END_TEST;
2627 }
2628
2629 int UtcDaliActorOnOffStageSignal(void)
2630 {
2631   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2632
2633   TestApplication application;
2634
2635   // clean test data
2636   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2637   gActorNamesOnOffStage.clear();
2638
2639   Actor parent = Actor::New();
2640   parent.SetName( "parent" );
2641   parent.OnStageSignal().Connect( OnStageCallback );
2642   parent.OffStageSignal().Connect( OffStageCallback );
2643   // sanity check
2644   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2645   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2646
2647   // add parent to stage
2648   Stage::GetCurrent().Add( parent );
2649   // onstage emitted, offstage not
2650   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2651   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2652   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2653
2654   // test adding a child, should get onstage emitted
2655   // clean test data
2656   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2657   gActorNamesOnOffStage.clear();
2658
2659   Actor child = Actor::New();
2660   child.SetName( "child" );
2661   child.OnStageSignal().Connect( OnStageCallback );
2662   child.OffStageSignal().Connect( OffStageCallback );
2663   parent.Add( child ); // add child
2664   // onstage emitted, offstage not
2665   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2666   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2667   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2668
2669   // test removing parent from stage
2670   // clean test data
2671   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2672   gActorNamesOnOffStage.clear();
2673
2674   Stage::GetCurrent().Remove( parent );
2675   // onstage not emitted, offstage is
2676   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2677   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2678   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2679   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2680
2681   // test adding parent back to stage
2682   // clean test data
2683   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2684   gActorNamesOnOffStage.clear();
2685
2686   Stage::GetCurrent().Add( parent );
2687   // onstage emitted, offstage not
2688   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2689   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2690   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2691   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2692
2693   // test removing child
2694   // clean test data
2695   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2696   gActorNamesOnOffStage.clear();
2697
2698   parent.Remove( child );
2699   // onstage not emitted, offstage is
2700   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2701   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2702   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2703
2704   // test removing parent
2705   // clean test data
2706   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2707   gActorNamesOnOffStage.clear();
2708
2709   Stage::GetCurrent().Remove( parent );
2710   // onstage not emitted, offstage is
2711   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2712   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2713   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2714   END_TEST;
2715 }
2716
2717 int UtcDaliActorFindChildByName(void)
2718 {
2719   tet_infoline("Testing Dali::Actor::FindChildByName()");
2720   TestApplication application;
2721
2722   Actor parent = Actor::New();
2723   parent.SetName( "parent" );
2724   Actor first  = Actor::New();
2725   first .SetName( "first" );
2726   Actor second = Actor::New();
2727   second.SetName( "second" );
2728
2729   parent.Add(first);
2730   first.Add(second);
2731
2732   Actor found = parent.FindChildByName( "foo" );
2733   DALI_TEST_CHECK( !found );
2734
2735   found = parent.FindChildByName( "parent" );
2736   DALI_TEST_CHECK( found == parent );
2737
2738   found = parent.FindChildByName( "first" );
2739   DALI_TEST_CHECK( found == first );
2740
2741   found = parent.FindChildByName( "second" );
2742   DALI_TEST_CHECK( found == second );
2743   END_TEST;
2744 }
2745
2746 int UtcDaliActorFindChildById(void)
2747 {
2748   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2749   TestApplication application;
2750
2751   Actor parent = Actor::New();
2752   Actor first  = Actor::New();
2753   Actor second = Actor::New();
2754
2755   parent.Add(first);
2756   first.Add(second);
2757
2758   Actor found = parent.FindChildById( 100000 );
2759   DALI_TEST_CHECK( !found );
2760
2761   found = parent.FindChildById( parent.GetId() );
2762   DALI_TEST_CHECK( found == parent );
2763
2764   found = parent.FindChildById( first.GetId() );
2765   DALI_TEST_CHECK( found == first );
2766
2767   found = parent.FindChildById( second.GetId() );
2768   DALI_TEST_CHECK( found == second );
2769   END_TEST;
2770 }
2771
2772 int UtcDaliActorHitTest(void)
2773 {
2774   struct HitTestData
2775   {
2776   public:
2777     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2778     : mScale( scale ),
2779       mTouchPoint( touchPoint ),
2780       mResult( result )
2781     {}
2782
2783     Vector3 mScale;
2784     Vector2 mTouchPoint;
2785     bool mResult;
2786   };
2787
2788   TestApplication application;
2789   tet_infoline(" UtcDaliActorHitTest");
2790
2791   // Fill a vector with different hit tests.
2792   struct HitTestData* hitTestData[] = {
2793     //                    scale                     touch point           result
2794     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2795     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2796     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.
2797     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2798     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.
2799     NULL,
2800   };
2801
2802   // get the root layer
2803   Actor actor = Actor::New();
2804   actor.SetAnchorPoint( AnchorPoint::CENTER );
2805   actor.SetParentOrigin( ParentOrigin::CENTER );
2806
2807   Stage::GetCurrent().Add( actor );
2808
2809   ResetTouchCallbacks();
2810
2811   unsigned int index = 0;
2812   while( NULL != hitTestData[index] )
2813   {
2814     actor.SetSize( 1.f, 1.f );
2815     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2816
2817     // flush the queue and render once
2818     application.SendNotification();
2819     application.Render();
2820
2821     DALI_TEST_CHECK( !gTouchCallBackCalled );
2822
2823     // connect to its touch signal
2824     actor.TouchedSignal().Connect(TestCallback);
2825
2826     Dali::Integration::Point point;
2827     point.SetState( PointState::DOWN );
2828     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2829     Dali::Integration::TouchEvent event;
2830     event.AddPoint( point );
2831
2832     // flush the queue and render once
2833     application.SendNotification();
2834     application.Render();
2835     application.ProcessEvent( event );
2836
2837     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2838
2839     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2840       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2841                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2842                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2843                  hitTestData[index]->mResult );
2844
2845     ResetTouchCallbacks();
2846     ++index;
2847   }
2848   END_TEST;
2849 }
2850
2851 int UtcDaliActorSetDrawMode(void)
2852 {
2853   TestApplication app;
2854   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2855
2856   Actor a = Actor::New();
2857
2858   Stage::GetCurrent().Add(a);
2859   app.SendNotification();
2860   app.Render(0);
2861   app.SendNotification();
2862   app.Render(1);
2863
2864   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2865
2866   a.SetDrawMode( DrawMode::OVERLAY_2D );
2867   app.SendNotification();
2868   app.Render(1);
2869
2870   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2871
2872   a.SetDrawMode( DrawMode::NORMAL );
2873   app.SendNotification();
2874   app.Render(1);
2875
2876   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2877   END_TEST;
2878 }
2879
2880 int UtcDaliActorSetDrawModeOverlayRender(void)
2881 {
2882   TestApplication app;
2883   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2884
2885   app.SendNotification();
2886   app.Render(1);
2887
2888   std::vector<GLuint> ids;
2889   ids.push_back( 8 );   // first rendered actor
2890   ids.push_back( 9 );   // second rendered actor
2891   ids.push_back( 10 );  // third rendered actor
2892   app.GetGlAbstraction().SetNextTextureIds( ids );
2893
2894   BufferImage imageA = BufferImage::New(16, 16);
2895   BufferImage imageB = BufferImage::New(16, 16);
2896   BufferImage imageC = BufferImage::New(16, 16);
2897   Actor a = CreateRenderableActor( imageA );
2898   Actor b = CreateRenderableActor( imageB );
2899   Actor c = CreateRenderableActor( imageC );
2900
2901   app.SendNotification();
2902   app.Render(1);
2903
2904   //Textures are bound when first created. Clear bound textures vector
2905   app.GetGlAbstraction().ClearBoundTextures();
2906
2907   // Render a,b,c as regular non-overlays. so order will be:
2908   // a (8)
2909   // b (9)
2910   // c (10)
2911   Stage::GetCurrent().Add(a);
2912   Stage::GetCurrent().Add(b);
2913   Stage::GetCurrent().Add(c);
2914
2915   app.SendNotification();
2916   app.Render(1);
2917
2918   // Should be 3 textures changes.
2919   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2920   typedef std::vector<GLuint>::size_type TextureSize;
2921   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2922   if( boundTextures.size() == 3 )
2923   {
2924     DALI_TEST_CHECK( boundTextures[0] == 8u );
2925     DALI_TEST_CHECK( boundTextures[1] == 9u );
2926     DALI_TEST_CHECK( boundTextures[2] == 10u );
2927   }
2928
2929   // Now texture ids have been set, we can monitor their render order.
2930   // render a as an overlay (last), so order will be:
2931   // b (9)
2932   // c (10)
2933   // a (8)
2934   a.SetDrawMode( DrawMode::OVERLAY_2D );
2935   app.GetGlAbstraction().ClearBoundTextures();
2936
2937   app.SendNotification();
2938   app.Render(1);
2939
2940   // Should be 3 texture changes.
2941   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2942   if( boundTextures.size() == 3 )
2943   {
2944     DALI_TEST_CHECK( boundTextures[0] == 9u );
2945     DALI_TEST_CHECK( boundTextures[1] == 10u );
2946     DALI_TEST_CHECK( boundTextures[2] == 8u );
2947   }
2948   END_TEST;
2949 }
2950
2951 int UtcDaliActorGetCurrentWorldMatrix(void)
2952 {
2953   TestApplication app;
2954   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2955
2956   Actor parent = Actor::New();
2957   parent.SetParentOrigin(ParentOrigin::CENTER);
2958   parent.SetAnchorPoint(AnchorPoint::CENTER);
2959   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2960   Radian rotationAngle(Degree(85.0f));
2961   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2962   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2963   parent.SetPosition( parentPosition );
2964   parent.SetOrientation( parentRotation );
2965   parent.SetScale( parentScale );
2966   Stage::GetCurrent().Add( parent );
2967
2968   Actor child = Actor::New();
2969   child.SetParentOrigin(ParentOrigin::CENTER);
2970   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2971   Radian childRotationAngle(Degree(23.0f));
2972   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2973   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2974   child.SetPosition( childPosition );
2975   child.SetOrientation( childRotation );
2976   child.SetScale( childScale );
2977   parent.Add( child );
2978
2979   app.SendNotification();
2980   app.Render(0);
2981   app.Render();
2982   app.SendNotification();
2983
2984   Matrix parentMatrix(false);
2985   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2986
2987   Matrix childMatrix(false);
2988   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2989
2990   //Child matrix should be the composition of child and parent
2991   Matrix childWorldMatrix(false);
2992   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2993
2994   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2995   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2996   END_TEST;
2997 }
2998
2999
3000
3001 int UtcDaliActorConstrainedToWorldMatrix(void)
3002 {
3003   TestApplication app;
3004   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3005
3006   Actor parent = Actor::New();
3007   parent.SetParentOrigin(ParentOrigin::CENTER);
3008   parent.SetAnchorPoint(AnchorPoint::CENTER);
3009   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3010   Radian rotationAngle(Degree(85.0f));
3011   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3012   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3013   parent.SetPosition( parentPosition );
3014   parent.SetOrientation( parentRotation );
3015   parent.SetScale( parentScale );
3016   Stage::GetCurrent().Add( parent );
3017
3018   Actor child = Actor::New();
3019   child.SetParentOrigin(ParentOrigin::CENTER);
3020   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3021   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3022   posConstraint.Apply();
3023
3024   Stage::GetCurrent().Add( child );
3025
3026   app.SendNotification();
3027   app.Render(0);
3028   app.Render();
3029   app.SendNotification();
3030
3031   Matrix parentMatrix(false);
3032   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3033
3034   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3035   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3036   END_TEST;
3037 }
3038
3039 int UtcDaliActorConstrainedToOrientation(void)
3040 {
3041   TestApplication app;
3042   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3043
3044   Actor parent = Actor::New();
3045   parent.SetParentOrigin(ParentOrigin::CENTER);
3046   parent.SetAnchorPoint(AnchorPoint::CENTER);
3047   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3048   Radian rotationAngle(Degree(85.0f));
3049   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3050   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3051   parent.SetPosition( parentPosition );
3052   parent.SetOrientation( parentRotation );
3053   parent.SetScale( parentScale );
3054   Stage::GetCurrent().Add( parent );
3055
3056   Actor child = Actor::New();
3057   child.SetParentOrigin(ParentOrigin::CENTER);
3058   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3059   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3060   posConstraint.Apply();
3061
3062   Stage::GetCurrent().Add( child );
3063
3064   app.SendNotification();
3065   app.Render(0);
3066   app.Render();
3067   app.SendNotification();
3068
3069   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3070   END_TEST;
3071 }
3072
3073 int UtcDaliActorConstrainedToOpacity(void)
3074 {
3075   TestApplication app;
3076   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3077
3078   Actor parent = Actor::New();
3079   parent.SetOpacity( 0.7f );
3080   Stage::GetCurrent().Add( parent );
3081
3082   Actor child = Actor::New();
3083   Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3084   opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3085   opacityConstraint.Apply();
3086
3087   Stage::GetCurrent().Add( child );
3088
3089   app.SendNotification();
3090   app.Render(0);
3091   app.Render();
3092   app.SendNotification();
3093
3094   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3095
3096   parent.SetOpacity( 0.3f );
3097
3098   app.SendNotification();
3099   app.Render(0);
3100   app.Render();
3101   app.SendNotification();
3102
3103   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3104
3105   END_TEST;
3106 }
3107
3108 int UtcDaliActorUnparent(void)
3109 {
3110   TestApplication app;
3111   tet_infoline(" UtcDaliActorUnparent");
3112
3113   Actor parent = Actor::New();
3114   Stage::GetCurrent().Add( parent );
3115
3116   Actor child = Actor::New();
3117
3118   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3119   DALI_TEST_CHECK( !child.GetParent() );
3120
3121   // Test that calling Unparent with no parent is a NOOP
3122   child.Unparent();
3123
3124   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3125   DALI_TEST_CHECK( !child.GetParent() );
3126
3127   // Test that Unparent works
3128   parent.Add( child );
3129
3130   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3131   DALI_TEST_CHECK( parent == child.GetParent() );
3132
3133   child.Unparent();
3134
3135   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3136   DALI_TEST_CHECK( !child.GetParent() );
3137
3138   // Test that UnparentAndReset works
3139   parent.Add( child );
3140
3141   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3142   DALI_TEST_CHECK( parent == child.GetParent() );
3143
3144   UnparentAndReset( child );
3145
3146   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3147   DALI_TEST_CHECK( !child );
3148
3149   // Test that UnparentAndReset is a NOOP with empty handle
3150   UnparentAndReset( child );
3151
3152   DALI_TEST_CHECK( !child );
3153   END_TEST;
3154 }
3155
3156 int UtcDaliActorGetChildAt(void)
3157 {
3158   TestApplication app;
3159   tet_infoline(" UtcDaliActorGetChildAt");
3160
3161   Actor parent = Actor::New();
3162   Stage::GetCurrent().Add( parent );
3163
3164   Actor child0 = Actor::New();
3165   parent.Add( child0 );
3166
3167   Actor child1 = Actor::New();
3168   parent.Add( child1 );
3169
3170   Actor child2 = Actor::New();
3171   parent.Add( child2 );
3172
3173   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3174   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3175   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3176   END_TEST;
3177 }
3178
3179 int UtcDaliActorSetGetOverlay(void)
3180 {
3181   TestApplication app;
3182   tet_infoline(" UtcDaliActorSetGetOverlay");
3183
3184   Actor parent = Actor::New();
3185   parent.SetDrawMode(DrawMode::OVERLAY_2D );
3186   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3187   END_TEST;
3188 }
3189
3190
3191 int UtcDaliActorCreateDestroy(void)
3192 {
3193   Actor* actor = new Actor;
3194   DALI_TEST_CHECK( actor );
3195   delete actor;
3196   END_TEST;
3197 }
3198
3199 namespace
3200 {
3201 struct PropertyStringIndex
3202 {
3203   const char * const name;
3204   const Property::Index index;
3205   const Property::Type type;
3206 };
3207
3208 const PropertyStringIndex PROPERTY_TABLE[] =
3209 {
3210   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
3211   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
3212   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
3213   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
3214   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
3215   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
3216   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
3217   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
3218   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
3219   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
3220   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
3221   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
3222   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
3223   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
3224   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
3225   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
3226   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
3227   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
3228   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
3229   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
3230   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
3231   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
3232   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
3233   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
3234   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
3235   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
3236   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
3237   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
3238   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
3239   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
3240   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
3241   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
3242   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
3243   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
3244   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
3245   { "name",                     Actor::Property::NAME,                     Property::STRING      },
3246   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
3247   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
3248   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
3249   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
3250   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
3251   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
3252   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
3253   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
3254   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
3255   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
3256   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
3257   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
3258   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
3259   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
3260   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
3261   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
3262   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
3263   { "opacity",                  DevelActor::Property::OPACITY,             Property::FLOAT       },
3264 };
3265 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3266 } // unnamed namespace
3267
3268 int UtcDaliActorProperties(void)
3269 {
3270   TestApplication app;
3271
3272   Actor actor = Actor::New();
3273
3274   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3275   {
3276     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3277     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3278     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3279     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3280   }
3281   END_TEST;
3282 }
3283
3284 int UtcDaliRelayoutProperties_ResizePolicies(void)
3285 {
3286   TestApplication app;
3287
3288   Actor actor = Actor::New();
3289
3290   // Defaults
3291   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3292   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3293
3294   // Set resize policy for all dimensions
3295   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3296   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3297   {
3298     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3299   }
3300
3301   // Set individual dimensions
3302   const char* const widthPolicy = "FILL_TO_PARENT";
3303   const char* const heightPolicy = "FIXED";
3304
3305   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3306   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3307
3308   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3309   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3310
3311   // Set individual dimensions using enums
3312   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3313   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3314
3315   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3316   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3317
3318   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3319   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3320
3321   END_TEST;
3322 }
3323
3324 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3325 {
3326   TestApplication app;
3327
3328   Actor actor = Actor::New();
3329
3330   // Defaults
3331   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3332   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3333
3334   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3335   actor.SetSizeScalePolicy( policy );
3336   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3337
3338   // Set
3339   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3340   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3341
3342   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3343   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3344
3345   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3346   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3347
3348   END_TEST;
3349 }
3350
3351 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3352 {
3353   TestApplication app;
3354
3355   Actor actor = Actor::New();
3356
3357   // Defaults
3358   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3359   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3360
3361   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3362   actor.SetSizeModeFactor( sizeMode );
3363   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3364
3365   // Set
3366   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3367
3368   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3369   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3370
3371   END_TEST;
3372 }
3373
3374 int UtcDaliRelayoutProperties_DimensionDependency(void)
3375 {
3376   TestApplication app;
3377
3378   Actor actor = Actor::New();
3379
3380   // Defaults
3381   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3382   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3383
3384   // Set
3385   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3386   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3387
3388   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3389   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3390
3391   // Test setting another resize policy
3392   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3393   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3394
3395   END_TEST;
3396 }
3397
3398 int UtcDaliRelayoutProperties_Padding(void)
3399 {
3400   TestApplication app;
3401
3402   Actor actor = Actor::New();
3403
3404   // Data
3405   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3406
3407   // PADDING
3408   actor.SetProperty( Actor::Property::PADDING, padding );
3409   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3410
3411   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3412
3413   END_TEST;
3414 }
3415
3416 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3417 {
3418   TestApplication app;
3419
3420   Actor actor = Actor::New();
3421
3422   // Data
3423   Vector2 minSize( 1.0f, 2.0f );
3424
3425   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3426   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3427
3428   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3429
3430   Vector2 maxSize( 3.0f, 4.0f );
3431
3432   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3433   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3434
3435   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3436
3437   END_TEST;
3438 }
3439
3440 int UtcDaliActorGetHeightForWidth(void)
3441 {
3442   TestApplication app;
3443
3444   Actor actor = Actor::New();
3445
3446   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3447
3448   END_TEST;
3449 }
3450
3451 int UtcDaliActorGetWidthForHeight(void)
3452 {
3453   TestApplication app;
3454
3455   Actor actor = Actor::New();
3456
3457   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3458
3459   END_TEST;
3460 }
3461
3462 int UtcDaliActorGetRelayoutSize(void)
3463 {
3464   TestApplication app;
3465
3466   Actor actor = Actor::New();
3467
3468   // Add actor to stage
3469   Stage::GetCurrent().Add( actor );
3470
3471   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3472
3473   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3474   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3475
3476   // Flush the queue and render once
3477   app.SendNotification();
3478   app.Render();
3479
3480   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3481
3482   END_TEST;
3483 }
3484
3485 int UtcDaliActorSetPadding(void)
3486 {
3487   TestApplication app;
3488
3489   Actor actor = Actor::New();
3490
3491   Padding padding;
3492   actor.GetPadding( padding );
3493
3494   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3495   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3496   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3497   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3498
3499   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3500   actor.SetPadding( padding2 );
3501
3502   actor.GetPadding( padding );
3503
3504   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3505   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3506   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3507   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3508
3509   END_TEST;
3510 }
3511
3512 int UtcDaliActorSetMinimumSize(void)
3513 {
3514   TestApplication app;
3515
3516   Actor actor = Actor::New();
3517
3518   Vector2 size = actor.GetMinimumSize();
3519
3520   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3521   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3522
3523   Vector2 size2( 1.0f, 2.0f );
3524   actor.SetMinimumSize( size2 );
3525
3526   size = actor.GetMinimumSize();
3527
3528   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3529   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3530
3531   END_TEST;
3532 }
3533
3534 int UtcDaliActorSetMaximumSize(void)
3535 {
3536   TestApplication app;
3537
3538   Actor actor = Actor::New();
3539
3540   Vector2 size = actor.GetMaximumSize();
3541
3542   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3543   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3544
3545   Vector2 size2( 1.0f, 2.0f );
3546   actor.SetMaximumSize( size2 );
3547
3548   size = actor.GetMaximumSize();
3549
3550   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3551   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3552
3553   END_TEST;
3554 }
3555
3556 int UtcDaliActorOnRelayoutSignal(void)
3557 {
3558   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3559
3560   TestApplication application;
3561
3562   // Clean test data
3563   gOnRelayoutCallBackCalled = false;
3564   gActorNamesRelayout.clear();
3565
3566   Actor actor = Actor::New();
3567   actor.SetName( "actor" );
3568   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3569
3570   // Sanity check
3571   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3572
3573   // Add actor to stage
3574   Stage::GetCurrent().Add( actor );
3575
3576   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3577   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3578
3579   // Flush the queue and render once
3580   application.SendNotification();
3581   application.Render();
3582
3583   // OnRelayout emitted
3584   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3585   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3586
3587   END_TEST;
3588 }
3589
3590 int UtcDaliActorGetHierachyDepth(void)
3591 {
3592   TestApplication application;
3593   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3594
3595
3596   /* Build tree of actors:
3597    *
3598    *                      Depth
3599    *
3600    *       A (parent)       1
3601    *      / \
3602    *     B   C              2`
3603    *    / \   \
3604    *   D   E   F            3
3605    *
3606    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3607    */
3608   Stage stage( Stage::GetCurrent() );
3609
3610   Actor actorA = Actor::New();
3611   Actor actorB = Actor::New();
3612   Actor actorC = Actor::New();
3613   Actor actorD = Actor::New();
3614   Actor actorE = Actor::New();
3615   Actor actorF = Actor::New();
3616
3617   //Test that root actor has depth equal 0
3618   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3619
3620   //Test actors return depth -1 when not connected to the tree
3621   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3622   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3623   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3624   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3625   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3626   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3627
3628   //Create the hierarchy
3629   stage.Add( actorA );
3630   actorA.Add( actorB );
3631   actorA.Add( actorC );
3632   actorB.Add( actorD );
3633   actorB.Add( actorE );
3634   actorC.Add( actorF );
3635
3636   //Test actors return correct depth
3637   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3638   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3639   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3640   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3641   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3642   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3643
3644   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3645   actorA.Remove( actorB );
3646
3647   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3648   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3649   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3650
3651   //Removing actorA from the stage. All actors should have depth equal -1
3652   stage.Remove( actorA );
3653
3654   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3655   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3656   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3657   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3658   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3659   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3660
3661   END_TEST;
3662 }
3663
3664 int UtcDaliActorAnchorPointPropertyAsString(void)
3665 {
3666   TestApplication application;
3667
3668   Actor actor = Actor::New();
3669
3670   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3671   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3672
3673   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3674   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3675
3676   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3677   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3678
3679   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3680   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3681
3682   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3683   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3684
3685   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3686   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3687
3688   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3689   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3690
3691   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3692   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3693
3694   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3695   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3696
3697   // Invalid should not change anything
3698   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3699   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3700
3701   END_TEST;
3702 }
3703
3704 int UtcDaliActorParentOriginPropertyAsString(void)
3705 {
3706   TestApplication application;
3707
3708   Actor actor = Actor::New();
3709
3710   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3711   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3712
3713   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3714   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3715
3716   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3717   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3718
3719   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3720   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3721
3722   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3723   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3724
3725   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3726   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3727
3728   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3729   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3730
3731   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3732   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3733
3734   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3735   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3736
3737   // Invalid should not change anything
3738   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3739   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3740
3741   END_TEST;
3742 }
3743
3744 int UtcDaliActorColorModePropertyAsString(void)
3745 {
3746   TestApplication application;
3747
3748   Actor actor = Actor::New();
3749
3750   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3751   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3752
3753   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3754   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3755
3756   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3757   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3758
3759   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3760   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3761
3762   // Invalid should not change anything
3763   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3764   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3765
3766   END_TEST;
3767 }
3768
3769 int UtcDaliActorDrawModePropertyAsString(void)
3770 {
3771   TestApplication application;
3772
3773   Actor actor = Actor::New();
3774
3775   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3776   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3777
3778   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3779   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3780
3781   // Invalid should not change anything
3782   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3783   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3784
3785   END_TEST;
3786 }
3787
3788 int UtcDaliActorColorModePropertyAsEnum(void)
3789 {
3790   TestApplication application;
3791
3792   Actor actor = Actor::New();
3793
3794   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3795   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3796
3797   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3798   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3799
3800   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3801   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3802
3803   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3804   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3805
3806   END_TEST;
3807 }
3808
3809 int UtcDaliActorDrawModePropertyAsEnum(void)
3810 {
3811   TestApplication application;
3812
3813   Actor actor = Actor::New();
3814
3815   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3816   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3817
3818   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3819   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3820
3821   END_TEST;
3822 }
3823
3824 int UtcDaliActorAddRendererP(void)
3825 {
3826   tet_infoline("Testing Actor::AddRenderer");
3827   TestApplication application;
3828
3829   Actor actor = Actor::New();
3830
3831   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3832
3833   Geometry geometry = CreateQuadGeometry();
3834   Shader shader = CreateShader();
3835   Renderer renderer = Renderer::New(geometry, shader);
3836
3837   actor.AddRenderer( renderer );
3838   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3839   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3840
3841   END_TEST;
3842 }
3843
3844 int UtcDaliActorAddRendererN(void)
3845 {
3846   tet_infoline("Testing Actor::AddRenderer");
3847   TestApplication application;
3848
3849   Actor actor = Actor::New();
3850   Renderer renderer;
3851
3852   // try illegal Add
3853   try
3854   {
3855     actor.AddRenderer( renderer );
3856     tet_printf("Assertion test failed - no Exception\n" );
3857     tet_result(TET_FAIL);
3858   }
3859   catch(Dali::DaliException& e)
3860   {
3861     DALI_TEST_PRINT_ASSERT( e );
3862     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3863     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864   }
3865   catch(...)
3866   {
3867     tet_printf("Assertion test failed - wrong Exception\n" );
3868     tet_result(TET_FAIL);
3869   }
3870
3871   END_TEST;
3872 }
3873
3874 int UtcDaliActorAddRendererOnStage(void)
3875 {
3876   tet_infoline("Testing Actor::AddRenderer");
3877   TestApplication application;
3878
3879   Actor actor = Actor::New();
3880   Stage::GetCurrent().Add(actor);
3881
3882   application.SendNotification();
3883   application.Render(0);
3884
3885   Geometry geometry = CreateQuadGeometry();
3886   Shader shader = CreateShader();
3887   Renderer renderer = Renderer::New(geometry, shader);
3888
3889   application.SendNotification();
3890   application.Render(0);
3891
3892   try
3893   {
3894     actor.AddRenderer( renderer );
3895     tet_result(TET_PASS);
3896   }
3897   catch(...)
3898   {
3899     tet_result(TET_FAIL);
3900   }
3901
3902   END_TEST;
3903 }
3904
3905 int UtcDaliActorRemoveRendererP1(void)
3906 {
3907   tet_infoline("Testing Actor::RemoveRenderer");
3908   TestApplication application;
3909
3910   Actor actor = Actor::New();
3911
3912   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3913
3914   {
3915     Geometry geometry = CreateQuadGeometry();
3916     Shader shader = CreateShader();
3917     Renderer renderer = Renderer::New(geometry, shader);
3918
3919     actor.AddRenderer( renderer );
3920     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3921     DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3922
3923     application.SendNotification();
3924     application.Render();
3925   }
3926
3927   {
3928     Renderer renderer = actor.GetRendererAt(0);
3929     actor.RemoveRenderer(renderer);
3930     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3931
3932     application.SendNotification();
3933     application.Render();
3934   }
3935
3936   // Call one final time to ensure that the renderer is actually removed after
3937   // the handle goes out of scope, and excercises the deletion code path in
3938   // scene graph and render.
3939   application.SendNotification();
3940   application.Render();
3941
3942   END_TEST;
3943 }
3944
3945 int UtcDaliActorRemoveRendererP2(void)
3946 {
3947   tet_infoline("Testing Actor::RemoveRenderer");
3948   TestApplication application;
3949
3950   Actor actor = Actor::New();
3951
3952   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3953
3954   Geometry geometry = CreateQuadGeometry();
3955   Shader shader = CreateShader();
3956   Renderer renderer = Renderer::New(geometry, shader);
3957
3958   actor.AddRenderer( renderer );
3959   application.SendNotification();
3960   application.Render();
3961
3962   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3963   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3964
3965   actor.RemoveRenderer(0);
3966   application.SendNotification();
3967   application.Render();
3968
3969   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3970
3971   // Shut down whilst holding onto the renderer handle.
3972   END_TEST;
3973 }
3974
3975
3976 int UtcDaliActorRemoveRendererN(void)
3977 {
3978   tet_infoline("Testing Actor::RemoveRenderer");
3979   TestApplication application;
3980
3981   Actor actor = Actor::New();
3982
3983   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3984
3985   Geometry geometry = CreateQuadGeometry();
3986   Shader shader = CreateShader();
3987   Renderer renderer = Renderer::New(geometry, shader);
3988
3989   actor.AddRenderer( renderer );
3990   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3991   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3992
3993   actor.RemoveRenderer(10);
3994   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3995   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3996
3997   END_TEST;
3998 }
3999
4000 // Clipping test helper functions:
4001 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4002 {
4003   BufferImage image = BufferImage::New( width, height );
4004   Actor actor = CreateRenderableActor( image );
4005
4006   // Setup dimensions and position so actor is not skipped by culling.
4007   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4008   actor.SetSize( width, height );
4009   actor.SetParentOrigin( ParentOrigin::CENTER );
4010   actor.SetAnchorPoint( AnchorPoint::CENTER );
4011
4012   return actor;
4013 }
4014
4015 Actor CreateActorWithContent16x16()
4016 {
4017   return CreateActorWithContent( 16, 16 );
4018 }
4019
4020 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4021 {
4022   enabledDisableTrace.Reset();
4023   stencilTrace.Reset();
4024   enabledDisableTrace.Enable( true );
4025   stencilTrace.Enable( true );
4026
4027   application.SendNotification();
4028   application.Render();
4029
4030   enabledDisableTrace.Enable( false );
4031   stencilTrace.Enable( false );
4032 }
4033
4034 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4035 {
4036   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4037
4038   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
4039   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4040   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
4041   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4042 }
4043
4044 int UtcDaliActorPropertyClippingP(void)
4045 {
4046   // This test checks the clippingMode property.
4047   tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4048   TestApplication application;
4049
4050   Actor actor = Actor::New();
4051
4052   // Check default clippingEnabled value.
4053   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4054
4055   int value = 0;
4056   bool getValueResult = getValue.Get( value );
4057   DALI_TEST_CHECK( getValueResult );
4058
4059   if( getValueResult )
4060   {
4061     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4062   }
4063
4064   // Check setting the property to the stencil mode.
4065   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4066
4067   // Check the new value was set.
4068   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4069   getValueResult = getValue.Get( value );
4070   DALI_TEST_CHECK( getValueResult );
4071
4072   if( getValueResult )
4073   {
4074     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4075   }
4076
4077   // Check setting the property to the scissor mode.
4078   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4079
4080   // Check the new value was set.
4081   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4082   getValueResult = getValue.Get( value );
4083   DALI_TEST_CHECK( getValueResult );
4084
4085   if( getValueResult )
4086   {
4087     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4088   }
4089   END_TEST;
4090 }
4091
4092 int UtcDaliActorPropertyClippingN(void)
4093 {
4094   // Negative test case for Clipping.
4095   tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4096   TestApplication application;
4097
4098   Actor actor = Actor::New();
4099
4100   // Check default clippingEnabled value.
4101   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4102
4103   int value = 0;
4104   bool getValueResult = getValue.Get( value );
4105   DALI_TEST_CHECK( getValueResult );
4106
4107   if( getValueResult )
4108   {
4109     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4110   }
4111
4112   // Check setting an invalid property value won't change the current property value.
4113   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4114
4115   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4116   getValueResult = getValue.Get( value );
4117   DALI_TEST_CHECK( getValueResult );
4118
4119   if( getValueResult )
4120   {
4121     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4122   }
4123
4124   END_TEST;
4125 }
4126
4127 int UtcDaliActorPropertyClippingActor(void)
4128 {
4129   // This test checks that an actor is correctly setup for clipping.
4130   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4131   TestApplication application;
4132
4133   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4134   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4135   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4136   size_t startIndex = 0u;
4137
4138   // Create a clipping actor.
4139   Actor actorDepth1Clip = CreateActorWithContent16x16();
4140   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4141   Stage::GetCurrent().Add( actorDepth1Clip );
4142
4143   // Gather the call trace.
4144   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4145
4146   // Check we are writing to the color buffer.
4147   CheckColorMask( glAbstraction, true );
4148
4149   // Check the stencil buffer was enabled.
4150   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4151
4152   // Check the stencil buffer was cleared.
4153   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4154
4155   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4156   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4157   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4158   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4159
4160   END_TEST;
4161 }
4162
4163 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4164 {
4165   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4166   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4167   TestApplication application;
4168
4169   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4170   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4171   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4172   size_t startIndex = 0u;
4173
4174   // Create a clipping actor.
4175   Actor actorDepth1Clip = CreateActorWithContent16x16();
4176   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4177   Stage::GetCurrent().Add( actorDepth1Clip );
4178
4179   // Gather the call trace.
4180   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4181
4182   // Check we are writing to the color buffer.
4183   CheckColorMask( glAbstraction, true );
4184
4185   // Check the stencil buffer was enabled.
4186   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4187
4188   // Check the stencil buffer was cleared.
4189   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4190
4191   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4192   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4193   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4194   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4195
4196   // Now disable the clipping
4197   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4198
4199   // Gather the call trace.
4200   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4201
4202   // Check the stencil buffer was disabled.
4203   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4204
4205   // Ensure all values in stencil-mask are set to 1.
4206   startIndex = 0u;
4207   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4208
4209   END_TEST;
4210 }
4211
4212 int UtcDaliActorPropertyClippingNestedChildren(void)
4213 {
4214   // This test checks that a hierarchy of actors are clipped correctly by
4215   // writing to and reading from the correct bit-planes of the stencil buffer.
4216   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4217   TestApplication application;
4218   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4219   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4220   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4221
4222   // Create a clipping actor.
4223   Actor actorDepth1Clip = CreateActorWithContent16x16();
4224   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4225   Stage::GetCurrent().Add( actorDepth1Clip );
4226
4227   // Create a child actor.
4228   Actor childDepth2 = CreateActorWithContent16x16();
4229   actorDepth1Clip.Add( childDepth2 );
4230
4231   // Create another clipping actor.
4232   Actor childDepth2Clip = CreateActorWithContent16x16();
4233   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4234   childDepth2.Add( childDepth2Clip );
4235
4236   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4237   // This tests the sort algorithm.
4238   Actor childDepth3 = CreateActorWithContent16x16();
4239   childDepth2Clip.Add( childDepth3 );
4240   Actor childDepth4 = CreateActorWithContent16x16();
4241   childDepth3.Add( childDepth4 );
4242
4243   // Gather the call trace.
4244   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4245
4246   // Check we are writing to the color buffer.
4247   CheckColorMask( glAbstraction, true );
4248
4249   // Check the stencil buffer was enabled.
4250   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4251
4252   // Perform the test twice, once for 2D layer, and once for 3D.
4253   for( unsigned int i = 0u ; i < 2u; ++i )
4254   {
4255     size_t startIndex = 0u;
4256
4257     // Check the stencil buffer was cleared.
4258     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4259
4260     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4261     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4262     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4263     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4264
4265     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4266     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4267     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4268
4269     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4270     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4271     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4272     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4273
4274     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4275     // (Both must be set to pass the check).
4276     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4277     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4278
4279     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4280     if( i == 0u )
4281     {
4282       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4283       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4284     }
4285   }
4286
4287   END_TEST;
4288 }
4289
4290 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4291 {
4292   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4293   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4294   TestApplication application;
4295   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4296   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4297
4298   /* We create a small tree of actors as follows:
4299
4300                            A
4301                           / \
4302      Clipping enabled -> B   D
4303                          |   |
4304                          C   E
4305
4306      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4307   */
4308   Actor actors[5];
4309   for( int i = 0; i < 5; ++i )
4310   {
4311     BufferImage image = BufferImage::New( 16u, 16u );
4312     Actor actor = CreateRenderableActor( image );
4313
4314     // Setup dimensions and position so actor is not skipped by culling.
4315     actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4316     actor.SetSize( 16.0f, 16.0f );
4317
4318     if( i == 0 )
4319     {
4320       actor.SetParentOrigin( ParentOrigin::CENTER );
4321     }
4322     else
4323     {
4324       float b = i > 2 ? 1.0f : -1.0f;
4325       actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4326     }
4327
4328     actors[i] = actor;
4329   }
4330
4331   // Enable clipping on the actor at the top of the left branch.
4332   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4333
4334   // Build the scene graph.
4335   Stage::GetCurrent().Add( actors[0] );
4336
4337   // Left branch:
4338   actors[0].Add( actors[1] );
4339   actors[1].Add( actors[2] );
4340
4341   // Right branch:
4342   actors[0].Add( actors[3] );
4343   actors[3].Add( actors[4] );
4344
4345   // Gather the call trace.
4346   enabledDisableTrace.Reset();
4347   enabledDisableTrace.Enable( true );
4348   application.SendNotification();
4349   application.Render();
4350   enabledDisableTrace.Enable( false );
4351
4352   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4353
4354      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
4355            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4356   */
4357   size_t startIndex = 0u;
4358   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "3042", startIndex ) );
4359   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4360   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4361
4362   // Swap the clipping actor from top of left branch to top of right branch.
4363   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4364   actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4365
4366   // Gather the call trace.
4367   enabledDisableTrace.Reset();
4368   enabledDisableTrace.Enable( true );
4369   application.SendNotification();
4370   application.Render();
4371   enabledDisableTrace.Enable( false );
4372
4373   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4374   // This proves the draw order has remained the same.
4375   startIndex = 0u;
4376   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex(  "Enable",  "2960", startIndex ) );
4377   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4378
4379   END_TEST;
4380 }
4381
4382 int UtcDaliActorPropertyScissorClippingActor(void)
4383 {
4384   // This test checks that an actor is correctly setup for clipping.
4385   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4386   TestApplication application;
4387
4388   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4389   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4390   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4391
4392   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4393   const Vector2 imageSize( 16.0f, 16.0f );
4394
4395   // Create a clipping actor.
4396   Actor clippingActorA = CreateActorWithContent16x16();
4397   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4398   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4399   clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4400   clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4401   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4402   Stage::GetCurrent().Add( clippingActorA );
4403
4404   // Gather the call trace.
4405   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4406
4407   // Check we are writing to the color buffer.
4408   CheckColorMask( glAbstraction, true );
4409
4410   // Check scissor test was enabled.
4411   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4412
4413   // Check the scissor was set, and the coordinates are correct.
4414   std::stringstream compareParametersString;
4415   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4416   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 0, 0, 16, 16
4417
4418   clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4419   clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4420
4421   // Gather the call trace.
4422   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4423
4424   // Check the scissor was set, and the coordinates are correct.
4425   compareParametersString.str( std::string() );
4426   compareParametersString.clear();
4427   compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4428   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 464, 784, 16, 16
4429
4430   END_TEST;
4431 }
4432
4433 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4434 {
4435   // This test checks that an actor is correctly setup for clipping.
4436   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4437   TestApplication application;
4438
4439
4440   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4441   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4442   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4443
4444   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4445   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4446   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4447
4448   // Create a clipping actors.
4449   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4450   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4451
4452   clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4453   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4454   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4455
4456   clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4457   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4458   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4459
4460   clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4461   clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4462
4463   Stage::GetCurrent().Add( clippingActorA );
4464   Stage::GetCurrent().Add( clippingActorB );
4465
4466   // Gather the call trace.
4467   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4468
4469   // Check we are writing to the color buffer.
4470   CheckColorMask( glAbstraction, true );
4471
4472   // Check scissor test was enabled.
4473   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4474
4475   // Check the scissor was set, and the coordinates are correct.
4476   std::stringstream compareParametersString;
4477
4478   std::string clipA( "0, 500, 480, 200" );
4479   std::string clipB( "0, 380, 480, 40" );
4480
4481   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4482   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4483
4484   END_TEST;
4485 }
4486
4487 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4488 {
4489   // This test checks that an actor is correctly setup for clipping.
4490   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4491   TestApplication application;
4492
4493   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4494   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4495   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4496
4497   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4498   const Vector2 imageSize( 16.0f, 16.0f );
4499
4500   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4501
4502      A is drawn first - with scissor clipping on
4503      B is drawn second - also with scissor clipping on
4504      C is the generated clipping region, the intersection ( A ∩ B )
4505
4506            ┏━━━━━━━┓                   ┌───────┐
4507            ┃     B ┃                   │     B │
4508        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4509        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4510        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4511        │ A     │                   ┊ A     ┊
4512        └───────┘                   └┄┄┄┄┄┄┄┘
4513
4514      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4515   */
4516
4517   // Create a clipping actor.
4518   Actor clippingActorA = CreateActorWithContent16x16();
4519   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4520   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4521   clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4522   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4523   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4524   Stage::GetCurrent().Add( clippingActorA );
4525
4526   // Create a child clipping actor.
4527   Actor clippingActorB = CreateActorWithContent16x16();
4528   clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4529   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4530   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4531   clippingActorA.Add( clippingActorB );
4532
4533   // positionModifiers is an array of positions to position B around.
4534   // expect is an array of expected scissor clip coordinate results.
4535   const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ),     Vector2( -1.0f, 1.0f ),    Vector2( -1.0f, -1.0f ),   Vector2( 1.0f, -1.0f )    };
4536   const Vector4 expect[4] =            { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4537
4538   // Loop through each overlap combination.
4539   for( unsigned int test = 0u; test < 4u; ++test )
4540   {
4541     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4542     const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4543     clippingActorB.SetPosition( position.x, position.y );
4544
4545     // Gather the call trace.
4546     GenerateTrace( application, enabledDisableTrace, scissorTrace );
4547
4548     // Check we are writing to the color buffer.
4549     CheckColorMask( glAbstraction, true );
4550
4551     // Check scissor test was enabled.
4552     DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4553
4554     // Check the scissor was set, and the coordinates are correct.
4555     const Vector4& expectResults( expect[test] );
4556     std::stringstream compareParametersString;
4557     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4558     DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with the expected result
4559   }
4560
4561   END_TEST;
4562 }
4563
4564 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4565 {
4566   // This test checks that an actor is correctly setup for clipping.
4567   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4568   TestApplication application;
4569
4570   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4571   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4572   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4573
4574   /* Create a nest of 2 scissors and siblings of the parent.
4575
4576             stage
4577               |
4578         ┌─────┐─────┐
4579         A     C     D
4580         |           |
4581         B           E
4582   */
4583
4584   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4585   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4586   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4587   const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4588   const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4589   const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4590
4591   // Create a clipping actors.
4592   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4593   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4594   Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4595   Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4596   Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4597
4598   clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4599   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4600   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4601
4602   clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4603   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4604   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4605
4606   clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4607   clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4608   clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4609
4610   clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4611   clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4612   clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4613
4614   clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4615   clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4616
4617   clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4618   clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4619   clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4620   clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4621   clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4622
4623   Stage::GetCurrent().Add( clippingActorA );
4624   clippingActorA.Add( clippingActorB );
4625   Stage::GetCurrent().Add( clippingActorC );
4626   Stage::GetCurrent().Add( clippingActorD );
4627   clippingActorD.Add( clippingActorE );
4628
4629   // Gather the call trace.
4630   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4631
4632   // Check we are writing to the color buffer.
4633   CheckColorMask( glAbstraction, true );
4634
4635   // Check scissor test was enabled.
4636   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4637
4638   // Check the scissor was set, and the coordinates are correct.
4639   std::string clipA( "0, 500, 480, 200" );
4640   std::string clipB( "0, 580, 480, 40" );
4641   std::string clipC( "0, 200, 480, 200" );
4642   std::string clipD( "0, 300, 480, 200" );
4643
4644   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4645   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4646   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4647   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4648   DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 );    // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4649
4650   END_TEST;
4651 }
4652
4653 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4654 {
4655   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4656   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4657   TestApplication application;
4658
4659   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4660   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4661   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4662
4663   // Create a clipping actor.
4664   Actor actorDepth1Clip = CreateActorWithContent16x16();
4665   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4666   Stage::GetCurrent().Add( actorDepth1Clip );
4667
4668   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4669   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4670
4671   // Gather the call trace.
4672   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4673
4674   // Check we are writing to the color buffer.
4675   CheckColorMask( glAbstraction, true );
4676
4677   // Check the stencil buffer was not enabled.
4678   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4679
4680   // Check stencil functions are not called.
4681   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4682   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4683   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4684
4685   // Check that scissor clipping is overriden by the renderer properties.
4686   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4687
4688   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4689
4690   // Gather the call trace.
4691   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4692
4693   // Check the stencil buffer was not enabled.
4694   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );    // 3089 = 0xC11 (GL_SCISSOR_TEST)
4695
4696   DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4697
4698   END_TEST;
4699 }
4700
4701 int UtcDaliGetPropertyN(void)
4702 {
4703   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4704   TestApplication app;
4705
4706   Actor actor = Actor::New();
4707
4708   unsigned int propertyCount = actor.GetPropertyCount();
4709   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4710   END_TEST;
4711 }
4712
4713 int UtcDaliActorRaiseLower(void)
4714 {
4715   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4716
4717   TestApplication application;
4718
4719   Stage stage( Stage::GetCurrent() );
4720
4721   Actor actorA = Actor::New();
4722   Actor actorB = Actor::New();
4723   Actor actorC = Actor::New();
4724
4725   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4726   actorA.SetParentOrigin( ParentOrigin::CENTER );
4727
4728   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4729   actorB.SetParentOrigin( ParentOrigin::CENTER );
4730
4731   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4732   actorC.SetParentOrigin( ParentOrigin::CENTER );
4733
4734   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4735   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4736
4737   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4738   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4739
4740   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4741   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4742
4743   stage.Add( actorA );
4744   stage.Add( actorB );
4745   stage.Add( actorC );
4746
4747   ResetTouchCallbacks();
4748
4749   application.SendNotification();
4750   application.Render();
4751
4752   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4753   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4754   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4755
4756   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4757   // Only top actor will get touched.
4758   actorA.TouchSignal().Connect( TestTouchCallback );
4759   actorB.TouchSignal().Connect( TestTouchCallback2 );
4760   actorC.TouchSignal().Connect( TestTouchCallback3 );
4761
4762   // Connect ChildOrderChangedSignal
4763   bool orderChangedSignal( false );
4764   Actor orderChangedActor;
4765   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4766   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4767
4768   Dali::Integration::Point point;
4769   point.SetDeviceId( 1 );
4770   point.SetState( PointState::DOWN );
4771   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4772   Dali::Integration::TouchEvent touchEvent;
4773   touchEvent.AddPoint( point );
4774
4775   application.ProcessEvent( touchEvent );
4776
4777   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4778   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4779   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4780
4781   ResetTouchCallbacks();
4782
4783   tet_printf( "Testing Raising of Actor\n" );
4784
4785   int preActorOrder( 0 );
4786   int postActorOrder( 0 );
4787
4788   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4789   value.Get( preActorOrder );
4790
4791   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4792   actorB.Raise();
4793   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4794   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4795
4796   // Ensure sort order is calculated before next touch event
4797   application.SendNotification();
4798
4799   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4800   value.Get( postActorOrder );
4801
4802   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4803
4804   application.ProcessEvent( touchEvent );
4805
4806   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4807   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4808   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4809
4810   ResetTouchCallbacks();
4811
4812   tet_printf( "Testing Lowering of Actor\n" );
4813
4814   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4815   value.Get( preActorOrder );
4816
4817   orderChangedSignal = false;
4818
4819   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4820   actorB.Lower();
4821   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4822   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4823
4824   application.SendNotification(); // ensure sort order calculated before next touch event
4825
4826   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4827   value.Get( postActorOrder );
4828
4829   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4830
4831   application.ProcessEvent( touchEvent );
4832
4833   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4834   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4835   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4836
4837   ResetTouchCallbacks();
4838
4839   END_TEST;
4840 }
4841
4842 int UtcDaliActorRaiseToTopLowerToBottom(void)
4843 {
4844   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4845
4846   TestApplication application;
4847
4848   Stage stage( Stage::GetCurrent() );
4849
4850   Actor actorA = Actor::New();
4851   Actor actorB = Actor::New();
4852   Actor actorC = Actor::New();
4853
4854   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4855   // enables checking of which actor the uniform is assigned too
4856   Shader shaderA = CreateShader();
4857   shaderA.RegisterProperty( "uRendererColor",1.f);
4858
4859   Shader shaderB = CreateShader();
4860   shaderB.RegisterProperty( "uRendererColor", 2.f );
4861
4862   Shader shaderC = CreateShader();
4863   shaderC.RegisterProperty( "uRendererColor", 3.f );
4864
4865   Geometry geometry = CreateQuadGeometry();
4866
4867   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4868   Renderer rendererA = Renderer::New(geometry, shaderA);
4869   actorA.AddRenderer(rendererA);
4870
4871   Renderer rendererB = Renderer::New(geometry, shaderB);
4872   actorB.AddRenderer(rendererB);
4873
4874   Renderer rendererC = Renderer::New(geometry, shaderC);
4875   actorC.AddRenderer(rendererC);
4876
4877   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4878   actorA.SetParentOrigin( ParentOrigin::CENTER );
4879
4880   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4881   actorB.SetParentOrigin( ParentOrigin::CENTER );
4882
4883   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4884   actorC.SetParentOrigin( ParentOrigin::CENTER );
4885
4886   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4887   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4888
4889   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4890   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4891
4892   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4893   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4894
4895   stage.Add( actorA );
4896   stage.Add( actorB );
4897   stage.Add( actorC );
4898
4899   ResetTouchCallbacks();
4900
4901   // Connect ChildOrderChangedSignal
4902   bool orderChangedSignal( false );
4903   Actor orderChangedActor;
4904   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4905   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4906
4907   // Set up gl abstraction trace so can query the set uniform order
4908   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4909   glAbstraction.EnableSetUniformCallTrace(true);
4910   glAbstraction.ResetSetUniformCallStack();
4911
4912   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4913
4914   application.SendNotification();
4915   application.Render();
4916
4917   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4918
4919
4920   // Test order of uniforms in stack
4921   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4922   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4923   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4924
4925   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4926
4927   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4928
4929   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4930   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4931   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4932
4933   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4934   // Only top actor will get touched.
4935   actorA.TouchSignal().Connect( TestTouchCallback );
4936   actorB.TouchSignal().Connect( TestTouchCallback2 );
4937   actorC.TouchSignal().Connect( TestTouchCallback3 );
4938
4939   Dali::Integration::Point point;
4940   point.SetDeviceId( 1 );
4941   point.SetState( PointState::DOWN );
4942   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4943   Dali::Integration::TouchEvent touchEvent;
4944   touchEvent.AddPoint( point );
4945
4946   application.ProcessEvent( touchEvent );
4947
4948   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4949   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4950   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4951
4952   ResetTouchCallbacks();
4953
4954   tet_printf( "RaiseToTop ActorA\n" );
4955
4956   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4957   actorA.RaiseToTop();
4958   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4959   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
4960
4961   application.SendNotification(); // ensure sorting order is calculated before next touch event
4962
4963   application.ProcessEvent( touchEvent );
4964
4965   glAbstraction.ResetSetUniformCallStack();
4966   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4967
4968   application.SendNotification();
4969   application.Render();
4970
4971   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4972
4973   // Test order of uniforms in stack
4974   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4975   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4976   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4977
4978   tet_infoline( "Testing A above C and B at bottom\n" );
4979   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4980
4981   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4982
4983   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4984   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4985   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4986
4987   ResetTouchCallbacks();
4988
4989   tet_printf( "RaiseToTop ActorB\n" );
4990
4991   orderChangedSignal = false;
4992
4993   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4994   actorB.RaiseToTop();
4995   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4996   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4997
4998   application.SendNotification(); // Ensure sort order is calculated before next touch event
4999
5000   application.ProcessEvent( touchEvent );
5001
5002   glAbstraction.ResetSetUniformCallStack();
5003   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5004
5005   application.SendNotification();
5006   application.Render();
5007
5008   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5009
5010   // Test order of uniforms in stack
5011   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5012   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5013   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5014
5015   tet_infoline( "Testing B above A and C at bottom\n" );
5016   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5017
5018   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5019
5020   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5021   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5022   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5023
5024   ResetTouchCallbacks();
5025
5026   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5027
5028   orderChangedSignal = false;
5029
5030   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5031   actorA.LowerToBottom();
5032   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5033   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5034
5035   application.SendNotification();
5036   application.Render();
5037
5038   orderChangedSignal = false;
5039
5040   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5041   actorB.LowerToBottom();
5042   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5043   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5044
5045   application.SendNotification();
5046   application.Render();
5047
5048   application.ProcessEvent( touchEvent );
5049
5050   glAbstraction.ResetSetUniformCallStack();
5051   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5052
5053   application.SendNotification();
5054   application.Render();
5055
5056   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5057
5058   // Test order of uniforms in stack
5059   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5060   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5061   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5062
5063   tet_infoline( "Testing C above A and B at bottom\n" );
5064   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5065
5066   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5067
5068   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5069   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5070   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5071
5072   ResetTouchCallbacks();
5073
5074   END_TEST;
5075 }
5076
5077 int UtcDaliActorRaiseAbove(void)
5078 {
5079   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5080
5081   TestApplication application;
5082
5083   Stage stage( Stage::GetCurrent() );
5084
5085   Actor actorA = Actor::New();
5086   Actor actorB = Actor::New();
5087   Actor actorC = Actor::New();
5088
5089   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5090   actorA.SetParentOrigin( ParentOrigin::CENTER );
5091
5092   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5093   actorB.SetParentOrigin( ParentOrigin::CENTER );
5094
5095   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5096   actorC.SetParentOrigin( ParentOrigin::CENTER );
5097
5098   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5099   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5100
5101   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5102   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5103
5104   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5105   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5106
5107   stage.Add( actorA );
5108   stage.Add( actorB );
5109   stage.Add( actorC );
5110
5111   ResetTouchCallbacks();
5112
5113   application.SendNotification();
5114   application.Render();
5115
5116   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5117   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5118   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5119
5120   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5121   // Only top actor will get touched.
5122   actorA.TouchSignal().Connect( TestTouchCallback );
5123   actorB.TouchSignal().Connect( TestTouchCallback2 );
5124   actorC.TouchSignal().Connect( TestTouchCallback3 );
5125
5126   bool orderChangedSignal( false );
5127   Actor orderChangedActor;
5128   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5129   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5130
5131   Dali::Integration::Point point;
5132   point.SetDeviceId( 1 );
5133   point.SetState( PointState::DOWN );
5134   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5135   Dali::Integration::TouchEvent touchEvent;
5136   touchEvent.AddPoint( point );
5137
5138   application.ProcessEvent( touchEvent );
5139
5140   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5141   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5142   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5143
5144   ResetTouchCallbacks();
5145
5146   tet_printf( "Raise actor B Above Actor C\n" );
5147
5148   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5149   actorB.RaiseAbove( actorC );
5150   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5151   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5152
5153   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5154   application.SendNotification();
5155   application.ProcessEvent( touchEvent );
5156
5157   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5158   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5159   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5160
5161   ResetTouchCallbacks();
5162
5163   tet_printf( "Raise actor A Above Actor B\n" );
5164
5165   orderChangedSignal = false;
5166
5167   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5168   actorA.RaiseAbove( actorB );
5169   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5170   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5171
5172   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5173   application.SendNotification();
5174
5175   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5176
5177   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5178   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5179   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5180
5181   ResetTouchCallbacks();
5182
5183   END_TEST;
5184 }
5185
5186 int UtcDaliActorLowerBelow(void)
5187 {
5188   tet_infoline( "UtcDaliActor LowerBelow test \n" );
5189
5190   TestApplication application;
5191
5192   Stage stage( Stage::GetCurrent() );
5193
5194   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5195   // enables checking of which actor the uniform is assigned too
5196   Shader shaderA = CreateShader();
5197   shaderA.RegisterProperty( "uRendererColor",1.f);
5198
5199   Shader shaderB = CreateShader();
5200   shaderB.RegisterProperty( "uRendererColor", 2.f );
5201
5202   Shader shaderC = CreateShader();
5203   shaderC.RegisterProperty( "uRendererColor", 3.f );
5204
5205   Actor actorA = Actor::New();
5206   Actor actorB = Actor::New();
5207   Actor actorC = Actor::New();
5208
5209   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5210   Geometry geometry = CreateQuadGeometry();
5211
5212   Renderer rendererA = Renderer::New(geometry, shaderA);
5213   actorA.AddRenderer(rendererA);
5214
5215   Renderer rendererB = Renderer::New(geometry, shaderB);
5216   actorB.AddRenderer(rendererB);
5217
5218   Renderer rendererC = Renderer::New(geometry, shaderC);
5219   actorC.AddRenderer(rendererC);
5220
5221   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5222   actorA.SetParentOrigin( ParentOrigin::CENTER );
5223
5224   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5225   actorB.SetParentOrigin( ParentOrigin::CENTER );
5226
5227   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5228   actorC.SetParentOrigin( ParentOrigin::CENTER );
5229
5230   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5231   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5232
5233   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5234   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5235
5236   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5237   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5238
5239   Actor container = Actor::New();
5240   container.SetParentOrigin( ParentOrigin::CENTER );
5241   container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5242   stage.Add( container );
5243
5244   container.Add( actorA );
5245   container.Add( actorB );
5246   container.Add( actorC );
5247
5248   ResetTouchCallbacks();
5249
5250   // Connect ChildOrderChangedSignal
5251   bool orderChangedSignal( false );
5252   Actor orderChangedActor;
5253   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5254   DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5255
5256   // Set up gl abstraction trace so can query the set uniform order
5257   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5258   glAbstraction.EnableSetUniformCallTrace(true);
5259   glAbstraction.ResetSetUniformCallStack();
5260   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5261
5262   glAbstraction.ResetSetUniformCallStack();
5263
5264   application.SendNotification();
5265   application.Render();
5266
5267   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5268
5269   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5270
5271   // Test order of uniforms in stack
5272   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5273   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5274   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5275
5276   tet_infoline( "Testing C above B and A at bottom\n" );
5277   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
5278
5279   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5280
5281   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5282   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5283   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5284
5285   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5286   // Only top actor will get touched.
5287   actorA.TouchSignal().Connect( TestTouchCallback );
5288   actorB.TouchSignal().Connect( TestTouchCallback2 );
5289   actorC.TouchSignal().Connect( TestTouchCallback3 );
5290
5291   Dali::Integration::Point point;
5292   point.SetDeviceId( 1 );
5293   point.SetState( PointState::DOWN );
5294   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5295   Dali::Integration::TouchEvent touchEvent;
5296   touchEvent.AddPoint( point );
5297
5298   tet_infoline( "UtcDaliActor Test Set up completed \n" );
5299
5300   application.ProcessEvent( touchEvent );
5301
5302   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5303   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5304   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5305
5306   ResetTouchCallbacks();
5307
5308   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" );
5309
5310   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5311   actorC.LowerBelow( actorB );
5312   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5313   DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5314
5315   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5316   application.SendNotification();
5317   application.Render();
5318
5319   application.ProcessEvent( touchEvent ); // touch event
5320
5321   glAbstraction.ResetSetUniformCallStack();
5322   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5323
5324   application.SendNotification();
5325   application.Render();
5326
5327   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5328
5329   // Test order of uniforms in stack
5330   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5331   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5332   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5333
5334   tet_infoline( "Testing render order is A, C, B" );
5335   DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5336   DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5337
5338   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5339   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5340   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5341
5342   ResetTouchCallbacks();
5343
5344   tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5345
5346   orderChangedSignal = false;
5347
5348   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5349   actorC.LowerBelow( actorA );
5350   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5351   DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5352
5353   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5354   application.SendNotification();
5355   application.Render();
5356
5357   application.ProcessEvent( touchEvent );
5358
5359   glAbstraction.ResetSetUniformCallStack();
5360   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5361
5362   application.Render();
5363   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5364
5365   // Test order of uniforms in stack
5366   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5367   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5368   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5369
5370   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5371   DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5372
5373   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5374   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5375   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5376
5377   ResetTouchCallbacks();
5378
5379   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5380
5381   orderChangedSignal = false;
5382
5383   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5384   actorB.LowerBelow( actorC );
5385   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5386   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5387
5388   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5389   application.SendNotification();
5390   application.Render();
5391
5392   application.ProcessEvent( touchEvent );
5393
5394   glAbstraction.ResetSetUniformCallStack();
5395   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5396
5397   application.Render();
5398   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5399
5400   // Test order of uniforms in stack
5401   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5402   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5403   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5404
5405   DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5406   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5407
5408   END_TEST;
5409 }
5410
5411
5412 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5413 {
5414   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5415
5416   TestApplication application;
5417
5418   Stage stage( Stage::GetCurrent() );
5419
5420   Actor parentA = Actor::New();
5421   Actor parentB = Actor::New();
5422   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5423   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5424   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5425   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5426
5427   parentA.SetAnchorPoint( AnchorPoint::CENTER );
5428   parentA.SetParentOrigin( ParentOrigin::CENTER );
5429
5430   parentB.SetAnchorPoint( AnchorPoint::CENTER );
5431   parentB.SetParentOrigin( ParentOrigin::CENTER );
5432
5433   stage.Add( parentA );
5434   stage.Add( parentB );
5435
5436   Actor actorA = Actor::New();
5437   Actor actorB = Actor::New();
5438   Actor actorC = Actor::New();
5439
5440   parentA.Add( actorA );
5441   parentA.Add( actorB );
5442
5443   tet_printf( "Actor C added to different parent from A and B \n" );
5444   parentB.Add( actorC );
5445
5446   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5447   actorA.SetParentOrigin( ParentOrigin::CENTER );
5448
5449   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5450   actorB.SetParentOrigin( ParentOrigin::CENTER );
5451
5452   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5453   actorC.SetParentOrigin( ParentOrigin::CENTER );
5454
5455   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5456   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5457
5458   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5459   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5460
5461   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5462   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5463
5464   ResetTouchCallbacks();
5465
5466   // Connect ChildOrderChangedSignal
5467   bool orderChangedSignal( false );
5468   Actor orderChangedActor;
5469   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5470   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5471
5472   application.SendNotification();
5473   application.Render();
5474
5475   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5477   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5478
5479   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5480   // Only top actor will get touched.
5481   actorA.TouchSignal().Connect( TestTouchCallback );
5482   actorB.TouchSignal().Connect( TestTouchCallback2 );
5483   actorC.TouchSignal().Connect( TestTouchCallback3 );
5484
5485   Dali::Integration::Point point;
5486   point.SetDeviceId( 1 );
5487   point.SetState( PointState::DOWN );
5488   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5489   Dali::Integration::TouchEvent touchEvent;
5490   touchEvent.AddPoint( point );
5491
5492   application.ProcessEvent( touchEvent );
5493
5494   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5495   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5496   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5497
5498   ResetTouchCallbacks();
5499
5500   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5501
5502   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5503   actorA.RaiseAbove( actorC );
5504   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5505
5506   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5507   application.SendNotification();
5508
5509   application.ProcessEvent( touchEvent ); // touch event
5510
5511   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5512   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5513   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5514
5515   ResetTouchCallbacks();
5516
5517   END_TEST;
5518 }
5519
5520 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5521 {
5522   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5523
5524   TestApplication application;
5525
5526   Stage stage( Stage::GetCurrent() );
5527
5528   Actor actorA = Actor::New();
5529   Actor actorB = Actor::New();
5530   Actor actorC = Actor::New();
5531
5532   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5533   actorA.SetParentOrigin( ParentOrigin::CENTER );
5534
5535   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5536   actorB.SetParentOrigin( ParentOrigin::CENTER );
5537
5538   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5539   actorC.SetParentOrigin( ParentOrigin::CENTER );
5540
5541   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5542   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5543
5544   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5545   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5546
5547   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5548   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5549
5550   ResetTouchCallbacks();
5551
5552   // Connect ChildOrderChangedSignal
5553   bool orderChangedSignal( false );
5554   Actor orderChangedActor;
5555   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5556   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5557
5558   application.SendNotification();
5559   application.Render();
5560
5561   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5562   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5563   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5564
5565   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5566   // Only top actor will get touched.
5567   actorA.TouchSignal().Connect( TestTouchCallback );
5568   actorB.TouchSignal().Connect( TestTouchCallback2 );
5569   actorC.TouchSignal().Connect( TestTouchCallback3 );
5570
5571   Dali::Integration::Point point;
5572   point.SetDeviceId( 1 );
5573   point.SetState( PointState::DOWN );
5574   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5575   Dali::Integration::TouchEvent touchEvent;
5576   touchEvent.AddPoint( point );
5577
5578   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5579
5580   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5581   actorA.RaiseAbove( actorC );
5582   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5583
5584   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5585   application.SendNotification();
5586
5587   application.ProcessEvent( touchEvent );
5588
5589   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5590
5591   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5592   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5593   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5594
5595   ResetTouchCallbacks();
5596
5597   orderChangedSignal = false;
5598
5599   stage.Add ( actorB );
5600   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5601
5602   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5603   actorA.LowerBelow( actorC );
5604   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5605
5606   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5607   application.SendNotification();
5608   application.Render();
5609
5610   application.ProcessEvent( touchEvent );
5611
5612   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5613   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5614   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5615   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5616
5617   ResetTouchCallbacks();
5618
5619   orderChangedSignal = false;
5620
5621   tet_printf( "Adding Actor A to stage, will be on top\n" );
5622
5623   stage.Add ( actorA );
5624   application.SendNotification();
5625   application.Render();
5626
5627   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5628
5629   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5630   actorB.RaiseAbove( actorC );
5631   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5632
5633   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5634   application.SendNotification();
5635
5636   application.ProcessEvent( touchEvent );
5637
5638   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5639   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5640   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5641   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5642
5643   ResetTouchCallbacks();
5644
5645   orderChangedSignal = false;
5646
5647   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5648
5649   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5650   actorA.LowerBelow( actorC );
5651   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5652
5653   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5654   application.SendNotification();
5655
5656   application.ProcessEvent( touchEvent );
5657
5658   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5659   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5660   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5661   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5662
5663   ResetTouchCallbacks();
5664
5665   orderChangedSignal = false;
5666
5667   stage.Add ( actorC );
5668
5669   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5670   actorA.RaiseAbove( actorC );
5671   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5672   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5673
5674   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5675   application.SendNotification();
5676   application.Render();
5677
5678   application.ProcessEvent( touchEvent );
5679
5680   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5681   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5682   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5683   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5684
5685   END_TEST;
5686 }
5687
5688 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5689 {
5690   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5691
5692   TestApplication application;
5693
5694   Stage stage( Stage::GetCurrent() );
5695
5696   Actor actorA = Actor::New();
5697   Actor actorB = Actor::New();
5698   Actor actorC = Actor::New();
5699
5700   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5701   actorA.SetParentOrigin( ParentOrigin::CENTER );
5702
5703   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5704   actorB.SetParentOrigin( ParentOrigin::CENTER );
5705
5706   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5707   actorC.SetParentOrigin( ParentOrigin::CENTER );
5708
5709   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5710   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5711
5712   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5713   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5714
5715   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5716   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5717
5718   ResetTouchCallbacks();
5719
5720   // Connect ChildOrderChangedSignal
5721   bool orderChangedSignal( false );
5722   Actor orderChangedActor;
5723   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5724   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5725
5726   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5727   // Only top actor will get touched.
5728   actorA.TouchSignal().Connect( TestTouchCallback );
5729   actorB.TouchSignal().Connect( TestTouchCallback2 );
5730   actorC.TouchSignal().Connect( TestTouchCallback3 );
5731
5732   Dali::Integration::Point point;
5733   point.SetDeviceId( 1 );
5734   point.SetState( PointState::DOWN );
5735   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5736   Dali::Integration::TouchEvent touchEvent;
5737   touchEvent.AddPoint( point );
5738
5739   stage.Add ( actorA );
5740   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5741
5742   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5743   actorB.Raise();
5744   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5745
5746   application.SendNotification();
5747   application.Render();
5748
5749   application.ProcessEvent( touchEvent );
5750
5751   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5752
5753   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5754   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5755   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5756
5757   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5758   ResetTouchCallbacks();
5759
5760   orderChangedSignal = false;
5761
5762   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5763   actorC.Lower();
5764   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5765
5766   // Sort actor tree before next touch event
5767   application.SendNotification();
5768   application.Render();
5769
5770   application.ProcessEvent( touchEvent );
5771
5772   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5773
5774   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5775   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5776   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5777   ResetTouchCallbacks();
5778
5779   orderChangedSignal = false;
5780
5781   tet_printf( "Lower actor C below B but C not parented\n" );
5782
5783   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5784   actorB.Lower();
5785   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5786
5787   // Sort actor tree before next touch event
5788   application.SendNotification();
5789   application.Render();
5790
5791   application.ProcessEvent( touchEvent );
5792
5793   tet_printf( "Not parented so Lower should show no effect\n" );
5794
5795   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5796   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5797   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5798   ResetTouchCallbacks();
5799
5800   orderChangedSignal = false;
5801
5802   tet_printf( "Raise actor B to top\n" );
5803
5804   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5805   actorB.RaiseToTop();
5806   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5807
5808   // Sort actor tree before next touch event
5809   application.SendNotification();
5810   application.Render();
5811
5812   application.ProcessEvent( touchEvent );
5813
5814   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5815
5816   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5817   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5818   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5819   ResetTouchCallbacks();
5820
5821   orderChangedSignal = false;
5822
5823   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5824
5825   stage.Add ( actorB );
5826
5827   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5828
5829   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5830   actorC.LowerToBottom();
5831   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5832
5833   application.SendNotification();
5834   application.Render();
5835
5836   application.ProcessEvent( touchEvent );
5837
5838   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5839
5840   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5841   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5842   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5843   ResetTouchCallbacks();
5844
5845   END_TEST;
5846 }
5847
5848
5849 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5850 {
5851   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5852
5853   TestApplication application;
5854
5855   Stage stage( Stage::GetCurrent() );
5856
5857   Actor actorA = Actor::New();
5858   Actor actorB = Actor::New();
5859   Actor actorC = Actor::New();
5860
5861   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5862   actorA.SetParentOrigin( ParentOrigin::CENTER );
5863
5864   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5865   actorB.SetParentOrigin( ParentOrigin::CENTER );
5866
5867   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5868   actorC.SetParentOrigin( ParentOrigin::CENTER );
5869
5870   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5871   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5872
5873   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5874   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5875
5876   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5877   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5878
5879   stage.Add( actorA );
5880   stage.Add( actorB );
5881   stage.Add( actorC );
5882
5883   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5884   // Only top actor will get touched.
5885   actorA.TouchSignal().Connect( TestTouchCallback );
5886   actorB.TouchSignal().Connect( TestTouchCallback2 );
5887   actorC.TouchSignal().Connect( TestTouchCallback3 );
5888
5889   ResetTouchCallbacks();
5890
5891   // Connect ChildOrderChangedSignal
5892   bool orderChangedSignal( false );
5893   Actor orderChangedActor;
5894   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5895   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5896
5897   application.SendNotification();
5898   application.Render();
5899
5900   Dali::Integration::Point point;
5901   point.SetDeviceId( 1 );
5902   point.SetState( PointState::DOWN );
5903   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5904   Dali::Integration::TouchEvent touchEvent;
5905   touchEvent.AddPoint( point );
5906
5907   application.ProcessEvent( touchEvent );
5908
5909   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5910   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5911   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5912
5913   ResetTouchCallbacks();
5914
5915   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5916
5917   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5918   actorA.RaiseAbove( actorA );
5919   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5920   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5921
5922   application.SendNotification();
5923   application.Render();
5924
5925   application.ProcessEvent( touchEvent );
5926
5927   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5928
5929   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5930   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5931   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5932
5933   ResetTouchCallbacks();
5934
5935   orderChangedSignal = false;
5936
5937   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5938   actorA.RaiseAbove( actorC );
5939   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5940   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5941
5942   application.SendNotification();
5943   application.Render();
5944
5945   application.ProcessEvent( touchEvent );
5946
5947   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5948   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5949   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5950   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5951
5952   END_TEST;
5953 }
5954
5955 int UtcDaliActorGetScreenPosition(void)
5956 {
5957   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5958
5959   TestApplication application;
5960
5961   Stage stage( Stage::GetCurrent() );
5962
5963   Actor actorA = Actor::New();
5964   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5965
5966   Vector2 size2( 10.0f, 20.0f );
5967   actorA.SetSize( size2 );
5968
5969   actorA.SetPosition( 0.f, 0.f );
5970
5971   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5972
5973   stage.Add( actorA );
5974
5975   application.SendNotification();
5976   application.Render();
5977
5978   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5979   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5980
5981   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
5982   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5983
5984   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5985   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5986
5987   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5988
5989   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5990
5991   application.SendNotification();
5992   application.Render();
5993
5994   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5995   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5996
5997   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
5998   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5999
6000   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6001   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6002
6003   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6004
6005   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6006
6007   application.SendNotification();
6008   application.Render();
6009
6010   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6011   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6012
6013   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
6014   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
6015
6016   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6017   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6018
6019   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6020
6021   actorA.SetPosition( 30.0, 0.0 );
6022
6023   application.SendNotification();
6024   application.Render();
6025
6026   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6027   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6028
6029   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
6030   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
6031
6032   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6033   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6034
6035   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6036
6037   actorA.SetPosition( 30.0, 420.0 );
6038
6039   application.SendNotification();
6040   application.Render();
6041
6042   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6043   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6044
6045   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6046   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
6047
6048   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
6049   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6050
6051   tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6052
6053   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6054   actorA.SetPosition( 30.0, 30.0 );
6055
6056   Actor actorB = Actor::New();
6057   actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6058   actorB.SetSize( size2 );
6059   actorB.SetPosition( 10.f, 10.f );
6060   actorA.Add( actorB );
6061
6062   actorA.SetScale( 2.0f );
6063
6064   application.SendNotification();
6065   application.Render();
6066
6067   actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6068
6069   DALI_TEST_EQUALS( actorScreenPosition.x,  50lu , TEST_LOCATION );
6070   DALI_TEST_EQUALS( actorScreenPosition.y,  50lu , TEST_LOCATION );
6071
6072   END_TEST;
6073 }
6074
6075 int UtcDaliActorGetScreenPositionAfterScaling(void)
6076 {
6077   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6078
6079   TestApplication application;
6080
6081   Stage stage( Stage::GetCurrent() );
6082
6083   Actor actorA = Actor::New();
6084   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6085
6086   Vector2 size2( 10.0f, 20.0f );
6087   actorA.SetSize( size2 );
6088   actorA.SetScale( 1.5f );
6089   actorA.SetPosition( 0.f, 0.f );
6090
6091   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6092
6093   stage.Add( actorA );
6094
6095   application.SendNotification();
6096   application.Render();
6097
6098   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6099   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6100
6101   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6102   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6103
6104   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6105   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6106
6107   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6108
6109   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6110
6111   application.SendNotification();
6112   application.Render();
6113
6114   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6115   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6116
6117   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6118   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6119
6120   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
6121   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6122
6123   END_TEST;
6124 }
6125
6126 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6127 {
6128   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6129
6130   TestApplication application;
6131
6132   Stage stage( Stage::GetCurrent() );
6133
6134   Actor actorA = Actor::New();
6135   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6136   actorA.SetParentOrigin( ParentOrigin::CENTER );
6137   Vector2 size2( 10.0f, 20.0f );
6138   actorA.SetSize( size2 );
6139   actorA.SetPosition( 0.f, 0.f );
6140
6141   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6142
6143   stage.Add( actorA );
6144
6145   application.SendNotification();
6146   application.Render();
6147
6148   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6149   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6150
6151   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6152   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6153
6154   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
6155   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
6156
6157   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6158
6159   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6160   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6161
6162   application.SendNotification();
6163   application.Render();
6164
6165   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6166   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6167
6168   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6169   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6170
6171   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6172   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6173
6174   END_TEST;
6175   END_TEST;
6176 }
6177
6178 int UtcDaliActorGetScreenPositionWithChildActors(void)
6179 {
6180   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6181
6182   TestApplication application;
6183
6184   Stage stage( Stage::GetCurrent() );
6185
6186   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6187
6188   Actor actorA = Actor::New();
6189   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6190   actorA.SetParentOrigin( ParentOrigin::CENTER );
6191   Vector2 size1( 10.0f, 20.0f );
6192   actorA.SetSize( size1 );
6193   actorA.SetPosition( 0.f, 0.f );
6194
6195   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6196
6197   Actor parentActorA = Actor::New();
6198   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6199   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6200   Vector2 size2( 30.0f, 60.0f );
6201   parentActorA.SetSize( size2 );
6202   parentActorA.SetPosition( 0.f, 0.f );
6203
6204   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6205
6206   stage.Add( parentActorA );
6207   parentActorA.Add ( actorA );
6208
6209   application.SendNotification();
6210   application.Render();
6211
6212   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6213   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6214
6215   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6216   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6217
6218   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
6219   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
6220
6221   tet_infoline( "Test 2\n");
6222
6223   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6224
6225   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6226   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6227
6228   application.SendNotification();
6229   application.Render();
6230
6231   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6232   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6233
6234   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6235   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6236
6237   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
6238   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
6239
6240   END_TEST;
6241 }
6242
6243 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6244 {
6245   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6246
6247   TestApplication application;
6248
6249   Stage stage( Stage::GetCurrent() );
6250
6251   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6252
6253   Actor actorA = Actor::New();
6254   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6255   actorA.SetParentOrigin( ParentOrigin::CENTER );
6256   Vector2 size1( 10.0f, 20.0f );
6257   actorA.SetSize( size1 );
6258   actorA.SetPosition( 0.f, 0.f );
6259
6260   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6261
6262   Actor parentActorA = Actor::New();
6263   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6264   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6265   Vector2 size2( 30.0f, 60.0f );
6266   parentActorA.SetSize( size2 );
6267   parentActorA.SetPosition( 0.f, 0.f );
6268
6269   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6270
6271   Actor grandParentActorA = Actor::New();
6272   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6273   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6274   Vector2 size3( 60.0f, 120.0f );
6275   grandParentActorA.SetSize( size3 );
6276   grandParentActorA.SetPosition( 0.f, 0.f );
6277
6278   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6279
6280   stage.Add( grandParentActorA );
6281   grandParentActorA.Add ( parentActorA );
6282
6283   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6284
6285   parentActorA.Add ( actorA );
6286
6287   application.SendNotification();
6288   application.Render();
6289
6290   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6291   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6292
6293   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6294   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6295
6296   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
6297   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
6298
6299   END_TEST;
6300 }
6301
6302 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6303 {
6304   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6305
6306   TestApplication application;
6307
6308   Stage stage( Stage::GetCurrent() );
6309
6310   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6311
6312   Actor actorA = Actor::New();
6313   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6314   actorA.SetParentOrigin( ParentOrigin::CENTER );
6315   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6316   actorA.SetSize( 10.0f, 20.0f );
6317   stage.Add( actorA );
6318
6319   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6320
6321   Actor actorB = Actor::New();
6322   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6323   actorB.SetParentOrigin( ParentOrigin::CENTER );
6324   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6325   Vector2 actorBSize( 30.0f, 60.0f );
6326   actorB.SetSize( actorBSize );
6327   stage.Add( actorB );
6328
6329   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6330
6331   Actor actorC = Actor::New();
6332   actorC.SetAnchorPoint( AnchorPoint::CENTER );
6333   actorC.SetParentOrigin( ParentOrigin::CENTER );
6334   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6335   Vector2 actorCSize( 60.0f, 120.0f );
6336   actorC.SetSize( actorCSize );
6337   stage.Add( actorC );
6338
6339   application.SendNotification();
6340   application.Render();
6341
6342   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6343
6344   Vector2 center( stage.GetSize() * 0.5f );
6345
6346   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6347   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6348   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6349
6350   tet_infoline( "Add scale to all actors" );
6351
6352   actorA.SetScale( 2.0f );
6353   actorB.SetScale( 2.0f );
6354   actorC.SetScale( 2.0f );
6355
6356   application.SendNotification();
6357   application.Render();
6358
6359   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6360   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6361   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6362
6363   END_TEST;
6364 }
6365
6366 int utcDaliActorPositionUsesAnchorPoint(void)
6367 {
6368   TestApplication application;
6369   tet_infoline( "Check default behaviour\n" );
6370
6371   Actor actor = Actor::New();
6372   actor.SetParentOrigin( ParentOrigin::CENTER );
6373   actor.SetAnchorPoint( AnchorPoint::CENTER );
6374   actor.SetSize( 100.0f, 100.0f );
6375   Stage::GetCurrent().Add( actor );
6376
6377   application.SendNotification();
6378   application.Render();
6379
6380   tet_infoline( "Check that the world position is in the center\n" );
6381   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6382
6383   tet_infoline( "Set the position uses anchor point property to false\n" );
6384   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6385
6386   application.SendNotification();
6387   application.Render();
6388
6389   tet_infoline( "Check that the world position has changed appropriately\n" );
6390   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6391
6392   END_TEST;
6393 }
6394
6395 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6396 {
6397   TestApplication application;
6398   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6399
6400   Actor actor = Actor::New();
6401   actor.SetParentOrigin( ParentOrigin::CENTER );
6402   actor.SetAnchorPoint( AnchorPoint::CENTER );
6403   actor.SetSize( 100.0f, 100.0f );
6404   actor.SetScale( 2.0f );
6405   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6406   Stage::GetCurrent().Add( actor );
6407
6408   application.SendNotification();
6409   application.Render();
6410
6411   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6412   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6413
6414   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6415   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6416   application.SendNotification();
6417   application.Render();
6418   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6419
6420   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6421   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6422   application.SendNotification();
6423   application.Render();
6424   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6425
6426   END_TEST;
6427 }
6428
6429 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6430 {
6431   TestApplication application;
6432   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6433
6434   Actor actor = Actor::New();
6435   actor.SetParentOrigin( ParentOrigin::CENTER );
6436   actor.SetAnchorPoint( AnchorPoint::CENTER );
6437   actor.SetSize( 100.0f, 100.0f );
6438   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6439   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6440   Stage::GetCurrent().Add( actor );
6441
6442   application.SendNotification();
6443   application.Render();
6444
6445   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6446   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6447
6448   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6449   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6450   application.SendNotification();
6451   application.Render();
6452   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6453
6454   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6455   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6456   application.SendNotification();
6457   application.Render();
6458   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6459
6460   END_TEST;
6461 }
6462
6463 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6464 {
6465   TestApplication application;
6466   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6467
6468   Actor actor = Actor::New();
6469   actor.SetParentOrigin( ParentOrigin::CENTER );
6470   actor.SetAnchorPoint( AnchorPoint::CENTER );
6471   actor.SetSize( 100.0f, 100.0f );
6472   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6473   actor.SetScale( 2.0f );
6474   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6475   Stage::GetCurrent().Add( actor );
6476
6477   application.SendNotification();
6478   application.Render();
6479
6480   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6481   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6482
6483   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6484   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6485   application.SendNotification();
6486   application.Render();
6487   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6488
6489   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6490   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6491   application.SendNotification();
6492   application.Render();
6493   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6494
6495   END_TEST;
6496 }
6497
6498 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6499 {
6500   TestApplication application;
6501   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6502
6503   Actor parent = Actor::New();
6504
6505   Stage::GetCurrent().Add( parent );
6506   Vector2 stageSize( Stage::GetCurrent().GetSize() );
6507
6508   Actor actor = Actor::New();
6509   actor.SetParentOrigin( ParentOrigin::CENTER );
6510   actor.SetAnchorPoint( AnchorPoint::CENTER );
6511   actor.SetSize( 100.0f, 100.0f );
6512   actor.SetInheritScale( false );
6513   actor.SetInheritOrientation( false );
6514   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6515   parent.Add( actor );
6516
6517   application.SendNotification();
6518   application.Render();
6519
6520   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6521
6522   tet_infoline( "Check the world position is in the right place\n" );
6523   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6524
6525   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6526   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6527   application.SendNotification();
6528   application.Render();
6529   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6530
6531   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6532   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6533   application.SendNotification();
6534   application.Render();
6535   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6536
6537   END_TEST;
6538 }
6539
6540 int utcDaliActorVisibilityChangeSignalSelf(void)
6541 {
6542   TestApplication application;
6543   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6544
6545   Actor actor = Actor::New();
6546
6547   VisibilityChangedFunctorData data;
6548   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6549
6550   actor.SetVisible( false );
6551
6552   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6553
6554   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6555   data.Reset();
6556
6557   actor.SetVisible( false );
6558   data.Check( false /* not called */, TEST_LOCATION );
6559
6560   tet_infoline( "Change the visibility using properties, ensure called" );
6561   data.Reset();
6562
6563   actor.SetProperty( Actor::Property::VISIBLE, true );
6564   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6565
6566   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6567   data.Reset();
6568
6569   actor.SetProperty( Actor::Property::VISIBLE, true );
6570   data.Check( false /* not called */, TEST_LOCATION );
6571
6572   END_TEST;
6573 }
6574
6575 int utcDaliActorVisibilityChangeSignalChildren(void)
6576 {
6577   TestApplication application;
6578   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6579
6580   Actor parent = Actor::New();
6581   Actor child = Actor::New();
6582   parent.Add( child );
6583
6584   Actor grandChild = Actor::New();
6585   child.Add( grandChild );
6586
6587   VisibilityChangedFunctorData parentData;
6588   VisibilityChangedFunctorData childData;
6589   VisibilityChangedFunctorData grandChildData;
6590
6591   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6592   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6593   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6594
6595   parent.SetVisible( false );
6596   parentData.Check( false /* not called */, TEST_LOCATION );
6597   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6598   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6599
6600   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6601   parentData.Reset();
6602   childData.Reset();
6603   grandChildData.Reset();
6604
6605   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6606
6607   parent.SetVisible( true );
6608   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6609   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6610   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6611
6612   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6613   parentData.Reset();
6614   childData.Reset();
6615   grandChildData.Reset();
6616
6617   parent.SetVisible( true );
6618   parentData.Check( false /* not called */, TEST_LOCATION );
6619   childData.Check( false /* not called */, TEST_LOCATION );
6620   grandChildData.Check( false /* not called */, TEST_LOCATION );
6621
6622   END_TEST;
6623 }
6624
6625 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6626 {
6627   TestApplication application;
6628   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6629
6630   Actor actor = Actor::New();
6631   Stage::GetCurrent().Add( actor );
6632
6633   application.SendNotification();
6634   application.Render();
6635
6636   VisibilityChangedFunctorData data;
6637   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6638
6639   Animation animation = Animation::New( 1.0f );
6640   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6641
6642   data.Check( false, TEST_LOCATION );
6643   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6644   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6645
6646   tet_infoline( "Play the animation and check the property value" );
6647   animation.Play();
6648
6649   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6650   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6651
6652   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6653   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6654
6655   application.SendNotification();
6656   application.Render( 1100 ); // After the animation
6657
6658   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6659
6660   END_TEST;
6661 }
6662
6663
6664 int utcDaliActorVisibilityChangeSignalByName(void)
6665 {
6666   TestApplication application;
6667   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6668
6669   Actor actor = Actor::New();
6670
6671   bool signalCalled=false;
6672   actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6673   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6674   actor.SetVisible( false );
6675   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6676
6677   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6678   signalCalled = false;
6679   actor.SetVisible( false );
6680   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6681
6682   tet_infoline( "Change the visibility using properties, ensure called" );
6683   actor.SetProperty( Actor::Property::VISIBLE, true );
6684   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6685
6686   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6687   signalCalled = false;
6688
6689   actor.SetProperty( Actor::Property::VISIBLE, true );
6690   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6691
6692   END_TEST;
6693 }
6694
6695
6696 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6697 {
6698   gLayoutDirectionType = type;
6699 }
6700
6701 int UtcDaliActorLayoutDirectionProperty(void)
6702 {
6703   TestApplication application;
6704   tet_infoline( "Check layout direction property" );
6705
6706   Actor actor0 = Actor::New();
6707   DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6708   Stage::GetCurrent().Add( actor0 );
6709
6710   application.SendNotification();
6711   application.Render();
6712
6713   Actor actor1 = Actor::New();
6714   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6715   Actor actor2 = Actor::New();
6716   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6717   Actor actor3 = Actor::New();
6718   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6719   Actor actor4 = Actor::New();
6720   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6721   Actor actor5 = Actor::New();
6722   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6723   Actor actor6 = Actor::New();
6724   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6725   Actor actor7 = Actor::New();
6726   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6727   Actor actor8 = Actor::New();
6728   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6729   Actor actor9 = Actor::New();
6730   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6731
6732   actor1.Add( actor2 );
6733   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6734   actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6735
6736   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6737   actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6738   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6739
6740   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6741   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6742   DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6743
6744   actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6745   actor0.Add( actor1 );
6746   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6747   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6748
6749   Stage::GetCurrent().Add( actor3 );
6750   actor3.Add( actor4 );
6751   actor4.Add( actor5 );
6752   actor5.Add( actor6 );
6753   actor5.Add( actor7 );
6754   actor7.Add( actor8 );
6755   actor8.Add( actor9 );
6756   actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6757   actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6758
6759   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6760   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6761   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6762
6763   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6764
6765   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6766   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6767   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6768   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6769   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6770   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6771   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6772
6773   actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6774   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6775   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6776
6777   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6778   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6779   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6780   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6781
6782   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6783   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6784   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6785
6786   END_TEST;
6787 }
6788
6789
6790 struct LayoutDirectionFunctor
6791 {
6792   LayoutDirectionFunctor(bool& signalCalled)
6793   : mSignalCalled( signalCalled )
6794   {
6795   }
6796
6797   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6798   : mSignalCalled( rhs.mSignalCalled )
6799   {
6800   }
6801
6802   void operator()()
6803   {
6804     mSignalCalled = true;
6805   }
6806
6807   bool& mSignalCalled;
6808 };
6809
6810 int UtcDaliActorLayoutDirectionSignal(void)
6811 {
6812   TestApplication application;
6813   tet_infoline( "Check changing layout direction property sends a signal" );
6814
6815   Actor actor = Actor::New();
6816   DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6817   Stage::GetCurrent().Add( actor );
6818   bool signalCalled = false;
6819   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6820
6821   actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6822   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6823
6824   // Test that writing the same value doesn't send a signal
6825   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6826   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6827
6828   // Test that writing a different value sends the signal
6829   signalCalled = false;
6830   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6831   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6832
6833   signalCalled = false;
6834   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6835   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6836
6837   END_TEST;
6838 }
6839
6840 struct ChildAddedSignalCheck
6841 {
6842   ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6843   : mSignalReceived( signalReceived ),
6844     mChildHandle( childHandle )
6845   {
6846   }
6847
6848   void operator() ( Actor childHandle )
6849   {
6850     mSignalReceived = true;
6851     mChildHandle = childHandle;
6852   }
6853   void operator() ()
6854   {
6855     mSignalReceived = true;
6856     mChildHandle = Actor();
6857   }
6858
6859   bool& mSignalReceived;
6860   Actor& mChildHandle;
6861 };
6862
6863 int UtcDaliChildAddedSignalP1(void)
6864 {
6865   TestApplication application;
6866   auto stage = Stage::GetCurrent();
6867
6868   bool signalReceived=false;
6869   Actor childActor;
6870
6871   ChildAddedSignalCheck signal( signalReceived, childActor );
6872   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6873   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6874
6875   auto actorA = Actor::New();
6876   stage.Add( actorA );
6877   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6878   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6879   signalReceived = false;
6880
6881   auto actorB = Actor::New();
6882   stage.Add( actorB );
6883   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6884   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6885
6886   END_TEST;
6887 }
6888
6889
6890 int UtcDaliChildAddedSignalP2(void)
6891 {
6892   TestApplication application;
6893   auto stage = Stage::GetCurrent();
6894
6895   bool signalReceived=false;
6896   Actor childActor;
6897
6898   ChildAddedSignalCheck signal( signalReceived, childActor );
6899   tet_infoline( "Connect to childAdded signal by name" );
6900
6901   stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6902   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6903
6904   auto actorA = Actor::New();
6905   stage.Add( actorA );
6906   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6907
6908   // Can't test which actor was added; signal signature is void() when connecting via name.
6909   signalReceived = false;
6910
6911   auto actorB = Actor::New();
6912   stage.Add( actorB );
6913   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6914
6915   END_TEST;
6916 }
6917
6918 int UtcDaliChildAddedSignalN(void)
6919 {
6920   TestApplication application;
6921   auto stage = Stage::GetCurrent();
6922
6923   bool signalReceived=false;
6924   Actor childActor;
6925
6926   ChildAddedSignalCheck signal( signalReceived, childActor );
6927   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6928   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6929
6930   auto actorA = Actor::New();
6931   stage.Add( actorA );
6932   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6933   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6934   signalReceived = false;
6935
6936   auto actorB = Actor::New();
6937   actorA.Add( actorB );
6938   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6939   END_TEST;
6940 }
6941
6942
6943 struct ChildRemovedSignalCheck
6944 {
6945   ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6946   : mSignalReceived( signalReceived ),
6947     mChildHandle( childHandle )
6948   {
6949   }
6950
6951   void operator() ( Actor childHandle )
6952   {
6953     mSignalReceived = true;
6954     mChildHandle = childHandle;
6955   }
6956
6957   void operator() ()
6958   {
6959     mSignalReceived = true;
6960   }
6961
6962   bool& mSignalReceived;
6963   Actor& mChildHandle;
6964 };
6965
6966 int UtcDaliChildRemovedSignalP1(void)
6967 {
6968   TestApplication application;
6969   auto stage = Stage::GetCurrent();
6970
6971   bool signalReceived=false;
6972   Actor childActor;
6973
6974   ChildRemovedSignalCheck signal( signalReceived, childActor );
6975   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6976   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6977
6978   auto actorA = Actor::New();
6979   stage.Add( actorA );
6980   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6981   DALI_TEST_CHECK( !childActor );
6982
6983   stage.Remove( actorA );
6984   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6985   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6986
6987   signalReceived = false;
6988   auto actorB = Actor::New();
6989   stage.Add( actorB );
6990   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6991
6992   stage.Remove( actorB );
6993   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6994   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6995
6996   END_TEST;
6997 }
6998
6999 int UtcDaliChildRemovedSignalP2(void)
7000 {
7001   TestApplication application;
7002   auto stage = Stage::GetCurrent();
7003
7004   bool signalReceived=false;
7005   Actor childActor;
7006
7007   ChildAddedSignalCheck signal( signalReceived, childActor );
7008   tet_infoline( "Connect to childRemoved signal by name" );
7009
7010   stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7011   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7012
7013   auto actorA = Actor::New();
7014   stage.Add( actorA );
7015   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7016
7017   stage.Remove( actorA );
7018   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7019
7020   signalReceived = false;
7021   auto actorB = Actor::New();
7022   stage.Add( actorB );
7023   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7024
7025   stage.Remove( actorB );
7026   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7027
7028   END_TEST;
7029 }
7030
7031
7032 int UtcDaliChildRemovedSignalN(void)
7033 {
7034   TestApplication application;
7035   auto stage = Stage::GetCurrent();
7036
7037   bool signalReceived=false;
7038   Actor childActor;
7039
7040   ChildRemovedSignalCheck signal( signalReceived, childActor );
7041   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7042   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7043
7044   auto actorA = Actor::New();
7045   stage.Add( actorA );
7046
7047   auto actorB = Actor::New();
7048   actorA.Add( actorB );
7049
7050   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7051   DALI_TEST_CHECK( ! childActor );
7052
7053   actorA.Remove( actorB );
7054   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7055   END_TEST;
7056 }
7057
7058
7059 int UtcDaliChildMovedSignalP(void)
7060 {
7061   TestApplication application;
7062   auto stage = Stage::GetCurrent();
7063
7064   bool addedASignalReceived   = false;
7065   bool removedASignalReceived = false;
7066   bool addedBSignalReceived   = false;
7067   bool removedBSignalReceived = false;
7068   Actor childActor;
7069
7070   auto actorA = Actor::New();
7071   auto actorB = Actor::New();
7072   stage.Add( actorA );
7073   stage.Add( actorB );
7074
7075   ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7076   ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7077   ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7078   ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7079
7080   DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7081   DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7082   DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7083   DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7084
7085   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7086   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7087   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7088   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7089
7090   // Create a child of A
7091
7092   auto child = Actor::New();
7093   actorA.Add( child );
7094
7095   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7096   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7097   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7098   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7099   DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7100
7101   // Move child to B:
7102   addedASignalReceived   = false;
7103   addedBSignalReceived   = false;
7104   removedASignalReceived = false;
7105   removedBSignalReceived = false;
7106
7107   actorB.Add( child ); // Expect this child to be re-parented
7108   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7109   DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7110   DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7111   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7112
7113   // Move child back to A:
7114   addedASignalReceived   = false;
7115   addedBSignalReceived   = false;
7116   removedASignalReceived = false;
7117   removedBSignalReceived = false;
7118
7119   actorA.Add( child ); // Expect this child to be re-parented
7120   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7121   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7122   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7123   DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7124
7125
7126   END_TEST;
7127 }
7128
7129 int utcDaliActorCulled(void)
7130 {
7131   TestApplication application;
7132   auto stage = Stage::GetCurrent();
7133
7134   tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7135
7136   Actor actor = Actor::New();
7137   actor.SetSize( 10.0f, 10.0f );
7138
7139   Geometry geometry = CreateQuadGeometry();
7140   Shader shader = CreateShader();
7141   Renderer renderer = Renderer::New(geometry, shader);
7142   actor.AddRenderer( renderer );
7143
7144   stage.Add( actor );
7145
7146   application.SendNotification();
7147   application.Render( 0 );
7148
7149   DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7150
7151   PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7152   notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7153
7154   // Connect NotifySignal
7155   bool propertyNotificationSignal( false );
7156   PropertyNotification source;
7157   CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7158   notification.NotifySignal().Connect( &application, f ) ;
7159
7160   actor.SetPosition( 1000.0f, 1000.0f );
7161
7162   application.SendNotification();
7163   application.Render();
7164
7165   application.SendNotification();
7166
7167   DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7168
7169   DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7170   DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7171   DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7172
7173   END_TEST;
7174 }