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