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