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