[dali_1.9.21] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2020 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.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == 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.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == 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::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
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.GetProperty< int >( Actor::Property::ID ) != second.GetProperty< int >( Actor::Property::ID ));
360   DALI_TEST_CHECK(second.GetProperty< int >( Actor::Property::ID ) != third.GetProperty< int >( Actor::Property::ID ));
361   END_TEST;
362 }
363
364 int UtcDaliActorIsRoot(void)
365 {
366   TestApplication application;
367
368   Actor actor = Actor::New();
369   DALI_TEST_CHECK(!actor.GetProperty< bool >( Actor::Property::IS_ROOT ));
370
371   // get the root layer
372   actor = application.GetScene().GetLayer( 0 );
373   DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_ROOT ) );
374   END_TEST;
375 }
376
377 int UtcDaliActorOnStage(void)
378 {
379   TestApplication application;
380
381   Actor actor = Actor::New();
382   DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
383
384   // get the root layer
385   actor = application.GetScene().GetLayer( 0 );
386   DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
387   END_TEST;
388 }
389
390 int UtcDaliActorIsLayer(void)
391 {
392   TestApplication application;
393
394   Actor actor = Actor::New();
395   DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
396
397   // get the root layer
398   actor = application.GetScene().GetLayer( 0 );
399   DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
400   END_TEST;
401 }
402
403 int UtcDaliActorGetLayer(void)
404 {
405   TestApplication application;
406
407   Actor actor = Actor::New();
408   application.GetScene().Add(actor);
409   Layer layer = actor.GetLayer();
410
411   DALI_TEST_CHECK(layer);
412
413   // get the root layers layer
414   actor = application.GetScene().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( application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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( Actor::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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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 >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2132
2133   actor.SetProperty( Actor::Property::OPACITY, 0.4f);
2134   // flush the queue and render once
2135   application.SendNotification();
2136   application.Render();
2137   DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2138
2139   // change opacity, actor is on stage to change is not immediate
2140   actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) + 0.1f );
2141   // flush the queue and render once
2142   application.SendNotification();
2143   application.Render();
2144   DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2145
2146   // put actor on stage
2147   application.GetScene().Add( actor );
2148
2149   // change opacity, actor is on stage to change is not immediate
2150   actor.SetProperty( Actor::Property::OPACITY, 0.9f );
2151   DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::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 >( Actor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2156
2157   // change opacity, actor is on stage to change is not immediate
2158   actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) - 0.9f );
2159   // flush the queue and render once
2160   application.SendNotification();
2161   application.Render();
2162   DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::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 >( Actor::Property::OPACITY ) != 0.5f);
2172
2173   actor.SetProperty( Actor::Property::OPACITY,0.5f);
2174   // flush the queue and render once
2175   application.SendNotification();
2176   application.Render();
2177   DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::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   application.GetScene().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   application.GetScene().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( Actor::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   application.GetScene().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   application.GetScene().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.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
2473   DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == true);
2474
2475   actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, false );
2476   DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == 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.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == 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   application.GetScene().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   application.GetScene().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 = application.GetScene().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( application.GetScene().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 = application.GetScene().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( application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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   application.GetScene().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.GetProperty< int >( Actor::Property::ID ) );
2794   DALI_TEST_CHECK( found == parent );
2795
2796   found = parent.FindChildById( first.GetProperty< int >( Actor::Property::ID ) );
2797   DALI_TEST_CHECK( found == first );
2798
2799   found = parent.FindChildById( second.GetProperty< int >( Actor::Property::ID ) );
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   application.GetScene().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 application;
2886   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2887
2888   Actor a = Actor::New();
2889
2890   application.GetScene().Add(a);
2891   application.SendNotification();
2892   application.Render(0);
2893   application.SendNotification();
2894   application.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   application.SendNotification();
2900   application.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   application.SendNotification();
2906   application.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 application;
2915   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2916
2917   application.SendNotification();
2918   application.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   application.GetGlAbstraction().SetNextTextureIds( ids );
2925
2926   Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2927   Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2928   Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2929   Actor a = CreateRenderableActor( imageA );
2930   Actor b = CreateRenderableActor( imageB );
2931   Actor c = CreateRenderableActor( imageC );
2932
2933   application.SendNotification();
2934   application.Render(1);
2935
2936   //Textures are bound when first created. Clear bound textures vector
2937   application.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   application.GetScene().Add(a);
2944   application.GetScene().Add(b);
2945   application.GetScene().Add(c);
2946
2947   application.SendNotification();
2948   application.Render(1);
2949
2950   // Should be 3 textures changes.
2951   const std::vector<GLuint>& boundTextures = application.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   application.GetGlAbstraction().ClearBoundTextures();
2968
2969   application.SendNotification();
2970   application.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 application;
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   application.GetScene().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   application.SendNotification();
3012   application.Render(0);
3013   application.Render();
3014   application.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 application;
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   application.GetScene().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   application.GetScene().Add( child );
3057
3058   application.SendNotification();
3059   application.Render(0);
3060   application.Render();
3061   application.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 application;
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   application.GetScene().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   application.GetScene().Add( child );
3095
3096   application.SendNotification();
3097   application.Render(0);
3098   application.Render();
3099   application.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 application;
3108   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3109
3110   Actor parent = Actor::New();
3111   parent.SetProperty( Actor::Property::OPACITY, 0.7f );
3112   application.GetScene().Add( parent );
3113
3114   Actor child = Actor::New();
3115   Constraint opacityConstraint = Constraint::New<float>( child, Actor::Property::OPACITY, EqualToConstraint() );
3116   opacityConstraint.AddSource( Source( parent, Actor::Property::OPACITY ) );
3117   opacityConstraint.Apply();
3118
3119   application.GetScene().Add( child );
3120
3121   application.SendNotification();
3122   application.Render(0);
3123   application.Render();
3124   application.SendNotification();
3125
3126   DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3127
3128   parent.SetProperty( Actor::Property::OPACITY, 0.3f );
3129
3130   application.SendNotification();
3131   application.Render(0);
3132   application.Render();
3133   application.SendNotification();
3134
3135   DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3136
3137   END_TEST;
3138 }
3139
3140 int UtcDaliActorUnparent(void)
3141 {
3142   TestApplication application;
3143   tet_infoline(" UtcDaliActorUnparent");
3144
3145   Actor parent = Actor::New();
3146   application.GetScene().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 application;
3191   tet_infoline(" UtcDaliActorGetChildAt");
3192
3193   Actor parent = Actor::New();
3194   application.GetScene().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 application;
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",                  Actor::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 application;
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 application;
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 application;
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 application;
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 application;
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 application;
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 application;
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 application;
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 application;
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 application;
3496
3497   Actor actor = Actor::New();
3498
3499   // Add actor to stage
3500   application.GetScene().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   application.SendNotification();
3509   application.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 application;
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 application;
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 application;
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   application.GetScene().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   Integration::Scene stage( application.GetScene() );
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().GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3650
3651   //Test actors return depth -1 when not connected to the tree
3652   DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3653   DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3654   DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3655   DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3656   DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3657   DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), 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.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3669   DALI_TEST_EQUALS( 2, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3670   DALI_TEST_EQUALS( 2, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3671   DALI_TEST_EQUALS( 3, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3672   DALI_TEST_EQUALS( 3, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3673   DALI_TEST_EQUALS( 3, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), 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.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3679   DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3680   DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), 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.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3686   DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3687   DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3688   DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3689   DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3690   DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), 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 UtcDaliActorAddRendererN01(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 UtcDaliActorAddRendererN02(void)
3906 {
3907   tet_infoline( "UtcDaliActorAddRendererN02" );
3908
3909   Actor actor;
3910   Renderer renderer;
3911
3912   {
3913     TestApplication application;
3914
3915     Geometry geometry = CreateQuadGeometry();
3916     Shader shader = CreateShader();
3917     renderer = Renderer::New( geometry, shader );
3918
3919     actor = Actor::New();
3920   }
3921
3922   // try illegal AddRenderer
3923   try
3924   {
3925     actor.AddRenderer( renderer );
3926     tet_printf( "Assertion test failed - no Exception\n" );
3927     tet_result( TET_FAIL );
3928   }
3929   catch( Dali::DaliException& e )
3930   {
3931     DALI_TEST_PRINT_ASSERT( e );
3932     DALI_TEST_ASSERT( e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION );
3933   }
3934   catch(...)
3935   {
3936     tet_printf( "Assertion test failed - wrong Exception\n" );
3937     tet_result( TET_FAIL );
3938   }
3939
3940   END_TEST;
3941 }
3942
3943 int UtcDaliActorAddRendererOnStage(void)
3944 {
3945   tet_infoline("Testing Actor::AddRenderer");
3946   TestApplication application;
3947
3948   Actor actor = Actor::New();
3949   application.GetScene().Add(actor);
3950
3951   application.SendNotification();
3952   application.Render(0);
3953
3954   Geometry geometry = CreateQuadGeometry();
3955   Shader shader = CreateShader();
3956   Renderer renderer = Renderer::New(geometry, shader);
3957
3958   application.SendNotification();
3959   application.Render(0);
3960
3961   try
3962   {
3963     actor.AddRenderer( renderer );
3964     tet_result(TET_PASS);
3965   }
3966   catch(...)
3967   {
3968     tet_result(TET_FAIL);
3969   }
3970
3971   END_TEST;
3972 }
3973
3974 int UtcDaliActorRemoveRendererP1(void)
3975 {
3976   tet_infoline("Testing Actor::RemoveRenderer");
3977   TestApplication application;
3978
3979   Actor actor = Actor::New();
3980
3981   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3982
3983   {
3984     Geometry geometry = CreateQuadGeometry();
3985     Shader shader = CreateShader();
3986     Renderer renderer = Renderer::New(geometry, shader);
3987
3988     actor.AddRenderer( renderer );
3989     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3990     DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3991
3992     application.SendNotification();
3993     application.Render();
3994   }
3995
3996   {
3997     Renderer renderer = actor.GetRendererAt(0);
3998     actor.RemoveRenderer(renderer);
3999     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4000
4001     application.SendNotification();
4002     application.Render();
4003   }
4004
4005   // Call one final time to ensure that the renderer is actually removed after
4006   // the handle goes out of scope, and excercises the deletion code path in
4007   // scene graph and render.
4008   application.SendNotification();
4009   application.Render();
4010
4011   END_TEST;
4012 }
4013
4014 int UtcDaliActorRemoveRendererP2(void)
4015 {
4016   tet_infoline("Testing Actor::RemoveRenderer");
4017   TestApplication application;
4018
4019   Actor actor = Actor::New();
4020
4021   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4022
4023   Geometry geometry = CreateQuadGeometry();
4024   Shader shader = CreateShader();
4025   Renderer renderer = Renderer::New(geometry, shader);
4026
4027   actor.AddRenderer( renderer );
4028   application.SendNotification();
4029   application.Render();
4030
4031   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4032   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4033
4034   actor.RemoveRenderer(0);
4035   application.SendNotification();
4036   application.Render();
4037
4038   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4039
4040   // Shut down whilst holding onto the renderer handle.
4041   END_TEST;
4042 }
4043
4044
4045 int UtcDaliActorRemoveRendererN(void)
4046 {
4047   tet_infoline("Testing Actor::RemoveRenderer");
4048   TestApplication application;
4049
4050   Actor actor = Actor::New();
4051
4052   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4053
4054   Geometry geometry = CreateQuadGeometry();
4055   Shader shader = CreateShader();
4056   Renderer renderer = Renderer::New(geometry, shader);
4057
4058   actor.AddRenderer( renderer );
4059   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4060   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4061
4062   actor.RemoveRenderer(10);
4063   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4064   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4065
4066   END_TEST;
4067 }
4068
4069 // Clipping test helper functions:
4070 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4071 {
4072   Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
4073   Actor actor = CreateRenderableActor( image );
4074
4075   // Setup dimensions and position so actor is not skipped by culling.
4076   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4077   actor.SetProperty( Actor::Property::SIZE, Vector2( width, height ) );
4078   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4079   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4080
4081   return actor;
4082 }
4083
4084 Actor CreateActorWithContent16x16()
4085 {
4086   return CreateActorWithContent( 16, 16 );
4087 }
4088
4089 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4090 {
4091   enabledDisableTrace.Reset();
4092   stencilTrace.Reset();
4093   enabledDisableTrace.Enable( true );
4094   stencilTrace.Enable( true );
4095
4096   application.SendNotification();
4097   application.Render();
4098
4099   enabledDisableTrace.Enable( false );
4100   stencilTrace.Enable( false );
4101 }
4102
4103 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4104 {
4105   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4106
4107   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
4108   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4109   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
4110   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4111 }
4112
4113 int UtcDaliActorPropertyClippingP(void)
4114 {
4115   // This test checks the clippingMode property.
4116   tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4117   TestApplication application;
4118
4119   Actor actor = Actor::New();
4120
4121   // Check default clippingEnabled value.
4122   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4123
4124   int value = 0;
4125   bool getValueResult = getValue.Get( value );
4126   DALI_TEST_CHECK( getValueResult );
4127
4128   if( getValueResult )
4129   {
4130     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4131   }
4132
4133   // Check setting the property to the stencil mode.
4134   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4135
4136   // Check the new value was set.
4137   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4138   getValueResult = getValue.Get( value );
4139   DALI_TEST_CHECK( getValueResult );
4140
4141   if( getValueResult )
4142   {
4143     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4144   }
4145
4146   // Check setting the property to the scissor mode.
4147   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4148
4149   // Check the new value was set.
4150   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4151   getValueResult = getValue.Get( value );
4152   DALI_TEST_CHECK( getValueResult );
4153
4154   if( getValueResult )
4155   {
4156     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4157   }
4158   END_TEST;
4159 }
4160
4161 int UtcDaliActorPropertyClippingN(void)
4162 {
4163   // Negative test case for Clipping.
4164   tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4165   TestApplication application;
4166
4167   Actor actor = Actor::New();
4168
4169   // Check default clippingEnabled value.
4170   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4171
4172   int value = 0;
4173   bool getValueResult = getValue.Get( value );
4174   DALI_TEST_CHECK( getValueResult );
4175
4176   if( getValueResult )
4177   {
4178     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4179   }
4180
4181   // Check setting an invalid property value won't change the current property value.
4182   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4183
4184   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4185   getValueResult = getValue.Get( value );
4186   DALI_TEST_CHECK( getValueResult );
4187
4188   if( getValueResult )
4189   {
4190     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4191   }
4192
4193   END_TEST;
4194 }
4195
4196 int UtcDaliActorPropertyClippingActor(void)
4197 {
4198   // This test checks that an actor is correctly setup for clipping.
4199   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4200   TestApplication application;
4201
4202   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4203   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4204   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4205   size_t startIndex = 0u;
4206
4207   // Create a clipping actor.
4208   Actor actorDepth1Clip = CreateActorWithContent16x16();
4209   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4210   application.GetScene().Add( actorDepth1Clip );
4211
4212   // Gather the call trace.
4213   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4214
4215   // Check we are writing to the color buffer.
4216   CheckColorMask( glAbstraction, true );
4217
4218   // Check the stencil buffer was enabled.
4219   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4220
4221   // Check the stencil buffer was cleared.
4222   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4223
4224   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4225   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4226   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4227   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4228
4229   END_TEST;
4230 }
4231
4232 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4233 {
4234   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4235   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4236   TestApplication application;
4237
4238   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4239   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4240   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4241   size_t startIndex = 0u;
4242
4243   // Create a clipping actor.
4244   Actor actorDepth1Clip = CreateActorWithContent16x16();
4245   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4246   application.GetScene().Add( actorDepth1Clip );
4247
4248   // Gather the call trace.
4249   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4250
4251   // Check we are writing to the color buffer.
4252   CheckColorMask( glAbstraction, true );
4253
4254   // Check the stencil buffer was enabled.
4255   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4256
4257   // Check the stencil buffer was cleared.
4258   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4259
4260   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4261   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4262   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4263   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4264
4265   // Now disable the clipping
4266   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4267
4268   // Gather the call trace.
4269   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4270
4271   // Check the stencil buffer was disabled.
4272   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4273
4274   // Ensure all values in stencil-mask are set to 1.
4275   startIndex = 0u;
4276   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4277
4278   END_TEST;
4279 }
4280
4281 int UtcDaliActorPropertyClippingNestedChildren(void)
4282 {
4283   // This test checks that a hierarchy of actors are clipped correctly by
4284   // writing to and reading from the correct bit-planes of the stencil buffer.
4285   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4286   TestApplication application;
4287   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4288   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4289   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4290
4291   // Create a clipping actor.
4292   Actor actorDepth1Clip = CreateActorWithContent16x16();
4293   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4294   application.GetScene().Add( actorDepth1Clip );
4295
4296   // Create a child actor.
4297   Actor childDepth2 = CreateActorWithContent16x16();
4298   actorDepth1Clip.Add( childDepth2 );
4299
4300   // Create another clipping actor.
4301   Actor childDepth2Clip = CreateActorWithContent16x16();
4302   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4303   childDepth2.Add( childDepth2Clip );
4304
4305   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4306   // This tests the sort algorithm.
4307   Actor childDepth3 = CreateActorWithContent16x16();
4308   childDepth2Clip.Add( childDepth3 );
4309   Actor childDepth4 = CreateActorWithContent16x16();
4310   childDepth3.Add( childDepth4 );
4311
4312   // Gather the call trace.
4313   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4314
4315   // Check we are writing to the color buffer.
4316   CheckColorMask( glAbstraction, true );
4317
4318   // Check the stencil buffer was enabled.
4319   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4320
4321   // Perform the test twice, once for 2D layer, and once for 3D.
4322   for( unsigned int i = 0u ; i < 2u; ++i )
4323   {
4324     size_t startIndex = 0u;
4325
4326     // Check the stencil buffer was cleared.
4327     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4328
4329     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4330     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4331     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4332     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4333
4334     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4335     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4336     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4337
4338     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4339     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4340     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4341     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4342
4343     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4344     // (Both must be set to pass the check).
4345     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4346     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4347
4348     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4349     if( i == 0u )
4350     {
4351       application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
4352       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4353     }
4354   }
4355
4356   END_TEST;
4357 }
4358
4359 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4360 {
4361   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4362   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4363   TestApplication application;
4364   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4365   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4366
4367   /* We create a small tree of actors as follows:
4368
4369                            A
4370                           / \
4371      Clipping enabled -> B   D
4372                          |   |
4373                          C   E
4374
4375      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4376   */
4377   Actor actors[5];
4378   for( int i = 0; i < 5; ++i )
4379   {
4380     Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u );
4381     Actor actor = CreateRenderableActor( image );
4382
4383     // Setup dimensions and position so actor is not skipped by culling.
4384     actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4385     actor.SetProperty( Actor::Property::SIZE, Vector2( 16.0f, 16.0f ) );
4386
4387     if( i == 0 )
4388     {
4389       actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4390     }
4391     else
4392     {
4393       float b = i > 2 ? 1.0f : -1.0f;
4394       actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4395     }
4396
4397     actors[i] = actor;
4398   }
4399
4400   // Enable clipping on the actor at the top of the left branch.
4401   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4402
4403   // Build the scene graph.
4404   application.GetScene().Add( actors[0] );
4405
4406   // Left branch:
4407   actors[0].Add( actors[1] );
4408   actors[1].Add( actors[2] );
4409
4410   // Right branch:
4411   actors[0].Add( actors[3] );
4412   actors[3].Add( actors[4] );
4413
4414   // Gather the call trace.
4415   enabledDisableTrace.Reset();
4416   enabledDisableTrace.Enable( true );
4417   application.SendNotification();
4418   application.Render();
4419   enabledDisableTrace.Enable( false );
4420
4421   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4422
4423      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
4424            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4425   */
4426   size_t startIndex = 0u;
4427   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "3042", startIndex ) );
4428   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4429   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4430
4431   // Swap the clipping actor from top of left branch to top of right branch.
4432   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4433   actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4434
4435   // Gather the call trace.
4436   enabledDisableTrace.Reset();
4437   enabledDisableTrace.Enable( true );
4438   application.SendNotification();
4439   application.Render();
4440   enabledDisableTrace.Enable( false );
4441
4442   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4443   // This proves the draw order has remained the same.
4444   startIndex = 0u;
4445   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex(  "Enable",  "2960", startIndex ) );
4446   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4447
4448   END_TEST;
4449 }
4450
4451 int UtcDaliActorPropertyScissorClippingActor(void)
4452 {
4453   // This test checks that an actor is correctly setup for clipping.
4454   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4455   TestApplication application;
4456
4457   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4458   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4459   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4460
4461   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4462   const Vector2 imageSize( 16.0f, 16.0f );
4463
4464   // Create a clipping actor.
4465   Actor clippingActorA = CreateActorWithContent16x16();
4466   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4467   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4468   clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4469   clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4470   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4471   application.GetScene().Add( clippingActorA );
4472
4473   // Gather the call trace.
4474   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4475
4476   // Check we are writing to the color buffer.
4477   CheckColorMask( glAbstraction, true );
4478
4479   // Check scissor test was enabled.
4480   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4481
4482   // Check the scissor was set, and the coordinates are correct.
4483   std::stringstream compareParametersString;
4484   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4485   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 0, 0, 16, 16
4486
4487   clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4488   clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4489
4490   // Gather the call trace.
4491   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4492
4493   // Check the scissor was set, and the coordinates are correct.
4494   compareParametersString.str( std::string() );
4495   compareParametersString.clear();
4496   compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4497   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with 464, 784, 16, 16
4498
4499   END_TEST;
4500 }
4501
4502 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4503 {
4504   // This test checks that an actor is correctly setup for clipping.
4505   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4506   TestApplication application;
4507
4508
4509   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4510   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4511   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4512
4513   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4514   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4515   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4516
4517   // Create a clipping actors.
4518   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4519   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4520
4521   clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4522   clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4523   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4524
4525   clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4526   clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4527   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4528
4529   clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4530   clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4531
4532   application.GetScene().Add( clippingActorA );
4533   application.GetScene().Add( clippingActorB );
4534
4535   // Gather the call trace.
4536   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4537
4538   // Check we are writing to the color buffer.
4539   CheckColorMask( glAbstraction, true );
4540
4541   // Check scissor test was enabled.
4542   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4543
4544   // Check the scissor was set, and the coordinates are correct.
4545   std::stringstream compareParametersString;
4546
4547   std::string clipA( "0, 500, 480, 200" );
4548   std::string clipB( "0, 380, 480, 40" );
4549
4550   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4551   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4552
4553   END_TEST;
4554 }
4555
4556 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4557 {
4558   // This test checks that an actor is correctly setup for clipping.
4559   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4560   TestApplication application;
4561
4562   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4563   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4564   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4565
4566   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4567   const Vector2 imageSize( 16.0f, 16.0f );
4568
4569   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4570
4571      A is drawn first - with scissor clipping on
4572      B is drawn second - also with scissor clipping on
4573      C is the generated clipping region, the intersection ( A ∩ B )
4574
4575            ┏━━━━━━━┓                   ┌───────┐
4576            ┃     B ┃                   │     B │
4577        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4578        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4579        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4580        │ A     │                   ┊ A     ┊
4581        └───────┘                   └┄┄┄┄┄┄┄┘
4582
4583      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4584   */
4585
4586   // Create a clipping actor.
4587   Actor clippingActorA = CreateActorWithContent16x16();
4588   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4589   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4590   clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4591   clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4592   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4593   application.GetScene().Add( clippingActorA );
4594
4595   // Create a child clipping actor.
4596   Actor clippingActorB = CreateActorWithContent16x16();
4597   clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4598   clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4599   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4600   clippingActorA.Add( clippingActorB );
4601
4602   // positionModifiers is an array of positions to position B around.
4603   // expect is an array of expected scissor clip coordinate results.
4604   const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ),     Vector2( -1.0f, 1.0f ),    Vector2( -1.0f, -1.0f ),   Vector2( 1.0f, -1.0f )    };
4605   const Vector4 expect[4] =            { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4606
4607   // Loop through each overlap combination.
4608   for( unsigned int test = 0u; test < 4u; ++test )
4609   {
4610     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4611     const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4612     clippingActorB.SetProperty( Actor::Property::POSITION, Vector2( position.x, position.y ));
4613
4614     // Gather the call trace.
4615     GenerateTrace( application, enabledDisableTrace, scissorTrace );
4616
4617     // Check we are writing to the color buffer.
4618     CheckColorMask( glAbstraction, true );
4619
4620     // Check scissor test was enabled.
4621     DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4622
4623     // Check the scissor was set, and the coordinates are correct.
4624     const Vector4& expectResults( expect[test] );
4625     std::stringstream compareParametersString;
4626     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4627     DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) );                  // Compare with the expected result
4628   }
4629
4630   END_TEST;
4631 }
4632
4633 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4634 {
4635   // This test checks that an actor is correctly setup for clipping.
4636   tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4637   TestApplication application;
4638
4639   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4640   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4641   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4642
4643   /* Create a nest of 2 scissors and siblings of the parent.
4644
4645             stage
4646               |
4647         ┌─────┐─────┐
4648         A     C     D
4649         |           |
4650         B           E
4651   */
4652
4653   const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4654   const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4655   const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4656   const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4657   const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4658   const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4659
4660   // Create a clipping actors.
4661   Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4662   Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4663   Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4664   Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4665   Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4666
4667   clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4668   clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4669   clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4670
4671   clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4672   clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4673   clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4674
4675   clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4676   clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4677   clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4678
4679   clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4680   clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4681   clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4682
4683   clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4684   clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4685
4686   clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4687   clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4688   clippingActorC.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 100.0f, 0.0f ));
4689   clippingActorD.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4690   clippingActorE.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4691
4692   application.GetScene().Add( clippingActorA );
4693   clippingActorA.Add( clippingActorB );
4694   application.GetScene().Add( clippingActorC );
4695   application.GetScene().Add( clippingActorD );
4696   clippingActorD.Add( clippingActorE );
4697
4698   // Gather the call trace.
4699   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4700
4701   // Check we are writing to the color buffer.
4702   CheckColorMask( glAbstraction, true );
4703
4704   // Check scissor test was enabled.
4705   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );                                   // 3089 = 0xC11 (GL_SCISSOR_TEST)
4706
4707   // Check the scissor was set, and the coordinates are correct.
4708   std::string clipA( "0, 500, 480, 200" );
4709   std::string clipB( "0, 580, 480, 40" );
4710   std::string clipC( "0, 200, 480, 200" );
4711   std::string clipD( "0, 300, 480, 200" );
4712
4713   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4714   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4715   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4716   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4717   DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 );    // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4718
4719   END_TEST;
4720 }
4721
4722 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4723 {
4724   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4725   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4726   TestApplication application;
4727
4728   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4729   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4730   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4731
4732   // Create a clipping actor.
4733   Actor actorDepth1Clip = CreateActorWithContent16x16();
4734   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4735   application.GetScene().Add( actorDepth1Clip );
4736
4737   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4738   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4739
4740   // Gather the call trace.
4741   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4742
4743   // Check we are writing to the color buffer.
4744   CheckColorMask( glAbstraction, true );
4745
4746   // Check the stencil buffer was not enabled.
4747   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4748
4749   // Check stencil functions are not called.
4750   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4751   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4752   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4753
4754   // Check that scissor clipping is overriden by the renderer properties.
4755   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4756
4757   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4758
4759   // Gather the call trace.
4760   GenerateTrace( application, enabledDisableTrace, scissorTrace );
4761
4762   // Check the stencil buffer was not enabled.
4763   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) );    // 3089 = 0xC11 (GL_SCISSOR_TEST)
4764
4765   DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4766
4767   END_TEST;
4768 }
4769
4770 int UtcDaliGetPropertyN(void)
4771 {
4772   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4773   TestApplication application;
4774
4775   Actor actor = Actor::New();
4776
4777   unsigned int propertyCount = actor.GetPropertyCount();
4778   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4779   END_TEST;
4780 }
4781
4782 int UtcDaliActorRaiseLower(void)
4783 {
4784   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4785
4786   TestApplication application;
4787
4788   Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4789
4790   Integration::Scene stage( application.GetScene() );
4791
4792   Actor actorA = Actor::New();
4793   Actor actorB = Actor::New();
4794   Actor actorC = Actor::New();
4795
4796   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4797   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4798
4799   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4800   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4801
4802   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4803   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4804
4805   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4806   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4807
4808   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4809   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4810
4811   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4812   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4813
4814   stage.Add( actorA );
4815   stage.Add( actorB );
4816   stage.Add( actorC );
4817
4818   ResetTouchCallbacks();
4819
4820   application.SendNotification();
4821   application.Render();
4822
4823   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4824   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4825   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4826
4827   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4828   // Only top actor will get touched.
4829   actorA.TouchSignal().Connect( TestTouchCallback );
4830   actorB.TouchSignal().Connect( TestTouchCallback2 );
4831   actorC.TouchSignal().Connect( TestTouchCallback3 );
4832
4833   // Connect ChildOrderChangedSignal
4834   bool orderChangedSignal( false );
4835   Actor orderChangedActor;
4836   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4837   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4838
4839   Dali::Integration::Point point;
4840   point.SetDeviceId( 1 );
4841   point.SetState( PointState::DOWN );
4842   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4843   Dali::Integration::TouchEvent touchEvent;
4844   touchEvent.AddPoint( point );
4845
4846   application.ProcessEvent( touchEvent );
4847
4848   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4849   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4850   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4851
4852   ResetTouchCallbacks();
4853
4854   tet_printf( "Testing Raising of Actor\n" );
4855
4856   int preActorOrder( 0 );
4857   int postActorOrder( 0 );
4858
4859   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4860   value.Get( preActorOrder );
4861
4862   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4863   actorB.Raise();
4864   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4865   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4866
4867   // Ensure sort order is calculated before next touch event
4868   application.SendNotification();
4869
4870   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4871   value.Get( postActorOrder );
4872
4873   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4874
4875   application.ProcessEvent( touchEvent );
4876
4877   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4878   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4879   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4880
4881   ResetTouchCallbacks();
4882
4883   tet_printf( "Testing Lowering of Actor\n" );
4884
4885   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4886   value.Get( preActorOrder );
4887
4888   orderChangedSignal = false;
4889
4890   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4891   actorB.Lower();
4892   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4893   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4894
4895   application.SendNotification(); // ensure sort order calculated before next touch event
4896
4897   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4898   value.Get( postActorOrder );
4899
4900   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4901
4902   application.ProcessEvent( touchEvent );
4903
4904   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4905   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4906   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4907
4908   ResetTouchCallbacks();
4909
4910   Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4911
4912   END_TEST;
4913 }
4914
4915 int UtcDaliActorRaiseToTopLowerToBottom(void)
4916 {
4917   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4918
4919   TestApplication application;
4920
4921   Integration::Scene stage( application.GetScene() );
4922
4923   Actor actorA = Actor::New();
4924   Actor actorB = Actor::New();
4925   Actor actorC = Actor::New();
4926
4927   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4928   // enables checking of which actor the uniform is assigned too
4929   Shader shaderA = CreateShader();
4930   shaderA.RegisterProperty( "uRendererColor",1.f);
4931
4932   Shader shaderB = CreateShader();
4933   shaderB.RegisterProperty( "uRendererColor", 2.f );
4934
4935   Shader shaderC = CreateShader();
4936   shaderC.RegisterProperty( "uRendererColor", 3.f );
4937
4938   Geometry geometry = CreateQuadGeometry();
4939
4940   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4941   Renderer rendererA = Renderer::New(geometry, shaderA);
4942   actorA.AddRenderer(rendererA);
4943
4944   Renderer rendererB = Renderer::New(geometry, shaderB);
4945   actorB.AddRenderer(rendererB);
4946
4947   Renderer rendererC = Renderer::New(geometry, shaderC);
4948   actorC.AddRenderer(rendererC);
4949
4950   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4951   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4952
4953   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4954   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4955
4956   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4957   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4958
4959   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4960   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4961
4962   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4963   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4964
4965   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4966   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4967
4968   stage.Add( actorA );
4969   stage.Add( actorB );
4970   stage.Add( actorC );
4971
4972   ResetTouchCallbacks();
4973
4974   // Connect ChildOrderChangedSignal
4975   bool orderChangedSignal( false );
4976   Actor orderChangedActor;
4977   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4978   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4979
4980   // Set up gl abstraction trace so can query the set uniform order
4981   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4982   glAbstraction.EnableSetUniformCallTrace(true);
4983   glAbstraction.ResetSetUniformCallStack();
4984
4985   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4986
4987   application.SendNotification();
4988   application.Render();
4989
4990   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4991
4992
4993   // Test order of uniforms in stack
4994   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4995   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4996   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4997
4998   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4999
5000   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5001
5002   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5003   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5004   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5005
5006   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5007   // Only top actor will get touched.
5008   actorA.TouchSignal().Connect( TestTouchCallback );
5009   actorB.TouchSignal().Connect( TestTouchCallback2 );
5010   actorC.TouchSignal().Connect( TestTouchCallback3 );
5011
5012   Dali::Integration::Point point;
5013   point.SetDeviceId( 1 );
5014   point.SetState( PointState::DOWN );
5015   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5016   Dali::Integration::TouchEvent touchEvent;
5017   touchEvent.AddPoint( point );
5018
5019   application.ProcessEvent( touchEvent );
5020
5021   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5022   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5023   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5024
5025   ResetTouchCallbacks();
5026
5027   tet_printf( "RaiseToTop ActorA\n" );
5028
5029   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5030   actorA.RaiseToTop();
5031   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5032   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5033
5034   application.SendNotification(); // ensure sorting order is calculated before next touch event
5035
5036   application.ProcessEvent( touchEvent );
5037
5038   glAbstraction.ResetSetUniformCallStack();
5039   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5040
5041   application.SendNotification();
5042   application.Render();
5043
5044   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5045
5046   // Test order of uniforms in stack
5047   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5048   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5049   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5050
5051   tet_infoline( "Testing A above C and B at bottom\n" );
5052   bool ACB = ( indexA > indexC) && ( indexC > indexB );
5053
5054   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5055
5056   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5057   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5058   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5059
5060   ResetTouchCallbacks();
5061
5062   tet_printf( "RaiseToTop ActorB\n" );
5063
5064   orderChangedSignal = false;
5065
5066   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5067   actorB.RaiseToTop();
5068   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5069   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5070
5071   application.SendNotification(); // Ensure sort order is calculated before next touch event
5072
5073   application.ProcessEvent( touchEvent );
5074
5075   glAbstraction.ResetSetUniformCallStack();
5076   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5077
5078   application.SendNotification();
5079   application.Render();
5080
5081   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5082
5083   // Test order of uniforms in stack
5084   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5085   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5086   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5087
5088   tet_infoline( "Testing B above A and C at bottom\n" );
5089   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5090
5091   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5092
5093   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5094   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5095   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5096
5097   ResetTouchCallbacks();
5098
5099   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5100
5101   orderChangedSignal = false;
5102
5103   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5104   actorA.LowerToBottom();
5105   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5106   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5107
5108   application.SendNotification();
5109   application.Render();
5110
5111   orderChangedSignal = false;
5112
5113   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5114   actorB.LowerToBottom();
5115   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5116   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5117
5118   application.SendNotification();
5119   application.Render();
5120
5121   application.ProcessEvent( touchEvent );
5122
5123   glAbstraction.ResetSetUniformCallStack();
5124   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5125
5126   application.SendNotification();
5127   application.Render();
5128
5129   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5130
5131   // Test order of uniforms in stack
5132   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5133   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5134   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5135
5136   tet_infoline( "Testing C above A and B at bottom\n" );
5137   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5138
5139   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5140
5141   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5142   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5143   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5144
5145   ResetTouchCallbacks();
5146
5147   END_TEST;
5148 }
5149
5150 int UtcDaliActorRaiseAbove(void)
5151 {
5152   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5153
5154   TestApplication application;
5155
5156   Integration::Scene stage( application.GetScene() );
5157
5158   Actor actorA = Actor::New();
5159   Actor actorB = Actor::New();
5160   Actor actorC = Actor::New();
5161
5162   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5163   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5164
5165   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5166   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5167
5168   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5169   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5170
5171   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5172   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5173
5174   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5175   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5176
5177   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5178   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5179
5180   stage.Add( actorA );
5181   stage.Add( actorB );
5182   stage.Add( actorC );
5183
5184   ResetTouchCallbacks();
5185
5186   application.SendNotification();
5187   application.Render();
5188
5189   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5190   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5191   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5192
5193   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5194   // Only top actor will get touched.
5195   actorA.TouchSignal().Connect( TestTouchCallback );
5196   actorB.TouchSignal().Connect( TestTouchCallback2 );
5197   actorC.TouchSignal().Connect( TestTouchCallback3 );
5198
5199   bool orderChangedSignal( false );
5200   Actor orderChangedActor;
5201   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5202   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5203
5204   Dali::Integration::Point point;
5205   point.SetDeviceId( 1 );
5206   point.SetState( PointState::DOWN );
5207   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5208   Dali::Integration::TouchEvent touchEvent;
5209   touchEvent.AddPoint( point );
5210
5211   application.ProcessEvent( touchEvent );
5212
5213   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5214   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5215   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5216
5217   ResetTouchCallbacks();
5218
5219   tet_printf( "Raise actor B Above Actor C\n" );
5220
5221   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5222   actorB.RaiseAbove( actorC );
5223   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5224   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5225
5226   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5227   application.SendNotification();
5228   application.ProcessEvent( touchEvent );
5229
5230   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5231   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5232   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5233
5234   ResetTouchCallbacks();
5235
5236   tet_printf( "Raise actor A Above Actor B\n" );
5237
5238   orderChangedSignal = false;
5239
5240   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5241   actorA.RaiseAbove( actorB );
5242   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5243   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5244
5245   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5246   application.SendNotification();
5247
5248   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5249
5250   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5251   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5252   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5253
5254   ResetTouchCallbacks();
5255
5256   END_TEST;
5257 }
5258
5259 int UtcDaliActorLowerBelow(void)
5260 {
5261   tet_infoline( "UtcDaliActor LowerBelow test \n" );
5262
5263   TestApplication application;
5264
5265   Integration::Scene stage( application.GetScene() );
5266
5267   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5268   // enables checking of which actor the uniform is assigned too
5269   Shader shaderA = CreateShader();
5270   shaderA.RegisterProperty( "uRendererColor",1.f);
5271
5272   Shader shaderB = CreateShader();
5273   shaderB.RegisterProperty( "uRendererColor", 2.f );
5274
5275   Shader shaderC = CreateShader();
5276   shaderC.RegisterProperty( "uRendererColor", 3.f );
5277
5278   Actor actorA = Actor::New();
5279   Actor actorB = Actor::New();
5280   Actor actorC = Actor::New();
5281
5282   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5283   Geometry geometry = CreateQuadGeometry();
5284
5285   Renderer rendererA = Renderer::New(geometry, shaderA);
5286   actorA.AddRenderer(rendererA);
5287
5288   Renderer rendererB = Renderer::New(geometry, shaderB);
5289   actorB.AddRenderer(rendererB);
5290
5291   Renderer rendererC = Renderer::New(geometry, shaderC);
5292   actorC.AddRenderer(rendererC);
5293
5294   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5295   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5296
5297   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5298   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5299
5300   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5301   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5302
5303   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5304   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5305
5306   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5307   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5308
5309   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5310   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5311
5312   Actor container = Actor::New();
5313   container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5314   container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5315   stage.Add( container );
5316
5317   container.Add( actorA );
5318   container.Add( actorB );
5319   container.Add( actorC );
5320
5321   ResetTouchCallbacks();
5322
5323   // Connect ChildOrderChangedSignal
5324   bool orderChangedSignal( false );
5325   Actor orderChangedActor;
5326   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5327   DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5328
5329   // Set up gl abstraction trace so can query the set uniform order
5330   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5331   glAbstraction.EnableSetUniformCallTrace(true);
5332   glAbstraction.ResetSetUniformCallStack();
5333   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5334
5335   glAbstraction.ResetSetUniformCallStack();
5336
5337   application.SendNotification();
5338   application.Render();
5339
5340   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5341
5342   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5343
5344   // Test order of uniforms in stack
5345   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5346   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5347   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5348
5349   tet_infoline( "Testing C above B and A at bottom\n" );
5350   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
5351
5352   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5353
5354   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5355   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5356   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5357
5358   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5359   // Only top actor will get touched.
5360   actorA.TouchSignal().Connect( TestTouchCallback );
5361   actorB.TouchSignal().Connect( TestTouchCallback2 );
5362   actorC.TouchSignal().Connect( TestTouchCallback3 );
5363
5364   Dali::Integration::Point point;
5365   point.SetDeviceId( 1 );
5366   point.SetState( PointState::DOWN );
5367   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5368   Dali::Integration::TouchEvent touchEvent;
5369   touchEvent.AddPoint( point );
5370
5371   tet_infoline( "UtcDaliActor Test Set up completed \n" );
5372
5373   application.ProcessEvent( touchEvent );
5374
5375   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5376   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5377   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5378
5379   ResetTouchCallbacks();
5380
5381   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" );
5382
5383   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5384   actorC.LowerBelow( actorB );
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 ); // touch event
5393
5394   glAbstraction.ResetSetUniformCallStack();
5395   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5396
5397   application.SendNotification();
5398   application.Render();
5399
5400   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5401
5402   // Test order of uniforms in stack
5403   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5404   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5405   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5406
5407   tet_infoline( "Testing render order is A, C, B" );
5408   DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5409   DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5410
5411   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5412   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5413   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5414
5415   ResetTouchCallbacks();
5416
5417   tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5418
5419   orderChangedSignal = false;
5420
5421   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5422   actorC.LowerBelow( actorA );
5423   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5424   DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5425
5426   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5427   application.SendNotification();
5428   application.Render();
5429
5430   application.ProcessEvent( touchEvent );
5431
5432   glAbstraction.ResetSetUniformCallStack();
5433   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5434
5435   application.Render();
5436   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5437
5438   // Test order of uniforms in stack
5439   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5440   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5441   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5442
5443   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5444   DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5445
5446   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5447   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5448   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5449
5450   ResetTouchCallbacks();
5451
5452   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5453
5454   orderChangedSignal = false;
5455
5456   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5457   actorB.LowerBelow( actorC );
5458   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5459   DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5460
5461   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5462   application.SendNotification();
5463   application.Render();
5464
5465   application.ProcessEvent( touchEvent );
5466
5467   glAbstraction.ResetSetUniformCallStack();
5468   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5469
5470   application.Render();
5471   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5472
5473   // Test order of uniforms in stack
5474   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
5475   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
5476   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
5477
5478   DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5479   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5480
5481   END_TEST;
5482 }
5483
5484
5485 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5486 {
5487   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5488
5489   TestApplication application;
5490
5491   Integration::Scene stage( application.GetScene() );
5492
5493   Actor parentA = Actor::New();
5494   Actor parentB = Actor::New();
5495   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5496   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5497   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5498   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5499
5500   parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5501   parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5502
5503   parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5504   parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5505
5506   stage.Add( parentA );
5507   stage.Add( parentB );
5508
5509   Actor actorA = Actor::New();
5510   Actor actorB = Actor::New();
5511   Actor actorC = Actor::New();
5512
5513   parentA.Add( actorA );
5514   parentA.Add( actorB );
5515
5516   tet_printf( "Actor C added to different parent from A and B \n" );
5517   parentB.Add( actorC );
5518
5519   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5520   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5521
5522   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5523   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5524
5525   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5526   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5527
5528   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5529   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5530
5531   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5532   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5533
5534   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5535   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5536
5537   ResetTouchCallbacks();
5538
5539   // Connect ChildOrderChangedSignal
5540   bool orderChangedSignal( false );
5541   Actor orderChangedActor;
5542   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5543   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5544
5545   application.SendNotification();
5546   application.Render();
5547
5548   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5549   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5550   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5551
5552   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5553   // Only top actor will get touched.
5554   actorA.TouchSignal().Connect( TestTouchCallback );
5555   actorB.TouchSignal().Connect( TestTouchCallback2 );
5556   actorC.TouchSignal().Connect( TestTouchCallback3 );
5557
5558   Dali::Integration::Point point;
5559   point.SetDeviceId( 1 );
5560   point.SetState( PointState::DOWN );
5561   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5562   Dali::Integration::TouchEvent touchEvent;
5563   touchEvent.AddPoint( point );
5564
5565   application.ProcessEvent( touchEvent );
5566
5567   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5568   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5569   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5570
5571   ResetTouchCallbacks();
5572
5573   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5574
5575   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5576   actorA.RaiseAbove( actorC );
5577   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5578
5579   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5580   application.SendNotification();
5581
5582   application.ProcessEvent( touchEvent ); // touch event
5583
5584   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5585   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5586   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5587
5588   ResetTouchCallbacks();
5589
5590   END_TEST;
5591 }
5592
5593 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5594 {
5595   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5596
5597   TestApplication application;
5598
5599   Integration::Scene stage( application.GetScene() );
5600
5601   Actor actorA = Actor::New();
5602   Actor actorB = Actor::New();
5603   Actor actorC = Actor::New();
5604
5605   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5606   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5607
5608   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5609   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5610
5611   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5612   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5613
5614   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5615   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5616
5617   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5618   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5619
5620   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5621   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5622
5623   ResetTouchCallbacks();
5624
5625   // Connect ChildOrderChangedSignal
5626   bool orderChangedSignal( false );
5627   Actor orderChangedActor;
5628   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5629   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5630
5631   application.SendNotification();
5632   application.Render();
5633
5634   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5635   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5636   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5637
5638   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5639   // Only top actor will get touched.
5640   actorA.TouchSignal().Connect( TestTouchCallback );
5641   actorB.TouchSignal().Connect( TestTouchCallback2 );
5642   actorC.TouchSignal().Connect( TestTouchCallback3 );
5643
5644   Dali::Integration::Point point;
5645   point.SetDeviceId( 1 );
5646   point.SetState( PointState::DOWN );
5647   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5648   Dali::Integration::TouchEvent touchEvent;
5649   touchEvent.AddPoint( point );
5650
5651   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5652
5653   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5654   actorA.RaiseAbove( actorC );
5655   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5656
5657   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5658   application.SendNotification();
5659
5660   application.ProcessEvent( touchEvent );
5661
5662   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5663
5664   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5665   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5666   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5667
5668   ResetTouchCallbacks();
5669
5670   orderChangedSignal = false;
5671
5672   stage.Add ( actorB );
5673   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5674
5675   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5676   actorA.LowerBelow( actorC );
5677   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5678
5679   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5680   application.SendNotification();
5681   application.Render();
5682
5683   application.ProcessEvent( touchEvent );
5684
5685   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5686   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5687   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5688   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5689
5690   ResetTouchCallbacks();
5691
5692   orderChangedSignal = false;
5693
5694   tet_printf( "Adding Actor A to stage, will be on top\n" );
5695
5696   stage.Add ( actorA );
5697   application.SendNotification();
5698   application.Render();
5699
5700   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5701
5702   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5703   actorB.RaiseAbove( actorC );
5704   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5705
5706   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5707   application.SendNotification();
5708
5709   application.ProcessEvent( touchEvent );
5710
5711   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5712   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5713   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5714   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5715
5716   ResetTouchCallbacks();
5717
5718   orderChangedSignal = false;
5719
5720   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5721
5722   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5723   actorA.LowerBelow( actorC );
5724   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5725
5726   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5727   application.SendNotification();
5728
5729   application.ProcessEvent( touchEvent );
5730
5731   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5732   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5733   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5734   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5735
5736   ResetTouchCallbacks();
5737
5738   orderChangedSignal = false;
5739
5740   stage.Add ( actorC );
5741
5742   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5743   actorA.RaiseAbove( actorC );
5744   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5745   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5746
5747   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5748   application.SendNotification();
5749   application.Render();
5750
5751   application.ProcessEvent( touchEvent );
5752
5753   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5754   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5755   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5756   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5757
5758   END_TEST;
5759 }
5760
5761 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5762 {
5763   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5764
5765   TestApplication application;
5766
5767   Integration::Scene stage( application.GetScene() );
5768
5769   Actor actorA = Actor::New();
5770   Actor actorB = Actor::New();
5771   Actor actorC = Actor::New();
5772
5773   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5774   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5775
5776   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5777   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5778
5779   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5780   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5781
5782   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5783   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5784
5785   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5786   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5787
5788   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5789   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5790
5791   ResetTouchCallbacks();
5792
5793   // Connect ChildOrderChangedSignal
5794   bool orderChangedSignal( false );
5795   Actor orderChangedActor;
5796   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5797   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5798
5799   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5800   // Only top actor will get touched.
5801   actorA.TouchSignal().Connect( TestTouchCallback );
5802   actorB.TouchSignal().Connect( TestTouchCallback2 );
5803   actorC.TouchSignal().Connect( TestTouchCallback3 );
5804
5805   Dali::Integration::Point point;
5806   point.SetDeviceId( 1 );
5807   point.SetState( PointState::DOWN );
5808   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5809   Dali::Integration::TouchEvent touchEvent;
5810   touchEvent.AddPoint( point );
5811
5812   stage.Add ( actorA );
5813   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5814
5815   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5816   actorB.Raise();
5817   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5818
5819   application.SendNotification();
5820   application.Render();
5821
5822   application.ProcessEvent( touchEvent );
5823
5824   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5825
5826   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5827   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5828   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5829
5830   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5831   ResetTouchCallbacks();
5832
5833   orderChangedSignal = false;
5834
5835   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5836   actorC.Lower();
5837   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5838
5839   // Sort actor tree before next touch event
5840   application.SendNotification();
5841   application.Render();
5842
5843   application.ProcessEvent( touchEvent );
5844
5845   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5846
5847   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5848   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5849   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5850   ResetTouchCallbacks();
5851
5852   orderChangedSignal = false;
5853
5854   tet_printf( "Lower actor C below B but C not parented\n" );
5855
5856   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5857   actorB.Lower();
5858   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5859
5860   // Sort actor tree before next touch event
5861   application.SendNotification();
5862   application.Render();
5863
5864   application.ProcessEvent( touchEvent );
5865
5866   tet_printf( "Not parented so Lower should show no effect\n" );
5867
5868   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5869   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5870   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5871   ResetTouchCallbacks();
5872
5873   orderChangedSignal = false;
5874
5875   tet_printf( "Raise actor B to top\n" );
5876
5877   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5878   actorB.RaiseToTop();
5879   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5880
5881   // Sort actor tree before next touch event
5882   application.SendNotification();
5883   application.Render();
5884
5885   application.ProcessEvent( touchEvent );
5886
5887   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5888
5889   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5890   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5891   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5892   ResetTouchCallbacks();
5893
5894   orderChangedSignal = false;
5895
5896   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5897
5898   stage.Add ( actorB );
5899
5900   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5901
5902   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5903   actorC.LowerToBottom();
5904   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5905
5906   application.SendNotification();
5907   application.Render();
5908
5909   application.ProcessEvent( touchEvent );
5910
5911   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5912
5913   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5914   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5915   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5916   ResetTouchCallbacks();
5917
5918   END_TEST;
5919 }
5920
5921
5922 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5923 {
5924   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5925
5926   TestApplication application;
5927
5928   Integration::Scene stage( application.GetScene() );
5929
5930   Actor actorA = Actor::New();
5931   Actor actorB = Actor::New();
5932   Actor actorC = Actor::New();
5933
5934   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5935   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5936
5937   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5938   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5939
5940   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5941   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5942
5943   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5944   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5945
5946   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5947   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5948
5949   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5950   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5951
5952   stage.Add( actorA );
5953   stage.Add( actorB );
5954   stage.Add( actorC );
5955
5956   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5957   // Only top actor will get touched.
5958   actorA.TouchSignal().Connect( TestTouchCallback );
5959   actorB.TouchSignal().Connect( TestTouchCallback2 );
5960   actorC.TouchSignal().Connect( TestTouchCallback3 );
5961
5962   ResetTouchCallbacks();
5963
5964   // Connect ChildOrderChangedSignal
5965   bool orderChangedSignal( false );
5966   Actor orderChangedActor;
5967   ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5968   DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5969
5970   application.SendNotification();
5971   application.Render();
5972
5973   Dali::Integration::Point point;
5974   point.SetDeviceId( 1 );
5975   point.SetState( PointState::DOWN );
5976   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5977   Dali::Integration::TouchEvent touchEvent;
5978   touchEvent.AddPoint( point );
5979
5980   application.ProcessEvent( touchEvent );
5981
5982   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5983   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5984   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5985
5986   ResetTouchCallbacks();
5987
5988   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5989
5990   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5991   actorA.RaiseAbove( actorA );
5992   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5993   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5994
5995   application.SendNotification();
5996   application.Render();
5997
5998   application.ProcessEvent( touchEvent );
5999
6000   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6001
6002   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
6003   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
6004   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
6005
6006   ResetTouchCallbacks();
6007
6008   orderChangedSignal = false;
6009
6010   DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6011   actorA.RaiseAbove( actorC );
6012   DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6013   DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6014
6015   application.SendNotification();
6016   application.Render();
6017
6018   application.ProcessEvent( touchEvent );
6019
6020   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6021   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
6022   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
6023   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
6024
6025   END_TEST;
6026 }
6027
6028 int UtcDaliActorGetScreenPosition(void)
6029 {
6030   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6031
6032   TestApplication application;
6033
6034   Integration::Scene stage( application.GetScene() );
6035
6036   Actor actorA = Actor::New();
6037   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6038
6039   Vector2 size2( 10.0f, 20.0f );
6040   actorA.SetProperty( Actor::Property::SIZE, size2 );
6041
6042   actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6043
6044   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6045
6046   stage.Add( actorA );
6047
6048   application.SendNotification();
6049   application.Render();
6050
6051   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6052   Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6053
6054   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
6055   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6056
6057   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6058   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6059
6060   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6061
6062   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6063
6064   application.SendNotification();
6065   application.Render();
6066
6067   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6068   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6069
6070   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
6071   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6072
6073   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6074   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6075
6076   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6077
6078   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6079
6080   application.SendNotification();
6081   application.Render();
6082
6083   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6084   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6085
6086   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
6087   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
6088
6089   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6090   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6091
6092   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6093
6094   actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 0.0 ));
6095
6096   application.SendNotification();
6097   application.Render();
6098
6099   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6100   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6101
6102   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
6103   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
6104
6105   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6106   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6107
6108   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6109
6110   actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 420.0 ));
6111
6112   application.SendNotification();
6113   application.Render();
6114
6115   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6116   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6117
6118   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
6119   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
6120
6121   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
6122   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6123
6124   tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6125
6126   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6127   actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 30.0 ));
6128
6129   Actor actorB = Actor::New();
6130   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6131   actorB.SetProperty( Actor::Property::SIZE, size2 );
6132   actorB.SetProperty( Actor::Property::POSITION, Vector2( 10.f, 10.f ));
6133   actorA.Add( actorB );
6134
6135   actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6136
6137   application.SendNotification();
6138   application.Render();
6139
6140   actorScreenPosition = actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6141
6142   DALI_TEST_EQUALS( actorScreenPosition.x,  50lu , TEST_LOCATION );
6143   DALI_TEST_EQUALS( actorScreenPosition.y,  50lu , TEST_LOCATION );
6144
6145   END_TEST;
6146 }
6147
6148 int UtcDaliActorGetScreenPositionAfterScaling(void)
6149 {
6150   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6151
6152   TestApplication application;
6153
6154   Integration::Scene stage( application.GetScene() );
6155
6156   Actor actorA = Actor::New();
6157   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6158
6159   Vector2 size2( 10.0f, 20.0f );
6160   actorA.SetProperty( Actor::Property::SIZE, size2 );
6161   actorA.SetProperty( Actor::Property::SCALE, 1.5f );
6162   actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6163
6164   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6165
6166   stage.Add( actorA );
6167
6168   application.SendNotification();
6169   application.Render();
6170
6171   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6172   Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6173
6174   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6175   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6176
6177   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
6178   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
6179
6180   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6181
6182   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6183
6184   application.SendNotification();
6185   application.Render();
6186
6187   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6188   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6189
6190   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6191   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6192
6193   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
6194   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6195
6196   END_TEST;
6197 }
6198
6199 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6200 {
6201   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6202
6203   TestApplication application;
6204
6205   Integration::Scene stage( application.GetScene() );
6206
6207   Actor actorA = Actor::New();
6208   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6209   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6210   Vector2 size2( 10.0f, 20.0f );
6211   actorA.SetProperty( Actor::Property::SIZE, size2 );
6212   actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6213
6214   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6215
6216   stage.Add( actorA );
6217
6218   application.SendNotification();
6219   application.Render();
6220
6221   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6222   Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6223
6224   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6225   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6226
6227   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
6228   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
6229
6230   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6231
6232   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6233   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6234
6235   application.SendNotification();
6236   application.Render();
6237
6238   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6239   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6240
6241   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
6242   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6243
6244   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6245   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
6246
6247   END_TEST;
6248   END_TEST;
6249 }
6250
6251 int UtcDaliActorGetScreenPositionWithChildActors(void)
6252 {
6253   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6254
6255   TestApplication application;
6256
6257   Integration::Scene stage( application.GetScene() );
6258
6259   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6260
6261   Actor actorA = Actor::New();
6262   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6263   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6264   Vector2 size1( 10.0f, 20.0f );
6265   actorA.SetProperty( Actor::Property::SIZE, size1 );
6266   actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6267
6268   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6269
6270   Actor parentActorA = Actor::New();
6271   parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6272   parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6273   Vector2 size2( 30.0f, 60.0f );
6274   parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6275   parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6276
6277   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6278
6279   stage.Add( parentActorA );
6280   parentActorA.Add ( actorA );
6281
6282   application.SendNotification();
6283   application.Render();
6284
6285   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6286   Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6287
6288   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6289   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6290
6291   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
6292   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
6293
6294   tet_infoline( "Test 2\n");
6295
6296   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6297
6298   parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6299   parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6300
6301   application.SendNotification();
6302   application.Render();
6303
6304   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6305   actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6306
6307   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6308   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6309
6310   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
6311   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
6312
6313   END_TEST;
6314 }
6315
6316 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6317 {
6318   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6319
6320   TestApplication application;
6321
6322   Integration::Scene stage( application.GetScene() );
6323
6324   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6325
6326   Actor actorA = Actor::New();
6327   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6328   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6329   Vector2 size1( 10.0f, 20.0f );
6330   actorA.SetProperty( Actor::Property::SIZE, size1 );
6331   actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6332
6333   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6334
6335   Actor parentActorA = Actor::New();
6336   parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6337   parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6338   Vector2 size2( 30.0f, 60.0f );
6339   parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6340   parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6341
6342   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6343
6344   Actor grandParentActorA = Actor::New();
6345   grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6346   grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6347   Vector2 size3( 60.0f, 120.0f );
6348   grandParentActorA.SetProperty( Actor::Property::SIZE, size3 );
6349   grandParentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6350
6351   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6352
6353   stage.Add( grandParentActorA );
6354   grandParentActorA.Add ( parentActorA );
6355
6356   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6357
6358   parentActorA.Add ( actorA );
6359
6360   application.SendNotification();
6361   application.Render();
6362
6363   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6364   Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6365
6366   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
6367   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6368
6369   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
6370   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
6371
6372   END_TEST;
6373 }
6374
6375 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6376 {
6377   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6378
6379   TestApplication application;
6380
6381   Integration::Scene stage( application.GetScene() );
6382
6383   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6384
6385   Actor actorA = Actor::New();
6386   actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6387   actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6388   actorA.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6389   actorA.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 20.0f ) );
6390   stage.Add( actorA );
6391
6392   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6393
6394   Actor actorB = Actor::New();
6395   actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6396   actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6397   actorB.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6398   Vector2 actorBSize( 30.0f, 60.0f );
6399   actorB.SetProperty( Actor::Property::SIZE, actorBSize );
6400   stage.Add( actorB );
6401
6402   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6403
6404   Actor actorC = Actor::New();
6405   actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6406   actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6407   actorC.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6408   Vector2 actorCSize( 60.0f, 120.0f );
6409   actorC.SetProperty( Actor::Property::SIZE, actorCSize );
6410   stage.Add( actorC );
6411
6412   application.SendNotification();
6413   application.Render();
6414
6415   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6416
6417   Vector2 center( stage.GetSize() * 0.5f );
6418
6419   DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6420   DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6421   DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6422
6423   tet_infoline( "Add scale to all actors" );
6424
6425   actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6426   actorB.SetProperty( Actor::Property::SCALE, 2.0f );
6427   actorC.SetProperty( Actor::Property::SCALE, 2.0f );
6428
6429   application.SendNotification();
6430   application.Render();
6431
6432   DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6433   DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6434   DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6435
6436   END_TEST;
6437 }
6438
6439 int utcDaliActorPositionUsesAnchorPoint(void)
6440 {
6441   TestApplication application;
6442   tet_infoline( "Check default behaviour\n" );
6443
6444   Actor actor = Actor::New();
6445   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6446   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6447   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6448   application.GetScene().Add( actor );
6449
6450   application.SendNotification();
6451   application.Render();
6452
6453   tet_infoline( "Check that the world position is in the center\n" );
6454   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6455
6456   tet_infoline( "Set the position uses anchor point property to false\n" );
6457   actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6458
6459   application.SendNotification();
6460   application.Render();
6461
6462   tet_infoline( "Check that the world position has changed appropriately\n" );
6463   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6464
6465   END_TEST;
6466 }
6467
6468 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6469 {
6470   TestApplication application;
6471   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6472
6473   Actor actor = Actor::New();
6474   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6475   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6476   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6477   actor.SetProperty( Actor::Property::SCALE, 2.0f );
6478   actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6479   application.GetScene().Add( actor );
6480
6481   application.SendNotification();
6482   application.Render();
6483
6484   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6485   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6486
6487   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6488   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6489   application.SendNotification();
6490   application.Render();
6491   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6492
6493   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6494   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6495   application.SendNotification();
6496   application.Render();
6497   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6498
6499   END_TEST;
6500 }
6501
6502 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6503 {
6504   TestApplication application;
6505   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6506
6507   Actor actor = Actor::New();
6508   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6509   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6510   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6511   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6512   actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6513   application.GetScene().Add( actor );
6514
6515   application.SendNotification();
6516   application.Render();
6517
6518   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6519   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6520
6521   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6522   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6523   application.SendNotification();
6524   application.Render();
6525   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6526
6527   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6528   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6529   application.SendNotification();
6530   application.Render();
6531   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6532
6533   END_TEST;
6534 }
6535
6536 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6537 {
6538   TestApplication application;
6539   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6540
6541   Actor actor = Actor::New();
6542   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6543   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6544   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6545   actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6546   actor.SetProperty( Actor::Property::SCALE, 2.0f );
6547   actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6548   application.GetScene().Add( actor );
6549
6550   application.SendNotification();
6551   application.Render();
6552
6553   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6554   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6555
6556   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6557   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6558   application.SendNotification();
6559   application.Render();
6560   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6561
6562   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6563   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6564   application.SendNotification();
6565   application.Render();
6566   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6567
6568   END_TEST;
6569 }
6570
6571 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6572 {
6573   TestApplication application;
6574   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6575
6576   Actor parent = Actor::New();
6577
6578   application.GetScene().Add( parent );
6579   Vector2 stageSize( application.GetScene().GetSize() );
6580
6581   Actor actor = Actor::New();
6582   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6583   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6584   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6585   actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6586   actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6587   actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6588   parent.Add( actor );
6589
6590   application.SendNotification();
6591   application.Render();
6592
6593   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6594
6595   tet_infoline( "Check the world position is in the right place\n" );
6596   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6597
6598   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6599   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6600   application.SendNotification();
6601   application.Render();
6602   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6603
6604   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6605   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6606   application.SendNotification();
6607   application.Render();
6608   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6609
6610   END_TEST;
6611 }
6612
6613 int utcDaliActorVisibilityChangeSignalSelf(void)
6614 {
6615   TestApplication application;
6616   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6617
6618   Actor actor = Actor::New();
6619
6620   VisibilityChangedFunctorData data;
6621   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6622
6623   actor.SetProperty( Actor::Property::VISIBLE, false );
6624
6625   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6626
6627   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6628   data.Reset();
6629
6630   actor.SetProperty( Actor::Property::VISIBLE, false );
6631   data.Check( false /* not called */, TEST_LOCATION );
6632
6633   tet_infoline( "Change the visibility using properties, ensure called" );
6634   data.Reset();
6635
6636   actor.SetProperty( Actor::Property::VISIBLE, true );
6637   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6638
6639   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6640   data.Reset();
6641
6642   actor.SetProperty( Actor::Property::VISIBLE, true );
6643   data.Check( false /* not called */, TEST_LOCATION );
6644
6645   END_TEST;
6646 }
6647
6648 int utcDaliActorVisibilityChangeSignalChildren(void)
6649 {
6650   TestApplication application;
6651   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6652
6653   Actor parent = Actor::New();
6654   Actor child = Actor::New();
6655   parent.Add( child );
6656
6657   Actor grandChild = Actor::New();
6658   child.Add( grandChild );
6659
6660   VisibilityChangedFunctorData parentData;
6661   VisibilityChangedFunctorData childData;
6662   VisibilityChangedFunctorData grandChildData;
6663
6664   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6665   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6666   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6667
6668   parent.SetProperty( Actor::Property::VISIBLE, false );
6669   parentData.Check( false /* not called */, TEST_LOCATION );
6670   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6671   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6672
6673   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6674   parentData.Reset();
6675   childData.Reset();
6676   grandChildData.Reset();
6677
6678   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6679
6680   parent.SetProperty( Actor::Property::VISIBLE, true );
6681   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6682   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6683   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6684
6685   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6686   parentData.Reset();
6687   childData.Reset();
6688   grandChildData.Reset();
6689
6690   parent.SetProperty( Actor::Property::VISIBLE, true );
6691   parentData.Check( false /* not called */, TEST_LOCATION );
6692   childData.Check( false /* not called */, TEST_LOCATION );
6693   grandChildData.Check( false /* not called */, TEST_LOCATION );
6694
6695   END_TEST;
6696 }
6697
6698 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6699 {
6700   TestApplication application;
6701   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6702
6703   Actor actor = Actor::New();
6704   application.GetScene().Add( actor );
6705
6706   application.SendNotification();
6707   application.Render();
6708
6709   VisibilityChangedFunctorData data;
6710   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6711
6712   Animation animation = Animation::New( 1.0f );
6713   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6714
6715   data.Check( false, TEST_LOCATION );
6716   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6717   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6718
6719   tet_infoline( "Play the animation and check the property value" );
6720   animation.Play();
6721
6722   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6723   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6724
6725   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6726   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6727
6728   application.SendNotification();
6729   application.Render( 1100 ); // After the animation
6730
6731   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6732
6733   END_TEST;
6734 }
6735
6736
6737 int utcDaliActorVisibilityChangeSignalByName(void)
6738 {
6739   TestApplication application;
6740   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6741
6742   Actor actor = Actor::New();
6743
6744   bool signalCalled=false;
6745   actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6746   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6747   actor.SetProperty( Actor::Property::VISIBLE, false );
6748   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6749
6750   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6751   signalCalled = false;
6752   actor.SetProperty( Actor::Property::VISIBLE, false );
6753   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6754
6755   tet_infoline( "Change the visibility using properties, ensure called" );
6756   actor.SetProperty( Actor::Property::VISIBLE, true );
6757   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6758
6759   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6760   signalCalled = false;
6761
6762   actor.SetProperty( Actor::Property::VISIBLE, true );
6763   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6764
6765   END_TEST;
6766 }
6767
6768
6769 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6770 {
6771   gLayoutDirectionType = type;
6772 }
6773
6774 int UtcDaliActorLayoutDirectionProperty(void)
6775 {
6776   TestApplication application;
6777   tet_infoline( "Check layout direction property" );
6778
6779   Actor actor0 = Actor::New();
6780   DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6781   application.GetScene().Add( actor0 );
6782
6783   application.SendNotification();
6784   application.Render();
6785
6786   Actor actor1 = Actor::New();
6787   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6788   Actor actor2 = Actor::New();
6789   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6790   Actor actor3 = Actor::New();
6791   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6792   Actor actor4 = Actor::New();
6793   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6794   Actor actor5 = Actor::New();
6795   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6796   Actor actor6 = Actor::New();
6797   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6798   Actor actor7 = Actor::New();
6799   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6800   Actor actor8 = Actor::New();
6801   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6802   Actor actor9 = Actor::New();
6803   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6804
6805   actor1.Add( actor2 );
6806   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6807   actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6808
6809   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6810   actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6811   DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6812
6813   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6814   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6815   DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6816
6817   actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6818   actor0.Add( actor1 );
6819   DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6820   DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821
6822   application.GetScene().Add( actor3 );
6823   actor3.Add( actor4 );
6824   actor4.Add( actor5 );
6825   actor5.Add( actor6 );
6826   actor5.Add( actor7 );
6827   actor7.Add( actor8 );
6828   actor8.Add( actor9 );
6829   actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6830   actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6831
6832   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6833   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6834   DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6835
6836   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6837
6838   DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6839   DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6840   DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6841   DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6842   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6843   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6844   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6845
6846   actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6847   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6848   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6849
6850   actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6851   DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6852   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6853   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6854
6855   actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6856   DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6857   DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6858
6859   END_TEST;
6860 }
6861
6862
6863 struct LayoutDirectionFunctor
6864 {
6865   LayoutDirectionFunctor(bool& signalCalled)
6866   : mSignalCalled( signalCalled )
6867   {
6868   }
6869
6870   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6871   : mSignalCalled( rhs.mSignalCalled )
6872   {
6873   }
6874
6875   void operator()()
6876   {
6877     mSignalCalled = true;
6878   }
6879
6880   bool& mSignalCalled;
6881 };
6882
6883 int UtcDaliActorLayoutDirectionSignal(void)
6884 {
6885   TestApplication application;
6886   tet_infoline( "Check changing layout direction property sends a signal" );
6887
6888   Actor actor = Actor::New();
6889   DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6890   application.GetScene().Add( actor );
6891   bool signalCalled = false;
6892   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6893
6894   actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6895   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6896
6897   // Test that writing the same value doesn't send a signal
6898   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6899   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6900
6901   // Test that writing a different value sends the signal
6902   signalCalled = false;
6903   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6904   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6905
6906   signalCalled = false;
6907   actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6908   DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6909
6910   END_TEST;
6911 }
6912
6913 struct ChildAddedSignalCheck
6914 {
6915   ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6916   : mSignalReceived( signalReceived ),
6917     mChildHandle( childHandle )
6918   {
6919   }
6920
6921   void operator() ( Actor childHandle )
6922   {
6923     mSignalReceived = true;
6924     mChildHandle = childHandle;
6925   }
6926   void operator() ()
6927   {
6928     mSignalReceived = true;
6929     mChildHandle = Actor();
6930   }
6931
6932   bool& mSignalReceived;
6933   Actor& mChildHandle;
6934 };
6935
6936 int UtcDaliChildAddedSignalP1(void)
6937 {
6938   TestApplication application;
6939   auto stage = application.GetScene();
6940
6941   bool signalReceived=false;
6942   Actor childActor;
6943
6944   ChildAddedSignalCheck signal( signalReceived, childActor );
6945   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6946   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6947
6948   auto actorA = Actor::New();
6949   stage.Add( actorA );
6950   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6951   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6952   signalReceived = false;
6953
6954   auto actorB = Actor::New();
6955   stage.Add( actorB );
6956   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6957   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6958
6959   END_TEST;
6960 }
6961
6962
6963 int UtcDaliChildAddedSignalP2(void)
6964 {
6965   TestApplication application;
6966   auto stage = application.GetScene();
6967
6968   bool signalReceived=false;
6969   Actor childActor;
6970
6971   ChildAddedSignalCheck signal( signalReceived, childActor );
6972   tet_infoline( "Connect to childAdded signal by name" );
6973
6974   stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6975   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6976
6977   auto actorA = Actor::New();
6978   stage.Add( actorA );
6979   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6980
6981   // Can't test which actor was added; signal signature is void() when connecting via name.
6982   signalReceived = false;
6983
6984   auto actorB = Actor::New();
6985   stage.Add( actorB );
6986   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6987
6988   END_TEST;
6989 }
6990
6991 int UtcDaliChildAddedSignalN(void)
6992 {
6993   TestApplication application;
6994   auto stage = application.GetScene();
6995
6996   bool signalReceived=false;
6997   Actor childActor;
6998
6999   ChildAddedSignalCheck signal( signalReceived, childActor );
7000   DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7001   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7002
7003   auto actorA = Actor::New();
7004   stage.Add( actorA );
7005   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7006   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7007   signalReceived = false;
7008
7009   auto actorB = Actor::New();
7010   actorA.Add( actorB );
7011   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7012   END_TEST;
7013 }
7014
7015
7016 struct ChildRemovedSignalCheck
7017 {
7018   ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7019   : mSignalReceived( signalReceived ),
7020     mChildHandle( childHandle )
7021   {
7022   }
7023
7024   void operator() ( Actor childHandle )
7025   {
7026     mSignalReceived = true;
7027     mChildHandle = childHandle;
7028   }
7029
7030   void operator() ()
7031   {
7032     mSignalReceived = true;
7033   }
7034
7035   bool& mSignalReceived;
7036   Actor& mChildHandle;
7037 };
7038
7039 int UtcDaliChildRemovedSignalP1(void)
7040 {
7041   TestApplication application;
7042   auto stage = application.GetScene();
7043
7044   bool signalReceived=false;
7045   Actor childActor;
7046
7047   ChildRemovedSignalCheck signal( signalReceived, childActor );
7048   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7049   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7050
7051   auto actorA = Actor::New();
7052   stage.Add( actorA );
7053   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7054   DALI_TEST_CHECK( !childActor );
7055
7056   stage.Remove( actorA );
7057   DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7058   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7059
7060   signalReceived = false;
7061   auto actorB = Actor::New();
7062   stage.Add( actorB );
7063   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7064
7065   stage.Remove( actorB );
7066   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7067   DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7068
7069   END_TEST;
7070 }
7071
7072 int UtcDaliChildRemovedSignalP2(void)
7073 {
7074   TestApplication application;
7075   auto stage = application.GetScene();
7076
7077   bool signalReceived=false;
7078   Actor childActor;
7079
7080   ChildAddedSignalCheck signal( signalReceived, childActor );
7081   tet_infoline( "Connect to childRemoved signal by name" );
7082
7083   stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7084   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7085
7086   auto actorA = Actor::New();
7087   stage.Add( actorA );
7088   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7089
7090   stage.Remove( actorA );
7091   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7092
7093   signalReceived = false;
7094   auto actorB = Actor::New();
7095   stage.Add( actorB );
7096   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7097
7098   stage.Remove( actorB );
7099   DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7100
7101   END_TEST;
7102 }
7103
7104
7105 int UtcDaliChildRemovedSignalN(void)
7106 {
7107   TestApplication application;
7108   auto stage = application.GetScene();
7109
7110   bool signalReceived=false;
7111   Actor childActor;
7112
7113   ChildRemovedSignalCheck signal( signalReceived, childActor );
7114   DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7115   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7116
7117   auto actorA = Actor::New();
7118   stage.Add( actorA );
7119
7120   auto actorB = Actor::New();
7121   actorA.Add( actorB );
7122
7123   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7124   DALI_TEST_CHECK( ! childActor );
7125
7126   actorA.Remove( actorB );
7127   DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7128   END_TEST;
7129 }
7130
7131
7132 int UtcDaliChildMovedSignalP(void)
7133 {
7134   TestApplication application;
7135   auto stage = application.GetScene();
7136
7137   bool addedASignalReceived   = false;
7138   bool removedASignalReceived = false;
7139   bool addedBSignalReceived   = false;
7140   bool removedBSignalReceived = false;
7141   Actor childActor;
7142
7143   auto actorA = Actor::New();
7144   auto actorB = Actor::New();
7145   stage.Add( actorA );
7146   stage.Add( actorB );
7147
7148   ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7149   ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7150   ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7151   ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7152
7153   DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7154   DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7155   DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7156   DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7157
7158   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7159   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7160   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7161   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7162
7163   // Create a child of A
7164
7165   auto child = Actor::New();
7166   actorA.Add( child );
7167
7168   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7169   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7170   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7171   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7172   DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7173
7174   // Move child to B:
7175   addedASignalReceived   = false;
7176   addedBSignalReceived   = false;
7177   removedASignalReceived = false;
7178   removedBSignalReceived = false;
7179
7180   actorB.Add( child ); // Expect this child to be re-parented
7181   DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7182   DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7183   DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7184   DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7185
7186   // Move child back to A:
7187   addedASignalReceived   = false;
7188   addedBSignalReceived   = false;
7189   removedASignalReceived = false;
7190   removedBSignalReceived = false;
7191
7192   actorA.Add( child ); // Expect this child to be re-parented
7193   DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7194   DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7195   DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7196   DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7197
7198
7199   END_TEST;
7200 }
7201
7202 int utcDaliActorCulled(void)
7203 {
7204   TestApplication application;
7205   auto stage = application.GetScene();
7206
7207   tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7208
7209   Actor actor = Actor::New();
7210   actor.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 10.0f ) );
7211
7212   Geometry geometry = CreateQuadGeometry();
7213   Shader shader = CreateShader();
7214   Renderer renderer = Renderer::New(geometry, shader);
7215   actor.AddRenderer( renderer );
7216
7217   stage.Add( actor );
7218
7219   application.SendNotification();
7220   application.Render( 0 );
7221
7222   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), false, TEST_LOCATION );
7223
7224   PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::CULLED, LessThanCondition( 0.5f ) );
7225   notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7226
7227   // Connect NotifySignal
7228   bool propertyNotificationSignal( false );
7229   PropertyNotification source;
7230   CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7231   notification.NotifySignal().Connect( &application, f ) ;
7232
7233   actor.SetProperty( Actor::Property::POSITION, Vector2( 1000.0f, 1000.0f ));
7234
7235   application.SendNotification();
7236   application.Render();
7237
7238   application.SendNotification();
7239
7240   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), true, TEST_LOCATION );
7241
7242   DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7243   DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( Actor::Property::CULLED ), TEST_LOCATION );
7244   DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7245
7246   END_TEST;
7247 }
7248
7249 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7250 {
7251   TestApplication application;
7252   auto stage = application.GetScene();
7253
7254   tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7255
7256   Actor actor = CreateRenderableActor();
7257   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7258   stage.Add( actor );
7259
7260   application.SendNotification();
7261   application.Render();
7262
7263   auto& glAbstraction = application.GetGlAbstraction();
7264   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7265
7266   actor.Unparent();
7267
7268   application.SendNotification();
7269   application.Render();
7270
7271   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7272
7273   END_TEST;
7274 }
7275
7276 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7277 {
7278   TestApplication application;
7279   auto stage = application.GetScene();
7280
7281   tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7282
7283   Actor actor = CreateRenderableActor();
7284   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7285   stage.Add( actor );
7286
7287   application.SendNotification();
7288   application.Render();
7289
7290   auto& glAbstraction = application.GetGlAbstraction();
7291   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7292
7293   actor.SetProperty( Actor::Property::VISIBLE, false );
7294
7295   application.SendNotification();
7296   application.Render();
7297
7298   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7299
7300   END_TEST;
7301 }
7302
7303 int utcDaliActorGetSizeAfterAnimation(void)
7304 {
7305   TestApplication application;
7306   tet_infoline( "Check the actor size before / after an animation is finished" );
7307
7308   Vector3 actorSize( 100.0f, 100.0f, 0.0f );
7309
7310   Actor actor = Actor::New();
7311   actor.SetProperty( Actor::Property::SIZE, actorSize );
7312   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7313   application.GetScene().Add( actor );
7314
7315   // Size should be updated without rendering.
7316   Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7317   DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7318
7319   application.SendNotification();
7320   application.Render();
7321
7322   // Size and current size should be updated.
7323   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7324   DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7325   DALI_TEST_EQUALS( actorSize.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7326   DALI_TEST_EQUALS( actorSize.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7327   DALI_TEST_EQUALS( actorSize.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7328
7329   Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7330   DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7331   DALI_TEST_EQUALS( actorSize.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7332   DALI_TEST_EQUALS( actorSize.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7333   DALI_TEST_EQUALS( actorSize.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7334
7335   // Set size again
7336   actorSize = Vector3( 200.0f, 200.0f, 0.0f );
7337   actor.SetProperty( Actor::Property::SIZE, actorSize );
7338
7339   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7340   DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7341
7342   Vector3 targetValue( 10.0f, 20.0f, 0.0f );
7343
7344   Animation animation = Animation::New( 1.0f );
7345   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7346   animation.Play();
7347
7348   // Size should be updated without rendering.
7349   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7350   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7351
7352   application.SendNotification();
7353   application.Render( 1100 ); // After the animation
7354
7355   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7356   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7357   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7358   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7359   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7360
7361   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7362   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7363   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7364   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7365   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7366
7367   targetValue.width = 50.0f;
7368
7369   animation.Clear();
7370   animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7371   animation.Play();
7372
7373   application.SendNotification();
7374   application.Render( 1100 ); // After the animation
7375
7376   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7377   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7378   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7379   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7380   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7381
7382   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7383   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7384   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7385   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7386   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7387
7388   targetValue.height = 70.0f;
7389
7390   animation.Clear();
7391   animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7392   animation.Play();
7393
7394   application.SendNotification();
7395   application.Render( 1100 ); // After the animation
7396
7397   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7398   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7399   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7400   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7401   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7402
7403   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7404   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7405   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7406   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7407   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7408
7409   Vector3 offset( 10.0f, 20.0f, 0.0f );
7410
7411   animation.Clear();
7412   animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7413   animation.Play();
7414
7415   application.SendNotification();
7416   application.Render( 1100 ); // After the animation
7417
7418   targetValue += offset;
7419
7420   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7421   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7422   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7423   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7424   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7425
7426   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7427   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7428   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7429   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7430   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7431
7432   offset.width = 20.0f;
7433
7434   animation.Clear();
7435   animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7436   animation.Play();
7437
7438   application.SendNotification();
7439   application.Render( 1100 ); // After the animation
7440
7441   targetValue.width += offset.width;
7442
7443   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7444   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7445   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7446   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7447   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7448
7449   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7450   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7451   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7452   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7453   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7454
7455   offset.height = 10.0f;
7456
7457   animation.Clear();
7458   animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7459   animation.Play();
7460
7461   application.SendNotification();
7462   application.Render( 1100 ); // After the animation
7463
7464   targetValue.height += offset.height;
7465
7466   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7467   DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7468   DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7469   DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7470   DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7471
7472   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7473   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7474   DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7475   DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7476   DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7477
7478   // Set size again
7479   actorSize = Vector3( 300.0f, 300.0f, 0.0f );
7480
7481   actor.SetProperty( Actor::Property::SIZE, actorSize );
7482
7483   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7484   DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7485
7486   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7487   DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7488
7489   application.SendNotification();
7490   application.Render();
7491
7492   size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7493   DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7494
7495   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7496   DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7497
7498   END_TEST;
7499 }
7500
7501 int utcDaliActorPartialUpdate(void)
7502 {
7503   TestApplication application(
7504     TestApplication::DEFAULT_SURFACE_WIDTH,
7505     TestApplication::DEFAULT_SURFACE_HEIGHT,
7506     TestApplication::DEFAULT_HORIZONTAL_DPI,
7507     TestApplication::DEFAULT_VERTICAL_DPI,
7508     true,
7509     true);
7510
7511   tet_infoline("Check the damaged area");
7512
7513   const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7514
7515   std::vector<Rect<int>> damagedRects;
7516   Rect<int> clippingRect;
7517   application.SendNotification();
7518   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7519
7520   // First render pass, nothing to render, adaptor would just do swap buffer.
7521   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7522   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7523
7524   Actor actor = CreateRenderableActor();
7525   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7526   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7527   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7528   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7529   application.GetScene().Add(actor);
7530
7531   application.SendNotification();
7532
7533   // 1. Actor added, damaged rect is added size of actor
7534   damagedRects.clear();
7535   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7536   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7537
7538   // Aligned by 16
7539   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7540   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7541   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7542   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7543   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7544   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7545   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7546
7547   // 2. Set new size
7548   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7549   application.SendNotification();
7550
7551   damagedRects.clear();
7552   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7553   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7554
7555   // Aligned by 16
7556   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7557   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7558   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7559   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7560   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7561   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7562   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7563
7564   // 3. Set new position
7565   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7566   application.SendNotification();
7567
7568   damagedRects.clear();
7569   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7570   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7571
7572   // Aligned by 16
7573   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7574   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7575   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7576   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7577   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7578   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7579   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7580
7581   application.GetScene().Remove(actor);
7582   application.SendNotification();
7583
7584   // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7585   damagedRects.clear();
7586   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7587   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7588
7589   clippingRect = damagedRects[0];
7590   clippingRect.Merge(damagedRects[1]);
7591   clippingRect.Merge(damagedRects[2]);
7592
7593   DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7594   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7595   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7596
7597   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7598   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7599   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7600   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7601   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7602
7603   END_TEST;
7604 }
7605
7606 int utcDaliActorPartialUpdateSetColor(void)
7607 {
7608   TestApplication application(
7609     TestApplication::DEFAULT_SURFACE_WIDTH,
7610     TestApplication::DEFAULT_SURFACE_HEIGHT,
7611     TestApplication::DEFAULT_HORIZONTAL_DPI,
7612     TestApplication::DEFAULT_VERTICAL_DPI,
7613     true,
7614     true);
7615
7616   tet_infoline("Check uniform update");
7617
7618   const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7619
7620   std::vector<Rect<int>> damagedRects;
7621   Rect<int> clippingRect;
7622   application.SendNotification();
7623   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7624
7625   // First render pass, nothing to render, adaptor would just do swap buffer.
7626   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7627   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7628
7629   Actor actor = CreateRenderableActor();
7630   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7631   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7632   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7633   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7634   application.GetScene().Add(actor);
7635
7636   application.SendNotification();
7637
7638   // 1. Actor added, damaged rect is added size of actor
7639   damagedRects.clear();
7640   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7641   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7642
7643   // Aligned by 16
7644   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7645   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7646   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7647   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7648   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7649   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7650   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7651
7652   damagedRects.clear();
7653   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7654
7655   damagedRects.clear();
7656   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7657
7658   // 2. Set new color
7659   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7660   application.SendNotification();
7661
7662   damagedRects.clear();
7663   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7664   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7665
7666   // Aligned by 16
7667   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7668   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7669   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7670   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7671   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7672   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7673   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7674
7675   END_TEST;
7676 }
7677
7678 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7679 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7680 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7681 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7682   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7683   " uniform mediump mat4 uLightCameraViewMatrix;\n"
7684   "\n"
7685   "void main()\n"
7686   "{\n"
7687   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7688   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
7689   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7690   "}\n";
7691
7692 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7693   "uniform lowp vec4 uShadowColor;\n"
7694   "void main()\n"
7695   "{\n"
7696   "  lowp float alpha;\n"
7697   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7698   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7699   "}\n";
7700
7701 int utcDaliActorPartialUpdateSetProperty(void)
7702 {
7703   TestApplication application(
7704     TestApplication::DEFAULT_SURFACE_WIDTH,
7705     TestApplication::DEFAULT_SURFACE_HEIGHT,
7706     TestApplication::DEFAULT_HORIZONTAL_DPI,
7707     TestApplication::DEFAULT_VERTICAL_DPI,
7708     true,
7709     true);
7710  
7711   tet_infoline( "Set/Update property with partial update" );
7712
7713   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7714
7715   std::vector<Rect<int>> damagedRects;
7716   Rect<int> clippingRect;
7717   application.SendNotification();
7718   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7719
7720   // First render pass, nothing to render, adaptor would just do swap buffer.
7721   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7722   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7723
7724   Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7725   Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7726   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7727   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7728   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7729   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7730   application.GetScene().Add(actor);
7731
7732   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7733
7734   damagedRects.clear();
7735   application.SendNotification();
7736   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7737   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7738
7739   // Aligned by 16
7740   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7741   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7742   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7743   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7744   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7745   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7746   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7747
7748   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex( SHADER_SHADOW_COLOR_PROPERTY_NAME );
7749   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7750
7751   damagedRects.clear();
7752   application.SendNotification();
7753   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7754   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7755
7756   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7757   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7758   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7759   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7760   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7761   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7762
7763   damagedRects.clear();
7764   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7765   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7766
7767   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7768   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7769   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7770   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7771   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7772   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7773
7774   damagedRects.clear();
7775   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7776   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7777
7778   END_TEST;
7779 }
7780
7781 int utcDaliActorPartialUpdateTwoActors(void)
7782 {
7783   TestApplication application(
7784     TestApplication::DEFAULT_SURFACE_WIDTH,
7785     TestApplication::DEFAULT_SURFACE_HEIGHT,
7786     TestApplication::DEFAULT_HORIZONTAL_DPI,
7787     TestApplication::DEFAULT_VERTICAL_DPI,
7788     true,
7789     true);
7790
7791   tet_infoline("Check the damaged rects with partial update and two actors");
7792
7793   const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7794
7795   Actor actor = CreateRenderableActor();
7796   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7797   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7798   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7799   application.GetScene().Add(actor);
7800
7801   Actor actor2 = CreateRenderableActor();
7802   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7803   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7804   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7805   application.GetScene().Add(actor2);
7806
7807   application.SendNotification();
7808   std::vector<Rect<int>> damagedRects;
7809   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7810
7811   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7812   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7813   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7814
7815   // in screen coordinates, adaptor would calculate it using previous frames information
7816   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7817   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7818
7819   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7820   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7821   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7822   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7823
7824   END_TEST;
7825 }
7826
7827 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7828 {
7829   TestApplication application(
7830     TestApplication::DEFAULT_SURFACE_WIDTH,
7831     TestApplication::DEFAULT_SURFACE_HEIGHT,
7832     TestApplication::DEFAULT_HORIZONTAL_DPI,
7833     TestApplication::DEFAULT_VERTICAL_DPI,
7834     true,
7835     true);
7836
7837   tet_infoline( "Check the damaged rect with partial update and actor size hint" );
7838
7839   const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7840
7841   Actor actor = CreateRenderableActor();
7842   actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7843   actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7844   actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7845   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7846   application.GetScene().Add(actor);
7847
7848   application.SendNotification();
7849   std::vector<Rect<int>> damagedRects;
7850   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7851
7852   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7853
7854   Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7855   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7856
7857   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7858
7859   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7860   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7861   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7862   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7863
7864   END_TEST;
7865 }
7866