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