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