Ensure cached values of properties animated using AnimateTo are updated
[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 touchEvent;
2487   touchEvent.AddPoint( point );
2488   application.ProcessEvent( touchEvent );
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 hoverEvent;
2517   hoverEvent.AddPoint( point );
2518   application.ProcessEvent( hoverEvent );
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   {
3863     Geometry geometry = CreateQuadGeometry();
3864     Shader shader = CreateShader();
3865     Renderer renderer = Renderer::New(geometry, shader);
3866
3867     actor.AddRenderer( renderer );
3868     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3869     DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3870
3871     application.SendNotification();
3872     application.Render();
3873   }
3874
3875   {
3876     Renderer renderer = actor.GetRendererAt(0);
3877     actor.RemoveRenderer(renderer);
3878     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3879
3880     application.SendNotification();
3881     application.Render();
3882   }
3883
3884   // Call one final time to ensure that the renderer is actually removed after
3885   // the handle goes out of scope, and excercises the deletion code path in
3886   // scene graph and render.
3887   application.SendNotification();
3888   application.Render();
3889
3890   END_TEST;
3891 }
3892
3893 int UtcDaliActorRemoveRendererP2(void)
3894 {
3895   tet_infoline("Testing Actor::RemoveRenderer");
3896   TestApplication application;
3897
3898   Actor actor = Actor::New();
3899
3900   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3901
3902   Geometry geometry = CreateQuadGeometry();
3903   Shader shader = CreateShader();
3904   Renderer renderer = Renderer::New(geometry, shader);
3905
3906   actor.AddRenderer( renderer );
3907   application.SendNotification();
3908   application.Render();
3909
3910   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3911   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3912
3913   actor.RemoveRenderer(0);
3914   application.SendNotification();
3915   application.Render();
3916
3917   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3918
3919   // Shut down whilst holding onto the renderer handle.
3920   END_TEST;
3921 }
3922
3923
3924 int UtcDaliActorRemoveRendererN(void)
3925 {
3926   tet_infoline("Testing Actor::RemoveRenderer");
3927   TestApplication application;
3928
3929   Actor actor = Actor::New();
3930
3931   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3932
3933   Geometry geometry = CreateQuadGeometry();
3934   Shader shader = CreateShader();
3935   Renderer renderer = Renderer::New(geometry, shader);
3936
3937   actor.AddRenderer( renderer );
3938   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3939   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3940
3941   actor.RemoveRenderer(10);
3942   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3943   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3944
3945   END_TEST;
3946 }
3947
3948 // Clipping test helper functions:
3949 Actor CreateActorWithContent()
3950 {
3951   BufferImage image = BufferImage::New( 16u, 16u );
3952   Actor actor = CreateRenderableActor( image );
3953
3954   // Setup dimensions and position so actor is not skipped by culling.
3955   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3956   actor.SetSize( 16.0f, 16.0f );
3957   actor.SetParentOrigin( ParentOrigin::CENTER );
3958   actor.SetAnchorPoint( AnchorPoint::CENTER );
3959
3960   return actor;
3961 }
3962
3963 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3964 {
3965   enabledDisableTrace.Reset();
3966   stencilTrace.Reset();
3967   enabledDisableTrace.Enable( true );
3968   stencilTrace.Enable( true );
3969
3970   application.SendNotification();
3971   application.Render();
3972
3973   enabledDisableTrace.Enable( false );
3974   stencilTrace.Enable( false );
3975 }
3976
3977 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3978 {
3979   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3980
3981   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3982   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3983   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3984   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3985 }
3986
3987 int UtcDaliActorPropertyClippingP(void)
3988 {
3989   // This test checks the clippingMode property.
3990   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3991   TestApplication application;
3992
3993   Actor actor = Actor::New();
3994
3995   // Check default clippingEnabled value.
3996   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3997
3998   int value = 0;
3999   bool getValueResult = getValue.Get( value );
4000   DALI_TEST_CHECK( getValueResult );
4001
4002   if( getValueResult )
4003   {
4004     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4005   }
4006
4007   // Check setting the property.
4008   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4009
4010   // Check the new value was set.
4011   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4012   getValueResult = getValue.Get( value );
4013   DALI_TEST_CHECK( getValueResult );
4014
4015   if( getValueResult )
4016   {
4017     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4018   }
4019
4020   END_TEST;
4021 }
4022
4023 int UtcDaliActorPropertyClippingN(void)
4024 {
4025   // Negative test case for Clipping.
4026   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4027   TestApplication application;
4028
4029   Actor actor = Actor::New();
4030
4031   // Check default clippingEnabled value.
4032   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4033
4034   int value = 0;
4035   bool getValueResult = getValue.Get( value );
4036   DALI_TEST_CHECK( getValueResult );
4037
4038   if( getValueResult )
4039   {
4040     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4041   }
4042
4043   // Check setting an invalid property value won't change the current property value.
4044   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4045
4046   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4047   getValueResult = getValue.Get( value );
4048   DALI_TEST_CHECK( getValueResult );
4049
4050   if( getValueResult )
4051   {
4052     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4053   }
4054
4055   END_TEST;
4056 }
4057
4058 int UtcDaliActorPropertyClippingActor(void)
4059 {
4060   // This test checks that an actor is correctly setup for clipping.
4061   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4062   TestApplication application;
4063
4064   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4065   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4066   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4067   size_t startIndex = 0u;
4068
4069   // Create a clipping actor.
4070   Actor actorDepth1Clip = CreateActorWithContent();
4071   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4072   Stage::GetCurrent().Add( actorDepth1Clip );
4073
4074   // Gather the call trace.
4075   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4076
4077   // Check we are writing to the color buffer.
4078   CheckColorMask( glAbstraction, true );
4079
4080   // Check the stencil buffer was enabled.
4081   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4082
4083   // Check the stencil buffer was cleared.
4084   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4085
4086   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4087   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4088   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4089   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4090
4091   END_TEST;
4092 }
4093
4094 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4095 {
4096   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4097   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4098   TestApplication application;
4099
4100   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4101   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4102   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4103   size_t startIndex = 0u;
4104
4105   // Create a clipping actor.
4106   Actor actorDepth1Clip = CreateActorWithContent();
4107   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4108   Stage::GetCurrent().Add( actorDepth1Clip );
4109
4110   // Gather the call trace.
4111   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4112
4113   // Check we are writing to the color buffer.
4114   CheckColorMask( glAbstraction, true );
4115
4116   // Check the stencil buffer was enabled.
4117   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4118
4119   // Check the stencil buffer was cleared.
4120   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4121
4122   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4123   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4124   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4125   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4126
4127   // Now disable the clipping
4128   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4129
4130   // Gather the call trace.
4131   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4132
4133   // Check the stencil buffer was disabled.
4134   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4135
4136   // Ensure all values in stencil-mask are set to 1.
4137   startIndex = 0u;
4138   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4139
4140   END_TEST;
4141 }
4142
4143
4144 int UtcDaliActorPropertyClippingNestedChildren(void)
4145 {
4146   // This test checks that a hierarchy of actors are clipped correctly by
4147   // writing to and reading from the correct bit-planes of the stencil buffer.
4148   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4149   TestApplication application;
4150   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4151   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4152   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4153
4154   // Create a clipping actor.
4155   Actor actorDepth1Clip = CreateActorWithContent();
4156   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4157   Stage::GetCurrent().Add( actorDepth1Clip );
4158
4159   // Create a child actor.
4160   Actor childDepth2 = CreateActorWithContent();
4161   actorDepth1Clip.Add( childDepth2 );
4162
4163   // Create another clipping actor.
4164   Actor childDepth2Clip = CreateActorWithContent();
4165   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4166   childDepth2.Add( childDepth2Clip );
4167
4168   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4169   // This tests the sort algorithm.
4170   Actor childDepth3 = CreateActorWithContent();
4171   childDepth2Clip.Add( childDepth3 );
4172   Actor childDepth4 = CreateActorWithContent();
4173   childDepth3.Add( childDepth4 );
4174
4175   // Gather the call trace.
4176   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4177
4178   // Check we are writing to the color buffer.
4179   CheckColorMask( glAbstraction, true );
4180
4181   // Check the stencil buffer was enabled.
4182   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4183
4184   // Perform the test twice, once for 2D layer, and once for 3D.
4185   for( unsigned int i = 0u ; i < 2u; ++i )
4186   {
4187     size_t startIndex = 0u;
4188
4189     // Check the stencil buffer was cleared.
4190     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4191
4192     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4193     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4194     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4195     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4196
4197     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4198     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4199     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4200
4201     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4202     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4203     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4204     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4205
4206     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4207     // (Both must be set to pass the check).
4208     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4209     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4210
4211     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4212     if( i == 0u )
4213     {
4214       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4215       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4216     }
4217   }
4218
4219   END_TEST;
4220 }
4221
4222 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4223 {
4224   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4225   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4226   TestApplication application;
4227
4228   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4229   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4230   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4231
4232   // Create a clipping actor.
4233   Actor actorDepth1Clip = CreateActorWithContent();
4234   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4235   Stage::GetCurrent().Add( actorDepth1Clip );
4236
4237   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4238   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4239
4240   // Gather the call trace.
4241   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4242
4243   // Check we are writing to the color buffer.
4244   CheckColorMask( glAbstraction, true );
4245
4246   // Check the stencil buffer was not enabled.
4247   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4248
4249   // Check stencil functions are not called.
4250   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4251   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4252   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4253
4254   END_TEST;
4255 }
4256
4257 int UtcDaliGetPropertyN(void)
4258 {
4259   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4260   TestApplication app;
4261
4262   Actor actor = Actor::New();
4263
4264   unsigned int propertyCount = actor.GetPropertyCount();
4265   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4266   END_TEST;
4267 }
4268
4269 int UtcDaliActorRaiseLower(void)
4270 {
4271   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4272
4273   TestApplication application;
4274
4275   Stage stage( Stage::GetCurrent() );
4276
4277   Actor actorA = Actor::New();
4278   Actor actorB = Actor::New();
4279   Actor actorC = Actor::New();
4280
4281   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4282   actorA.SetParentOrigin( ParentOrigin::CENTER );
4283
4284   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4285   actorB.SetParentOrigin( ParentOrigin::CENTER );
4286
4287   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4288   actorC.SetParentOrigin( ParentOrigin::CENTER );
4289
4290   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4291   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4292
4293   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4294   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4295
4296   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4297   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4298
4299   stage.Add( actorA );
4300   stage.Add( actorB );
4301   stage.Add( actorC );
4302
4303   ResetTouchCallbacks();
4304
4305   application.SendNotification();
4306   application.Render();
4307
4308   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4309   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4310   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4311
4312   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4313   // Only top actor will get touched.
4314   actorA.TouchSignal().Connect( TestTouchCallback );
4315   actorB.TouchSignal().Connect( TestTouchCallback2 );
4316   actorC.TouchSignal().Connect( TestTouchCallback3 );
4317
4318   Dali::Integration::Point point;
4319   point.SetDeviceId( 1 );
4320   point.SetState( PointState::DOWN );
4321   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4322   Dali::Integration::TouchEvent touchEvent;
4323   touchEvent.AddPoint( point );
4324
4325   application.ProcessEvent( touchEvent );
4326
4327   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4328   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4329   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4330
4331   ResetTouchCallbacks();
4332
4333   tet_printf( "Testing Raising of Actor\n" );
4334
4335   int preActorOrder( 0 );
4336   int postActorOrder( 0 );
4337
4338   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4339   value.Get( preActorOrder );
4340
4341   DevelActor::Raise( actorB );
4342   // Ensure sort order is calculated before next touch event
4343   application.SendNotification();
4344
4345   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4346   value.Get( postActorOrder );
4347
4348   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4349
4350   application.ProcessEvent( touchEvent );
4351
4352   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4353   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4354   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4355
4356   ResetTouchCallbacks();
4357
4358   tet_printf( "Testing Lowering of Actor\n" );
4359
4360   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4361   value.Get( preActorOrder );
4362
4363   DevelActor::Lower( actorB );
4364   application.SendNotification(); // ensure sort order calculated before next touch event
4365
4366   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4367   value.Get( postActorOrder );
4368
4369   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4370
4371   application.ProcessEvent( touchEvent );
4372
4373   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4374   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4375   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4376
4377   ResetTouchCallbacks();
4378
4379   END_TEST;
4380 }
4381
4382 int UtcDaliActorRaiseToTopLowerToBottom(void)
4383 {
4384   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4385
4386   TestApplication application;
4387
4388   Stage stage( Stage::GetCurrent() );
4389
4390   Actor actorA = Actor::New();
4391   Actor actorB = Actor::New();
4392   Actor actorC = Actor::New();
4393
4394   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4395   // enables checking of which actor the uniform is assigned too
4396   Shader shaderA = CreateShader();
4397   shaderA.RegisterProperty( "uRendererColor",1.f);
4398
4399   Shader shaderB = CreateShader();
4400   shaderB.RegisterProperty( "uRendererColor", 2.f );
4401
4402   Shader shaderC = CreateShader();
4403   shaderC.RegisterProperty( "uRendererColor", 3.f );
4404
4405   Geometry geometry = CreateQuadGeometry();
4406
4407   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4408   Renderer rendererA = Renderer::New(geometry, shaderA);
4409   actorA.AddRenderer(rendererA);
4410
4411   Renderer rendererB = Renderer::New(geometry, shaderB);
4412   actorB.AddRenderer(rendererB);
4413
4414   Renderer rendererC = Renderer::New(geometry, shaderC);
4415   actorC.AddRenderer(rendererC);
4416
4417   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4418   actorA.SetParentOrigin( ParentOrigin::CENTER );
4419
4420   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4421   actorB.SetParentOrigin( ParentOrigin::CENTER );
4422
4423   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4424   actorC.SetParentOrigin( ParentOrigin::CENTER );
4425
4426   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4427   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4428
4429   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4430   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4431
4432   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4433   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4434
4435   stage.Add( actorA );
4436   stage.Add( actorB );
4437   stage.Add( actorC );
4438
4439   ResetTouchCallbacks();
4440
4441   // Set up gl abstraction trace so can query the set uniform order
4442   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4443   glAbstraction.EnableSetUniformCallTrace(true);
4444   glAbstraction.ResetSetUniformCallStack();
4445
4446   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4447
4448   application.SendNotification();
4449   application.Render();
4450
4451   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4452
4453
4454   // Test order of uniforms in stack
4455   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4456   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4457   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4458
4459   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4460
4461   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4462
4463   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4464   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4465   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4466
4467   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4468   // Only top actor will get touched.
4469   actorA.TouchSignal().Connect( TestTouchCallback );
4470   actorB.TouchSignal().Connect( TestTouchCallback2 );
4471   actorC.TouchSignal().Connect( TestTouchCallback3 );
4472
4473   Dali::Integration::Point point;
4474   point.SetDeviceId( 1 );
4475   point.SetState( PointState::DOWN );
4476   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4477   Dali::Integration::TouchEvent touchEvent;
4478   touchEvent.AddPoint( point );
4479
4480   application.ProcessEvent( touchEvent );
4481
4482   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4483   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4484   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4485
4486   ResetTouchCallbacks();
4487
4488   tet_printf( "RaiseToTop ActorA\n" );
4489
4490   DevelActor::RaiseToTop( actorA );
4491   application.SendNotification(); // ensure sorting order is calculated before next touch event
4492
4493   application.ProcessEvent( touchEvent );
4494
4495   glAbstraction.ResetSetUniformCallStack();
4496   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4497
4498   application.SendNotification();
4499   application.Render();
4500
4501   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4502
4503   // Test order of uniforms in stack
4504   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4505   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4506   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4507
4508   tet_infoline( "Testing A above C and B at bottom\n" );
4509   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4510
4511   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4512
4513   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4514   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4515   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4516
4517   ResetTouchCallbacks();
4518
4519   tet_printf( "RaiseToTop ActorB\n" );
4520
4521   DevelActor::RaiseToTop( actorB );
4522   application.SendNotification(); // Ensure sort order is calculated before next touch event
4523
4524   application.ProcessEvent( touchEvent );
4525
4526   glAbstraction.ResetSetUniformCallStack();
4527   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4528
4529   application.SendNotification();
4530   application.Render();
4531
4532   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4533
4534   // Test order of uniforms in stack
4535   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4536   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4537   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4538
4539   tet_infoline( "Testing B above A and C at bottom\n" );
4540   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4541
4542   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4543
4544   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4545   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4546   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4547
4548   ResetTouchCallbacks();
4549
4550   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4551
4552   DevelActor::LowerToBottom( actorA );
4553   application.SendNotification();
4554   application.Render();
4555
4556   DevelActor::LowerToBottom( actorB );
4557   application.SendNotification();
4558   application.Render();
4559
4560   application.ProcessEvent( touchEvent );
4561
4562   glAbstraction.ResetSetUniformCallStack();
4563   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4564
4565   application.SendNotification();
4566   application.Render();
4567
4568   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4569
4570   // Test order of uniforms in stack
4571   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4572   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4573   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4574
4575   tet_infoline( "Testing C above A and B at bottom\n" );
4576   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4577
4578   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4579
4580   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4581   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4582   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4583
4584   ResetTouchCallbacks();
4585
4586   END_TEST;
4587 }
4588
4589 int UtcDaliActorRaiseAbove(void)
4590 {
4591   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4592
4593   TestApplication application;
4594
4595   Stage stage( Stage::GetCurrent() );
4596
4597   Actor actorA = Actor::New();
4598   Actor actorB = Actor::New();
4599   Actor actorC = Actor::New();
4600
4601   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4602   actorA.SetParentOrigin( ParentOrigin::CENTER );
4603
4604   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4605   actorB.SetParentOrigin( ParentOrigin::CENTER );
4606
4607   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4608   actorC.SetParentOrigin( ParentOrigin::CENTER );
4609
4610   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4611   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4612
4613   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4614   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4615
4616   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4617   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4618
4619   stage.Add( actorA );
4620   stage.Add( actorB );
4621   stage.Add( actorC );
4622
4623   ResetTouchCallbacks();
4624
4625   application.SendNotification();
4626   application.Render();
4627
4628   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4629   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4630   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4631
4632   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4633   // Only top actor will get touched.
4634   actorA.TouchSignal().Connect( TestTouchCallback );
4635   actorB.TouchSignal().Connect( TestTouchCallback2 );
4636   actorC.TouchSignal().Connect( TestTouchCallback3 );
4637
4638   Dali::Integration::Point point;
4639   point.SetDeviceId( 1 );
4640   point.SetState( PointState::DOWN );
4641   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4642   Dali::Integration::TouchEvent touchEvent;
4643   touchEvent.AddPoint( point );
4644
4645   application.ProcessEvent( touchEvent );
4646
4647   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4648   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4649   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4650
4651   ResetTouchCallbacks();
4652
4653   tet_printf( "Raise actor B Above Actor C\n" );
4654
4655   DevelActor::RaiseAbove( actorB, actorC );
4656   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4657   application.SendNotification();
4658
4659   application.ProcessEvent( touchEvent );
4660
4661   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4662   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4663   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4664
4665   ResetTouchCallbacks();
4666
4667   tet_printf( "Raise actor A Above Actor B\n" );
4668
4669   DevelActor::RaiseAbove( actorA, actorB );
4670
4671   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4672   application.SendNotification();
4673
4674   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4675
4676   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4677   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4678   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4679
4680   ResetTouchCallbacks();
4681
4682   END_TEST;
4683 }
4684
4685 int UtcDaliActorLowerBelow(void)
4686 {
4687   tet_infoline( "UtcDaliActor LowerBelow test \n" );
4688
4689   TestApplication application;
4690
4691   Stage stage( Stage::GetCurrent() );
4692
4693   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4694   // enables checking of which actor the uniform is assigned too
4695   Shader shaderA = CreateShader();
4696   shaderA.RegisterProperty( "uRendererColor",1.f);
4697
4698   Shader shaderB = CreateShader();
4699   shaderB.RegisterProperty( "uRendererColor", 2.f );
4700
4701   Shader shaderC = CreateShader();
4702   shaderC.RegisterProperty( "uRendererColor", 3.f );
4703
4704   Actor actorA = Actor::New();
4705   Actor actorB = Actor::New();
4706   Actor actorC = Actor::New();
4707
4708   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4709   Geometry geometry = CreateQuadGeometry();
4710
4711   Renderer rendererA = Renderer::New(geometry, shaderA);
4712   actorA.AddRenderer(rendererA);
4713
4714   Renderer rendererB = Renderer::New(geometry, shaderB);
4715   actorB.AddRenderer(rendererB);
4716
4717   Renderer rendererC = Renderer::New(geometry, shaderC);
4718   actorC.AddRenderer(rendererC);
4719
4720   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4721   actorA.SetParentOrigin( ParentOrigin::CENTER );
4722
4723   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4724   actorB.SetParentOrigin( ParentOrigin::CENTER );
4725
4726   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4727   actorC.SetParentOrigin( ParentOrigin::CENTER );
4728
4729   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4730   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4731
4732   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4733   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4734
4735   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4736   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4737
4738   stage.Add( actorA );
4739   stage.Add( actorB );
4740   stage.Add( actorC );
4741
4742   ResetTouchCallbacks();
4743
4744   // Set up gl abstraction trace so can query the set uniform order
4745   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4746   glAbstraction.EnableSetUniformCallTrace(true);
4747   glAbstraction.ResetSetUniformCallStack();
4748   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4749
4750   glAbstraction.ResetSetUniformCallStack();
4751
4752   application.SendNotification();
4753   application.Render();
4754
4755   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4756
4757   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4758
4759   // Test order of uniforms in stack
4760   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4761   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4762   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4763
4764   tet_infoline( "Testing C above B and A at bottom\n" );
4765   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4766
4767   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4768
4769   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4770   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4771   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4772
4773   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4774   // Only top actor will get touched.
4775   actorA.TouchSignal().Connect( TestTouchCallback );
4776   actorB.TouchSignal().Connect( TestTouchCallback2 );
4777   actorC.TouchSignal().Connect( TestTouchCallback3 );
4778
4779   Dali::Integration::Point point;
4780   point.SetDeviceId( 1 );
4781   point.SetState( PointState::DOWN );
4782   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4783   Dali::Integration::TouchEvent touchEvent;
4784   touchEvent.AddPoint( point );
4785
4786   tet_infoline( "UtcDaliActor Test Set up completed \n" );
4787
4788   application.ProcessEvent( touchEvent );
4789
4790   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4791   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4792   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4793
4794   ResetTouchCallbacks();
4795
4796   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" );
4797
4798   DevelActor::LowerBelow( actorC, actorB );
4799   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4800   application.SendNotification();
4801   application.Render();
4802
4803   application.ProcessEvent( touchEvent ); // touch event
4804
4805   glAbstraction.ResetSetUniformCallStack();
4806   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4807
4808   application.SendNotification();
4809   application.Render();
4810
4811   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4812
4813   // Test order of uniforms in stack
4814   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4815   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4816   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4817
4818   tet_infoline( "Testing B above A and C at bottom\n" );
4819   bool BAC = ( indexB > indexA) &&  ( indexA > indexC ); // B at TOP, then A then C at bottom
4820
4821   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4822
4823   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4824   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4825   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4826
4827   ResetTouchCallbacks();
4828
4829   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4830
4831   DevelActor::LowerBelow( actorB, actorC );
4832   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4833   application.SendNotification();
4834   application.Render();
4835
4836   application.ProcessEvent( touchEvent );
4837
4838   glAbstraction.ResetSetUniformCallStack();
4839   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4840
4841   application.Render();
4842   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4843
4844   // Test order of uniforms in stack
4845   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4846   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4847   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4848
4849   bool ACB = ( indexA > indexC) &&  ( indexC > indexB ); // A on TOP, then C then B at bottom
4850
4851   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4852
4853   DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4854   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4855   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4856
4857   ResetTouchCallbacks();
4858
4859   tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4860
4861   DevelActor::LowerBelow( actorA, actorC );
4862   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4863   application.SendNotification();
4864   application.Render();
4865
4866   application.ProcessEvent( touchEvent );
4867
4868   glAbstraction.ResetSetUniformCallStack();
4869   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4870
4871   application.Render();
4872   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4873
4874   // Test order of uniforms in stack
4875   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4876   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4877   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4878
4879   bool CAB = ( indexC > indexA) &&  ( indexA > indexB );
4880
4881   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4882
4883   END_TEST;
4884 }
4885
4886 int UtcDaliActorMaxSiblingOrder(void)
4887 {
4888   tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4889
4890   TestApplication application;
4891
4892   int testOrders[] = { 0,1,3,5,17,998, 999 };
4893   int resultingOrders[] = { 0,1,2,3,4,6,5 };
4894
4895   const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4896
4897   Stage stage( Stage::GetCurrent() );
4898
4899   Actor parent = Actor::New();
4900
4901   for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4902   {
4903     Actor newActor = Actor::New();
4904     newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4905     parent.Add( newActor );
4906   }
4907   stage.Add( parent );
4908
4909   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4910   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4911   {
4912     Actor sibling = parent.GetChildAt( index );
4913     int siblingOrder = 0;
4914     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4915     value.Get( siblingOrder );
4916     tet_printf( "%d, ", siblingOrder );
4917   }
4918   tet_printf( "\n" );
4919
4920   Actor sibling = parent.GetChildAt( 5 );
4921   DevelActor::RaiseToTop( sibling );
4922
4923   // Ensure sorting happens at end of Core::ProcessEvents()
4924   application.SendNotification();
4925   application.Render();
4926
4927   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4928   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4929   {
4930     Actor sibling = parent.GetChildAt( index );
4931     int siblingOrder = 0;
4932     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4933     value.Get( siblingOrder );
4934     tet_printf( "%d, ", siblingOrder );
4935     DALI_TEST_EQUALS( siblingOrder,  resultingOrders[ index] , TEST_LOCATION );
4936   }
4937
4938   tet_printf( "\n" );
4939
4940   END_TEST;
4941 }
4942
4943 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4944 {
4945   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4946
4947   TestApplication application;
4948
4949   Stage stage( Stage::GetCurrent() );
4950
4951   Actor parentA = Actor::New();
4952   Actor parentB = Actor::New();
4953   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4954   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4955   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4956   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4957
4958   parentA.SetAnchorPoint( AnchorPoint::CENTER );
4959   parentA.SetParentOrigin( ParentOrigin::CENTER );
4960
4961   parentB.SetAnchorPoint( AnchorPoint::CENTER );
4962   parentB.SetParentOrigin( ParentOrigin::CENTER );
4963
4964   stage.Add( parentA );
4965   stage.Add( parentB );
4966
4967   Actor actorA = Actor::New();
4968   Actor actorB = Actor::New();
4969   Actor actorC = Actor::New();
4970
4971   parentA.Add( actorA );
4972   parentA.Add( actorB );
4973
4974   tet_printf( "Actor C added to different parent from A and B \n" );
4975   parentB.Add( actorC );
4976
4977   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4978   actorA.SetParentOrigin( ParentOrigin::CENTER );
4979
4980   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4981   actorB.SetParentOrigin( ParentOrigin::CENTER );
4982
4983   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4984   actorC.SetParentOrigin( ParentOrigin::CENTER );
4985
4986   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4987   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4988
4989   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4990   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4991
4992   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4993   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4994
4995   ResetTouchCallbacks();
4996
4997   application.SendNotification();
4998   application.Render();
4999
5000   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5001   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5002   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5003
5004   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5005   // Only top actor will get touched.
5006   actorA.TouchSignal().Connect( TestTouchCallback );
5007   actorB.TouchSignal().Connect( TestTouchCallback2 );
5008   actorC.TouchSignal().Connect( TestTouchCallback3 );
5009
5010   Dali::Integration::Point point;
5011   point.SetDeviceId( 1 );
5012   point.SetState( PointState::DOWN );
5013   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5014   Dali::Integration::TouchEvent touchEvent;
5015   touchEvent.AddPoint( point );
5016
5017   application.ProcessEvent( touchEvent );
5018
5019   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5020   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5021   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5022
5023   ResetTouchCallbacks();
5024
5025   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5026
5027   DevelActor::RaiseAbove( actorA, actorC );
5028   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5029   application.SendNotification();
5030
5031   application.ProcessEvent( touchEvent ); // touch event
5032
5033   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5034   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5035   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5036
5037   ResetTouchCallbacks();
5038
5039   END_TEST;
5040 }
5041
5042 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5043 {
5044   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5045
5046   TestApplication application;
5047
5048   Stage stage( Stage::GetCurrent() );
5049
5050   Actor actorA = Actor::New();
5051   Actor actorB = Actor::New();
5052   Actor actorC = Actor::New();
5053
5054   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5055   actorA.SetParentOrigin( ParentOrigin::CENTER );
5056
5057   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5058   actorB.SetParentOrigin( ParentOrigin::CENTER );
5059
5060   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5061   actorC.SetParentOrigin( ParentOrigin::CENTER );
5062
5063   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5064   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5065
5066   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5067   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5068
5069   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5070   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5071
5072   ResetTouchCallbacks();
5073
5074   application.SendNotification();
5075   application.Render();
5076
5077   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5078   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5079   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5080
5081   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5082   // Only top actor will get touched.
5083   actorA.TouchSignal().Connect( TestTouchCallback );
5084   actorB.TouchSignal().Connect( TestTouchCallback2 );
5085   actorC.TouchSignal().Connect( TestTouchCallback3 );
5086
5087   Dali::Integration::Point point;
5088   point.SetDeviceId( 1 );
5089   point.SetState( PointState::DOWN );
5090   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5091   Dali::Integration::TouchEvent touchEvent;
5092   touchEvent.AddPoint( point );
5093
5094   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5095
5096   DevelActor::RaiseAbove( actorA, actorC );
5097   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5098   application.SendNotification();
5099
5100   application.ProcessEvent( touchEvent );
5101
5102   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5103
5104   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5105   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5106   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5107
5108   ResetTouchCallbacks();
5109
5110   stage.Add ( actorB );
5111   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5112   DevelActor::LowerBelow( actorA, actorC );
5113
5114   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5115   application.SendNotification();
5116   application.Render();
5117
5118   application.ProcessEvent( touchEvent );
5119
5120   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5121   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5122   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5123   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5124
5125   ResetTouchCallbacks();
5126
5127   tet_printf( "Adding Actor A to stage, will be on top\n" );
5128
5129   stage.Add ( actorA );
5130   application.SendNotification();
5131   application.Render();
5132
5133   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5134   DevelActor::RaiseAbove( actorB, actorC );
5135   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5136   application.SendNotification();
5137
5138   application.ProcessEvent( touchEvent );
5139
5140   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5141   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5142   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5143   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5144
5145   ResetTouchCallbacks();
5146
5147   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5148   DevelActor::LowerBelow( actorA, actorC );
5149   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5150   application.SendNotification();
5151
5152   application.ProcessEvent( touchEvent );
5153
5154   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5155   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5156   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5157   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5158
5159   ResetTouchCallbacks();
5160
5161   stage.Add ( actorC );
5162   DevelActor::RaiseAbove( actorA, actorC );
5163   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5164   application.SendNotification();
5165   application.Render();
5166
5167   application.ProcessEvent( touchEvent );
5168
5169   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5170   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5171   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5172   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5173
5174   END_TEST;
5175 }
5176
5177 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5178 {
5179   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5180
5181   TestApplication application;
5182
5183   Stage stage( Stage::GetCurrent() );
5184
5185   Actor actorA = Actor::New();
5186   Actor actorB = Actor::New();
5187   Actor actorC = Actor::New();
5188
5189   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5190   actorA.SetParentOrigin( ParentOrigin::CENTER );
5191
5192   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5193   actorB.SetParentOrigin( ParentOrigin::CENTER );
5194
5195   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5196   actorC.SetParentOrigin( ParentOrigin::CENTER );
5197
5198   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5199   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5200
5201   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5202   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5203
5204   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5205   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5206
5207   ResetTouchCallbacks();
5208
5209   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5210   // Only top actor will get touched.
5211   actorA.TouchSignal().Connect( TestTouchCallback );
5212   actorB.TouchSignal().Connect( TestTouchCallback2 );
5213   actorC.TouchSignal().Connect( TestTouchCallback3 );
5214
5215   Dali::Integration::Point point;
5216   point.SetDeviceId( 1 );
5217   point.SetState( PointState::DOWN );
5218   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5219   Dali::Integration::TouchEvent touchEvent;
5220   touchEvent.AddPoint( point );
5221
5222   stage.Add ( actorA );
5223   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5224   DevelActor::Raise( actorB );
5225
5226   application.SendNotification();
5227   application.Render();
5228
5229   application.ProcessEvent( touchEvent );
5230
5231   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5232
5233   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5234   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5235   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5236
5237   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5238   ResetTouchCallbacks();
5239
5240   DevelActor::Lower( actorC );
5241   // Sort actor tree before next touch event
5242   application.SendNotification();
5243   application.Render();
5244
5245   application.ProcessEvent( touchEvent );
5246
5247   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5248
5249   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5250   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5251   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5252   ResetTouchCallbacks();
5253
5254   tet_printf( "Lower actor C below B but C not parented\n" );
5255
5256   DevelActor::Lower( actorB );
5257   // Sort actor tree before next touch event
5258   application.SendNotification();
5259   application.Render();
5260
5261   application.ProcessEvent( touchEvent );
5262
5263   tet_printf( "Not parented so Lower should show no effect\n" );
5264
5265   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5266   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5267   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5268   ResetTouchCallbacks();
5269
5270   tet_printf( "Raise actor B to top\n" );
5271
5272   DevelActor::RaiseToTop( actorB );
5273   // Sort actor tree before next touch event
5274   application.SendNotification();
5275   application.Render();
5276
5277   application.ProcessEvent( touchEvent );
5278
5279   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5280
5281   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5282   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5283   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5284   ResetTouchCallbacks();
5285
5286   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5287
5288   stage.Add ( actorB );
5289
5290   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5291
5292   DevelActor::LowerToBottom( actorC );
5293   application.SendNotification();
5294   application.Render();
5295
5296   application.ProcessEvent( touchEvent );
5297
5298   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5299
5300   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5301   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5302   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5303   ResetTouchCallbacks();
5304
5305   END_TEST;
5306 }
5307
5308
5309 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5310 {
5311   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5312
5313   TestApplication application;
5314
5315   Stage stage( Stage::GetCurrent() );
5316
5317   Actor actorA = Actor::New();
5318   Actor actorB = Actor::New();
5319   Actor actorC = Actor::New();
5320
5321   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5322   actorA.SetParentOrigin( ParentOrigin::CENTER );
5323
5324   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5325   actorB.SetParentOrigin( ParentOrigin::CENTER );
5326
5327   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5328   actorC.SetParentOrigin( ParentOrigin::CENTER );
5329
5330   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5331   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5332
5333   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5334   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5335
5336   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5337   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5338
5339   stage.Add( actorA );
5340   stage.Add( actorB );
5341   stage.Add( actorC );
5342
5343   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5344   // Only top actor will get touched.
5345   actorA.TouchSignal().Connect( TestTouchCallback );
5346   actorB.TouchSignal().Connect( TestTouchCallback2 );
5347   actorC.TouchSignal().Connect( TestTouchCallback3 );
5348
5349   ResetTouchCallbacks();
5350
5351   application.SendNotification();
5352   application.Render();
5353
5354   Dali::Integration::Point point;
5355   point.SetDeviceId( 1 );
5356   point.SetState( PointState::DOWN );
5357   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5358   Dali::Integration::TouchEvent touchEvent;
5359   touchEvent.AddPoint( point );
5360
5361   application.ProcessEvent( touchEvent );
5362
5363   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5364   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5365   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5366
5367   ResetTouchCallbacks();
5368
5369   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5370
5371   DevelActor::RaiseAbove( actorA, actorA );
5372   application.SendNotification();
5373   application.Render();
5374
5375   application.ProcessEvent( touchEvent );
5376
5377   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5378
5379   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5380   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5381   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5382
5383   ResetTouchCallbacks();
5384
5385   DevelActor::RaiseAbove( actorA, actorC );
5386   application.SendNotification();
5387   application.Render();
5388
5389   application.ProcessEvent( touchEvent );
5390
5391   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5392   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5393   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5394   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5395
5396   END_TEST;
5397 }
5398
5399 int UtcDaliActorGetScreenPosition(void)
5400 {
5401   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5402
5403   TestApplication application;
5404
5405   Stage stage( Stage::GetCurrent() );
5406
5407   Actor actorA = Actor::New();
5408   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5409
5410   Vector2 size2( 10.0f, 20.0f );
5411   actorA.SetSize( size2 );
5412
5413   actorA.SetPosition( 0.f, 0.f );
5414
5415   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5416
5417   stage.Add( actorA );
5418
5419   application.SendNotification();
5420   application.Render();
5421
5422   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5423   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5424
5425   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
5426   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5427
5428   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5429   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5430
5431   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5432
5433   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5434
5435   application.SendNotification();
5436   application.Render();
5437
5438   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5439   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5440
5441   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
5442   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5443
5444   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5445   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5446
5447   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5448
5449   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5450
5451   application.SendNotification();
5452   application.Render();
5453
5454   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5455   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5456
5457   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
5458   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
5459
5460   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5461   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5462
5463   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5464
5465   actorA.SetPosition( 30.0, 0.0 );
5466
5467   application.SendNotification();
5468   application.Render();
5469
5470   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5471   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5472
5473   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
5474   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
5475
5476   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5477   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5478
5479   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5480
5481   actorA.SetPosition( 30.0, 420.0 );
5482
5483   application.SendNotification();
5484   application.Render();
5485
5486   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5487   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5488
5489   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5490   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
5491
5492   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
5493   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5494
5495
5496   END_TEST;
5497 }
5498
5499 int UtcDaliActorGetScreenPositionAfterScaling(void)
5500 {
5501   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5502
5503   TestApplication application;
5504
5505   Stage stage( Stage::GetCurrent() );
5506
5507   Actor actorA = Actor::New();
5508   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5509
5510   Vector2 size2( 10.0f, 20.0f );
5511   actorA.SetSize( size2 );
5512   actorA.SetScale( 1.5f );
5513   actorA.SetPosition( 0.f, 0.f );
5514
5515   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5516
5517   stage.Add( actorA );
5518
5519   application.SendNotification();
5520   application.Render();
5521
5522   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5523   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5524
5525   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5526   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5527
5528   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5529   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5530
5531   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5532
5533   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5534
5535   application.SendNotification();
5536   application.Render();
5537
5538   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5539   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5540
5541   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5542   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5543
5544   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
5545   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5546
5547   END_TEST;
5548 }
5549
5550 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5551 {
5552   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5553
5554   TestApplication application;
5555
5556   Stage stage( Stage::GetCurrent() );
5557
5558   Actor actorA = Actor::New();
5559   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5560   actorA.SetParentOrigin( ParentOrigin::CENTER );
5561   Vector2 size2( 10.0f, 20.0f );
5562   actorA.SetSize( size2 );
5563   actorA.SetPosition( 0.f, 0.f );
5564
5565   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5566
5567   stage.Add( actorA );
5568
5569   application.SendNotification();
5570   application.Render();
5571
5572   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5573   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5574
5575   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5576   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5577
5578   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
5579   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
5580
5581   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5582
5583   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5584   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5585
5586   application.SendNotification();
5587   application.Render();
5588
5589   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5590   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5591
5592   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5593   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5594
5595   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5596   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5597
5598   END_TEST;
5599   END_TEST;
5600 }
5601
5602 int UtcDaliActorGetScreenPositionWithChildActors(void)
5603 {
5604   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5605
5606   TestApplication application;
5607
5608   Stage stage( Stage::GetCurrent() );
5609
5610   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5611
5612   Actor actorA = Actor::New();
5613   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5614   actorA.SetParentOrigin( ParentOrigin::CENTER );
5615   Vector2 size1( 10.0f, 20.0f );
5616   actorA.SetSize( size1 );
5617   actorA.SetPosition( 0.f, 0.f );
5618
5619   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5620
5621   Actor parentActorA = Actor::New();
5622   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5623   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5624   Vector2 size2( 30.0f, 60.0f );
5625   parentActorA.SetSize( size2 );
5626   parentActorA.SetPosition( 0.f, 0.f );
5627
5628   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5629
5630   stage.Add( parentActorA );
5631   parentActorA.Add ( actorA );
5632
5633   application.SendNotification();
5634   application.Render();
5635
5636   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5637   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5638
5639   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5640   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5641
5642   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
5643   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
5644
5645   tet_infoline( "Test 2\n");
5646
5647   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5648
5649   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5650   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5651
5652   application.SendNotification();
5653   application.Render();
5654
5655   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5656   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5657
5658   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5659   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5660
5661   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
5662   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
5663
5664   END_TEST;
5665 }
5666
5667 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5668 {
5669   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5670
5671   TestApplication application;
5672
5673   Stage stage( Stage::GetCurrent() );
5674
5675   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5676
5677   Actor actorA = Actor::New();
5678   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5679   actorA.SetParentOrigin( ParentOrigin::CENTER );
5680   Vector2 size1( 10.0f, 20.0f );
5681   actorA.SetSize( size1 );
5682   actorA.SetPosition( 0.f, 0.f );
5683
5684   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5685
5686   Actor parentActorA = Actor::New();
5687   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5688   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5689   Vector2 size2( 30.0f, 60.0f );
5690   parentActorA.SetSize( size2 );
5691   parentActorA.SetPosition( 0.f, 0.f );
5692
5693   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5694
5695   Actor grandParentActorA = Actor::New();
5696   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5697   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5698   Vector2 size3( 60.0f, 120.0f );
5699   grandParentActorA.SetSize( size3 );
5700   grandParentActorA.SetPosition( 0.f, 0.f );
5701
5702   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5703
5704   stage.Add( grandParentActorA );
5705   grandParentActorA.Add ( parentActorA );
5706
5707   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5708
5709   parentActorA.Add ( actorA );
5710
5711   application.SendNotification();
5712   application.Render();
5713
5714   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5715   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5716
5717   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5718   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5719
5720   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
5721   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
5722
5723   END_TEST;
5724 }
5725
5726 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5727 {
5728   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5729
5730   TestApplication application;
5731
5732   Stage stage( Stage::GetCurrent() );
5733
5734   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5735
5736   Actor actorA = Actor::New();
5737   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5738   actorA.SetParentOrigin( ParentOrigin::CENTER );
5739   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5740   actorA.SetSize( 10.0f, 20.0f );
5741   stage.Add( actorA );
5742
5743   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5744
5745   Actor actorB = Actor::New();
5746   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5747   actorB.SetParentOrigin( ParentOrigin::CENTER );
5748   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5749   Vector2 actorBSize( 30.0f, 60.0f );
5750   actorB.SetSize( actorBSize );
5751   stage.Add( actorB );
5752
5753   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5754
5755   Actor actorC = Actor::New();
5756   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5757   actorC.SetParentOrigin( ParentOrigin::CENTER );
5758   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5759   Vector2 actorCSize( 60.0f, 120.0f );
5760   actorC.SetSize( actorCSize );
5761   stage.Add( actorC );
5762
5763   application.SendNotification();
5764   application.Render();
5765
5766   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5767
5768   Vector2 center( stage.GetSize() * 0.5f );
5769
5770   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5771   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5772   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5773
5774   tet_infoline( "Add scale to all actors" );
5775
5776   actorA.SetScale( 2.0f );
5777   actorB.SetScale( 2.0f );
5778   actorC.SetScale( 2.0f );
5779
5780   application.SendNotification();
5781   application.Render();
5782
5783   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5784   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5785   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5786
5787   END_TEST;
5788 }
5789
5790 int utcDaliActorPositionUsesAnchorPoint(void)
5791 {
5792   TestApplication application;
5793   tet_infoline( "Check default behaviour\n" );
5794
5795   Actor actor = Actor::New();
5796   actor.SetParentOrigin( ParentOrigin::CENTER );
5797   actor.SetAnchorPoint( AnchorPoint::CENTER );
5798   actor.SetSize( 100.0f, 100.0f );
5799   Stage::GetCurrent().Add( actor );
5800
5801   application.SendNotification();
5802   application.Render();
5803
5804   tet_infoline( "Check that the world position is in the center\n" );
5805   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5806
5807   tet_infoline( "Set the position uses anchor point property to false\n" );
5808   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5809
5810   application.SendNotification();
5811   application.Render();
5812
5813   tet_infoline( "Check that the world position has changed appropriately\n" );
5814   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5815
5816   END_TEST;
5817 }
5818
5819 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5820 {
5821   TestApplication application;
5822   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5823
5824   Actor actor = Actor::New();
5825   actor.SetParentOrigin( ParentOrigin::CENTER );
5826   actor.SetAnchorPoint( AnchorPoint::CENTER );
5827   actor.SetSize( 100.0f, 100.0f );
5828   actor.SetScale( 2.0f );
5829   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5830   Stage::GetCurrent().Add( actor );
5831
5832   application.SendNotification();
5833   application.Render();
5834
5835   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5836   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5837
5838   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5839   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5840   application.SendNotification();
5841   application.Render();
5842   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5843
5844   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5845   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5846   application.SendNotification();
5847   application.Render();
5848   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5849
5850   END_TEST;
5851 }
5852
5853 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5854 {
5855   TestApplication application;
5856   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5857
5858   Actor actor = Actor::New();
5859   actor.SetParentOrigin( ParentOrigin::CENTER );
5860   actor.SetAnchorPoint( AnchorPoint::CENTER );
5861   actor.SetSize( 100.0f, 100.0f );
5862   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5863   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5864   Stage::GetCurrent().Add( actor );
5865
5866   application.SendNotification();
5867   application.Render();
5868
5869   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5870   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5871
5872   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5873   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5874   application.SendNotification();
5875   application.Render();
5876   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5877
5878   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5879   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5880   application.SendNotification();
5881   application.Render();
5882   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5883
5884   END_TEST;
5885 }
5886
5887 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5888 {
5889   TestApplication application;
5890   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5891
5892   Actor actor = Actor::New();
5893   actor.SetParentOrigin( ParentOrigin::CENTER );
5894   actor.SetAnchorPoint( AnchorPoint::CENTER );
5895   actor.SetSize( 100.0f, 100.0f );
5896   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5897   actor.SetScale( 2.0f );
5898   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5899   Stage::GetCurrent().Add( actor );
5900
5901   application.SendNotification();
5902   application.Render();
5903
5904   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5905   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5906
5907   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5908   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5909   application.SendNotification();
5910   application.Render();
5911   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5912
5913   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5914   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5915   application.SendNotification();
5916   application.Render();
5917   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5918
5919   END_TEST;
5920 }
5921
5922 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5923 {
5924   TestApplication application;
5925   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5926
5927   Actor parent = Actor::New();
5928
5929   Stage::GetCurrent().Add( parent );
5930   Vector2 stageSize( Stage::GetCurrent().GetSize() );
5931
5932   Actor actor = Actor::New();
5933   actor.SetParentOrigin( ParentOrigin::CENTER );
5934   actor.SetAnchorPoint( AnchorPoint::CENTER );
5935   actor.SetSize( 100.0f, 100.0f );
5936   actor.SetInheritScale( false );
5937   actor.SetInheritOrientation( false );
5938   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5939   parent.Add( actor );
5940
5941   application.SendNotification();
5942   application.Render();
5943
5944   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5945
5946   tet_infoline( "Check the world position is in the right place\n" );
5947   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5948
5949   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5950   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5951   application.SendNotification();
5952   application.Render();
5953   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5954
5955   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5956   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5957   application.SendNotification();
5958   application.Render();
5959   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5960
5961   END_TEST;
5962 }
5963
5964 int utcDaliActorVisibilityChangeSignalSelf(void)
5965 {
5966   TestApplication application;
5967   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5968
5969   Actor actor = Actor::New();
5970
5971   VisibilityChangedFunctorData data;
5972   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5973
5974   actor.SetVisible( false );
5975
5976   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5977
5978   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5979   data.Reset();
5980
5981   actor.SetVisible( false );
5982   data.Check( false /* not called */, TEST_LOCATION );
5983
5984   tet_infoline( "Change the visibility using properties, ensure called" );
5985   data.Reset();
5986
5987   actor.SetProperty( Actor::Property::VISIBLE, true );
5988   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5989
5990   tet_infoline( "Set the visibility to current using properties, ensure not called" );
5991   data.Reset();
5992
5993   actor.SetProperty( Actor::Property::VISIBLE, true );
5994   data.Check( false /* not called */, TEST_LOCATION );
5995
5996   END_TEST;
5997 }
5998
5999 int utcDaliActorVisibilityChangeSignalChildren(void)
6000 {
6001   TestApplication application;
6002   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6003
6004   Actor parent = Actor::New();
6005   Actor child = Actor::New();
6006   parent.Add( child );
6007
6008   Actor grandChild = Actor::New();
6009   child.Add( grandChild );
6010
6011   VisibilityChangedFunctorData parentData;
6012   VisibilityChangedFunctorData childData;
6013   VisibilityChangedFunctorData grandChildData;
6014
6015   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6016   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6017   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6018
6019   parent.SetVisible( false );
6020   parentData.Check( false /* not called */, TEST_LOCATION );
6021   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6022   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6023
6024   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6025   parentData.Reset();
6026   childData.Reset();
6027   grandChildData.Reset();
6028
6029   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6030
6031   parent.SetVisible( true );
6032   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6033   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6034   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6035
6036   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6037   parentData.Reset();
6038   childData.Reset();
6039   grandChildData.Reset();
6040
6041   parent.SetVisible( true );
6042   parentData.Check( false /* not called */, TEST_LOCATION );
6043   childData.Check( false /* not called */, TEST_LOCATION );
6044   grandChildData.Check( false /* not called */, TEST_LOCATION );
6045
6046   END_TEST;
6047 }
6048
6049 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6050 {
6051   TestApplication application;
6052   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6053
6054   Actor actor = Actor::New();
6055   Stage::GetCurrent().Add( actor );
6056
6057   application.SendNotification();
6058   application.Render();
6059
6060   VisibilityChangedFunctorData data;
6061   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6062
6063   Animation animation = Animation::New( 1.0f );
6064   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6065
6066   data.Check( false, TEST_LOCATION );
6067   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6068   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION );
6069
6070   tet_infoline( "Play the animation and check the property value" );
6071   animation.Play();
6072
6073   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6074   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6075
6076   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6077   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION );
6078
6079   application.SendNotification();
6080   application.Render( 1100 ); // After the animation
6081
6082   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), false, TEST_LOCATION );
6083
6084   END_TEST;
6085 }