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