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