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