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