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