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