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