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