Added checks to Sibling Order Raise/Lower API
[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
983 int UtcDaliActorGetCurrentSize(void)
984 {
985   TestApplication application;
986
987   Actor actor = Actor::New();
988   Vector3 vector(100.0f, 100.0f, 20.0f);
989
990   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
991
992   actor.SetSize(vector);
993
994   // flush the queue and render once
995   application.SendNotification();
996   application.Render();
997
998   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
999   END_TEST;
1000 }
1001
1002 int UtcDaliActorGetNaturalSize(void)
1003 {
1004   TestApplication application;
1005
1006   Actor actor = Actor::New();
1007   Vector3 vector( 0.0f, 0.0f, 0.0f );
1008
1009   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1010
1011   END_TEST;
1012 }
1013
1014 int UtcDaliActorGetCurrentSizeImmediate(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.GetTargetSize());
1022   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1023
1024   actor.SetSize(vector);
1025
1026   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1027   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1028
1029   // flush the queue and render once
1030   application.SendNotification();
1031   application.Render();
1032
1033   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1034   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1035
1036   // Animation
1037   // Build the animation
1038   const float durationSeconds = 2.0f;
1039   Animation animation = Animation::New( durationSeconds );
1040   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1041   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1042
1043   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1044
1045   // Start the animation
1046   animation.Play();
1047
1048   application.SendNotification();
1049   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1050
1051   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1052
1053   END_TEST;
1054 }
1055
1056 // SetPosition(float x, float y)
1057 int UtcDaliActorSetPosition01(void)
1058 {
1059   TestApplication application;
1060
1061   Actor actor = Actor::New();
1062
1063   // Set to random to start off with
1064   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1065
1066   Vector3 vector(100.0f, 100.0f, 0.0f);
1067
1068   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1069
1070   actor.SetPosition(vector.x, vector.y);
1071   // flush the queue and render once
1072   application.SendNotification();
1073   application.Render();
1074   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1075
1076   Stage::GetCurrent().Add( actor );
1077   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1078   // flush the queue and render once
1079   application.SendNotification();
1080   application.Render();
1081   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1082
1083   actor.SetX( 1.0f );
1084   actor.SetY( 1.1f );
1085   actor.SetZ( 1.2f );
1086   // flush the queue and render once
1087   application.SendNotification();
1088   application.Render();
1089   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1090
1091   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1092   // flush the queue and render once
1093   application.SendNotification();
1094   application.Render();
1095   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1096
1097   Stage::GetCurrent().Remove( actor );
1098   END_TEST;
1099 }
1100
1101 // SetPosition(float x, float y, float z)
1102 int UtcDaliActorSetPosition02(void)
1103 {
1104   TestApplication application;
1105
1106   Actor actor = Actor::New();
1107
1108   // Set to random to start off with
1109   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1110
1111   Vector3 vector(100.0f, 100.0f, 100.0f);
1112
1113   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1114
1115   actor.SetPosition(vector.x, vector.y, vector.z);
1116
1117   // flush the queue and render once
1118   application.SendNotification();
1119   application.Render();
1120
1121   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1122   END_TEST;
1123 }
1124
1125 // SetPosition(Vector3 position)
1126 int UtcDaliActorSetPosition03(void)
1127 {
1128   TestApplication application;
1129
1130   Actor actor = Actor::New();
1131
1132   // Set to random to start off with
1133   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1134
1135   Vector3 vector(100.0f, 100.0f, 100.0f);
1136
1137   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1138
1139   actor.SetPosition(vector);
1140
1141   // flush the queue and render once
1142   application.SendNotification();
1143   application.Render();
1144
1145   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1146   END_TEST;
1147 }
1148
1149 int UtcDaliActorSetX(void)
1150 {
1151   TestApplication application;
1152
1153   Actor actor = Actor::New();
1154
1155   Vector3 vector(100.0f, 0.0f, 0.0f);
1156
1157   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1158
1159   actor.SetX(100.0f);
1160
1161   // flush the queue and render once
1162   application.SendNotification();
1163   application.Render();
1164
1165   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1166   END_TEST;
1167 }
1168
1169 int UtcDaliActorSetY(void)
1170 {
1171   TestApplication application;
1172
1173   Actor actor = Actor::New();
1174
1175   Vector3 vector(0.0f, 100.0f, 0.0f);
1176
1177   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1178
1179   actor.SetY(100.0f);
1180
1181   // flush the queue and render once
1182   application.SendNotification();
1183   application.Render();
1184
1185   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1186   END_TEST;
1187 }
1188
1189 int UtcDaliActorSetZ(void)
1190 {
1191   TestApplication application;
1192
1193   Actor actor = Actor::New();
1194
1195   Vector3 vector(0.0f, 0.0f, 100.0f);
1196
1197   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1198
1199   actor.SetZ(100.0f);
1200
1201   // flush the queue and render once
1202   application.SendNotification();
1203   application.Render();
1204
1205   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1206   END_TEST;
1207 }
1208
1209 int UtcDaliActorSetPositionProperties(void)
1210 {
1211   TestApplication application;
1212
1213   Actor actor = Actor::New();
1214
1215   Vector3 vector(0.7f, 0.8f, 0.9f);
1216   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1217
1218   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1219
1220   // flush the queue and render once
1221   application.SendNotification();
1222   application.Render();
1223
1224   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1225
1226   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1227
1228   // flush the queue and render once
1229   application.SendNotification();
1230   application.Render();
1231
1232   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1233
1234   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1235
1236   // flush the queue and render once
1237   application.SendNotification();
1238   application.Render();
1239
1240   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1241
1242   END_TEST;
1243 }
1244
1245 int UtcDaliActorTranslateBy(void)
1246 {
1247   TestApplication application;
1248
1249   Actor actor = Actor::New();
1250   Vector3 vector(100.0f, 100.0f, 100.0f);
1251
1252   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1253
1254   actor.SetPosition(vector);
1255
1256   // flush the queue and render once
1257   application.SendNotification();
1258   application.Render();
1259
1260   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1261
1262   actor.TranslateBy(vector);
1263
1264   // flush the queue and render once
1265   application.SendNotification();
1266   application.Render();
1267
1268   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1269   END_TEST;
1270 }
1271
1272 int UtcDaliActorGetCurrentPosition(void)
1273 {
1274   TestApplication application;
1275
1276   Actor actor = Actor::New();
1277   Vector3 setVector(100.0f, 100.0f, 0.0f);
1278   actor.SetPosition(setVector);
1279
1280   // flush the queue and render once
1281   application.SendNotification();
1282   application.Render();
1283
1284   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1285   END_TEST;
1286 }
1287
1288 int UtcDaliActorGetCurrentWorldPosition(void)
1289 {
1290   TestApplication application;
1291
1292   Actor parent = Actor::New();
1293   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1294   parent.SetPosition( parentPosition );
1295   parent.SetParentOrigin( ParentOrigin::CENTER );
1296   parent.SetAnchorPoint( AnchorPoint::CENTER );
1297   Stage::GetCurrent().Add( parent );
1298
1299   Actor child = Actor::New();
1300   child.SetParentOrigin( ParentOrigin::CENTER );
1301   child.SetAnchorPoint( AnchorPoint::CENTER );
1302   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1303   child.SetPosition( childPosition );
1304   parent.Add( child );
1305
1306   // The actors should not have a world position yet
1307   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1308   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1309
1310   application.SendNotification();
1311   application.Render(0);
1312
1313   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1314   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1315
1316   // The actors should have a world position now
1317   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1318   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1319   END_TEST;
1320 }
1321
1322 int UtcDaliActorInheritPosition(void)
1323 {
1324   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1325   TestApplication application;
1326
1327   Actor parent = Actor::New();
1328   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1329   parent.SetPosition( parentPosition );
1330   parent.SetParentOrigin( ParentOrigin::CENTER );
1331   parent.SetAnchorPoint( AnchorPoint::CENTER );
1332   Stage::GetCurrent().Add( parent );
1333
1334   Actor child = Actor::New();
1335   child.SetParentOrigin( ParentOrigin::CENTER );
1336   child.SetAnchorPoint( AnchorPoint::CENTER );
1337   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1338   child.SetPosition( childPosition );
1339   parent.Add( child );
1340
1341   // The actors should not have a world position yet
1342   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1343   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1344
1345   // first test default, which is to inherit position
1346   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1347   application.SendNotification();
1348   application.Render(0); // should only really call Update as Render is not required to update scene
1349   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1350   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1351   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1352   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1353
1354
1355   //Change child position
1356   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1357   child.SetPosition( childOffset );
1358
1359   // Change inheritance mode to not inherit
1360   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1361   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1362   application.SendNotification();
1363   application.Render(0); // should only really call Update as Render is not required to update scene
1364   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1365   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1366   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1367   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1368   END_TEST;
1369 }
1370
1371 int UtcDaliActorSetInheritPosition(void)
1372 {
1373   tet_infoline("Testing Actor::SetInheritPosition");
1374   TestApplication application;
1375
1376   Actor parent = Actor::New();
1377   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1378   parent.SetPosition( parentPosition );
1379   parent.SetParentOrigin( ParentOrigin::CENTER );
1380   parent.SetAnchorPoint( AnchorPoint::CENTER );
1381   Stage::GetCurrent().Add( parent );
1382
1383   Actor child = Actor::New();
1384   child.SetParentOrigin( ParentOrigin::CENTER );
1385   child.SetAnchorPoint( AnchorPoint::CENTER );
1386   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1387   child.SetPosition( childPosition );
1388   parent.Add( child );
1389
1390   // The actors should not have a world position yet
1391   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1392   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1393
1394   // first test default, which is to inherit position
1395   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1396   application.SendNotification();
1397   application.Render(0); // should only really call Update as Render is not required to update scene
1398   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1399   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1400   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1401   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1402
1403   //Change child position
1404   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1405   child.SetPosition( childOffset );
1406
1407   // Use local position as world postion
1408   child.SetInheritPosition( false );
1409   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1410   application.SendNotification();
1411   application.Render(0); // should only really call Update as Render is not required to update scene
1412   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1413   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1414   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1415   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1416
1417   //Change back to inherit position from parent
1418   child.SetInheritPosition( true );
1419   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1420   application.SendNotification();
1421   application.Render(0); // should only really call Update as Render is not required to update scene
1422   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1423   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1424   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1425   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1426   END_TEST;
1427 }
1428
1429 // SetOrientation(float angleRadians, Vector3 axis)
1430 int UtcDaliActorSetOrientation01(void)
1431 {
1432   TestApplication application;
1433
1434   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1435   Actor actor = Actor::New();
1436
1437   actor.SetOrientation(rotation);
1438
1439   // flush the queue and render once
1440   application.SendNotification();
1441   application.Render();
1442
1443   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1444   END_TEST;
1445 }
1446
1447 int UtcDaliActorSetOrientation02(void)
1448 {
1449   TestApplication application;
1450
1451   Actor actor = Actor::New();
1452
1453   Radian angle( 0.785f );
1454   Vector3 axis(1.0f, 1.0f, 0.0f);
1455
1456   actor.SetOrientation( angle, axis);
1457   Quaternion rotation( angle, axis );
1458   // flush the queue and render once
1459   application.SendNotification();
1460   application.Render();
1461   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1462
1463   Stage::GetCurrent().Add( actor );
1464   actor.RotateBy( Degree( 360 ), axis);
1465   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1466
1467   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1468   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1469   // flush the queue and render once
1470   application.SendNotification();
1471   application.Render();
1472   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1473
1474   actor.SetOrientation( angle, axis);
1475   // flush the queue and render once
1476   application.SendNotification();
1477   application.Render();
1478   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1479
1480   Stage::GetCurrent().Remove( actor );
1481   END_TEST;
1482 }
1483
1484 // SetOrientation(float angleRadians, Vector3 axis)
1485 int UtcDaliActorSetOrientationProperty(void)
1486 {
1487   TestApplication application;
1488
1489   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1490   Actor actor = Actor::New();
1491
1492   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1493
1494   // flush the queue and render once
1495   application.SendNotification();
1496   application.Render();
1497
1498   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1499   END_TEST;
1500 }
1501
1502 // RotateBy(float angleRadians, Vector3 axis)
1503 int UtcDaliActorRotateBy01(void)
1504 {
1505   TestApplication application;
1506
1507   Actor actor = Actor::New();
1508
1509   Radian angle( M_PI * 0.25f );
1510   actor.RotateBy(( angle ), Vector3::ZAXIS);
1511   // flush the queue and render once
1512   application.SendNotification();
1513   application.Render();
1514   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1515
1516   Stage::GetCurrent().Add( actor );
1517
1518   actor.RotateBy( angle, Vector3::ZAXIS);
1519   // flush the queue and render once
1520   application.SendNotification();
1521   application.Render();
1522   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1523
1524   Stage::GetCurrent().Remove( actor );
1525   END_TEST;
1526 }
1527
1528 // RotateBy(Quaternion relativeRotation)
1529 int UtcDaliActorRotateBy02(void)
1530 {
1531   TestApplication application;
1532
1533   Actor actor = Actor::New();
1534
1535   Radian angle( M_PI * 0.25f );
1536   Quaternion rotation(angle, Vector3::ZAXIS);
1537   actor.RotateBy(rotation);
1538   // flush the queue and render once
1539   application.SendNotification();
1540   application.Render();
1541   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1542
1543   actor.RotateBy(rotation);
1544   // flush the queue and render once
1545   application.SendNotification();
1546   application.Render();
1547   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1548   END_TEST;
1549 }
1550
1551 int UtcDaliActorGetCurrentOrientation(void)
1552 {
1553   TestApplication application;
1554   Actor actor = Actor::New();
1555
1556   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1557   actor.SetOrientation(rotation);
1558   // flush the queue and render once
1559   application.SendNotification();
1560   application.Render();
1561   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1562   END_TEST;
1563 }
1564
1565 int UtcDaliActorGetCurrentWorldOrientation(void)
1566 {
1567   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1568   TestApplication application;
1569
1570   Actor parent = Actor::New();
1571   Radian rotationAngle( Degree(90.0f) );
1572   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1573   parent.SetOrientation( rotation );
1574   Stage::GetCurrent().Add( parent );
1575
1576   Actor child = Actor::New();
1577   child.SetOrientation( rotation );
1578   parent.Add( child );
1579
1580   // The actors should not have a world rotation yet
1581   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1582   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1583
1584   application.SendNotification();
1585   application.Render(0);
1586
1587   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1588   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1589
1590   // The actors should have a world rotation now
1591   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1592   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1593
1594   // turn off child rotation inheritance
1595   child.SetInheritOrientation( false );
1596   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1597   application.SendNotification();
1598   application.Render(0);
1599
1600   // The actors should have a world rotation now
1601   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1602   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1603   END_TEST;
1604 }
1605
1606 // SetScale(float scale)
1607 int UtcDaliActorSetScale01(void)
1608 {
1609   TestApplication application;
1610
1611   Actor actor = Actor::New();
1612
1613   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1614   actor.SetScale(0.25f);
1615
1616   Vector3 scale(10.0f, 10.0f, 10.0f);
1617   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1618
1619   actor.SetScale(scale.x);
1620
1621   // flush the queue and render once
1622   application.SendNotification();
1623   application.Render();
1624
1625   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1626   END_TEST;
1627 }
1628
1629 // SetScale(float scaleX, float scaleY, float scaleZ)
1630 int UtcDaliActorSetScale02(void)
1631 {
1632   TestApplication application;
1633   Vector3 scale(10.0f, 10.0f, 10.0f);
1634
1635   Actor actor = Actor::New();
1636
1637   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1638   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1639
1640   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1641
1642   actor.SetScale(scale.x, scale.y, scale.z);
1643   // flush the queue and render once
1644   application.SendNotification();
1645   application.Render();
1646   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1647
1648   // add to stage and test
1649   Stage::GetCurrent().Add( actor );
1650   actor.SetScale( 2.0f, 2.0f, 2.0f );
1651   // flush the queue and render once
1652   application.SendNotification();
1653   application.Render();
1654   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1655
1656   Stage::GetCurrent().Remove( actor );
1657
1658   END_TEST;
1659 }
1660
1661 // SetScale(Vector3 scale)
1662 int UtcDaliActorSetScale03(void)
1663 {
1664   TestApplication application;
1665   Vector3 scale(10.0f, 10.0f, 10.0f);
1666
1667   Actor actor = Actor::New();
1668
1669   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1670   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1671
1672   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1673
1674   actor.SetScale(scale);
1675
1676   // flush the queue and render once
1677   application.SendNotification();
1678   application.Render();
1679
1680   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1681   END_TEST;
1682 }
1683
1684 int UtcDaliActorSetScaleIndividual(void)
1685 {
1686   TestApplication application;
1687
1688   Actor actor = Actor::New();
1689
1690   Vector3 vector(0.7f, 0.8f, 0.9f);
1691   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1692
1693   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1694
1695   // flush the queue and render once
1696   application.SendNotification();
1697   application.Render();
1698
1699   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1700
1701   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1702
1703   // flush the queue and render once
1704   application.SendNotification();
1705   application.Render();
1706
1707   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1708
1709   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1710
1711   // flush the queue and render once
1712   application.SendNotification();
1713   application.Render();
1714
1715   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1716
1717   END_TEST;
1718 }
1719
1720 int UtcDaliActorScaleBy(void)
1721 {
1722   TestApplication application;
1723   Actor actor = Actor::New();
1724   Vector3 vector(100.0f, 100.0f, 100.0f);
1725
1726   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1727
1728   actor.SetScale(vector);
1729
1730   // flush the queue and render once
1731   application.SendNotification();
1732   application.Render();
1733
1734   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1735
1736   actor.ScaleBy(vector);
1737
1738   // flush the queue and render once
1739   application.SendNotification();
1740   application.Render();
1741
1742   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1743   END_TEST;
1744 }
1745
1746 int UtcDaliActorGetCurrentScale(void)
1747 {
1748   TestApplication application;
1749   Vector3 scale(12.0f, 1.0f, 2.0f);
1750
1751   Actor actor = Actor::New();
1752
1753   actor.SetScale(scale);
1754
1755   // flush the queue and render once
1756   application.SendNotification();
1757   application.Render();
1758
1759   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1760   END_TEST;
1761 }
1762
1763 int UtcDaliActorGetCurrentWorldScale(void)
1764 {
1765   TestApplication application;
1766
1767   Actor parent = Actor::New();
1768   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1769   parent.SetScale( parentScale );
1770   Stage::GetCurrent().Add( parent );
1771
1772   Actor child = Actor::New();
1773   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1774   child.SetScale( childScale );
1775   parent.Add( child );
1776
1777   // The actors should not have a scale yet
1778   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1779   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1780
1781   // The actors should not have a world scale yet
1782   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1783   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1784
1785   application.SendNotification();
1786   application.Render(0);
1787
1788   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1789   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1790
1791   // The actors should have a world scale now
1792   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1793   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1794   END_TEST;
1795 }
1796
1797 int UtcDaliActorInheritScale(void)
1798 {
1799   tet_infoline("Testing Actor::SetInheritScale");
1800   TestApplication application;
1801
1802   Actor parent = Actor::New();
1803   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1804   parent.SetScale( parentScale );
1805   Stage::GetCurrent().Add( parent );
1806
1807   Actor child = Actor::New();
1808   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1809   child.SetScale( childScale );
1810   parent.Add( child );
1811
1812   application.SendNotification();
1813   application.Render(0);
1814
1815   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1816   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1817
1818   child.SetInheritScale( false );
1819   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1820
1821   application.SendNotification();
1822   application.Render(0);
1823
1824   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1825   END_TEST;
1826 }
1827
1828 int UtcDaliActorSetVisible(void)
1829 {
1830   TestApplication application;
1831
1832   Actor actor = Actor::New();
1833   actor.SetVisible(false);
1834   // flush the queue and render once
1835   application.SendNotification();
1836   application.Render();
1837   DALI_TEST_CHECK(actor.IsVisible() == false);
1838
1839   actor.SetVisible(true);
1840   // flush the queue and render once
1841   application.SendNotification();
1842   application.Render();
1843   DALI_TEST_CHECK(actor.IsVisible() == true);
1844
1845   // put actor on stage
1846   Stage::GetCurrent().Add( actor );
1847   actor.SetVisible(false);
1848   // flush the queue and render once
1849   application.SendNotification();
1850   application.Render();
1851   DALI_TEST_CHECK(actor.IsVisible() == false);
1852   END_TEST;
1853 }
1854
1855 int UtcDaliActorIsVisible(void)
1856 {
1857   TestApplication application;
1858
1859   Actor actor = Actor::New();
1860
1861   DALI_TEST_CHECK(actor.IsVisible() == true);
1862   END_TEST;
1863 }
1864
1865 int UtcDaliActorSetOpacity(void)
1866 {
1867   TestApplication application;
1868
1869   Actor actor = Actor::New();
1870   // initial opacity is 1
1871   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1872
1873   actor.SetOpacity( 0.4f);
1874   // flush the queue and render once
1875   application.SendNotification();
1876   application.Render();
1877   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1878
1879   // change opacity, actor is on stage to change is not immediate
1880   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1881   // flush the queue and render once
1882   application.SendNotification();
1883   application.Render();
1884   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1885
1886   // put actor on stage
1887   Stage::GetCurrent().Add( actor );
1888
1889   // change opacity, actor is on stage to change is not immediate
1890   actor.SetOpacity( 0.9f );
1891   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1892   // flush the queue and render once
1893   application.SendNotification();
1894   application.Render();
1895   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1896
1897   // change opacity, actor is on stage to change is not immediate
1898   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1899   // flush the queue and render once
1900   application.SendNotification();
1901   application.Render();
1902   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1903   END_TEST;
1904 }
1905
1906 int UtcDaliActorGetCurrentOpacity(void)
1907 {
1908   TestApplication application;
1909
1910   Actor actor = Actor::New();
1911   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1912
1913   actor.SetOpacity(0.5f);
1914   // flush the queue and render once
1915   application.SendNotification();
1916   application.Render();
1917   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1918   END_TEST;
1919 }
1920
1921 int UtcDaliActorSetSensitive(void)
1922 {
1923   TestApplication application;
1924   Actor actor = Actor::New();
1925
1926   bool sensitive = !actor.IsSensitive();
1927
1928   actor.SetSensitive(sensitive);
1929
1930   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1931   END_TEST;
1932 }
1933
1934 int UtcDaliActorIsSensitive(void)
1935 {
1936   TestApplication application;
1937   Actor actor = Actor::New();
1938   actor.SetSensitive(false);
1939
1940   DALI_TEST_CHECK(false == actor.IsSensitive());
1941   END_TEST;
1942 }
1943
1944 int UtcDaliActorSetColor(void)
1945 {
1946   TestApplication application;
1947   Actor actor = Actor::New();
1948   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1949
1950   DALI_TEST_CHECK(color != actor.GetCurrentColor());
1951
1952   actor.SetColor(color);
1953   // flush the queue and render once
1954   application.SendNotification();
1955   application.Render();
1956   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1957
1958   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1959   // flush the queue and render once
1960   application.SendNotification();
1961   application.Render();
1962   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
1963
1964   Stage::GetCurrent().Add( actor );
1965   actor.SetColor( color );
1966   // flush the queue and render once
1967   application.SendNotification();
1968   application.Render();
1969   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
1970
1971   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1972   // flush the queue and render once
1973   application.SendNotification();
1974   application.Render();
1975   // Actor color is not clamped
1976   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
1977   // world color is clamped
1978   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
1979
1980   Stage::GetCurrent().Remove( actor );
1981   END_TEST;
1982 }
1983
1984 int UtcDaliActorSetColorIndividual(void)
1985 {
1986   TestApplication application;
1987
1988   Actor actor = Actor::New();
1989
1990   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1991   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1992
1993   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1994
1995   // flush the queue and render once
1996   application.SendNotification();
1997   application.Render();
1998
1999   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2000
2001   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2002
2003   // flush the queue and render once
2004   application.SendNotification();
2005   application.Render();
2006
2007   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2008
2009   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2010
2011   // flush the queue and render once
2012   application.SendNotification();
2013   application.Render();
2014
2015   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2016
2017   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2018
2019   // flush the queue and render once
2020   application.SendNotification();
2021   application.Render();
2022
2023   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2024
2025   actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2026
2027   // flush the queue and render once
2028   application.SendNotification();
2029   application.Render();
2030
2031   DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2032
2033   END_TEST;
2034 }
2035
2036
2037 int UtcDaliActorGetCurrentColor(void)
2038 {
2039   TestApplication application;
2040   Actor actor = Actor::New();
2041   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2042
2043   actor.SetColor(color);
2044   // flush the queue and render once
2045   application.SendNotification();
2046   application.Render();
2047   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2048   END_TEST;
2049 }
2050
2051 int UtcDaliActorGetCurrentWorldColor(void)
2052 {
2053   tet_infoline("Actor::GetCurrentWorldColor");
2054   TestApplication application;
2055
2056   Actor parent = Actor::New();
2057   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2058   parent.SetColor( parentColor );
2059   Stage::GetCurrent().Add( parent );
2060
2061   Actor child = Actor::New();
2062   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2063   child.SetColor( childColor );
2064   parent.Add( child );
2065
2066   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2067   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2068
2069   // verify the default color mode
2070   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2071
2072   // The actors should not have a world color yet
2073   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2074   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2075
2076   application.SendNotification();
2077   application.Render(0);
2078
2079   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2080   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2081
2082   // The actors should have a world color now
2083   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2084   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2085
2086   // use own color
2087   child.SetColorMode( USE_OWN_COLOR );
2088   application.SendNotification();
2089   application.Render(0);
2090   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2091
2092   // use parent color
2093   child.SetColorMode( USE_PARENT_COLOR );
2094   application.SendNotification();
2095   application.Render(0);
2096   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2097   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2098
2099   // use parent alpha
2100   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2101   application.SendNotification();
2102   application.Render(0);
2103   Vector4 expectedColor( childColor );
2104   expectedColor.a *= parentColor.a;
2105   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2106   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2107   END_TEST;
2108 }
2109
2110 int UtcDaliActorSetColorMode(void)
2111 {
2112   tet_infoline("Actor::SetColorMode");
2113   TestApplication application;
2114   Actor actor = Actor::New();
2115   Actor child = Actor::New();
2116   actor.Add( child );
2117
2118   actor.SetColorMode( USE_OWN_COLOR );
2119   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2120
2121   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2122   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2123
2124   actor.SetColorMode( USE_PARENT_COLOR );
2125   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2126
2127   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2128   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2129   END_TEST;
2130 }
2131
2132 int UtcDaliActorScreenToLocal(void)
2133 {
2134   TestApplication application;
2135   Actor actor = Actor::New();
2136   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2137   actor.SetSize(100.0f, 100.0f);
2138   actor.SetPosition(10.0f, 10.0f);
2139   Stage::GetCurrent().Add(actor);
2140
2141   // flush the queue and render once
2142   application.SendNotification();
2143   application.Render();
2144
2145   float localX;
2146   float localY;
2147
2148   application.SendNotification();
2149   application.Render();
2150
2151   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2152
2153   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2154   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2155   END_TEST;
2156 }
2157
2158 int UtcDaliActorSetLeaveRequired(void)
2159 {
2160   TestApplication application;
2161
2162   Actor actor = Actor::New();
2163
2164   actor.SetLeaveRequired(false);
2165   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2166
2167   actor.SetLeaveRequired(true);
2168   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2169   END_TEST;
2170 }
2171
2172 int UtcDaliActorGetLeaveRequired(void)
2173 {
2174   TestApplication application;
2175
2176   Actor actor = Actor::New();
2177
2178   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2179   END_TEST;
2180 }
2181
2182 int UtcDaliActorSetKeyboardFocusable(void)
2183 {
2184   TestApplication application;
2185
2186   Actor actor = Actor::New();
2187
2188   actor.SetKeyboardFocusable(true);
2189   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2190
2191   actor.SetKeyboardFocusable(false);
2192   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2193   END_TEST;
2194 }
2195
2196 int UtcDaliActorIsKeyboardFocusable(void)
2197 {
2198   TestApplication application;
2199
2200   Actor actor = Actor::New();
2201
2202   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2203   END_TEST;
2204 }
2205
2206 int UtcDaliActorRemoveConstraints(void)
2207 {
2208   tet_infoline(" UtcDaliActorRemoveConstraints");
2209   TestApplication application;
2210
2211   gTestConstraintCalled = false;
2212
2213   Actor actor = Actor::New();
2214
2215   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2216   constraint.Apply();
2217   actor.RemoveConstraints();
2218
2219   DALI_TEST_CHECK( gTestConstraintCalled == false );
2220
2221   Stage::GetCurrent().Add( actor );
2222   constraint.Apply();
2223
2224   // flush the queue and render once
2225   application.SendNotification();
2226   application.Render();
2227
2228   actor.RemoveConstraints();
2229
2230   DALI_TEST_CHECK( gTestConstraintCalled == true );
2231   END_TEST;
2232 }
2233
2234 int UtcDaliActorRemoveConstraintTag(void)
2235 {
2236   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2237   TestApplication application;
2238
2239   Actor actor = Actor::New();
2240
2241   // 1. Apply Constraint1 and Constraint2, and test...
2242   unsigned int result1 = 0u;
2243   unsigned int result2 = 0u;
2244
2245   unsigned constraint1Tag = 1u;
2246   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2247   constraint1.SetTag( constraint1Tag );
2248   constraint1.Apply();
2249
2250   unsigned constraint2Tag = 2u;
2251   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2252   constraint2.SetTag( constraint2Tag );
2253   constraint2.Apply();
2254
2255   Stage::GetCurrent().Add( actor );
2256   // flush the queue and render once
2257   application.SendNotification();
2258   application.Render();
2259
2260   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2261   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2262
2263   // 2. Remove Constraint1 and test...
2264   result1 = 0;
2265   result2 = 0;
2266   actor.RemoveConstraints(constraint1Tag);
2267   // make color property dirty, which will trigger constraints to be reapplied.
2268   actor.SetColor( Color::WHITE );
2269   // flush the queue and render once
2270   application.SendNotification();
2271   application.Render();
2272
2273   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2274   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2275
2276   // 3. Re-Apply Constraint1 and test...
2277   result1 = 0;
2278   result2 = 0;
2279   constraint1.Apply();
2280   // make color property dirty, which will trigger constraints to be reapplied.
2281   actor.SetColor( Color::WHITE );
2282   // flush the queue and render once
2283   application.SendNotification();
2284   application.Render();
2285
2286   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2287   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2288
2289   // 2. Remove Constraint2 and test...
2290   result1 = 0;
2291   result2 = 0;
2292   actor.RemoveConstraints(constraint2Tag);
2293   // make color property dirty, which will trigger constraints to be reapplied.
2294   actor.SetColor( Color::WHITE );
2295   // flush the queue and render once
2296   application.SendNotification();
2297   application.Render();
2298
2299   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2300   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2301
2302   // 2. Remove Constraint1 as well and test...
2303   result1 = 0;
2304   result2 = 0;
2305   actor.RemoveConstraints(constraint1Tag);
2306   // make color property dirty, which will trigger constraints to be reapplied.
2307   actor.SetColor( Color::WHITE );
2308   // flush the queue and render once
2309   application.SendNotification();
2310   application.Render();
2311
2312   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2313   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2314   END_TEST;
2315 }
2316
2317 int UtcDaliActorTouchedSignal(void)
2318 {
2319   TestApplication application;
2320
2321   ResetTouchCallbacks();
2322
2323   // get the root layer
2324   Actor actor = Stage::GetCurrent().GetRootLayer();
2325   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2326
2327   application.SendNotification();
2328   application.Render();
2329
2330   // connect to its touch signal
2331   actor.TouchedSignal().Connect( TestCallback );
2332
2333   // simulate a touch event in the middle of the screen
2334   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2335   Dali::Integration::Point point;
2336   point.SetDeviceId( 1 );
2337   point.SetState( PointState::DOWN );
2338   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2339   Dali::Integration::TouchEvent event;
2340   event.AddPoint( point );
2341   application.ProcessEvent( event );
2342
2343   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2344   END_TEST;
2345 }
2346
2347 int UtcDaliActorHoveredSignal(void)
2348 {
2349   TestApplication application;
2350
2351   gHoverCallBackCalled = false;
2352
2353   // get the root layer
2354   Actor actor = Stage::GetCurrent().GetRootLayer();
2355   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2356
2357   application.SendNotification();
2358   application.Render();
2359
2360   // connect to its hover signal
2361   actor.HoveredSignal().Connect( TestCallback3 );
2362
2363   // simulate a hover event in the middle of the screen
2364   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2365   Dali::Integration::Point point;
2366   point.SetDeviceId( 1 );
2367   point.SetState( PointState::MOTION );
2368   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2369   Dali::Integration::HoverEvent event;
2370   event.AddPoint( point );
2371   application.ProcessEvent( event );
2372
2373   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2374   END_TEST;
2375 }
2376
2377 int UtcDaliActorOnOffStageSignal(void)
2378 {
2379   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2380
2381   TestApplication application;
2382
2383   // clean test data
2384   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2385   gActorNamesOnOffStage.clear();
2386
2387   Actor parent = Actor::New();
2388   parent.SetName( "parent" );
2389   parent.OnStageSignal().Connect( OnStageCallback );
2390   parent.OffStageSignal().Connect( OffStageCallback );
2391   // sanity check
2392   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2393   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2394
2395   // add parent to stage
2396   Stage::GetCurrent().Add( parent );
2397   // onstage emitted, offstage not
2398   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2399   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2400   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2401
2402   // test adding a child, should get onstage emitted
2403   // clean test data
2404   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2405   gActorNamesOnOffStage.clear();
2406
2407   Actor child = Actor::New();
2408   child.SetName( "child" );
2409   child.OnStageSignal().Connect( OnStageCallback );
2410   child.OffStageSignal().Connect( OffStageCallback );
2411   parent.Add( child ); // add child
2412   // onstage emitted, offstage not
2413   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2414   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2415   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2416
2417   // test removing parent from stage
2418   // clean test data
2419   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2420   gActorNamesOnOffStage.clear();
2421
2422   Stage::GetCurrent().Remove( parent );
2423   // onstage not emitted, offstage is
2424   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2425   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2426   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2427   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2428
2429   // test adding parent back to stage
2430   // clean test data
2431   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2432   gActorNamesOnOffStage.clear();
2433
2434   Stage::GetCurrent().Add( parent );
2435   // onstage emitted, offstage not
2436   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2437   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2438   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2439   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2440
2441   // test removing child
2442   // clean test data
2443   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2444   gActorNamesOnOffStage.clear();
2445
2446   parent.Remove( child );
2447   // onstage not emitted, offstage is
2448   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2449   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2450   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2451
2452   // test removing parent
2453   // clean test data
2454   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2455   gActorNamesOnOffStage.clear();
2456
2457   Stage::GetCurrent().Remove( parent );
2458   // onstage not emitted, offstage is
2459   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2460   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2461   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2462   END_TEST;
2463 }
2464
2465 int UtcDaliActorFindChildByName(void)
2466 {
2467   tet_infoline("Testing Dali::Actor::FindChildByName()");
2468   TestApplication application;
2469
2470   Actor parent = Actor::New();
2471   parent.SetName( "parent" );
2472   Actor first  = Actor::New();
2473   first .SetName( "first" );
2474   Actor second = Actor::New();
2475   second.SetName( "second" );
2476
2477   parent.Add(first);
2478   first.Add(second);
2479
2480   Actor found = parent.FindChildByName( "foo" );
2481   DALI_TEST_CHECK( !found );
2482
2483   found = parent.FindChildByName( "parent" );
2484   DALI_TEST_CHECK( found == parent );
2485
2486   found = parent.FindChildByName( "first" );
2487   DALI_TEST_CHECK( found == first );
2488
2489   found = parent.FindChildByName( "second" );
2490   DALI_TEST_CHECK( found == second );
2491   END_TEST;
2492 }
2493
2494 int UtcDaliActorFindChildById(void)
2495 {
2496   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2497   TestApplication application;
2498
2499   Actor parent = Actor::New();
2500   Actor first  = Actor::New();
2501   Actor second = Actor::New();
2502
2503   parent.Add(first);
2504   first.Add(second);
2505
2506   Actor found = parent.FindChildById( 100000 );
2507   DALI_TEST_CHECK( !found );
2508
2509   found = parent.FindChildById( parent.GetId() );
2510   DALI_TEST_CHECK( found == parent );
2511
2512   found = parent.FindChildById( first.GetId() );
2513   DALI_TEST_CHECK( found == first );
2514
2515   found = parent.FindChildById( second.GetId() );
2516   DALI_TEST_CHECK( found == second );
2517   END_TEST;
2518 }
2519
2520 int UtcDaliActorHitTest(void)
2521 {
2522   struct HitTestData
2523   {
2524   public:
2525     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2526     : mScale( scale ),
2527       mTouchPoint( touchPoint ),
2528       mResult( result )
2529     {}
2530
2531     Vector3 mScale;
2532     Vector2 mTouchPoint;
2533     bool mResult;
2534   };
2535
2536   TestApplication application;
2537   tet_infoline(" UtcDaliActorHitTest");
2538
2539   // Fill a vector with different hit tests.
2540   struct HitTestData* hitTestData[] = {
2541     //                    scale                     touch point           result
2542     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2543     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2544     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.
2545     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2546     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.
2547     NULL,
2548   };
2549
2550   // get the root layer
2551   Actor actor = Actor::New();
2552   actor.SetAnchorPoint( AnchorPoint::CENTER );
2553   actor.SetParentOrigin( ParentOrigin::CENTER );
2554
2555   Stage::GetCurrent().Add( actor );
2556
2557   ResetTouchCallbacks();
2558
2559   unsigned int index = 0;
2560   while( NULL != hitTestData[index] )
2561   {
2562     actor.SetSize( 1.f, 1.f );
2563     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2564
2565     // flush the queue and render once
2566     application.SendNotification();
2567     application.Render();
2568
2569     DALI_TEST_CHECK( !gTouchCallBackCalled );
2570
2571     // connect to its touch signal
2572     actor.TouchedSignal().Connect(TestCallback);
2573
2574     Dali::Integration::Point point;
2575     point.SetState( PointState::DOWN );
2576     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2577     Dali::Integration::TouchEvent event;
2578     event.AddPoint( point );
2579
2580     // flush the queue and render once
2581     application.SendNotification();
2582     application.Render();
2583     application.ProcessEvent( event );
2584
2585     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2586
2587     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2588       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2589                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2590                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2591                  hitTestData[index]->mResult );
2592
2593     ResetTouchCallbacks();
2594     ++index;
2595   }
2596   END_TEST;
2597 }
2598
2599 int UtcDaliActorSetDrawMode(void)
2600 {
2601   TestApplication app;
2602   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2603
2604   Actor a = Actor::New();
2605
2606   Stage::GetCurrent().Add(a);
2607   app.SendNotification();
2608   app.Render(0);
2609   app.SendNotification();
2610   app.Render(1);
2611
2612   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2613
2614   a.SetDrawMode( DrawMode::OVERLAY_2D );
2615   app.SendNotification();
2616   app.Render(1);
2617
2618   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2619
2620   a.SetDrawMode( DrawMode::NORMAL );
2621   app.SendNotification();
2622   app.Render(1);
2623
2624   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2625   END_TEST;
2626 }
2627
2628 int UtcDaliActorSetDrawModeOverlayRender(void)
2629 {
2630   TestApplication app;
2631   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2632
2633   app.SendNotification();
2634   app.Render(1);
2635
2636   std::vector<GLuint> ids;
2637   ids.push_back( 8 );   // first rendered actor
2638   ids.push_back( 9 );   // second rendered actor
2639   ids.push_back( 10 );  // third rendered actor
2640   app.GetGlAbstraction().SetNextTextureIds( ids );
2641
2642   BufferImage imageA = BufferImage::New(16, 16);
2643   BufferImage imageB = BufferImage::New(16, 16);
2644   BufferImage imageC = BufferImage::New(16, 16);
2645   Actor a = CreateRenderableActor( imageA );
2646   Actor b = CreateRenderableActor( imageB );
2647   Actor c = CreateRenderableActor( imageC );
2648
2649   app.SendNotification();
2650   app.Render(1);
2651
2652   //Textures are bound when first created. Clear bound textures vector
2653   app.GetGlAbstraction().ClearBoundTextures();
2654
2655   // Render a,b,c as regular non-overlays. so order will be:
2656   // a (8)
2657   // b (9)
2658   // c (10)
2659   Stage::GetCurrent().Add(a);
2660   Stage::GetCurrent().Add(b);
2661   Stage::GetCurrent().Add(c);
2662
2663   app.SendNotification();
2664   app.Render(1);
2665
2666   // Should be 3 textures changes.
2667   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2668   typedef std::vector<GLuint>::size_type TextureSize;
2669   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2670   if( boundTextures.size() == 3 )
2671   {
2672     DALI_TEST_CHECK( boundTextures[0] == 8u );
2673     DALI_TEST_CHECK( boundTextures[1] == 9u );
2674     DALI_TEST_CHECK( boundTextures[2] == 10u );
2675   }
2676
2677   // Now texture ids have been set, we can monitor their render order.
2678   // render a as an overlay (last), so order will be:
2679   // b (9)
2680   // c (10)
2681   // a (8)
2682   a.SetDrawMode( DrawMode::OVERLAY_2D );
2683   app.GetGlAbstraction().ClearBoundTextures();
2684
2685   app.SendNotification();
2686   app.Render(1);
2687
2688   // Should be 3 texture changes.
2689   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2690   if( boundTextures.size() == 3 )
2691   {
2692     DALI_TEST_CHECK( boundTextures[0] == 9u );
2693     DALI_TEST_CHECK( boundTextures[1] == 10u );
2694     DALI_TEST_CHECK( boundTextures[2] == 8u );
2695   }
2696   END_TEST;
2697 }
2698
2699 int UtcDaliActorGetCurrentWorldMatrix(void)
2700 {
2701   TestApplication app;
2702   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2703
2704   Actor parent = Actor::New();
2705   parent.SetParentOrigin(ParentOrigin::CENTER);
2706   parent.SetAnchorPoint(AnchorPoint::CENTER);
2707   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2708   Radian rotationAngle(Degree(85.0f));
2709   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2710   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2711   parent.SetPosition( parentPosition );
2712   parent.SetOrientation( parentRotation );
2713   parent.SetScale( parentScale );
2714   Stage::GetCurrent().Add( parent );
2715
2716   Actor child = Actor::New();
2717   child.SetParentOrigin(ParentOrigin::CENTER);
2718   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2719   Radian childRotationAngle(Degree(23.0f));
2720   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2721   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2722   child.SetPosition( childPosition );
2723   child.SetOrientation( childRotation );
2724   child.SetScale( childScale );
2725   parent.Add( child );
2726
2727   app.SendNotification();
2728   app.Render(0);
2729   app.Render();
2730   app.SendNotification();
2731
2732   Matrix parentMatrix(false);
2733   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2734
2735   Matrix childMatrix(false);
2736   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2737
2738   //Child matrix should be the composition of child and parent
2739   Matrix childWorldMatrix(false);
2740   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2741
2742   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2743   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2744   END_TEST;
2745 }
2746
2747
2748
2749 int UtcDaliActorConstrainedToWorldMatrix(void)
2750 {
2751   TestApplication app;
2752   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2753
2754   Actor parent = Actor::New();
2755   parent.SetParentOrigin(ParentOrigin::CENTER);
2756   parent.SetAnchorPoint(AnchorPoint::CENTER);
2757   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2758   Radian rotationAngle(Degree(85.0f));
2759   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2760   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2761   parent.SetPosition( parentPosition );
2762   parent.SetOrientation( parentRotation );
2763   parent.SetScale( parentScale );
2764   Stage::GetCurrent().Add( parent );
2765
2766   Actor child = Actor::New();
2767   child.SetParentOrigin(ParentOrigin::CENTER);
2768   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2769   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2770   posConstraint.Apply();
2771
2772   Stage::GetCurrent().Add( child );
2773
2774   app.SendNotification();
2775   app.Render(0);
2776   app.Render();
2777   app.SendNotification();
2778
2779   Matrix parentMatrix(false);
2780   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2781
2782   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2783   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2784   END_TEST;
2785 }
2786
2787 int UtcDaliActorConstrainedToOrientation(void)
2788 {
2789   TestApplication app;
2790   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2791
2792   Actor parent = Actor::New();
2793   parent.SetParentOrigin(ParentOrigin::CENTER);
2794   parent.SetAnchorPoint(AnchorPoint::CENTER);
2795   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2796   Radian rotationAngle(Degree(85.0f));
2797   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2798   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2799   parent.SetPosition( parentPosition );
2800   parent.SetOrientation( parentRotation );
2801   parent.SetScale( parentScale );
2802   Stage::GetCurrent().Add( parent );
2803
2804   Actor child = Actor::New();
2805   child.SetParentOrigin(ParentOrigin::CENTER);
2806   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2807   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2808   posConstraint.Apply();
2809
2810   Stage::GetCurrent().Add( child );
2811
2812   app.SendNotification();
2813   app.Render(0);
2814   app.Render();
2815   app.SendNotification();
2816
2817   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2818   END_TEST;
2819 }
2820
2821 int UtcDaliActorConstrainedToOpacity(void)
2822 {
2823   TestApplication app;
2824   tet_infoline(" UtcDaliActorConstrainedToOpacity");
2825
2826   Actor parent = Actor::New();
2827   parent.SetOpacity( 0.7f );
2828   Stage::GetCurrent().Add( parent );
2829
2830   Actor child = Actor::New();
2831   Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2832   opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2833   opacityConstraint.Apply();
2834
2835   Stage::GetCurrent().Add( child );
2836
2837   app.SendNotification();
2838   app.Render(0);
2839   app.Render();
2840   app.SendNotification();
2841
2842   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2843
2844   parent.SetOpacity( 0.3f );
2845
2846   app.SendNotification();
2847   app.Render(0);
2848   app.Render();
2849   app.SendNotification();
2850
2851   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2852
2853   END_TEST;
2854 }
2855
2856 int UtcDaliActorUnparent(void)
2857 {
2858   TestApplication app;
2859   tet_infoline(" UtcDaliActorUnparent");
2860
2861   Actor parent = Actor::New();
2862   Stage::GetCurrent().Add( parent );
2863
2864   Actor child = Actor::New();
2865
2866   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2867   DALI_TEST_CHECK( !child.GetParent() );
2868
2869   // Test that calling Unparent with no parent is a NOOP
2870   child.Unparent();
2871
2872   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2873   DALI_TEST_CHECK( !child.GetParent() );
2874
2875   // Test that Unparent works
2876   parent.Add( child );
2877
2878   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2879   DALI_TEST_CHECK( parent == child.GetParent() );
2880
2881   child.Unparent();
2882
2883   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2884   DALI_TEST_CHECK( !child.GetParent() );
2885
2886   // Test that UnparentAndReset works
2887   parent.Add( child );
2888
2889   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2890   DALI_TEST_CHECK( parent == child.GetParent() );
2891
2892   UnparentAndReset( child );
2893
2894   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2895   DALI_TEST_CHECK( !child );
2896
2897   // Test that UnparentAndReset is a NOOP with empty handle
2898   UnparentAndReset( child );
2899
2900   DALI_TEST_CHECK( !child );
2901   END_TEST;
2902 }
2903
2904 int UtcDaliActorGetChildAt(void)
2905 {
2906   TestApplication app;
2907   tet_infoline(" UtcDaliActorGetChildAt");
2908
2909   Actor parent = Actor::New();
2910   Stage::GetCurrent().Add( parent );
2911
2912   Actor child0 = Actor::New();
2913   parent.Add( child0 );
2914
2915   Actor child1 = Actor::New();
2916   parent.Add( child1 );
2917
2918   Actor child2 = Actor::New();
2919   parent.Add( child2 );
2920
2921   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2922   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2923   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2924   END_TEST;
2925 }
2926
2927 int UtcDaliActorSetGetOverlay(void)
2928 {
2929   TestApplication app;
2930   tet_infoline(" UtcDaliActorSetGetOverlay");
2931
2932   Actor parent = Actor::New();
2933   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2934   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2935   END_TEST;
2936 }
2937
2938
2939 int UtcDaliActorCreateDestroy(void)
2940 {
2941   Actor* actor = new Actor;
2942   DALI_TEST_CHECK( actor );
2943   delete actor;
2944   END_TEST;
2945 }
2946
2947 namespace
2948 {
2949 struct PropertyStringIndex
2950 {
2951   const char * const name;
2952   const Property::Index index;
2953   const Property::Type type;
2954 };
2955
2956 const PropertyStringIndex PROPERTY_TABLE[] =
2957 {
2958   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2959   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2960   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2961   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2962   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2963   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2964   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2965   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2966   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2967   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2968   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2969   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2970   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2971   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2972   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2973   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2974   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2975   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2976   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2977   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2978   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2979   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2980   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2981   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2982   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2983   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2984   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2985   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2986   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2987   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2988   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2989   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2990   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2991   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2992   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2993   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2994   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2995   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2996   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2997   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2998   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2999   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
3000   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
3001   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
3002   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
3003   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
3004   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
3005   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
3006   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
3007   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
3008   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
3009   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
3010   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
3011   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
3012   { "opacity",                  DevelActor::Property::OPACITY,             Property::FLOAT       },
3013 };
3014 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3015 } // unnamed namespace
3016
3017 int UtcDaliActorProperties(void)
3018 {
3019   TestApplication app;
3020
3021   Actor actor = Actor::New();
3022
3023   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3024   {
3025     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3026     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3027     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3028     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3029   }
3030   END_TEST;
3031 }
3032
3033 int UtcDaliRelayoutProperties_ResizePolicies(void)
3034 {
3035   TestApplication app;
3036
3037   Actor actor = Actor::New();
3038
3039   // Defaults
3040   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3041   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3042
3043   // Set resize policy for all dimensions
3044   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3045   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3046   {
3047     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3048   }
3049
3050   // Set individual dimensions
3051   const char* const widthPolicy = "FILL_TO_PARENT";
3052   const char* const heightPolicy = "FIXED";
3053
3054   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3055   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3056
3057   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3058   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3059
3060   // Set individual dimensions using enums
3061   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3062   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3063
3064   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3065   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3066
3067   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3068   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3069
3070   END_TEST;
3071 }
3072
3073 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3074 {
3075   TestApplication app;
3076
3077   Actor actor = Actor::New();
3078
3079   // Defaults
3080   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3081   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3082
3083   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3084   actor.SetSizeScalePolicy( policy );
3085   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3086
3087   // Set
3088   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3089   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3090
3091   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3092   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3093
3094   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3095   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3096
3097   END_TEST;
3098 }
3099
3100 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3101 {
3102   TestApplication app;
3103
3104   Actor actor = Actor::New();
3105
3106   // Defaults
3107   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3108   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3109
3110   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3111   actor.SetSizeModeFactor( sizeMode );
3112   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3113
3114   // Set
3115   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3116
3117   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3118   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3119
3120   END_TEST;
3121 }
3122
3123 int UtcDaliRelayoutProperties_DimensionDependency(void)
3124 {
3125   TestApplication app;
3126
3127   Actor actor = Actor::New();
3128
3129   // Defaults
3130   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3131   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3132
3133   // Set
3134   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3135   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3136
3137   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3138   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3139
3140   // Test setting another resize policy
3141   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3142   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3143
3144   END_TEST;
3145 }
3146
3147 int UtcDaliRelayoutProperties_Padding(void)
3148 {
3149   TestApplication app;
3150
3151   Actor actor = Actor::New();
3152
3153   // Data
3154   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3155
3156   // PADDING
3157   actor.SetProperty( Actor::Property::PADDING, padding );
3158   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3159
3160   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3161
3162   END_TEST;
3163 }
3164
3165 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3166 {
3167   TestApplication app;
3168
3169   Actor actor = Actor::New();
3170
3171   // Data
3172   Vector2 minSize( 1.0f, 2.0f );
3173
3174   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3175   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3176
3177   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3178
3179   Vector2 maxSize( 3.0f, 4.0f );
3180
3181   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3182   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3183
3184   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3185
3186   END_TEST;
3187 }
3188
3189 int UtcDaliActorGetHeightForWidth(void)
3190 {
3191   TestApplication app;
3192
3193   Actor actor = Actor::New();
3194
3195   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3196
3197   END_TEST;
3198 }
3199
3200 int UtcDaliActorGetWidthForHeight(void)
3201 {
3202   TestApplication app;
3203
3204   Actor actor = Actor::New();
3205
3206   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3207
3208   END_TEST;
3209 }
3210
3211 int UtcDaliActorGetRelayoutSize(void)
3212 {
3213   TestApplication app;
3214
3215   Actor actor = Actor::New();
3216
3217   // Add actor to stage
3218   Stage::GetCurrent().Add( actor );
3219
3220   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3221
3222   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3223   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3224
3225   // Flush the queue and render once
3226   app.SendNotification();
3227   app.Render();
3228
3229   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3230
3231   END_TEST;
3232 }
3233
3234 int UtcDaliActorSetPadding(void)
3235 {
3236   TestApplication app;
3237
3238   Actor actor = Actor::New();
3239
3240   Padding padding;
3241   actor.GetPadding( padding );
3242
3243   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3244   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3245   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3246   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3247
3248   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3249   actor.SetPadding( padding2 );
3250
3251   actor.GetPadding( padding );
3252
3253   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3254   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3255   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3256   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3257
3258   END_TEST;
3259 }
3260
3261 int UtcDaliActorSetMinimumSize(void)
3262 {
3263   TestApplication app;
3264
3265   Actor actor = Actor::New();
3266
3267   Vector2 size = actor.GetMinimumSize();
3268
3269   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3270   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3271
3272   Vector2 size2( 1.0f, 2.0f );
3273   actor.SetMinimumSize( size2 );
3274
3275   size = actor.GetMinimumSize();
3276
3277   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3278   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3279
3280   END_TEST;
3281 }
3282
3283 int UtcDaliActorSetMaximumSize(void)
3284 {
3285   TestApplication app;
3286
3287   Actor actor = Actor::New();
3288
3289   Vector2 size = actor.GetMaximumSize();
3290
3291   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3292   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3293
3294   Vector2 size2( 1.0f, 2.0f );
3295   actor.SetMaximumSize( size2 );
3296
3297   size = actor.GetMaximumSize();
3298
3299   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3300   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3301
3302   END_TEST;
3303 }
3304
3305 int UtcDaliActorOnRelayoutSignal(void)
3306 {
3307   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3308
3309   TestApplication application;
3310
3311   // Clean test data
3312   gOnRelayoutCallBackCalled = false;
3313   gActorNamesRelayout.clear();
3314
3315   Actor actor = Actor::New();
3316   actor.SetName( "actor" );
3317   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3318
3319   // Sanity check
3320   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3321
3322   // Add actor to stage
3323   Stage::GetCurrent().Add( actor );
3324
3325   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3326   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3327
3328   // Flush the queue and render once
3329   application.SendNotification();
3330   application.Render();
3331
3332   // OnRelayout emitted
3333   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3334   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3335
3336   END_TEST;
3337 }
3338
3339 int UtcDaliActorGetHierachyDepth(void)
3340 {
3341   TestApplication application;
3342   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3343
3344
3345   /* Build tree of actors:
3346    *
3347    *                      Depth
3348    *
3349    *       A (parent)       1
3350    *      / \
3351    *     B   C              2`
3352    *    / \   \
3353    *   D   E   F            3
3354    *
3355    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3356    */
3357   Stage stage( Stage::GetCurrent() );
3358
3359   Actor actorA = Actor::New();
3360   Actor actorB = Actor::New();
3361   Actor actorC = Actor::New();
3362   Actor actorD = Actor::New();
3363   Actor actorE = Actor::New();
3364   Actor actorF = Actor::New();
3365
3366   //Test that root actor has depth equal 0
3367   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3368
3369   //Test actors return depth -1 when not connected to the tree
3370   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3371   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3372   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3373   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3374   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3375   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3376
3377   //Create the hierarchy
3378   stage.Add( actorA );
3379   actorA.Add( actorB );
3380   actorA.Add( actorC );
3381   actorB.Add( actorD );
3382   actorB.Add( actorE );
3383   actorC.Add( actorF );
3384
3385   //Test actors return correct depth
3386   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3387   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3388   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3389   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3390   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3391   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3392
3393   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3394   actorA.Remove( actorB );
3395
3396   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3397   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3398   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3399
3400   //Removing actorA from the stage. All actors should have depth equal -1
3401   stage.Remove( actorA );
3402
3403   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3404   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3405   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3406   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3407   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3408   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3409
3410   END_TEST;
3411 }
3412
3413 int UtcDaliActorAnchorPointPropertyAsString(void)
3414 {
3415   TestApplication application;
3416
3417   Actor actor = Actor::New();
3418
3419   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3420   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3421
3422   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3423   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3424
3425   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3426   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3427
3428   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3429   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3430
3431   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3432   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3433
3434   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3435   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3436
3437   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3438   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3439
3440   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3441   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3442
3443   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3444   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3445
3446   // Invalid should not change anything
3447   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3448   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3449
3450   END_TEST;
3451 }
3452
3453 int UtcDaliActorParentOriginPropertyAsString(void)
3454 {
3455   TestApplication application;
3456
3457   Actor actor = Actor::New();
3458
3459   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3460   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3461
3462   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3463   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3464
3465   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3466   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3467
3468   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3469   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3470
3471   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3472   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3473
3474   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3475   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3476
3477   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3478   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3479
3480   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3481   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3482
3483   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3484   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3485
3486   // Invalid should not change anything
3487   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3488   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3489
3490   END_TEST;
3491 }
3492
3493 int UtcDaliActorColorModePropertyAsString(void)
3494 {
3495   TestApplication application;
3496
3497   Actor actor = Actor::New();
3498
3499   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3500   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3501
3502   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3503   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3504
3505   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3506   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3507
3508   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3509   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3510
3511   // Invalid should not change anything
3512   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3513   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3514
3515   END_TEST;
3516 }
3517
3518 int UtcDaliActorPositionInheritancePropertyAsString(void)
3519 {
3520   TestApplication application;
3521
3522   Actor actor = Actor::New();
3523
3524   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3525   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3526
3527   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3528   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3529
3530   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3531   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3532
3533   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3534   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3535
3536   // Invalid should not change anything
3537   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3538   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3539
3540   END_TEST;
3541 }
3542
3543 int UtcDaliActorDrawModePropertyAsString(void)
3544 {
3545   TestApplication application;
3546
3547   Actor actor = Actor::New();
3548
3549   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3550   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3551
3552   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3553   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3554
3555   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3556   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3557
3558   // Invalid should not change anything
3559   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3560   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3561
3562   END_TEST;
3563 }
3564
3565 int UtcDaliActorColorModePropertyAsEnum(void)
3566 {
3567   TestApplication application;
3568
3569   Actor actor = Actor::New();
3570
3571   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3572   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3573
3574   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3575   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3576
3577   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3578   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3579
3580   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3581   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3582
3583   END_TEST;
3584 }
3585
3586 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3587 {
3588   TestApplication application;
3589
3590   Actor actor = Actor::New();
3591
3592   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3593   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3594
3595   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3596   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3597
3598   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3599   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3600
3601   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3602   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3603
3604   END_TEST;
3605 }
3606
3607 int UtcDaliActorDrawModePropertyAsEnum(void)
3608 {
3609   TestApplication application;
3610
3611   Actor actor = Actor::New();
3612
3613   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3614   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3615
3616   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3617   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3618
3619   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3620   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3621
3622   END_TEST;
3623 }
3624
3625 int UtcDaliActorAddRendererP(void)
3626 {
3627   tet_infoline("Testing Actor::AddRenderer");
3628   TestApplication application;
3629
3630   Actor actor = Actor::New();
3631
3632   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3633
3634   Geometry geometry = CreateQuadGeometry();
3635   Shader shader = CreateShader();
3636   Renderer renderer = Renderer::New(geometry, shader);
3637
3638   actor.AddRenderer( renderer );
3639   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3640   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3641
3642   END_TEST;
3643 }
3644
3645 int UtcDaliActorAddRendererN(void)
3646 {
3647   tet_infoline("Testing Actor::AddRenderer");
3648   TestApplication application;
3649
3650   Actor actor = Actor::New();
3651   Renderer renderer;
3652
3653   // try illegal Add
3654   try
3655   {
3656     actor.AddRenderer( renderer );
3657     tet_printf("Assertion test failed - no Exception\n" );
3658     tet_result(TET_FAIL);
3659   }
3660   catch(Dali::DaliException& e)
3661   {
3662     DALI_TEST_PRINT_ASSERT( e );
3663     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3664     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3665   }
3666   catch(...)
3667   {
3668     tet_printf("Assertion test failed - wrong Exception\n" );
3669     tet_result(TET_FAIL);
3670   }
3671
3672   END_TEST;
3673 }
3674
3675 int UtcDaliActorAddRendererOnStage(void)
3676 {
3677   tet_infoline("Testing Actor::AddRenderer");
3678   TestApplication application;
3679
3680   Actor actor = Actor::New();
3681   Stage::GetCurrent().Add(actor);
3682
3683   application.SendNotification();
3684   application.Render(0);
3685
3686   Geometry geometry = CreateQuadGeometry();
3687   Shader shader = CreateShader();
3688   Renderer renderer = Renderer::New(geometry, shader);
3689
3690   application.SendNotification();
3691   application.Render(0);
3692
3693   try
3694   {
3695     actor.AddRenderer( renderer );
3696     tet_result(TET_PASS);
3697   }
3698   catch(...)
3699   {
3700     tet_result(TET_FAIL);
3701   }
3702
3703   END_TEST;
3704 }
3705
3706 int UtcDaliActorRemoveRendererP1(void)
3707 {
3708   tet_infoline("Testing Actor::RemoveRenderer");
3709   TestApplication application;
3710
3711   Actor actor = Actor::New();
3712
3713   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3714
3715   Geometry geometry = CreateQuadGeometry();
3716   Shader shader = CreateShader();
3717   Renderer renderer = Renderer::New(geometry, shader);
3718
3719   actor.AddRenderer( renderer );
3720   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3721   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3722
3723   actor.RemoveRenderer(renderer);
3724   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3725
3726
3727   END_TEST;
3728 }
3729
3730 int UtcDaliActorRemoveRendererP2(void)
3731 {
3732   tet_infoline("Testing Actor::RemoveRenderer");
3733   TestApplication application;
3734
3735   Actor actor = Actor::New();
3736
3737   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3738
3739   Geometry geometry = CreateQuadGeometry();
3740   Shader shader = CreateShader();
3741   Renderer renderer = Renderer::New(geometry, shader);
3742
3743   actor.AddRenderer( renderer );
3744   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3745   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3746
3747   actor.RemoveRenderer(0);
3748   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3749
3750
3751   END_TEST;
3752 }
3753
3754
3755 int UtcDaliActorRemoveRendererN(void)
3756 {
3757   tet_infoline("Testing Actor::RemoveRenderer");
3758   TestApplication application;
3759
3760   Actor actor = Actor::New();
3761
3762   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3763
3764   Geometry geometry = CreateQuadGeometry();
3765   Shader shader = CreateShader();
3766   Renderer renderer = Renderer::New(geometry, shader);
3767
3768   actor.AddRenderer( renderer );
3769   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3770   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3771
3772   actor.RemoveRenderer(10);
3773   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3774   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3775
3776   END_TEST;
3777 }
3778
3779 // Clipping test helper functions:
3780 Actor CreateActorWithContent()
3781 {
3782   BufferImage image = BufferImage::New( 16u, 16u );
3783   Actor actor = CreateRenderableActor( image );
3784
3785   // Setup dimensions and position so actor is not skipped by culling.
3786   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3787   actor.SetSize( 16.0f, 16.0f );
3788   actor.SetParentOrigin( ParentOrigin::CENTER );
3789   actor.SetAnchorPoint( AnchorPoint::CENTER );
3790
3791   return actor;
3792 }
3793
3794 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3795 {
3796   enabledDisableTrace.Reset();
3797   stencilTrace.Reset();
3798   enabledDisableTrace.Enable( true );
3799   stencilTrace.Enable( true );
3800
3801   application.SendNotification();
3802   application.Render();
3803
3804   enabledDisableTrace.Enable( false );
3805   stencilTrace.Enable( false );
3806 }
3807
3808 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3809 {
3810   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3811
3812   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3813   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3814   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3815   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3816 }
3817
3818 int UtcDaliActorPropertyClippingP(void)
3819 {
3820   // This test checks the clippingMode property.
3821   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3822   TestApplication application;
3823
3824   Actor actor = Actor::New();
3825
3826   // Check default clippingEnabled value.
3827   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3828
3829   int value = 0;
3830   bool getValueResult = getValue.Get( value );
3831   DALI_TEST_CHECK( getValueResult );
3832
3833   if( getValueResult )
3834   {
3835     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3836   }
3837
3838   // Check setting the property.
3839   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3840
3841   // Check the new value was set.
3842   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3843   getValueResult = getValue.Get( value );
3844   DALI_TEST_CHECK( getValueResult );
3845
3846   if( getValueResult )
3847   {
3848     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3849   }
3850
3851   END_TEST;
3852 }
3853
3854 int UtcDaliActorPropertyClippingN(void)
3855 {
3856   // Negative test case for Clipping.
3857   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3858   TestApplication application;
3859
3860   Actor actor = Actor::New();
3861
3862   // Check default clippingEnabled value.
3863   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3864
3865   int value = 0;
3866   bool getValueResult = getValue.Get( value );
3867   DALI_TEST_CHECK( getValueResult );
3868
3869   if( getValueResult )
3870   {
3871     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3872   }
3873
3874   // Check setting an invalid property value won't change the current property value.
3875   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3876
3877   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3878   getValueResult = getValue.Get( value );
3879   DALI_TEST_CHECK( getValueResult );
3880
3881   if( getValueResult )
3882   {
3883     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3884   }
3885
3886   END_TEST;
3887 }
3888
3889 int UtcDaliActorPropertyClippingActor(void)
3890 {
3891   // This test checks that an actor is correctly setup for clipping.
3892   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3893   TestApplication application;
3894
3895   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3896   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3897   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3898   size_t startIndex = 0u;
3899
3900   // Create a clipping actor.
3901   Actor actorDepth1Clip = CreateActorWithContent();
3902   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3903   Stage::GetCurrent().Add( actorDepth1Clip );
3904
3905   // Gather the call trace.
3906   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3907
3908   // Check we are writing to the color buffer.
3909   CheckColorMask( glAbstraction, true );
3910
3911   // Check the stencil buffer was enabled.
3912   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3913
3914   // Check the stencil buffer was cleared.
3915   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3916
3917   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3918   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3919   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3920   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3921
3922   END_TEST;
3923 }
3924
3925 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3926 {
3927   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3928   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3929   TestApplication application;
3930
3931   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3932   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3933   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3934   size_t startIndex = 0u;
3935
3936   // Create a clipping actor.
3937   Actor actorDepth1Clip = CreateActorWithContent();
3938   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3939   Stage::GetCurrent().Add( actorDepth1Clip );
3940
3941   // Gather the call trace.
3942   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3943
3944   // Check we are writing to the color buffer.
3945   CheckColorMask( glAbstraction, true );
3946
3947   // Check the stencil buffer was enabled.
3948   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3949
3950   // Check the stencil buffer was cleared.
3951   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3952
3953   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3954   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3955   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3956   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3957
3958   // Now disable the clipping
3959   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3960
3961   // Gather the call trace.
3962   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3963
3964   // Check the stencil buffer was disabled.
3965   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3966
3967   // Ensure all values in stencil-mask are set to 1.
3968   startIndex = 0u;
3969   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3970
3971   END_TEST;
3972 }
3973
3974
3975 int UtcDaliActorPropertyClippingNestedChildren(void)
3976 {
3977   // This test checks that a hierarchy of actors are clipped correctly by
3978   // writing to and reading from the correct bit-planes of the stencil buffer.
3979   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3980   TestApplication application;
3981   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3982   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3983   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3984
3985   // Create a clipping actor.
3986   Actor actorDepth1Clip = CreateActorWithContent();
3987   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3988   Stage::GetCurrent().Add( actorDepth1Clip );
3989
3990   // Create a child actor.
3991   Actor childDepth2 = CreateActorWithContent();
3992   actorDepth1Clip.Add( childDepth2 );
3993
3994   // Create another clipping actor.
3995   Actor childDepth2Clip = CreateActorWithContent();
3996   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3997   childDepth2.Add( childDepth2Clip );
3998
3999   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4000   // This tests the sort algorithm.
4001   Actor childDepth3 = CreateActorWithContent();
4002   childDepth2Clip.Add( childDepth3 );
4003   Actor childDepth4 = CreateActorWithContent();
4004   childDepth3.Add( childDepth4 );
4005
4006   // Gather the call trace.
4007   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4008
4009   // Check we are writing to the color buffer.
4010   CheckColorMask( glAbstraction, true );
4011
4012   // Check the stencil buffer was enabled.
4013   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4014
4015   // Perform the test twice, once for 2D layer, and once for 3D.
4016   for( unsigned int i = 0u ; i < 2u; ++i )
4017   {
4018     size_t startIndex = 0u;
4019
4020     // Check the stencil buffer was cleared.
4021     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4022
4023     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4024     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4025     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4026     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4027
4028     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4029     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4030     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4031
4032     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4033     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4034     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4035     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4036
4037     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4038     // (Both must be set to pass the check).
4039     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4040     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4041
4042     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4043     if( i == 0u )
4044     {
4045       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4046       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4047     }
4048   }
4049
4050   END_TEST;
4051 }
4052
4053 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4054 {
4055   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4056   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4057   TestApplication application;
4058
4059   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4060   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4061   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4062
4063   // Create a clipping actor.
4064   Actor actorDepth1Clip = CreateActorWithContent();
4065   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4066   Stage::GetCurrent().Add( actorDepth1Clip );
4067
4068   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4069   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4070
4071   // Gather the call trace.
4072   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4073
4074   // Check we are writing to the color buffer.
4075   CheckColorMask( glAbstraction, true );
4076
4077   // Check the stencil buffer was not enabled.
4078   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4079
4080   // Check stencil functions are not called.
4081   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4082   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4083   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4084
4085   END_TEST;
4086 }
4087
4088 int UtcDaliGetPropertyN(void)
4089 {
4090   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4091   TestApplication app;
4092
4093   Actor actor = Actor::New();
4094
4095   unsigned int propertyCount = actor.GetPropertyCount();
4096   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4097   END_TEST;
4098 }
4099
4100 int UtcDaliActorRaiseLower(void)
4101 {
4102   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4103
4104   TestApplication application;
4105
4106   Stage stage( Stage::GetCurrent() );
4107
4108   Actor actorA = Actor::New();
4109   Actor actorB = Actor::New();
4110   Actor actorC = Actor::New();
4111
4112   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4113   actorA.SetParentOrigin( ParentOrigin::CENTER );
4114
4115   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4116   actorB.SetParentOrigin( ParentOrigin::CENTER );
4117
4118   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4119   actorC.SetParentOrigin( ParentOrigin::CENTER );
4120
4121   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4122   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4123
4124   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4125   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4126
4127   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4128   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4129
4130   stage.Add( actorA );
4131   stage.Add( actorB );
4132   stage.Add( actorC );
4133
4134   ResetTouchCallbacks();
4135
4136   application.SendNotification();
4137   application.Render();
4138
4139   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4140   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4141   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4142
4143   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4144   // Only top actor will get touched.
4145   actorA.TouchSignal().Connect( TestTouchCallback );
4146   actorB.TouchSignal().Connect( TestTouchCallback2 );
4147   actorC.TouchSignal().Connect( TestTouchCallback3 );
4148
4149   Dali::Integration::Point point;
4150   point.SetDeviceId( 1 );
4151   point.SetState( PointState::DOWN );
4152   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4153   Dali::Integration::TouchEvent event;
4154   event.AddPoint( point );
4155
4156   application.ProcessEvent( event );
4157
4158   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4159   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4160   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4161
4162   ResetTouchCallbacks();
4163
4164   tet_printf( "Testing Raising of Actor\n" );
4165
4166   int preActorOrder( 0 );
4167   int postActorOrder( 0 );
4168
4169   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4170   value.Get( preActorOrder );
4171
4172   DevelActor::Raise( actorB );
4173
4174   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4175   value.Get( postActorOrder );
4176
4177   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4178
4179   application.ProcessEvent( event );
4180
4181   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4182   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4183   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4184
4185   ResetTouchCallbacks();
4186
4187   tet_printf( "Testing Lowering of Actor\n" );
4188
4189   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4190   value.Get( preActorOrder );
4191
4192   DevelActor::Lower( actorB );
4193
4194   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4195   value.Get( postActorOrder );
4196
4197   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4198
4199   application.ProcessEvent( event );
4200
4201   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4202   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4203   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4204
4205   ResetTouchCallbacks();
4206
4207   END_TEST;
4208 }
4209
4210 int UtcDaliActorRaiseToTopLowerToBottom(void)
4211 {
4212   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4213
4214   TestApplication application;
4215
4216   Stage stage( Stage::GetCurrent() );
4217
4218   Actor actorA = Actor::New();
4219   Actor actorB = Actor::New();
4220   Actor actorC = Actor::New();
4221
4222   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4223   // enables checking of which actor the uniform is assigned too
4224   Shader shaderA = CreateShader();
4225   shaderA.RegisterProperty( "uRendererColor",1.f);
4226
4227   Shader shaderB = CreateShader();
4228   shaderB.RegisterProperty( "uRendererColor", 2.f );
4229
4230   Shader shaderC = CreateShader();
4231   shaderC.RegisterProperty( "uRendererColor", 3.f );
4232
4233   Geometry geometry = CreateQuadGeometry();
4234
4235   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4236   Renderer rendererA = Renderer::New(geometry, shaderA);
4237   actorA.AddRenderer(rendererA);
4238
4239   Renderer rendererB = Renderer::New(geometry, shaderB);
4240   actorB.AddRenderer(rendererB);
4241
4242   Renderer rendererC = Renderer::New(geometry, shaderC);
4243   actorC.AddRenderer(rendererC);
4244
4245   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4246   actorA.SetParentOrigin( ParentOrigin::CENTER );
4247
4248   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4249   actorB.SetParentOrigin( ParentOrigin::CENTER );
4250
4251   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4252   actorC.SetParentOrigin( ParentOrigin::CENTER );
4253
4254   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4255   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4256
4257   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4258   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4259
4260   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4261   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4262
4263   stage.Add( actorA );
4264   stage.Add( actorB );
4265   stage.Add( actorC );
4266
4267   ResetTouchCallbacks();
4268
4269   // Set up gl abstraction trace so can query the set uniform order
4270   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4271   glAbstraction.EnableSetUniformCallTrace(true);
4272   glAbstraction.ResetSetUniformCallStack();
4273
4274   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4275
4276   application.SendNotification();
4277   application.Render();
4278
4279   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4280
4281
4282   // Test order of uniforms in stack
4283   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4284   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4285   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4286
4287   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4288
4289   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4290
4291   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4292   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4293   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4294
4295   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4296   // Only top actor will get touched.
4297   actorA.TouchSignal().Connect( TestTouchCallback );
4298   actorB.TouchSignal().Connect( TestTouchCallback2 );
4299   actorC.TouchSignal().Connect( TestTouchCallback3 );
4300
4301   Dali::Integration::Point point;
4302   point.SetDeviceId( 1 );
4303   point.SetState( PointState::DOWN );
4304   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4305   Dali::Integration::TouchEvent event;
4306   event.AddPoint( point );
4307
4308   application.ProcessEvent( event );
4309
4310   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4311   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4312   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4313
4314   ResetTouchCallbacks();
4315
4316   tet_printf( "RaiseToTop ActorA\n" );
4317
4318   DevelActor::RaiseToTop( actorA );
4319
4320   application.ProcessEvent( event );
4321
4322   glAbstraction.ResetSetUniformCallStack();
4323   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4324
4325   application.SendNotification();
4326   application.Render();
4327
4328   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4329
4330   // Test order of uniforms in stack
4331   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4332   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4333   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4334
4335   tet_infoline( "Testing A above C and B at bottom\n" );
4336   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4337
4338   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4339
4340   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4341   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4342   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4343
4344   ResetTouchCallbacks();
4345
4346   tet_printf( "RaiseToTop ActorB\n" );
4347
4348   DevelActor::RaiseToTop( actorB );
4349
4350   application.ProcessEvent( event );
4351
4352   glAbstraction.ResetSetUniformCallStack();
4353   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4354
4355   application.SendNotification();
4356   application.Render();
4357
4358   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4359
4360   // Test order of uniforms in stack
4361   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4362   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4363   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4364
4365   tet_infoline( "Testing B above A and C at bottom\n" );
4366   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4367
4368   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4369
4370   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4371   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4372   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4373
4374   ResetTouchCallbacks();
4375
4376   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4377
4378   DevelActor::LowerToBottom( actorA );
4379   application.SendNotification();
4380   application.Render();
4381
4382   DevelActor::LowerToBottom( actorB );
4383   application.SendNotification();
4384   application.Render();
4385
4386   application.ProcessEvent( event );
4387
4388   glAbstraction.ResetSetUniformCallStack();
4389   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4390
4391   application.SendNotification();
4392   application.Render();
4393
4394   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4395
4396   // Test order of uniforms in stack
4397   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4398   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4399   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4400
4401   tet_infoline( "Testing C above A and B at bottom\n" );
4402   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4403
4404   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4405
4406   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4407   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4408   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4409
4410   ResetTouchCallbacks();
4411
4412   END_TEST;
4413 }
4414
4415 int UtcDaliActorRaiseAbove(void)
4416 {
4417   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4418
4419   TestApplication application;
4420
4421   Stage stage( Stage::GetCurrent() );
4422
4423   Actor actorA = Actor::New();
4424   Actor actorB = Actor::New();
4425   Actor actorC = Actor::New();
4426
4427   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4428   actorA.SetParentOrigin( ParentOrigin::CENTER );
4429
4430   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4431   actorB.SetParentOrigin( ParentOrigin::CENTER );
4432
4433   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4434   actorC.SetParentOrigin( ParentOrigin::CENTER );
4435
4436   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4437   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4438
4439   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4440   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4441
4442   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4443   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4444
4445   stage.Add( actorA );
4446   stage.Add( actorB );
4447   stage.Add( actorC );
4448
4449   ResetTouchCallbacks();
4450
4451   application.SendNotification();
4452   application.Render();
4453
4454   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4455   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4456   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4457
4458   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4459   // Only top actor will get touched.
4460   actorA.TouchSignal().Connect( TestTouchCallback );
4461   actorB.TouchSignal().Connect( TestTouchCallback2 );
4462   actorC.TouchSignal().Connect( TestTouchCallback3 );
4463
4464   Dali::Integration::Point point;
4465   point.SetDeviceId( 1 );
4466   point.SetState( PointState::DOWN );
4467   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4468   Dali::Integration::TouchEvent event;
4469   event.AddPoint( point );
4470
4471   application.ProcessEvent( event );
4472
4473   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4474   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4475   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4476
4477   ResetTouchCallbacks();
4478
4479   tet_printf( "Raise actor B Above Actor C\n" );
4480
4481   DevelActor::RaiseAbove( actorB, actorC );
4482
4483   application.ProcessEvent( event );
4484
4485   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4486   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4487   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4488
4489   ResetTouchCallbacks();
4490
4491   tet_printf( "Raise actor A Above Actor B\n" );
4492
4493   DevelActor::RaiseAbove( actorA, actorB );
4494
4495   application.ProcessEvent( event );
4496
4497   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4498   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4499   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4500
4501   ResetTouchCallbacks();
4502
4503   END_TEST;
4504 }
4505
4506 int UtcDaliActorLowerBelow(void)
4507 {
4508   tet_infoline( "UtcDaliActor LowerBelow test \n" );
4509
4510   TestApplication application;
4511
4512   Stage stage( Stage::GetCurrent() );
4513
4514   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4515   // enables checking of which actor the uniform is assigned too
4516   Shader shaderA = CreateShader();
4517   shaderA.RegisterProperty( "uRendererColor",1.f);
4518
4519   Shader shaderB = CreateShader();
4520   shaderB.RegisterProperty( "uRendererColor", 2.f );
4521
4522   Shader shaderC = CreateShader();
4523   shaderC.RegisterProperty( "uRendererColor", 3.f );
4524
4525   Actor actorA = Actor::New();
4526   Actor actorB = Actor::New();
4527   Actor actorC = Actor::New();
4528
4529   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4530   Geometry geometry = CreateQuadGeometry();
4531
4532   Renderer rendererA = Renderer::New(geometry, shaderA);
4533   actorA.AddRenderer(rendererA);
4534
4535   Renderer rendererB = Renderer::New(geometry, shaderB);
4536   actorB.AddRenderer(rendererB);
4537
4538   Renderer rendererC = Renderer::New(geometry, shaderC);
4539   actorC.AddRenderer(rendererC);
4540
4541   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4542   actorA.SetParentOrigin( ParentOrigin::CENTER );
4543
4544   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4545   actorB.SetParentOrigin( ParentOrigin::CENTER );
4546
4547   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4548   actorC.SetParentOrigin( ParentOrigin::CENTER );
4549
4550   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4551   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4552
4553   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4554   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4555
4556   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4557   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4558
4559   stage.Add( actorA );
4560   stage.Add( actorB );
4561   stage.Add( actorC );
4562
4563   ResetTouchCallbacks();
4564
4565   // Set up gl abstraction trace so can query the set uniform order
4566   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4567   glAbstraction.EnableSetUniformCallTrace(true);
4568   glAbstraction.ResetSetUniformCallStack();
4569   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4570
4571   glAbstraction.ResetSetUniformCallStack();
4572
4573   application.SendNotification();
4574   application.Render();
4575
4576   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4577
4578   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4579
4580   // Test order of uniforms in stack
4581   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4582   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4583   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4584
4585   tet_infoline( "Testing C above B and A at bottom\n" );
4586   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4587
4588   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4589
4590   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4591   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4592   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4593
4594   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4595   // Only top actor will get touched.
4596   actorA.TouchSignal().Connect( TestTouchCallback );
4597   actorB.TouchSignal().Connect( TestTouchCallback2 );
4598   actorC.TouchSignal().Connect( TestTouchCallback3 );
4599
4600   Dali::Integration::Point point;
4601   point.SetDeviceId( 1 );
4602   point.SetState( PointState::DOWN );
4603   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4604   Dali::Integration::TouchEvent event;
4605   event.AddPoint( point );
4606
4607   tet_infoline( "UtcDaliActor Test Set up completed \n" );
4608
4609   application.ProcessEvent( event );
4610
4611   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4612   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4613   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4614
4615   ResetTouchCallbacks();
4616
4617   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" );
4618
4619   DevelActor::LowerBelow( actorC, actorB );
4620
4621   application.SendNotification();
4622   application.Render();
4623
4624   application.ProcessEvent( event );
4625
4626   glAbstraction.ResetSetUniformCallStack();
4627   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4628
4629   application.SendNotification();
4630   application.Render();
4631
4632   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4633
4634   // Test order of uniforms in stack
4635   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4636   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4637   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4638
4639   tet_infoline( "Testing B above A and C at bottom\n" );
4640   bool BAC = ( indexB > indexA) &&  ( indexA > indexC ); // B at TOP, then A then C at bottom
4641
4642   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4643
4644   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4645   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4646   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4647
4648   ResetTouchCallbacks();
4649
4650   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4651
4652   DevelActor::LowerBelow( actorB, actorC );
4653
4654   application.SendNotification();
4655   application.Render();
4656
4657   application.ProcessEvent( event );
4658
4659   glAbstraction.ResetSetUniformCallStack();
4660   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4661
4662   application.Render();
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   bool ACB = ( indexA > indexC) &&  ( indexC > indexB ); // A on TOP, then C then B at bottom
4671
4672   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4673
4674   DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4675   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4676   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4677
4678   ResetTouchCallbacks();
4679
4680   tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4681
4682   DevelActor::LowerBelow( actorA, actorC );
4683
4684   application.SendNotification();
4685   application.Render();
4686
4687   application.ProcessEvent( event );
4688
4689   glAbstraction.ResetSetUniformCallStack();
4690   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4691
4692   application.Render();
4693   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4694
4695   // Test order of uniforms in stack
4696   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4697   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4698   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4699
4700   bool CAB = ( indexC > indexA) &&  ( indexA > indexB );
4701
4702   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4703
4704   END_TEST;
4705 }
4706
4707 int UtcDaliActorMaxSiblingOrder(void)
4708 {
4709   tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4710
4711   TestApplication application;
4712
4713   int testOrders[] = { 0,1,3,5,17,998, 999 };
4714   int resultingOrders[] = { 0,1,2,3,4,6,5 };
4715
4716   const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4717
4718   Stage stage( Stage::GetCurrent() );
4719
4720   Actor parent = Actor::New();
4721
4722   for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4723   {
4724     Actor newActor = Actor::New();
4725     newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4726     parent.Add( newActor );
4727   }
4728   stage.Add( parent );
4729
4730   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4731   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4732   {
4733     Actor sibling = parent.GetChildAt( index );
4734     int siblingOrder = 0;
4735     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4736     value.Get( siblingOrder );
4737     tet_printf( "%d, ", siblingOrder );
4738   }
4739   tet_printf( "\n" );
4740
4741   Actor sibling = parent.GetChildAt( 5 );
4742   DevelActor::RaiseToTop( sibling );
4743
4744   application.SendNotification();
4745   application.Render();
4746
4747   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4748   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4749   {
4750     Actor sibling = parent.GetChildAt( index );
4751     int siblingOrder = 0;
4752     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4753     value.Get( siblingOrder );
4754     tet_printf( "%d, ", siblingOrder );
4755     DALI_TEST_EQUALS( siblingOrder,  resultingOrders[ index] , TEST_LOCATION );
4756   }
4757
4758   tet_printf( "\n" );
4759
4760   END_TEST;
4761 }
4762
4763 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4764 {
4765   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4766
4767   TestApplication application;
4768
4769   Stage stage( Stage::GetCurrent() );
4770
4771   Actor parentA = Actor::New();
4772   Actor parentB = Actor::New();
4773   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4774   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4775   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4776   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4777
4778   parentA.SetAnchorPoint( AnchorPoint::CENTER );
4779   parentA.SetParentOrigin( ParentOrigin::CENTER );
4780
4781   parentB.SetAnchorPoint( AnchorPoint::CENTER );
4782   parentB.SetParentOrigin( ParentOrigin::CENTER );
4783
4784   stage.Add( parentA );
4785   stage.Add( parentB );
4786
4787   Actor actorA = Actor::New();
4788   Actor actorB = Actor::New();
4789   Actor actorC = Actor::New();
4790
4791   parentA.Add( actorA );
4792   parentA.Add( actorB );
4793
4794   tet_printf( "Actor C added to different parent from A and B \n" );
4795   parentB.Add( actorC );
4796
4797   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4798   actorA.SetParentOrigin( ParentOrigin::CENTER );
4799
4800   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4801   actorB.SetParentOrigin( ParentOrigin::CENTER );
4802
4803   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4804   actorC.SetParentOrigin( ParentOrigin::CENTER );
4805
4806   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4807   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4808
4809   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4810   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4811
4812   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4813   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4814
4815   ResetTouchCallbacks();
4816
4817   application.SendNotification();
4818   application.Render();
4819
4820   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4821   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4822   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4823
4824   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4825   // Only top actor will get touched.
4826   actorA.TouchSignal().Connect( TestTouchCallback );
4827   actorB.TouchSignal().Connect( TestTouchCallback2 );
4828   actorC.TouchSignal().Connect( TestTouchCallback3 );
4829
4830   Dali::Integration::Point point;
4831   point.SetDeviceId( 1 );
4832   point.SetState( PointState::DOWN );
4833   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4834   Dali::Integration::TouchEvent event;
4835   event.AddPoint( point );
4836
4837   application.ProcessEvent( event );
4838
4839   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4840   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4841   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4842
4843   ResetTouchCallbacks();
4844
4845   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
4846
4847   DevelActor::RaiseAbove( actorA, actorC );
4848
4849   application.ProcessEvent( event );
4850
4851   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4852   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4853   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4854
4855   ResetTouchCallbacks();
4856
4857   END_TEST;
4858 }
4859
4860 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
4861 {
4862   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
4863
4864   TestApplication application;
4865
4866   Stage stage( Stage::GetCurrent() );
4867
4868   Actor actorA = Actor::New();
4869   Actor actorB = Actor::New();
4870   Actor actorC = Actor::New();
4871
4872   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4873   actorA.SetParentOrigin( ParentOrigin::CENTER );
4874
4875   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4876   actorB.SetParentOrigin( ParentOrigin::CENTER );
4877
4878   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4879   actorC.SetParentOrigin( ParentOrigin::CENTER );
4880
4881   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4882   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4883
4884   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4885   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4886
4887   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4888   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4889
4890   ResetTouchCallbacks();
4891
4892   application.SendNotification();
4893   application.Render();
4894
4895   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4896   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4897   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4898
4899   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4900   // Only top actor will get touched.
4901   actorA.TouchSignal().Connect( TestTouchCallback );
4902   actorB.TouchSignal().Connect( TestTouchCallback2 );
4903   actorC.TouchSignal().Connect( TestTouchCallback3 );
4904
4905   Dali::Integration::Point point;
4906   point.SetDeviceId( 1 );
4907   point.SetState( PointState::DOWN );
4908   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4909   Dali::Integration::TouchEvent event;
4910   event.AddPoint( point );
4911
4912   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
4913
4914   DevelActor::RaiseAbove( actorA, actorC );
4915
4916   application.ProcessEvent( event );
4917
4918   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
4919
4920   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4921   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4922   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4923
4924   ResetTouchCallbacks();
4925
4926   stage.Add ( actorB );
4927
4928   application.SendNotification();
4929   application.Render();
4930
4931   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
4932   DevelActor::LowerBelow( actorA, actorC );
4933   application.ProcessEvent( event );
4934
4935   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
4936   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4937   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4938   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4939
4940   ResetTouchCallbacks();
4941
4942   tet_printf( "Adding Actor A to stage, will be on top\n" );
4943
4944   stage.Add ( actorA );
4945   application.SendNotification();
4946   application.Render();
4947
4948   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
4949   DevelActor::RaiseAbove( actorB, actorC );
4950   application.ProcessEvent( event );
4951
4952   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
4953   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4954   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4955   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4956
4957   ResetTouchCallbacks();
4958
4959   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
4960   DevelActor::LowerBelow( actorA, actorC );
4961   application.ProcessEvent( event );
4962
4963   tet_printf( "C not parented so LowerBelow should show no effect\n" );
4964   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4965   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4966   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4967
4968   ResetTouchCallbacks();
4969
4970   stage.Add ( actorC );
4971
4972   application.SendNotification();
4973   application.Render();
4974
4975   DevelActor::RaiseAbove( actorA, actorC );
4976   application.ProcessEvent( event );
4977
4978   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
4979   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4980   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4981   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4982
4983   END_TEST;
4984 }
4985
4986 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
4987 {
4988   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
4989
4990   TestApplication application;
4991
4992   Stage stage( Stage::GetCurrent() );
4993
4994   Actor actorA = Actor::New();
4995   Actor actorB = Actor::New();
4996   Actor actorC = Actor::New();
4997
4998   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4999   actorA.SetParentOrigin( ParentOrigin::CENTER );
5000
5001   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5002   actorB.SetParentOrigin( ParentOrigin::CENTER );
5003
5004   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5005   actorC.SetParentOrigin( ParentOrigin::CENTER );
5006
5007   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5008   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5009
5010   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5011   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5012
5013   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5014   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5015
5016   ResetTouchCallbacks();
5017
5018   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5019   // Only top actor will get touched.
5020   actorA.TouchSignal().Connect( TestTouchCallback );
5021   actorB.TouchSignal().Connect( TestTouchCallback2 );
5022   actorC.TouchSignal().Connect( TestTouchCallback3 );
5023
5024   Dali::Integration::Point point;
5025   point.SetDeviceId( 1 );
5026   point.SetState( PointState::DOWN );
5027   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5028   Dali::Integration::TouchEvent event;
5029   event.AddPoint( point );
5030
5031   stage.Add ( actorA );
5032
5033   application.SendNotification();
5034   application.Render();
5035
5036   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5037
5038   DevelActor::Raise( actorB );
5039
5040   application.ProcessEvent( event );
5041
5042   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5043
5044   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5045   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5046   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5047
5048   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5049   ResetTouchCallbacks();
5050
5051   DevelActor::Lower( actorC );
5052
5053   application.ProcessEvent( event );
5054
5055   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5056
5057   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5058   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5059   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5060   ResetTouchCallbacks();
5061
5062   tet_printf( "Lower actor C below B but C not parented\n" );
5063
5064   DevelActor::Lower( actorB );
5065
5066   application.ProcessEvent( event );
5067
5068   tet_printf( "Not parented so Lower should show no effect\n" );
5069
5070   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5071   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5072   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5073   ResetTouchCallbacks();
5074
5075   tet_printf( "Raise actor B to top\n" );
5076
5077   DevelActor::RaiseToTop( actorB );
5078
5079   application.ProcessEvent( event );
5080
5081   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5082
5083   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5084   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5085   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5086   ResetTouchCallbacks();
5087
5088   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5089
5090   stage.Add ( actorB );
5091
5092   application.SendNotification();
5093   application.Render();
5094
5095   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5096
5097   DevelActor::LowerToBottom( actorC );
5098
5099   application.ProcessEvent( event );
5100
5101   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5102
5103   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5104   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5105   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5106   ResetTouchCallbacks();
5107
5108   END_TEST;
5109 }
5110
5111
5112 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5113 {
5114   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5115
5116   TestApplication application;
5117
5118   Stage stage( Stage::GetCurrent() );
5119
5120   Actor actorA = Actor::New();
5121   Actor actorB = Actor::New();
5122   Actor actorC = Actor::New();
5123
5124   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5125   actorA.SetParentOrigin( ParentOrigin::CENTER );
5126
5127   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5128   actorB.SetParentOrigin( ParentOrigin::CENTER );
5129
5130   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5131   actorC.SetParentOrigin( ParentOrigin::CENTER );
5132
5133   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5134   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5135
5136   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5137   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5138
5139   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5140   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5141
5142   stage.Add( actorA );
5143   stage.Add( actorB );
5144   stage.Add( actorC );
5145
5146   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5147   // Only top actor will get touched.
5148   actorA.TouchSignal().Connect( TestTouchCallback );
5149   actorB.TouchSignal().Connect( TestTouchCallback2 );
5150   actorC.TouchSignal().Connect( TestTouchCallback3 );
5151
5152   ResetTouchCallbacks();
5153
5154   application.SendNotification();
5155   application.Render();
5156
5157   Dali::Integration::Point point;
5158   point.SetDeviceId( 1 );
5159   point.SetState( PointState::DOWN );
5160   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5161   Dali::Integration::TouchEvent event;
5162   event.AddPoint( point );
5163
5164   application.ProcessEvent( event );
5165
5166   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5167   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5168   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5169
5170   ResetTouchCallbacks();
5171
5172   tet_printf( "Raise actor A Above Actor A which is the same actor!!\n" );
5173
5174   DevelActor::RaiseAbove( actorA, actorA );
5175
5176   application.ProcessEvent( event );
5177
5178   tet_printf( "No target is source Actor so RaiseAbove should show no effect\n" );
5179
5180   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5181   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5182   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5183
5184   ResetTouchCallbacks();
5185
5186   DevelActor::RaiseAbove( actorA, actorC );
5187   application.ProcessEvent( event );
5188
5189   tet_printf( "Raise actor A Above Actor C which will now be successful \n" );
5190   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5191   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5192   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5193
5194   END_TEST;
5195 }
5196