Merge "Add logs to check the messages processed by the update thread" into tizen_4...
[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()
3951 {
3952   BufferImage image = BufferImage::New( 16u, 16u );
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( 16.0f, 16.0f );
3958   actor.SetParentOrigin( ParentOrigin::CENTER );
3959   actor.SetAnchorPoint( AnchorPoint::CENTER );
3960
3961   return actor;
3962 }
3963
3964 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3965 {
3966   enabledDisableTrace.Reset();
3967   stencilTrace.Reset();
3968   enabledDisableTrace.Enable( true );
3969   stencilTrace.Enable( true );
3970
3971   application.SendNotification();
3972   application.Render();
3973
3974   enabledDisableTrace.Enable( false );
3975   stencilTrace.Enable( false );
3976 }
3977
3978 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3979 {
3980   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3981
3982   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3983   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3984   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3985   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3986 }
3987
3988 int UtcDaliActorPropertyClippingP(void)
3989 {
3990   // This test checks the clippingMode property.
3991   tet_infoline( "Testing Actor::Property::ClippingMode: P" );
3992   TestApplication application;
3993
3994   Actor actor = Actor::New();
3995
3996   // Check default clippingEnabled value.
3997   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3998
3999   int value = 0;
4000   bool getValueResult = getValue.Get( value );
4001   DALI_TEST_CHECK( getValueResult );
4002
4003   if( getValueResult )
4004   {
4005     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4006   }
4007
4008   // Check setting the property to the stencil mode.
4009   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4010
4011   // Check the new value was set.
4012   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4013   getValueResult = getValue.Get( value );
4014   DALI_TEST_CHECK( getValueResult );
4015
4016   if( getValueResult )
4017   {
4018     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4019   }
4020
4021   // Check setting the property to the scissor mode.
4022   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4023
4024   // Check the new value was set.
4025   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4026   getValueResult = getValue.Get( value );
4027   DALI_TEST_CHECK( getValueResult );
4028
4029   if( getValueResult )
4030   {
4031     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4032   }
4033   END_TEST;
4034 }
4035
4036 int UtcDaliActorPropertyClippingN(void)
4037 {
4038   // Negative test case for Clipping.
4039   tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4040   TestApplication application;
4041
4042   Actor actor = Actor::New();
4043
4044   // Check default clippingEnabled value.
4045   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4046
4047   int value = 0;
4048   bool getValueResult = getValue.Get( value );
4049   DALI_TEST_CHECK( getValueResult );
4050
4051   if( getValueResult )
4052   {
4053     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4054   }
4055
4056   // Check setting an invalid property value won't change the current property value.
4057   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4058
4059   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4060   getValueResult = getValue.Get( value );
4061   DALI_TEST_CHECK( getValueResult );
4062
4063   if( getValueResult )
4064   {
4065     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4066   }
4067
4068   END_TEST;
4069 }
4070
4071 int UtcDaliActorPropertyClippingActor(void)
4072 {
4073   // This test checks that an actor is correctly setup for clipping.
4074   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4075   TestApplication application;
4076
4077   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4078   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4079   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4080   size_t startIndex = 0u;
4081
4082   // Create a clipping actor.
4083   Actor actorDepth1Clip = CreateActorWithContent();
4084   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4085   Stage::GetCurrent().Add( actorDepth1Clip );
4086
4087   // Gather the call trace.
4088   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4089
4090   // Check we are writing to the color buffer.
4091   CheckColorMask( glAbstraction, true );
4092
4093   // Check the stencil buffer was enabled.
4094   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4095
4096   // Check the stencil buffer was cleared.
4097   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4098
4099   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4100   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4101   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4102   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4103
4104   END_TEST;
4105 }
4106
4107 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4108 {
4109   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4110   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4111   TestApplication application;
4112
4113   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4114   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4115   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4116   size_t startIndex = 0u;
4117
4118   // Create a clipping actor.
4119   Actor actorDepth1Clip = CreateActorWithContent();
4120   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4121   Stage::GetCurrent().Add( actorDepth1Clip );
4122
4123   // Gather the call trace.
4124   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4125
4126   // Check we are writing to the color buffer.
4127   CheckColorMask( glAbstraction, true );
4128
4129   // Check the stencil buffer was enabled.
4130   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4131
4132   // Check the stencil buffer was cleared.
4133   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4134
4135   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4136   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4137   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4138   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4139
4140   // Now disable the clipping
4141   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4142
4143   // Gather the call trace.
4144   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4145
4146   // Check the stencil buffer was disabled.
4147   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4148
4149   // Ensure all values in stencil-mask are set to 1.
4150   startIndex = 0u;
4151   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4152
4153   END_TEST;
4154 }
4155
4156 int UtcDaliActorPropertyClippingNestedChildren(void)
4157 {
4158   // This test checks that a hierarchy of actors are clipped correctly by
4159   // writing to and reading from the correct bit-planes of the stencil buffer.
4160   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4161   TestApplication application;
4162   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4163   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4164   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4165
4166   // Create a clipping actor.
4167   Actor actorDepth1Clip = CreateActorWithContent();
4168   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4169   Stage::GetCurrent().Add( actorDepth1Clip );
4170
4171   // Create a child actor.
4172   Actor childDepth2 = CreateActorWithContent();
4173   actorDepth1Clip.Add( childDepth2 );
4174
4175   // Create another clipping actor.
4176   Actor childDepth2Clip = CreateActorWithContent();
4177   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4178   childDepth2.Add( childDepth2Clip );
4179
4180   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4181   // This tests the sort algorithm.
4182   Actor childDepth3 = CreateActorWithContent();
4183   childDepth2Clip.Add( childDepth3 );
4184   Actor childDepth4 = CreateActorWithContent();
4185   childDepth3.Add( childDepth4 );
4186
4187   // Gather the call trace.
4188   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4189
4190   // Check we are writing to the color buffer.
4191   CheckColorMask( glAbstraction, true );
4192
4193   // Check the stencil buffer was enabled.
4194   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4195
4196   // Perform the test twice, once for 2D layer, and once for 3D.
4197   for( unsigned int i = 0u ; i < 2u; ++i )
4198   {
4199     size_t startIndex = 0u;
4200
4201     // Check the stencil buffer was cleared.
4202     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4203
4204     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4205     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4206     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4207     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4208
4209     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4210     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4211     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4212
4213     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4214     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4215     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4216     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4217
4218     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4219     // (Both must be set to pass the check).
4220     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4221     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4222
4223     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4224     if( i == 0u )
4225     {
4226       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4227       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4228     }
4229   }
4230
4231   END_TEST;
4232 }
4233
4234 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4235 {
4236   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4237   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4238   TestApplication application;
4239   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4240   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4241
4242   /* We create a small tree of actors as follows:
4243
4244                            A
4245                           / \
4246      Clipping enabled -> B   D
4247                          |   |
4248                          C   E
4249
4250      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4251   */
4252   Actor actors[5];
4253   for( int i = 0; i < 5; ++i )
4254   {
4255     BufferImage image = BufferImage::New( 16u, 16u );
4256     Actor actor = CreateRenderableActor( image );
4257
4258     // Setup dimensions and position so actor is not skipped by culling.
4259     actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4260     actor.SetSize( 16.0f, 16.0f );
4261
4262     if( i == 0 )
4263     {
4264       actor.SetParentOrigin( ParentOrigin::CENTER );
4265     }
4266     else
4267     {
4268       float b = i > 2 ? 1.0f : -1.0f;
4269       actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4270     }
4271
4272     actors[i] = actor;
4273   }
4274
4275   // Enable clipping on the actor at the top of the left branch.
4276   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4277
4278   // Build the scene graph.
4279   Stage::GetCurrent().Add( actors[0] );
4280
4281   // Left branch:
4282   actors[0].Add( actors[1] );
4283   actors[1].Add( actors[2] );
4284
4285   // Right branch:
4286   actors[0].Add( actors[3] );
4287   actors[3].Add( actors[4] );
4288
4289   // Gather the call trace.
4290   enabledDisableTrace.Reset();
4291   enabledDisableTrace.Enable( true );
4292   application.SendNotification();
4293   application.Render();
4294   enabledDisableTrace.Enable( false );
4295
4296   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4297
4298      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
4299            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4300   */
4301   size_t startIndex = 0u;
4302   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "3042", startIndex ) );
4303   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4304   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4305
4306   // Swap the clipping actor from top of left branch to top of right branch.
4307   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4308   actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4309
4310   // Gather the call trace.
4311   enabledDisableTrace.Reset();
4312   enabledDisableTrace.Enable( true );
4313   application.SendNotification();
4314   application.Render();
4315   enabledDisableTrace.Enable( false );
4316
4317   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4318   // This proves the draw order has remained the same.
4319   startIndex = 0u;
4320   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex(  "Enable",  "2960", startIndex ) );
4321   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4322
4323   END_TEST;
4324 }
4325
4326 int UtcDaliActorPropertyScissorClippingActor(void)
4327 {
4328   // This test checks that an actor is correctly setup for clipping.
4329   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4330   TestApplication application;
4331
4332   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4333   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4334   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4335
4336   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4337   const Vector2 imageSize( 16.0f, 16.0f );
4338
4339   // Create a clipping actor.
4340   Actor clippingActorA = CreateActorWithContent();
4341   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4342   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4343   clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4344   clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4345   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4346   Stage::GetCurrent().Add( clippingActorA );
4347
4348   // Gather the call trace.
4349   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4350
4351   // Check we are writing to the color buffer.
4352   CheckColorMask( glAbstraction, true );
4353
4354   // Check scissor test was enabled.
4355   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4356
4357   // Check the scissor was set, and the coordinates are correct.
4358   std::stringstream compareParametersString;
4359   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4360   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 0, 0, 16, 16
4361
4362   clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4363   clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4364
4365   // Gather the call trace.
4366   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4367
4368   // Check the scissor was set, and the coordinates are correct.
4369   compareParametersString.str( std::string() );
4370   compareParametersString.clear();
4371   compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4372   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 464, 784, 16, 16
4373
4374   END_TEST;
4375 }
4376
4377 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4378 {
4379   // This test checks that an actor is correctly setup for clipping.
4380   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4381   TestApplication application;
4382
4383   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4384   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4385   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4386
4387   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4388   const Vector2 imageSize( 16.0f, 16.0f );
4389
4390   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4391
4392      A is drawn first - with scissor clipping on
4393      B is drawn second - also with scissor clipping on
4394      C is the generated clipping region, the intersection ( A ∩ B )
4395
4396            ┏━━━━━━━┓                   ┌───────┐
4397            ┃     B ┃                   │     B │
4398        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4399        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4400        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4401        │ A     │                   ┊ A     ┊
4402        └───────┘                   └┄┄┄┄┄┄┄┘
4403
4404      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4405   */
4406
4407   // Create a clipping actor.
4408   Actor clippingActorA = CreateActorWithContent();
4409   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4410   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4411   clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4412   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4413   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4414   Stage::GetCurrent().Add( clippingActorA );
4415
4416   // Create a child clipping actor.
4417   Actor clippingActorB = CreateActorWithContent();
4418   clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4419   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4420   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4421   clippingActorA.Add( clippingActorB );
4422
4423   // positionModifiers is an array of positions to position B around.
4424   // expect is an array of expected scissor clip coordinate results.
4425   const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ),     Vector2( -1.0f, 1.0f ),    Vector2( -1.0f, -1.0f ),   Vector2( 1.0f, -1.0f )    };
4426   const Vector4 expect[4] =            { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4427
4428   // Loop through each overlap combination.
4429   for( unsigned int test = 0u; test < 4u; ++test )
4430   {
4431     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4432     const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4433     clippingActorB.SetPosition( position.x, position.y );
4434
4435     // Gather the call trace.
4436     GenerateTrace( application, enabledDisableTrace, scissorTrace );
4437
4438     // Check we are writing to the color buffer.
4439     CheckColorMask( glAbstraction, true );
4440
4441     // Check scissor test was enabled.
4442     DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4443
4444     // Check the scissor was set, and the coordinates are correct.
4445     const Vector4& expectResults( expect[test] );
4446     std::stringstream compareParametersString;
4447     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4448     DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with the expected result
4449   }
4450
4451   END_TEST;
4452 }
4453
4454 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4455 {
4456   // This test checks that an actor is correctly setup for clipping.
4457   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4458   TestApplication application;
4459
4460   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4461   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4462   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4463
4464   /* Create a nest of 2 scissors and siblings of the parent.
4465
4466             stage
4467               |
4468         ┌─────┐─────┐
4469         A     C     D
4470         |           |
4471         B           E
4472   */
4473
4474   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4475   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4476   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4477   const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4478   const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4479   const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4480
4481   // Create a clipping actors.
4482   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4483   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4484   Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4485   Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4486   Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4487
4488   clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4489   clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4490   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4491
4492   clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4493   clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4494   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4495
4496   clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4497   clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4498   clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4499
4500   clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4501   clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4502   clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4503
4504   clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4505   clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4506
4507   clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4508   clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4509   clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4510   clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4511   clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4512
4513   Stage::GetCurrent().Add( clippingActorA );
4514   clippingActorA.Add( clippingActorB );
4515   Stage::GetCurrent().Add( clippingActorC );
4516   Stage::GetCurrent().Add( clippingActorD );
4517   clippingActorD.Add( clippingActorE );
4518
4519   // Gather the call trace.
4520   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4521
4522   // Check we are writing to the color buffer.
4523   CheckColorMask( glAbstraction, true );
4524
4525   // Check scissor test was enabled.
4526   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4527
4528   // Check the scissor was set, and the coordinates are correct.
4529   std::string clipA( "0, 500, 480, 200" );
4530   std::string clipB( "0, 580, 480, 40" );
4531   std::string clipC( "0, 200, 480, 200" );
4532   std::string clipD( "0, 300, 480, 200" );
4533
4534   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4535   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4536   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4537   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4538   DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 );    // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4539
4540   END_TEST;
4541 }
4542
4543 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4544 {
4545   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4546   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4547   TestApplication application;
4548
4549   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4550   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4551   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4552
4553   // Create a clipping actor.
4554   Actor actorDepth1Clip = CreateActorWithContent();
4555   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4556   Stage::GetCurrent().Add( actorDepth1Clip );
4557
4558   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4559   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4560
4561   // Gather the call trace.
4562   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4563
4564   // Check we are writing to the color buffer.
4565   CheckColorMask( glAbstraction, true );
4566
4567   // Check the stencil buffer was not enabled.
4568   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4569
4570   // Check stencil functions are not called.
4571   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4572   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4573   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4574
4575   // Check that scissor clipping is overriden by the renderer properties.
4576   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4577
4578   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4579
4580   // Gather the call trace.
4581   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4582
4583   // Check the stencil buffer was not enabled.
4584   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );    // 3089 = 0xC11 (GL_SCISSOR_TEST)
4585
4586   DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4587
4588   END_TEST;
4589 }
4590
4591 int UtcDaliGetPropertyN(void)
4592 {
4593   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4594   TestApplication app;
4595
4596   Actor actor = Actor::New();
4597
4598   unsigned int propertyCount = actor.GetPropertyCount();
4599   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4600   END_TEST;
4601 }
4602
4603 int UtcDaliActorRaiseLower(void)
4604 {
4605   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4606
4607   TestApplication application;
4608
4609   Stage stage( Stage::GetCurrent() );
4610
4611   Actor actorA = Actor::New();
4612   Actor actorB = Actor::New();
4613   Actor actorC = Actor::New();
4614
4615   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4616   actorA.SetParentOrigin( ParentOrigin::CENTER );
4617
4618   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4619   actorB.SetParentOrigin( ParentOrigin::CENTER );
4620
4621   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4622   actorC.SetParentOrigin( ParentOrigin::CENTER );
4623
4624   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4625   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4626
4627   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4628   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4629
4630   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4631   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4632
4633   stage.Add( actorA );
4634   stage.Add( actorB );
4635   stage.Add( actorC );
4636
4637   ResetTouchCallbacks();
4638
4639   application.SendNotification();
4640   application.Render();
4641
4642   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4643   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4644   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4645
4646   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4647   // Only top actor will get touched.
4648   actorA.TouchSignal().Connect( TestTouchCallback );
4649   actorB.TouchSignal().Connect( TestTouchCallback2 );
4650   actorC.TouchSignal().Connect( TestTouchCallback3 );
4651
4652   Dali::Integration::Point point;
4653   point.SetDeviceId( 1 );
4654   point.SetState( PointState::DOWN );
4655   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4656   Dali::Integration::TouchEvent touchEvent;
4657   touchEvent.AddPoint( point );
4658
4659   application.ProcessEvent( touchEvent );
4660
4661   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4662   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4663   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4664
4665   ResetTouchCallbacks();
4666
4667   tet_printf( "Testing Raising of Actor\n" );
4668
4669   int preActorOrder( 0 );
4670   int postActorOrder( 0 );
4671
4672   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4673   value.Get( preActorOrder );
4674
4675   actorB.Raise();
4676   // Ensure sort order is calculated before next touch event
4677   application.SendNotification();
4678
4679   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4680   value.Get( postActorOrder );
4681
4682   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4683
4684   application.ProcessEvent( touchEvent );
4685
4686   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4687   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4688   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4689
4690   ResetTouchCallbacks();
4691
4692   tet_printf( "Testing Lowering of Actor\n" );
4693
4694   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4695   value.Get( preActorOrder );
4696
4697   actorB.Lower();
4698   application.SendNotification(); // ensure sort order calculated before next touch event
4699
4700   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4701   value.Get( postActorOrder );
4702
4703   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4704
4705   application.ProcessEvent( touchEvent );
4706
4707   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4708   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4709   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4710
4711   ResetTouchCallbacks();
4712
4713   END_TEST;
4714 }
4715
4716 int UtcDaliActorRaiseToTopLowerToBottom(void)
4717 {
4718   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4719
4720   TestApplication application;
4721
4722   Stage stage( Stage::GetCurrent() );
4723
4724   Actor actorA = Actor::New();
4725   Actor actorB = Actor::New();
4726   Actor actorC = Actor::New();
4727
4728   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4729   // enables checking of which actor the uniform is assigned too
4730   Shader shaderA = CreateShader();
4731   shaderA.RegisterProperty( "uRendererColor",1.f);
4732
4733   Shader shaderB = CreateShader();
4734   shaderB.RegisterProperty( "uRendererColor", 2.f );
4735
4736   Shader shaderC = CreateShader();
4737   shaderC.RegisterProperty( "uRendererColor", 3.f );
4738
4739   Geometry geometry = CreateQuadGeometry();
4740
4741   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4742   Renderer rendererA = Renderer::New(geometry, shaderA);
4743   actorA.AddRenderer(rendererA);
4744
4745   Renderer rendererB = Renderer::New(geometry, shaderB);
4746   actorB.AddRenderer(rendererB);
4747
4748   Renderer rendererC = Renderer::New(geometry, shaderC);
4749   actorC.AddRenderer(rendererC);
4750
4751   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4752   actorA.SetParentOrigin( ParentOrigin::CENTER );
4753
4754   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4755   actorB.SetParentOrigin( ParentOrigin::CENTER );
4756
4757   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4758   actorC.SetParentOrigin( ParentOrigin::CENTER );
4759
4760   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4761   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4762
4763   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4764   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4765
4766   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4767   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4768
4769   stage.Add( actorA );
4770   stage.Add( actorB );
4771   stage.Add( actorC );
4772
4773   ResetTouchCallbacks();
4774
4775   // Set up gl abstraction trace so can query the set uniform order
4776   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4777   glAbstraction.EnableSetUniformCallTrace(true);
4778   glAbstraction.ResetSetUniformCallStack();
4779
4780   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4781
4782   application.SendNotification();
4783   application.Render();
4784
4785   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4786
4787
4788   // Test order of uniforms in stack
4789   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4790   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4791   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4792
4793   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4794
4795   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4796
4797   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4798   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4799   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4800
4801   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4802   // Only top actor will get touched.
4803   actorA.TouchSignal().Connect( TestTouchCallback );
4804   actorB.TouchSignal().Connect( TestTouchCallback2 );
4805   actorC.TouchSignal().Connect( TestTouchCallback3 );
4806
4807   Dali::Integration::Point point;
4808   point.SetDeviceId( 1 );
4809   point.SetState( PointState::DOWN );
4810   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4811   Dali::Integration::TouchEvent touchEvent;
4812   touchEvent.AddPoint( point );
4813
4814   application.ProcessEvent( touchEvent );
4815
4816   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4817   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4818   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4819
4820   ResetTouchCallbacks();
4821
4822   tet_printf( "RaiseToTop ActorA\n" );
4823
4824   actorA.RaiseToTop();
4825   application.SendNotification(); // ensure sorting order is calculated before next touch event
4826
4827   application.ProcessEvent( touchEvent );
4828
4829   glAbstraction.ResetSetUniformCallStack();
4830   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4831
4832   application.SendNotification();
4833   application.Render();
4834
4835   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4836
4837   // Test order of uniforms in stack
4838   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4839   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4840   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4841
4842   tet_infoline( "Testing A above C and B at bottom\n" );
4843   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4844
4845   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4846
4847   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4848   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4849   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4850
4851   ResetTouchCallbacks();
4852
4853   tet_printf( "RaiseToTop ActorB\n" );
4854
4855   actorB.RaiseToTop();
4856   application.SendNotification(); // Ensure sort order is calculated before next touch event
4857
4858   application.ProcessEvent( touchEvent );
4859
4860   glAbstraction.ResetSetUniformCallStack();
4861   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4862
4863   application.SendNotification();
4864   application.Render();
4865
4866   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4867
4868   // Test order of uniforms in stack
4869   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4870   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4871   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4872
4873   tet_infoline( "Testing B above A and C at bottom\n" );
4874   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4875
4876   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4877
4878   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4879   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4880   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4881
4882   ResetTouchCallbacks();
4883
4884   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4885
4886   actorA.LowerToBottom();
4887   application.SendNotification();
4888   application.Render();
4889
4890   actorB.LowerToBottom();
4891   application.SendNotification();
4892   application.Render();
4893
4894   application.ProcessEvent( touchEvent );
4895
4896   glAbstraction.ResetSetUniformCallStack();
4897   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4898
4899   application.SendNotification();
4900   application.Render();
4901
4902   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4903
4904   // Test order of uniforms in stack
4905   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4906   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4907   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4908
4909   tet_infoline( "Testing C above A and B at bottom\n" );
4910   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4911
4912   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4913
4914   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4915   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4916   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4917
4918   ResetTouchCallbacks();
4919
4920   END_TEST;
4921 }
4922
4923 int UtcDaliActorRaiseAbove(void)
4924 {
4925   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4926
4927   TestApplication application;
4928
4929   Stage stage( Stage::GetCurrent() );
4930
4931   Actor actorA = Actor::New();
4932   Actor actorB = Actor::New();
4933   Actor actorC = Actor::New();
4934
4935   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4936   actorA.SetParentOrigin( ParentOrigin::CENTER );
4937
4938   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4939   actorB.SetParentOrigin( ParentOrigin::CENTER );
4940
4941   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4942   actorC.SetParentOrigin( ParentOrigin::CENTER );
4943
4944   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4945   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4946
4947   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4948   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4949
4950   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4951   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4952
4953   stage.Add( actorA );
4954   stage.Add( actorB );
4955   stage.Add( actorC );
4956
4957   ResetTouchCallbacks();
4958
4959   application.SendNotification();
4960   application.Render();
4961
4962   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4963   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4964   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4965
4966   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4967   // Only top actor will get touched.
4968   actorA.TouchSignal().Connect( TestTouchCallback );
4969   actorB.TouchSignal().Connect( TestTouchCallback2 );
4970   actorC.TouchSignal().Connect( TestTouchCallback3 );
4971
4972   Dali::Integration::Point point;
4973   point.SetDeviceId( 1 );
4974   point.SetState( PointState::DOWN );
4975   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4976   Dali::Integration::TouchEvent touchEvent;
4977   touchEvent.AddPoint( point );
4978
4979   application.ProcessEvent( touchEvent );
4980
4981   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4982   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4983   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4984
4985   ResetTouchCallbacks();
4986
4987   tet_printf( "Raise actor B Above Actor C\n" );
4988
4989   actorB.RaiseAbove( actorC );
4990   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4991   application.SendNotification();
4992
4993   application.ProcessEvent( touchEvent );
4994
4995   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4996   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4997   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4998
4999   ResetTouchCallbacks();
5000
5001   tet_printf( "Raise actor A Above Actor B\n" );
5002
5003   actorA.RaiseAbove( actorB );
5004
5005   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5006   application.SendNotification();
5007
5008   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5009
5010   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5011   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5012   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5013
5014   ResetTouchCallbacks();
5015
5016   END_TEST;
5017 }
5018
5019 int UtcDaliActorLowerBelow(void)
5020 {
5021   tet_infoline( "UtcDaliActor LowerBelow test \n" );
5022
5023   TestApplication application;
5024
5025   Stage stage( Stage::GetCurrent() );
5026
5027   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5028   // enables checking of which actor the uniform is assigned too
5029   Shader shaderA = CreateShader();
5030   shaderA.RegisterProperty( "uRendererColor",1.f);
5031
5032   Shader shaderB = CreateShader();
5033   shaderB.RegisterProperty( "uRendererColor", 2.f );
5034
5035   Shader shaderC = CreateShader();
5036   shaderC.RegisterProperty( "uRendererColor", 3.f );
5037
5038   Actor actorA = Actor::New();
5039   Actor actorB = Actor::New();
5040   Actor actorC = Actor::New();
5041
5042   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5043   Geometry geometry = CreateQuadGeometry();
5044
5045   Renderer rendererA = Renderer::New(geometry, shaderA);
5046   actorA.AddRenderer(rendererA);
5047
5048   Renderer rendererB = Renderer::New(geometry, shaderB);
5049   actorB.AddRenderer(rendererB);
5050
5051   Renderer rendererC = Renderer::New(geometry, shaderC);
5052   actorC.AddRenderer(rendererC);
5053
5054   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5055   actorA.SetParentOrigin( ParentOrigin::CENTER );
5056
5057   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5058   actorB.SetParentOrigin( ParentOrigin::CENTER );
5059
5060   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5061   actorC.SetParentOrigin( ParentOrigin::CENTER );
5062
5063   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5064   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5065
5066   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5067   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5068
5069   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5070   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5071
5072   Actor container = Actor::New();
5073   container.SetParentOrigin( ParentOrigin::CENTER );
5074   container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5075   stage.Add( container );
5076
5077   container.Add( actorA );
5078   container.Add( actorB );
5079   container.Add( actorC );
5080
5081   ResetTouchCallbacks();
5082
5083   // Set up gl abstraction trace so can query the set uniform order
5084   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5085   glAbstraction.EnableSetUniformCallTrace(true);
5086   glAbstraction.ResetSetUniformCallStack();
5087   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5088
5089   glAbstraction.ResetSetUniformCallStack();
5090
5091   application.SendNotification();
5092   application.Render();
5093
5094   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5095
5096   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5097
5098   // Test order of uniforms in stack
5099   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5100   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5101   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5102
5103   tet_infoline( "Testing C above B and A at bottom\n" );
5104   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
5105
5106   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5107
5108   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5109   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5110   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5111
5112   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5113   // Only top actor will get touched.
5114   actorA.TouchSignal().Connect( TestTouchCallback );
5115   actorB.TouchSignal().Connect( TestTouchCallback2 );
5116   actorC.TouchSignal().Connect( TestTouchCallback3 );
5117
5118   Dali::Integration::Point point;
5119   point.SetDeviceId( 1 );
5120   point.SetState( PointState::DOWN );
5121   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5122   Dali::Integration::TouchEvent touchEvent;
5123   touchEvent.AddPoint( point );
5124
5125   tet_infoline( "UtcDaliActor Test Set up completed \n" );
5126
5127   application.ProcessEvent( touchEvent );
5128
5129   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5130   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5131   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5132
5133   ResetTouchCallbacks();
5134
5135   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" );
5136
5137   actorC.LowerBelow( actorB );
5138   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5139   application.SendNotification();
5140   application.Render();
5141
5142   application.ProcessEvent( touchEvent ); // touch event
5143
5144   glAbstraction.ResetSetUniformCallStack();
5145   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5146
5147   application.SendNotification();
5148   application.Render();
5149
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   tet_infoline( "Testing render order is A, C, B" );
5158   DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5159   DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5160
5161   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5162   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5163   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5164
5165   ResetTouchCallbacks();
5166
5167   tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5168
5169   actorC.LowerBelow( actorA );
5170   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5171   application.SendNotification();
5172   application.Render();
5173
5174   application.ProcessEvent( touchEvent );
5175
5176   glAbstraction.ResetSetUniformCallStack();
5177   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5178
5179   application.Render();
5180   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5181
5182   // Test order of uniforms in stack
5183   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5184   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5185   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5186
5187   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5188   DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5189
5190   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5191   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5192   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5193
5194   ResetTouchCallbacks();
5195
5196   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5197
5198   actorB.LowerBelow( actorC );
5199   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5200   application.SendNotification();
5201   application.Render();
5202
5203   application.ProcessEvent( touchEvent );
5204
5205   glAbstraction.ResetSetUniformCallStack();
5206   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5207
5208   application.Render();
5209   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5210
5211   // Test order of uniforms in stack
5212   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5213   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5214   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5215
5216   DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5217   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5218
5219   END_TEST;
5220 }
5221
5222
5223 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5224 {
5225   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5226
5227   TestApplication application;
5228
5229   Stage stage( Stage::GetCurrent() );
5230
5231   Actor parentA = Actor::New();
5232   Actor parentB = Actor::New();
5233   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5234   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5235   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5236   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5237
5238   parentA.SetAnchorPoint( AnchorPoint::CENTER );
5239   parentA.SetParentOrigin( ParentOrigin::CENTER );
5240
5241   parentB.SetAnchorPoint( AnchorPoint::CENTER );
5242   parentB.SetParentOrigin( ParentOrigin::CENTER );
5243
5244   stage.Add( parentA );
5245   stage.Add( parentB );
5246
5247   Actor actorA = Actor::New();
5248   Actor actorB = Actor::New();
5249   Actor actorC = Actor::New();
5250
5251   parentA.Add( actorA );
5252   parentA.Add( actorB );
5253
5254   tet_printf( "Actor C added to different parent from A and B \n" );
5255   parentB.Add( actorC );
5256
5257   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5258   actorA.SetParentOrigin( ParentOrigin::CENTER );
5259
5260   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5261   actorB.SetParentOrigin( ParentOrigin::CENTER );
5262
5263   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5264   actorC.SetParentOrigin( ParentOrigin::CENTER );
5265
5266   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5267   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5268
5269   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5270   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5271
5272   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5273   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5274
5275   ResetTouchCallbacks();
5276
5277   application.SendNotification();
5278   application.Render();
5279
5280   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5281   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5282   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5283
5284   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5285   // Only top actor will get touched.
5286   actorA.TouchSignal().Connect( TestTouchCallback );
5287   actorB.TouchSignal().Connect( TestTouchCallback2 );
5288   actorC.TouchSignal().Connect( TestTouchCallback3 );
5289
5290   Dali::Integration::Point point;
5291   point.SetDeviceId( 1 );
5292   point.SetState( PointState::DOWN );
5293   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5294   Dali::Integration::TouchEvent touchEvent;
5295   touchEvent.AddPoint( point );
5296
5297   application.ProcessEvent( touchEvent );
5298
5299   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5300   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5301   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5302
5303   ResetTouchCallbacks();
5304
5305   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5306
5307   actorA.RaiseAbove( actorC );
5308   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5309   application.SendNotification();
5310
5311   application.ProcessEvent( touchEvent ); // touch event
5312
5313   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5314   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5315   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5316
5317   ResetTouchCallbacks();
5318
5319   END_TEST;
5320 }
5321
5322 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5323 {
5324   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5325
5326   TestApplication application;
5327
5328   Stage stage( Stage::GetCurrent() );
5329
5330   Actor actorA = Actor::New();
5331   Actor actorB = Actor::New();
5332   Actor actorC = Actor::New();
5333
5334   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5335   actorA.SetParentOrigin( ParentOrigin::CENTER );
5336
5337   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5338   actorB.SetParentOrigin( ParentOrigin::CENTER );
5339
5340   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5341   actorC.SetParentOrigin( ParentOrigin::CENTER );
5342
5343   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5344   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5345
5346   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5347   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5348
5349   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5350   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5351
5352   ResetTouchCallbacks();
5353
5354   application.SendNotification();
5355   application.Render();
5356
5357   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5358   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5359   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5360
5361   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5362   // Only top actor will get touched.
5363   actorA.TouchSignal().Connect( TestTouchCallback );
5364   actorB.TouchSignal().Connect( TestTouchCallback2 );
5365   actorC.TouchSignal().Connect( TestTouchCallback3 );
5366
5367   Dali::Integration::Point point;
5368   point.SetDeviceId( 1 );
5369   point.SetState( PointState::DOWN );
5370   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5371   Dali::Integration::TouchEvent touchEvent;
5372   touchEvent.AddPoint( point );
5373
5374   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5375
5376   actorA.RaiseAbove( actorC );
5377   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5378   application.SendNotification();
5379
5380   application.ProcessEvent( touchEvent );
5381
5382   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5383
5384   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5385   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5386   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5387
5388   ResetTouchCallbacks();
5389
5390   stage.Add ( actorB );
5391   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5392   actorA.LowerBelow( actorC );
5393
5394   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5395   application.SendNotification();
5396   application.Render();
5397
5398   application.ProcessEvent( touchEvent );
5399
5400   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5401   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5402   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5403   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5404
5405   ResetTouchCallbacks();
5406
5407   tet_printf( "Adding Actor A to stage, will be on top\n" );
5408
5409   stage.Add ( actorA );
5410   application.SendNotification();
5411   application.Render();
5412
5413   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5414   actorB.RaiseAbove( actorC );
5415   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5416   application.SendNotification();
5417
5418   application.ProcessEvent( touchEvent );
5419
5420   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5421   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5422   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5423   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5424
5425   ResetTouchCallbacks();
5426
5427   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5428   actorA.LowerBelow( actorC );
5429   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5430   application.SendNotification();
5431
5432   application.ProcessEvent( touchEvent );
5433
5434   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5435   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5436   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5437   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5438
5439   ResetTouchCallbacks();
5440
5441   stage.Add ( actorC );
5442   actorA.RaiseAbove( actorC );
5443   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5444   application.SendNotification();
5445   application.Render();
5446
5447   application.ProcessEvent( touchEvent );
5448
5449   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5450   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5451   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5452   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5453
5454   END_TEST;
5455 }
5456
5457 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5458 {
5459   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5460
5461   TestApplication application;
5462
5463   Stage stage( Stage::GetCurrent() );
5464
5465   Actor actorA = Actor::New();
5466   Actor actorB = Actor::New();
5467   Actor actorC = Actor::New();
5468
5469   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5470   actorA.SetParentOrigin( ParentOrigin::CENTER );
5471
5472   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5473   actorB.SetParentOrigin( ParentOrigin::CENTER );
5474
5475   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5476   actorC.SetParentOrigin( ParentOrigin::CENTER );
5477
5478   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5479   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5480
5481   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5482   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5483
5484   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5485   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5486
5487   ResetTouchCallbacks();
5488
5489   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5490   // Only top actor will get touched.
5491   actorA.TouchSignal().Connect( TestTouchCallback );
5492   actorB.TouchSignal().Connect( TestTouchCallback2 );
5493   actorC.TouchSignal().Connect( TestTouchCallback3 );
5494
5495   Dali::Integration::Point point;
5496   point.SetDeviceId( 1 );
5497   point.SetState( PointState::DOWN );
5498   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5499   Dali::Integration::TouchEvent touchEvent;
5500   touchEvent.AddPoint( point );
5501
5502   stage.Add ( actorA );
5503   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5504   actorB.Raise();
5505
5506   application.SendNotification();
5507   application.Render();
5508
5509   application.ProcessEvent( touchEvent );
5510
5511   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5512
5513   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5514   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5515   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5516
5517   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5518   ResetTouchCallbacks();
5519
5520   actorC.Lower();
5521   // Sort actor tree before next touch event
5522   application.SendNotification();
5523   application.Render();
5524
5525   application.ProcessEvent( touchEvent );
5526
5527   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5528
5529   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5530   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5531   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5532   ResetTouchCallbacks();
5533
5534   tet_printf( "Lower actor C below B but C not parented\n" );
5535
5536   actorB.Lower();
5537   // Sort actor tree before next touch event
5538   application.SendNotification();
5539   application.Render();
5540
5541   application.ProcessEvent( touchEvent );
5542
5543   tet_printf( "Not parented so Lower should show no effect\n" );
5544
5545   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5546   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5547   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5548   ResetTouchCallbacks();
5549
5550   tet_printf( "Raise actor B to top\n" );
5551
5552   actorB.RaiseToTop();
5553   // Sort actor tree before next touch event
5554   application.SendNotification();
5555   application.Render();
5556
5557   application.ProcessEvent( touchEvent );
5558
5559   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5560
5561   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5562   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5563   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5564   ResetTouchCallbacks();
5565
5566   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5567
5568   stage.Add ( actorB );
5569
5570   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5571
5572   actorC.LowerToBottom();
5573   application.SendNotification();
5574   application.Render();
5575
5576   application.ProcessEvent( touchEvent );
5577
5578   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5579
5580   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5581   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5582   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5583   ResetTouchCallbacks();
5584
5585   END_TEST;
5586 }
5587
5588
5589 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5590 {
5591   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5592
5593   TestApplication application;
5594
5595   Stage stage( Stage::GetCurrent() );
5596
5597   Actor actorA = Actor::New();
5598   Actor actorB = Actor::New();
5599   Actor actorC = Actor::New();
5600
5601   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5602   actorA.SetParentOrigin( ParentOrigin::CENTER );
5603
5604   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5605   actorB.SetParentOrigin( ParentOrigin::CENTER );
5606
5607   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5608   actorC.SetParentOrigin( ParentOrigin::CENTER );
5609
5610   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5611   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5612
5613   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5614   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5615
5616   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5617   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5618
5619   stage.Add( actorA );
5620   stage.Add( actorB );
5621   stage.Add( actorC );
5622
5623   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5624   // Only top actor will get touched.
5625   actorA.TouchSignal().Connect( TestTouchCallback );
5626   actorB.TouchSignal().Connect( TestTouchCallback2 );
5627   actorC.TouchSignal().Connect( TestTouchCallback3 );
5628
5629   ResetTouchCallbacks();
5630
5631   application.SendNotification();
5632   application.Render();
5633
5634   Dali::Integration::Point point;
5635   point.SetDeviceId( 1 );
5636   point.SetState( PointState::DOWN );
5637   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5638   Dali::Integration::TouchEvent touchEvent;
5639   touchEvent.AddPoint( point );
5640
5641   application.ProcessEvent( touchEvent );
5642
5643   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5644   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5645   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5646
5647   ResetTouchCallbacks();
5648
5649   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5650
5651   actorA.RaiseAbove( actorA );
5652   application.SendNotification();
5653   application.Render();
5654
5655   application.ProcessEvent( touchEvent );
5656
5657   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5658
5659   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5660   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5661   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5662
5663   ResetTouchCallbacks();
5664
5665   actorA.RaiseAbove( actorC );
5666   application.SendNotification();
5667   application.Render();
5668
5669   application.ProcessEvent( touchEvent );
5670
5671   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5672   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5673   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5674   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5675
5676   END_TEST;
5677 }
5678
5679 int UtcDaliActorGetScreenPosition(void)
5680 {
5681   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5682
5683   TestApplication application;
5684
5685   Stage stage( Stage::GetCurrent() );
5686
5687   Actor actorA = Actor::New();
5688   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5689
5690   Vector2 size2( 10.0f, 20.0f );
5691   actorA.SetSize( size2 );
5692
5693   actorA.SetPosition( 0.f, 0.f );
5694
5695   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5696
5697   stage.Add( actorA );
5698
5699   application.SendNotification();
5700   application.Render();
5701
5702   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5703   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5704
5705   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
5706   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5707
5708   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5709   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5710
5711   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5712
5713   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5714
5715   application.SendNotification();
5716   application.Render();
5717
5718   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5719   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5720
5721   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
5722   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5723
5724   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5725   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5726
5727   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5728
5729   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5730
5731   application.SendNotification();
5732   application.Render();
5733
5734   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5735   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5736
5737   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
5738   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
5739
5740   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5741   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5742
5743   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5744
5745   actorA.SetPosition( 30.0, 0.0 );
5746
5747   application.SendNotification();
5748   application.Render();
5749
5750   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5751   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5752
5753   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
5754   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
5755
5756   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5757   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5758
5759   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5760
5761   actorA.SetPosition( 30.0, 420.0 );
5762
5763   application.SendNotification();
5764   application.Render();
5765
5766   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5767   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5768
5769   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5770   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
5771
5772   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
5773   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5774
5775   tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5776
5777   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5778   actorA.SetPosition( 30.0, 30.0 );
5779
5780   Actor actorB = Actor::New();
5781   actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5782   actorB.SetSize( size2 );
5783   actorB.SetPosition( 10.f, 10.f );
5784   actorA.Add( actorB );
5785
5786   actorA.SetScale( 2.0f );
5787
5788   application.SendNotification();
5789   application.Render();
5790
5791   actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5792
5793   DALI_TEST_EQUALS( actorScreenPosition.x,  50lu , TEST_LOCATION );
5794   DALI_TEST_EQUALS( actorScreenPosition.y,  50lu , TEST_LOCATION );
5795
5796   END_TEST;
5797 }
5798
5799 int UtcDaliActorGetScreenPositionAfterScaling(void)
5800 {
5801   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5802
5803   TestApplication application;
5804
5805   Stage stage( Stage::GetCurrent() );
5806
5807   Actor actorA = Actor::New();
5808   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5809
5810   Vector2 size2( 10.0f, 20.0f );
5811   actorA.SetSize( size2 );
5812   actorA.SetScale( 1.5f );
5813   actorA.SetPosition( 0.f, 0.f );
5814
5815   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5816
5817   stage.Add( actorA );
5818
5819   application.SendNotification();
5820   application.Render();
5821
5822   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5823   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5824
5825   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5826   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5827
5828   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5829   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5830
5831   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5832
5833   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5834
5835   application.SendNotification();
5836   application.Render();
5837
5838   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5839   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5840
5841   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5842   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5843
5844   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
5845   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5846
5847   END_TEST;
5848 }
5849
5850 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5851 {
5852   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5853
5854   TestApplication application;
5855
5856   Stage stage( Stage::GetCurrent() );
5857
5858   Actor actorA = Actor::New();
5859   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5860   actorA.SetParentOrigin( ParentOrigin::CENTER );
5861   Vector2 size2( 10.0f, 20.0f );
5862   actorA.SetSize( size2 );
5863   actorA.SetPosition( 0.f, 0.f );
5864
5865   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5866
5867   stage.Add( actorA );
5868
5869   application.SendNotification();
5870   application.Render();
5871
5872   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5873   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5874
5875   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5876   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5877
5878   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
5879   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
5880
5881   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5882
5883   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5884   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5885
5886   application.SendNotification();
5887   application.Render();
5888
5889   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5890   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5891
5892   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5893   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5894
5895   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5896   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5897
5898   END_TEST;
5899   END_TEST;
5900 }
5901
5902 int UtcDaliActorGetScreenPositionWithChildActors(void)
5903 {
5904   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5905
5906   TestApplication application;
5907
5908   Stage stage( Stage::GetCurrent() );
5909
5910   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5911
5912   Actor actorA = Actor::New();
5913   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5914   actorA.SetParentOrigin( ParentOrigin::CENTER );
5915   Vector2 size1( 10.0f, 20.0f );
5916   actorA.SetSize( size1 );
5917   actorA.SetPosition( 0.f, 0.f );
5918
5919   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5920
5921   Actor parentActorA = Actor::New();
5922   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5923   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5924   Vector2 size2( 30.0f, 60.0f );
5925   parentActorA.SetSize( size2 );
5926   parentActorA.SetPosition( 0.f, 0.f );
5927
5928   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5929
5930   stage.Add( parentActorA );
5931   parentActorA.Add ( actorA );
5932
5933   application.SendNotification();
5934   application.Render();
5935
5936   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5937   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5938
5939   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5940   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5941
5942   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
5943   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
5944
5945   tet_infoline( "Test 2\n");
5946
5947   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5948
5949   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5950   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5951
5952   application.SendNotification();
5953   application.Render();
5954
5955   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5956   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5957
5958   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5959   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5960
5961   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
5962   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
5963
5964   END_TEST;
5965 }
5966
5967 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5968 {
5969   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5970
5971   TestApplication application;
5972
5973   Stage stage( Stage::GetCurrent() );
5974
5975   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5976
5977   Actor actorA = Actor::New();
5978   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5979   actorA.SetParentOrigin( ParentOrigin::CENTER );
5980   Vector2 size1( 10.0f, 20.0f );
5981   actorA.SetSize( size1 );
5982   actorA.SetPosition( 0.f, 0.f );
5983
5984   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5985
5986   Actor parentActorA = Actor::New();
5987   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5988   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5989   Vector2 size2( 30.0f, 60.0f );
5990   parentActorA.SetSize( size2 );
5991   parentActorA.SetPosition( 0.f, 0.f );
5992
5993   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5994
5995   Actor grandParentActorA = Actor::New();
5996   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5997   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5998   Vector2 size3( 60.0f, 120.0f );
5999   grandParentActorA.SetSize( size3 );
6000   grandParentActorA.SetPosition( 0.f, 0.f );
6001
6002   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6003
6004   stage.Add( grandParentActorA );
6005   grandParentActorA.Add ( parentActorA );
6006
6007   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6008
6009   parentActorA.Add ( actorA );
6010
6011   application.SendNotification();
6012   application.Render();
6013
6014   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6015   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6016
6017   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6018   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6019
6020   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
6021   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
6022
6023   END_TEST;
6024 }
6025
6026 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6027 {
6028   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6029
6030   TestApplication application;
6031
6032   Stage stage( Stage::GetCurrent() );
6033
6034   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6035
6036   Actor actorA = Actor::New();
6037   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6038   actorA.SetParentOrigin( ParentOrigin::CENTER );
6039   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6040   actorA.SetSize( 10.0f, 20.0f );
6041   stage.Add( actorA );
6042
6043   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6044
6045   Actor actorB = Actor::New();
6046   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6047   actorB.SetParentOrigin( ParentOrigin::CENTER );
6048   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6049   Vector2 actorBSize( 30.0f, 60.0f );
6050   actorB.SetSize( actorBSize );
6051   stage.Add( actorB );
6052
6053   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6054
6055   Actor actorC = Actor::New();
6056   actorC.SetAnchorPoint( AnchorPoint::CENTER );
6057   actorC.SetParentOrigin( ParentOrigin::CENTER );
6058   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6059   Vector2 actorCSize( 60.0f, 120.0f );
6060   actorC.SetSize( actorCSize );
6061   stage.Add( actorC );
6062
6063   application.SendNotification();
6064   application.Render();
6065
6066   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6067
6068   Vector2 center( stage.GetSize() * 0.5f );
6069
6070   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6071   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6072   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6073
6074   tet_infoline( "Add scale to all actors" );
6075
6076   actorA.SetScale( 2.0f );
6077   actorB.SetScale( 2.0f );
6078   actorC.SetScale( 2.0f );
6079
6080   application.SendNotification();
6081   application.Render();
6082
6083   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6084   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6085   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6086
6087   END_TEST;
6088 }
6089
6090 int utcDaliActorPositionUsesAnchorPoint(void)
6091 {
6092   TestApplication application;
6093   tet_infoline( "Check default behaviour\n" );
6094
6095   Actor actor = Actor::New();
6096   actor.SetParentOrigin( ParentOrigin::CENTER );
6097   actor.SetAnchorPoint( AnchorPoint::CENTER );
6098   actor.SetSize( 100.0f, 100.0f );
6099   Stage::GetCurrent().Add( actor );
6100
6101   application.SendNotification();
6102   application.Render();
6103
6104   tet_infoline( "Check that the world position is in the center\n" );
6105   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6106
6107   tet_infoline( "Set the position uses anchor point property to false\n" );
6108   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6109
6110   application.SendNotification();
6111   application.Render();
6112
6113   tet_infoline( "Check that the world position has changed appropriately\n" );
6114   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6115
6116   END_TEST;
6117 }
6118
6119 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6120 {
6121   TestApplication application;
6122   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6123
6124   Actor actor = Actor::New();
6125   actor.SetParentOrigin( ParentOrigin::CENTER );
6126   actor.SetAnchorPoint( AnchorPoint::CENTER );
6127   actor.SetSize( 100.0f, 100.0f );
6128   actor.SetScale( 2.0f );
6129   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6130   Stage::GetCurrent().Add( actor );
6131
6132   application.SendNotification();
6133   application.Render();
6134
6135   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6136   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6137
6138   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6139   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6140   application.SendNotification();
6141   application.Render();
6142   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6143
6144   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6145   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6146   application.SendNotification();
6147   application.Render();
6148   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6149
6150   END_TEST;
6151 }
6152
6153 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6154 {
6155   TestApplication application;
6156   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6157
6158   Actor actor = Actor::New();
6159   actor.SetParentOrigin( ParentOrigin::CENTER );
6160   actor.SetAnchorPoint( AnchorPoint::CENTER );
6161   actor.SetSize( 100.0f, 100.0f );
6162   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6163   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6164   Stage::GetCurrent().Add( actor );
6165
6166   application.SendNotification();
6167   application.Render();
6168
6169   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6170   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6171
6172   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6173   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6174   application.SendNotification();
6175   application.Render();
6176   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6177
6178   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6179   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6180   application.SendNotification();
6181   application.Render();
6182   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6183
6184   END_TEST;
6185 }
6186
6187 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6188 {
6189   TestApplication application;
6190   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6191
6192   Actor actor = Actor::New();
6193   actor.SetParentOrigin( ParentOrigin::CENTER );
6194   actor.SetAnchorPoint( AnchorPoint::CENTER );
6195   actor.SetSize( 100.0f, 100.0f );
6196   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6197   actor.SetScale( 2.0f );
6198   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6199   Stage::GetCurrent().Add( actor );
6200
6201   application.SendNotification();
6202   application.Render();
6203
6204   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6205   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6206
6207   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6208   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6209   application.SendNotification();
6210   application.Render();
6211   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6212
6213   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6214   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6215   application.SendNotification();
6216   application.Render();
6217   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6218
6219   END_TEST;
6220 }
6221
6222 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6223 {
6224   TestApplication application;
6225   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6226
6227   Actor parent = Actor::New();
6228
6229   Stage::GetCurrent().Add( parent );
6230   Vector2 stageSize( Stage::GetCurrent().GetSize() );
6231
6232   Actor actor = Actor::New();
6233   actor.SetParentOrigin( ParentOrigin::CENTER );
6234   actor.SetAnchorPoint( AnchorPoint::CENTER );
6235   actor.SetSize( 100.0f, 100.0f );
6236   actor.SetInheritScale( false );
6237   actor.SetInheritOrientation( false );
6238   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6239   parent.Add( actor );
6240
6241   application.SendNotification();
6242   application.Render();
6243
6244   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6245
6246   tet_infoline( "Check the world position is in the right place\n" );
6247   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6248
6249   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6250   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6251   application.SendNotification();
6252   application.Render();
6253   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6254
6255   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6256   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6257   application.SendNotification();
6258   application.Render();
6259   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6260
6261   END_TEST;
6262 }
6263
6264 int utcDaliActorVisibilityChangeSignalSelf(void)
6265 {
6266   TestApplication application;
6267   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6268
6269   Actor actor = Actor::New();
6270
6271   VisibilityChangedFunctorData data;
6272   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6273
6274   actor.SetVisible( false );
6275
6276   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6277
6278   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6279   data.Reset();
6280
6281   actor.SetVisible( false );
6282   data.Check( false /* not called */, TEST_LOCATION );
6283
6284   tet_infoline( "Change the visibility using properties, ensure called" );
6285   data.Reset();
6286
6287   actor.SetProperty( Actor::Property::VISIBLE, true );
6288   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6289
6290   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6291   data.Reset();
6292
6293   actor.SetProperty( Actor::Property::VISIBLE, true );
6294   data.Check( false /* not called */, TEST_LOCATION );
6295
6296   END_TEST;
6297 }
6298
6299 int utcDaliActorVisibilityChangeSignalChildren(void)
6300 {
6301   TestApplication application;
6302   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6303
6304   Actor parent = Actor::New();
6305   Actor child = Actor::New();
6306   parent.Add( child );
6307
6308   Actor grandChild = Actor::New();
6309   child.Add( grandChild );
6310
6311   VisibilityChangedFunctorData parentData;
6312   VisibilityChangedFunctorData childData;
6313   VisibilityChangedFunctorData grandChildData;
6314
6315   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6316   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6317   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6318
6319   parent.SetVisible( false );
6320   parentData.Check( false /* not called */, TEST_LOCATION );
6321   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6322   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6323
6324   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6325   parentData.Reset();
6326   childData.Reset();
6327   grandChildData.Reset();
6328
6329   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6330
6331   parent.SetVisible( true );
6332   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6333   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6334   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6335
6336   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6337   parentData.Reset();
6338   childData.Reset();
6339   grandChildData.Reset();
6340
6341   parent.SetVisible( true );
6342   parentData.Check( false /* not called */, TEST_LOCATION );
6343   childData.Check( false /* not called */, TEST_LOCATION );
6344   grandChildData.Check( false /* not called */, TEST_LOCATION );
6345
6346   END_TEST;
6347 }
6348
6349 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6350 {
6351   TestApplication application;
6352   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6353
6354   Actor actor = Actor::New();
6355   Stage::GetCurrent().Add( actor );
6356
6357   application.SendNotification();
6358   application.Render();
6359
6360   VisibilityChangedFunctorData data;
6361   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6362
6363   Animation animation = Animation::New( 1.0f );
6364   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6365
6366   data.Check( false, TEST_LOCATION );
6367   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6368   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6369
6370   tet_infoline( "Play the animation and check the property value" );
6371   animation.Play();
6372
6373   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6374   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6375
6376   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6377   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6378
6379   application.SendNotification();
6380   application.Render( 1100 ); // After the animation
6381
6382   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6383
6384   END_TEST;
6385 }
6386
6387
6388 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6389 {
6390   gLayoutDirectionType = type;
6391 }
6392
6393 int UtcDaliActorLayoutDirectionProperty(void)
6394 {
6395   TestApplication application;
6396   tet_infoline( "Check layout direction property" );
6397
6398   Actor actor0 = Actor::New();
6399   DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6400   Stage::GetCurrent().Add( actor0 );
6401
6402   application.SendNotification();
6403   application.Render();
6404
6405   Actor actor1 = Actor::New();
6406   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6407   Actor actor2 = Actor::New();
6408   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6409   Actor actor3 = Actor::New();
6410   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6411   Actor actor4 = Actor::New();
6412   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6413   Actor actor5 = Actor::New();
6414   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6415   Actor actor6 = Actor::New();
6416   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6417   Actor actor7 = Actor::New();
6418   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6419   Actor actor8 = Actor::New();
6420   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6421   Actor actor9 = Actor::New();
6422   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6423
6424   actor1.Add( actor2 );
6425   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6426   actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6427
6428   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6429   actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6430   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6431
6432   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6433   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6434   DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6435
6436   actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6437   actor0.Add( actor1 );
6438   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6439   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6440
6441   Stage::GetCurrent().Add( actor3 );
6442   actor3.Add( actor4 );
6443   actor4.Add( actor5 );
6444   actor5.Add( actor6 );
6445   actor5.Add( actor7 );
6446   actor7.Add( actor8 );
6447   actor8.Add( actor9 );
6448   actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6449   actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6450
6451   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6452   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6453   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6454
6455   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6456
6457   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6458   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6459   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6460   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6461   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6462   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6463   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6464
6465   actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6466   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6467   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6468
6469   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6470   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6471   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6472   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6473
6474   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6475   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6476   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6477
6478   END_TEST;
6479 }