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