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