Merge "Revert public API changes. BATCH property." into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2015 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 gHoverCallBackCalled=false;
48
49 /**
50  * Simulates a Down Touch at 25.0, 25.0.
51  * @param[in] app Test Application instance.
52  */
53 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
54 {
55   app.SendNotification();
56   app.Render(1);
57   app.SendNotification();
58   app.Render(1);
59
60   gTouchCallBackCalled = false;
61
62   // simulate a touch event
63   Dali::Integration::Point point;
64   point.SetState( PointState::DOWN );
65   point.SetScreenPosition( Vector2( 25.0f, 25.0f ) );
66   Dali::Integration::TouchEvent event;
67   event.AddPoint( point );
68   app.ProcessEvent( event );
69
70   app.SendNotification();
71   app.Render(1);
72   app.SendNotification();
73   app.Render(1);
74   END_TEST;
75 }
76
77
78 static bool gTestConstraintCalled;
79
80 struct TestConstraint
81 {
82   void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
83   {
84     gTestConstraintCalled = true;
85   }
86 };
87
88 /**
89  * TestConstraint reference.
90  * When constraint is called, the resultRef is updated
91  * with the value supplied.
92  */
93 template<typename T>
94 struct TestConstraintRef
95 {
96   TestConstraintRef(unsigned int& resultRef, unsigned int value)
97   : mResultRef(resultRef),
98     mValue(value)
99   {
100   }
101
102   void operator()( T& current, const PropertyInputContainer& /* inputs */ )
103   {
104     mResultRef = mValue;
105   }
106
107   unsigned int& mResultRef;
108   unsigned int mValue;
109 };
110
111 static bool TestCallback(Actor actor, const TouchEvent& event)
112 {
113   gTouchCallBackCalled = true;
114   return false;
115   END_TEST;
116 }
117
118 static bool TestCallback3(Actor actor, const HoverEvent& event)
119 {
120   gHoverCallBackCalled = true;
121   return false;
122   END_TEST;
123 }
124
125 static Vector3 gSetSize;
126 static bool gSetSizeCallBackCalled;
127 void SetSizeCallback( Actor actor, const Vector3& size )
128 {
129   gSetSizeCallBackCalled = true;
130   gSetSize = size;
131 }
132 // validation stuff for onstage & offstage signals
133 static std::vector< std::string > gActorNamesOnOffStage;
134 static int gOnStageCallBackCalled;
135 void OnStageCallback( Actor actor )
136 {
137   ++gOnStageCallBackCalled;
138   gActorNamesOnOffStage.push_back( actor.GetName() );
139   DALI_TEST_CHECK( actor.OnStage() == true );
140 }
141 static int gOffStageCallBackCalled;
142 void OffStageCallback( Actor actor )
143 {
144   ++gOffStageCallBackCalled;
145   gActorNamesOnOffStage.push_back( actor.GetName() );
146   DALI_TEST_CHECK( actor.OnStage() == false );
147 }
148
149 struct PositionComponentConstraint
150 {
151   PositionComponentConstraint(){}
152
153   void operator()( Vector3& pos, const PropertyInputContainer& inputs )
154   {
155     const Matrix& m = inputs[0]->GetMatrix();
156     Vector3 scale;
157     Quaternion rot;
158     m.GetTransformComponents(pos, rot, scale);
159   }
160 };
161
162 struct OrientationComponentConstraint
163 {
164   OrientationComponentConstraint(){}
165
166   void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
167   {
168     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
169     Vector3 pos, scale;
170     Quaternion rot;
171     orientation = parentOrientation;
172   }
173 };
174 // OnRelayout
175
176 static bool gOnRelayoutCallBackCalled = false;
177 static std::vector< std::string > gActorNamesRelayout;
178
179 void OnRelayoutCallback( Actor actor )
180 {
181   gOnRelayoutCallBackCalled = true;
182   gActorNamesRelayout.push_back( actor.GetName() );
183 }
184
185 } // anonymous namespace
186
187
188 //& purpose: Testing New API
189 int UtcDaliActorNew(void)
190 {
191   TestApplication application;
192
193   Actor actor = Actor::New();
194
195   DALI_TEST_CHECK(actor);
196   END_TEST;
197 }
198
199 //& purpose: Testing Dali::Actor::DownCast()
200 int UtcDaliActorDownCastP(void)
201 {
202   TestApplication application;
203   tet_infoline("Testing Dali::Actor::DownCast()");
204
205   Actor actor = Actor::New();
206   BaseHandle object(actor);
207   Actor actor2 = Actor::DownCast(object);
208   DALI_TEST_CHECK(actor2);
209   END_TEST;
210 }
211
212 //& purpose: Testing Dali::Actor::DownCast()
213 int UtcDaliActorDownCastN(void)
214 {
215   TestApplication application;
216   tet_infoline("Testing Dali::Actor::DownCast()");
217
218   BaseHandle unInitializedObject;
219   Actor actor = Actor::DownCast(unInitializedObject);
220   DALI_TEST_CHECK(!actor);
221   END_TEST;
222 }
223
224 //& purpose: Testing Dali::Actor::GetName()
225 int UtcDaliActorGetName(void)
226 {
227   TestApplication application;
228
229   Actor actor = Actor::New();
230
231   DALI_TEST_CHECK(actor.GetName().empty());
232   END_TEST;
233 }
234
235 //& purpose: Testing Dali::Actor::SetName()
236 int UtcDaliActorSetName(void)
237 {
238   TestApplication application;
239
240   string str("ActorName");
241   Actor actor = Actor::New();
242
243   actor.SetName(str);
244   DALI_TEST_CHECK(actor.GetName() == str);
245   END_TEST;
246 }
247
248 int UtcDaliActorGetId(void)
249 {
250   tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
251   TestApplication application;
252
253   Actor first = Actor::New();
254   Actor second = Actor::New();
255   Actor third = Actor::New();
256
257   DALI_TEST_CHECK(first.GetId() != second.GetId());
258   DALI_TEST_CHECK(second.GetId() != third.GetId());
259   END_TEST;
260 }
261
262 int UtcDaliActorIsRoot(void)
263 {
264   TestApplication application;
265
266   Actor actor = Actor::New();
267   DALI_TEST_CHECK(!actor.IsRoot());
268
269   // get the root layer
270   actor = Stage::GetCurrent().GetLayer( 0 );
271   DALI_TEST_CHECK( actor.IsRoot() );
272   END_TEST;
273 }
274
275 int UtcDaliActorOnStage(void)
276 {
277   TestApplication application;
278
279   Actor actor = Actor::New();
280   DALI_TEST_CHECK( !actor.OnStage() );
281
282   // get the root layer
283   actor = Stage::GetCurrent().GetLayer( 0 );
284   DALI_TEST_CHECK( actor.OnStage() );
285   END_TEST;
286 }
287
288 int UtcDaliActorIsLayer(void)
289 {
290   TestApplication application;
291
292   Actor actor = Actor::New();
293   DALI_TEST_CHECK( !actor.IsLayer() );
294
295   // get the root layer
296   actor = Stage::GetCurrent().GetLayer( 0 );
297   DALI_TEST_CHECK( actor.IsLayer() );
298   END_TEST;
299 }
300
301 int UtcDaliActorGetLayer(void)
302 {
303   TestApplication application;
304
305   Actor actor = Actor::New();
306   Stage::GetCurrent().Add(actor);
307   Layer layer = actor.GetLayer();
308
309   DALI_TEST_CHECK(layer);
310
311   // get the root layers layer
312   actor = Stage::GetCurrent().GetLayer( 0 );
313   DALI_TEST_CHECK( actor.GetLayer() );
314   END_TEST;
315 }
316
317 int UtcDaliActorAddP(void)
318 {
319   tet_infoline("Testing Actor::Add");
320   TestApplication application;
321
322   Actor parent = Actor::New();
323   Actor child = Actor::New();
324
325   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
326
327   parent.Add(child);
328
329   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
330
331   Actor parent2 = Actor::New();
332   parent2.Add( child );
333
334   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
335   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
336
337   // try Adding to same parent again, works
338   parent2.Add( child );
339   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
340
341   // try reparenting an orphaned child
342   {
343     Actor temporaryParent = Actor::New();
344     temporaryParent.Add( child );
345     DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
346   }
347   // temporaryParent has now died, reparent the orphaned child
348   parent2.Add( child );
349   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
350
351   END_TEST;
352 }
353
354 int UtcDaliActorAddN(void)
355 {
356   tet_infoline("Testing Actor::Add");
357   TestApplication application;
358
359   Actor child = Actor::New();
360
361   Actor parent2 = Actor::New();
362   parent2.Add( child );
363
364   // try illegal Add
365   try
366   {
367     parent2.Add( parent2 );
368     tet_printf("Assertion test failed - no Exception\n" );
369     tet_result(TET_FAIL);
370   }
371   catch(Dali::DaliException& e)
372   {
373     DALI_TEST_PRINT_ASSERT( e );
374     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
375     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
376   }
377   catch(...)
378   {
379     tet_printf("Assertion test failed - wrong Exception\n" );
380     tet_result(TET_FAIL);
381   }
382
383   // try reparenting root
384   try
385   {
386     parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
387     tet_printf("Assertion test failed - no Exception\n" );
388     tet_result(TET_FAIL);
389   }
390   catch(Dali::DaliException& e)
391   {
392     DALI_TEST_PRINT_ASSERT( e );
393     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
394     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
395   }
396   catch(...)
397   {
398     tet_printf("Assertion test failed - wrong Exception\n" );
399     tet_result(TET_FAIL);
400   }
401
402   // try Add empty
403   try
404   {
405     Actor empty;
406     parent2.Add( empty );
407     tet_printf("Assertion test failed - no Exception\n" );
408     tet_result(TET_FAIL);
409   }
410   catch(Dali::DaliException& e)
411   {
412     DALI_TEST_PRINT_ASSERT( e );
413     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
414     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
415   }
416   catch(...)
417   {
418     tet_printf("Assertion test failed - wrong Exception\n" );
419     tet_result(TET_FAIL);
420   }
421
422   END_TEST;
423 }
424
425 int UtcDaliActorRemoveN(void)
426 {
427   tet_infoline("Testing Actor::Remove");
428   TestApplication application;
429
430   Actor parent = Actor::New();
431   Actor child = Actor::New();
432   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
433
434   parent.Add(child);
435   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
436
437   parent.Remove(child);
438   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
439
440   // remove again, no problem
441   parent.Remove(child);
442   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
443
444   // add child back
445   parent.Add(child);
446   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
447   // try Remove self, its a no-op
448   parent.Remove( parent );
449   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
450
451   // try Remove empty
452   try
453   {
454     Actor empty;
455     parent.Remove( empty );
456     tet_printf("Assertion test failed - no Exception\n" );
457     tet_result(TET_FAIL);
458   }
459   catch(Dali::DaliException& e)
460   {
461     DALI_TEST_PRINT_ASSERT( e );
462     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
463     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
464   }
465   catch(...)
466   {
467     tet_printf("Assertion test failed - wrong Exception\n" );
468     tet_result(TET_FAIL);
469   }
470   END_TEST;
471 }
472
473 int UtcDaliActorRemoveP(void)
474 {
475   TestApplication application;
476
477   Actor parent = Actor::New();
478   Actor child = Actor::New();
479   Actor random = Actor::New();
480
481   Stage::GetCurrent().Add( parent );
482
483   DALI_TEST_CHECK(parent.GetChildCount() == 0);
484
485   parent.Add(child);
486
487   DALI_TEST_CHECK(parent.GetChildCount() == 1);
488
489   parent.Remove(random);
490
491   DALI_TEST_CHECK(parent.GetChildCount() == 1);
492
493   Stage::GetCurrent().Remove( parent );
494
495   DALI_TEST_CHECK(parent.GetChildCount() == 1);
496   END_TEST;
497 }
498
499 int UtcDaliActorGetChildCount(void)
500 {
501   TestApplication application;
502
503   Actor parent = Actor::New();
504   Actor child = Actor::New();
505
506   DALI_TEST_CHECK(parent.GetChildCount() == 0);
507
508   parent.Add(child);
509
510   DALI_TEST_CHECK(parent.GetChildCount() == 1);
511   END_TEST;
512 }
513
514 int UtcDaliActorGetChildren01(void)
515 {
516   TestApplication application;
517
518   Actor parent = Actor::New();
519   Actor first  = Actor::New();
520   Actor second = Actor::New();
521   Actor third  = Actor::New();
522
523   parent.Add(first);
524   parent.Add(second);
525   parent.Add(third);
526
527   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
528   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
529   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
530   END_TEST;
531 }
532
533 int UtcDaliActorGetChildren02(void)
534 {
535   TestApplication application;
536
537   Actor parent = Actor::New();
538   Actor first  = Actor::New();
539   Actor second = Actor::New();
540   Actor third  = Actor::New();
541
542   parent.Add(first);
543   parent.Add(second);
544   parent.Add(third);
545
546   const Actor& constParent = parent;
547
548   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
549   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
550   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
551   END_TEST;
552 }
553
554 int UtcDaliActorGetParent01(void)
555 {
556   TestApplication application;
557
558   Actor parent = Actor::New();
559   Actor child = Actor::New();
560
561   parent.Add(child);
562
563   DALI_TEST_CHECK(child.GetParent() == parent);
564   END_TEST;
565 }
566
567 int UtcDaliActorGetParent02(void)
568 {
569   TestApplication application;
570
571   Actor actor = Actor::New();
572
573   DALI_TEST_CHECK(!actor.GetParent());
574   END_TEST;
575 }
576
577 int UtcDaliActorSetParentOrigin(void)
578 {
579   TestApplication application;
580
581   Actor actor = Actor::New();
582
583   Vector3 vector(0.7f, 0.8f, 0.9f);
584   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
585
586   actor.SetParentOrigin(vector);
587
588   // flush the queue and render once
589   application.SendNotification();
590   application.Render();
591
592   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
593
594   Stage::GetCurrent().Add( actor );
595
596   actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
597
598   // flush the queue and render once
599   application.SendNotification();
600   application.Render();
601
602   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
603
604   Stage::GetCurrent().Remove( actor );
605   END_TEST;
606 }
607
608 int UtcDaliActorSetParentOriginIndividual(void)
609 {
610   TestApplication application;
611
612   Actor actor = Actor::New();
613
614   Vector3 vector(0.7f, 0.8f, 0.9f);
615   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
616
617   actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
618
619   // flush the queue and render once
620   application.SendNotification();
621   application.Render();
622
623   DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
624
625   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
626
627   // flush the queue and render once
628   application.SendNotification();
629   application.Render();
630
631   DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
632
633   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
634
635   // flush the queue and render once
636   application.SendNotification();
637   application.Render();
638
639   DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
640
641   END_TEST;
642 }
643
644 int UtcDaliActorGetCurrentParentOrigin(void)
645 {
646   TestApplication application;
647
648   Actor actor = Actor::New();
649
650   Vector3 vector(0.7f, 0.8f, 0.9f);
651   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
652
653   actor.SetParentOrigin(vector);
654
655   // flush the queue and render once
656   application.SendNotification();
657   application.Render();
658
659   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
660   END_TEST;
661 }
662
663 int UtcDaliActorSetAnchorPoint(void)
664 {
665   TestApplication application;
666
667   Actor actor = Actor::New();
668
669   Vector3 vector(0.7f, 0.8f, 0.9f);
670   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
671
672   actor.SetAnchorPoint(vector);
673
674   // flush the queue and render once
675   application.SendNotification();
676   application.Render();
677
678   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
679
680   Stage::GetCurrent().Add( actor );
681
682   actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
683   // flush the queue and render once
684   application.SendNotification();
685   application.Render();
686
687   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
688
689   Stage::GetCurrent().Remove( actor );
690   END_TEST;
691 }
692
693 int UtcDaliActorSetAnchorPointIndividual(void)
694 {
695   TestApplication application;
696
697   Actor actor = Actor::New();
698
699   Vector3 vector(0.7f, 0.8f, 0.9f);
700   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
701
702   actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
703
704   // flush the queue and render once
705   application.SendNotification();
706   application.Render();
707
708   DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
709
710   actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
711
712   // flush the queue and render once
713   application.SendNotification();
714   application.Render();
715
716   DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
717
718   actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
719
720   // flush the queue and render once
721   application.SendNotification();
722   application.Render();
723
724   DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
725
726   END_TEST;
727 }
728
729 int UtcDaliActorGetCurrentAnchorPoint(void)
730 {
731   TestApplication application;
732
733   Actor actor = Actor::New();
734
735   Vector3 vector(0.7f, 0.8f, 0.9f);
736   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
737
738   actor.SetAnchorPoint(vector);
739
740   // flush the queue and render once
741   application.SendNotification();
742   application.Render();
743
744   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
745   END_TEST;
746 }
747
748 // SetSize(float width, float height)
749 int UtcDaliActorSetSize01(void)
750 {
751   TestApplication application;
752
753   Actor actor = Actor::New();
754   Vector3 vector(100.0f, 100.0f, 0.0f);
755
756   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
757
758   actor.SetSize(vector.x, vector.y);
759
760   // flush the queue and render once
761   application.SendNotification();
762   application.Render();
763
764   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
765   END_TEST;
766 }
767
768 // SetSize(float width, float height, float depth)
769 int UtcDaliActorSetSize02(void)
770 {
771   TestApplication application;
772
773   Actor actor = Actor::New();
774   Vector3 vector(100.0f, 100.0f, 100.0f);
775
776   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
777
778   actor.SetSize(vector.x, vector.y, vector.z);
779
780   // flush the queue and render once
781   application.SendNotification();
782   application.Render();
783
784   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
785   END_TEST;
786 }
787
788 // SetSize(Vector2 size)
789 int UtcDaliActorSetSize03(void)
790 {
791   TestApplication application;
792
793   Actor actor = Actor::New();
794   Vector3 vector(100.0f, 100.0f, 0.0f);
795
796   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
797
798   actor.SetSize(Vector2(vector.x, vector.y));
799
800   // flush the queue and render once
801   application.SendNotification();
802   application.Render();
803
804   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
805   END_TEST;
806 }
807
808 // SetSize(Vector3 size)
809 int UtcDaliActorSetSize04(void)
810 {
811   TestApplication application;
812
813   Actor actor = Actor::New();
814   Vector3 vector(100.0f, 100.0f, 100.0f);
815
816   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
817
818   actor.SetSize(vector);
819
820   // flush the queue and render once
821   application.SendNotification();
822   application.Render();
823
824   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
825
826   Stage::GetCurrent().Add( actor );
827   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
828
829   // flush the queue and render once
830   application.SendNotification();
831   application.Render();
832
833   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
834   Stage::GetCurrent().Remove( actor );
835   END_TEST;
836 }
837
838 int UtcDaliActorSetSizeIndividual(void)
839 {
840   TestApplication application;
841
842   Actor actor = Actor::New();
843
844   Vector3 vector(0.7f, 0.8f, 0.9f);
845   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
846
847   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
848
849   // flush the queue and render once
850   application.SendNotification();
851   application.Render();
852
853   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
854
855   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
856
857   // flush the queue and render once
858   application.SendNotification();
859   application.Render();
860
861   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
862
863   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
864
865   // flush the queue and render once
866   application.SendNotification();
867   application.Render();
868
869   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
870
871   END_TEST;
872 }
873
874
875 int UtcDaliActorGetCurrentSize(void)
876 {
877   TestApplication application;
878
879   Actor actor = Actor::New();
880   Vector3 vector(100.0f, 100.0f, 20.0f);
881
882   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
883
884   actor.SetSize(vector);
885
886   // flush the queue and render once
887   application.SendNotification();
888   application.Render();
889
890   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
891   END_TEST;
892 }
893
894 int UtcDaliActorGetNaturalSize(void)
895 {
896   TestApplication application;
897
898   Actor actor = Actor::New();
899   Vector3 vector( 0.0f, 0.0f, 0.0f );
900
901   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
902
903   END_TEST;
904 }
905
906 int UtcDaliActorGetCurrentSizeImmediate(void)
907 {
908   TestApplication application;
909
910   Actor actor = Actor::New();
911   Vector3 vector(100.0f, 100.0f, 20.0f);
912
913   DALI_TEST_CHECK(vector != actor.GetTargetSize());
914   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
915
916   actor.SetSize(vector);
917
918   DALI_TEST_CHECK(vector == actor.GetTargetSize());
919   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
920
921   // flush the queue and render once
922   application.SendNotification();
923   application.Render();
924
925   DALI_TEST_CHECK(vector == actor.GetTargetSize());
926   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
927
928   // Animation
929   // Build the animation
930   const float durationSeconds = 2.0f;
931   Animation animation = Animation::New( durationSeconds );
932   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
933   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
934
935   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
936
937   // Start the animation
938   animation.Play();
939
940   application.SendNotification();
941   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
942
943   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
944
945   END_TEST;
946 }
947
948 // SetPosition(float x, float y)
949 int UtcDaliActorSetPosition01(void)
950 {
951   TestApplication application;
952
953   Actor actor = Actor::New();
954
955   // Set to random to start off with
956   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
957
958   Vector3 vector(100.0f, 100.0f, 0.0f);
959
960   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
961
962   actor.SetPosition(vector.x, vector.y);
963   // flush the queue and render once
964   application.SendNotification();
965   application.Render();
966   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
967
968   Stage::GetCurrent().Add( actor );
969   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
970   // flush the queue and render once
971   application.SendNotification();
972   application.Render();
973   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
974
975   actor.SetX( 1.0f );
976   actor.SetY( 1.1f );
977   actor.SetZ( 1.2f );
978   // flush the queue and render once
979   application.SendNotification();
980   application.Render();
981   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
982
983   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
984   // flush the queue and render once
985   application.SendNotification();
986   application.Render();
987   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
988
989   Stage::GetCurrent().Remove( actor );
990   END_TEST;
991 }
992
993 // SetPosition(float x, float y, float z)
994 int UtcDaliActorSetPosition02(void)
995 {
996   TestApplication application;
997
998   Actor actor = Actor::New();
999
1000   // Set to random to start off with
1001   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1002
1003   Vector3 vector(100.0f, 100.0f, 100.0f);
1004
1005   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1006
1007   actor.SetPosition(vector.x, vector.y, vector.z);
1008
1009   // flush the queue and render once
1010   application.SendNotification();
1011   application.Render();
1012
1013   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1014   END_TEST;
1015 }
1016
1017 // SetPosition(Vector3 position)
1018 int UtcDaliActorSetPosition03(void)
1019 {
1020   TestApplication application;
1021
1022   Actor actor = Actor::New();
1023
1024   // Set to random to start off with
1025   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1026
1027   Vector3 vector(100.0f, 100.0f, 100.0f);
1028
1029   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1030
1031   actor.SetPosition(vector);
1032
1033   // flush the queue and render once
1034   application.SendNotification();
1035   application.Render();
1036
1037   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1038   END_TEST;
1039 }
1040
1041 int UtcDaliActorSetX(void)
1042 {
1043   TestApplication application;
1044
1045   Actor actor = Actor::New();
1046
1047   Vector3 vector(100.0f, 0.0f, 0.0f);
1048
1049   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1050
1051   actor.SetX(100.0f);
1052
1053   // flush the queue and render once
1054   application.SendNotification();
1055   application.Render();
1056
1057   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1058   END_TEST;
1059 }
1060
1061 int UtcDaliActorSetY(void)
1062 {
1063   TestApplication application;
1064
1065   Actor actor = Actor::New();
1066
1067   Vector3 vector(0.0f, 100.0f, 0.0f);
1068
1069   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1070
1071   actor.SetY(100.0f);
1072
1073   // flush the queue and render once
1074   application.SendNotification();
1075   application.Render();
1076
1077   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1078   END_TEST;
1079 }
1080
1081 int UtcDaliActorSetZ(void)
1082 {
1083   TestApplication application;
1084
1085   Actor actor = Actor::New();
1086
1087   Vector3 vector(0.0f, 0.0f, 100.0f);
1088
1089   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1090
1091   actor.SetZ(100.0f);
1092
1093   // flush the queue and render once
1094   application.SendNotification();
1095   application.Render();
1096
1097   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1098   END_TEST;
1099 }
1100
1101 int UtcDaliActorSetPositionProperties(void)
1102 {
1103   TestApplication application;
1104
1105   Actor actor = Actor::New();
1106
1107   Vector3 vector(0.7f, 0.8f, 0.9f);
1108   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1109
1110   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1111
1112   // flush the queue and render once
1113   application.SendNotification();
1114   application.Render();
1115
1116   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1117
1118   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1119
1120   // flush the queue and render once
1121   application.SendNotification();
1122   application.Render();
1123
1124   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1125
1126   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1127
1128   // flush the queue and render once
1129   application.SendNotification();
1130   application.Render();
1131
1132   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1133
1134   END_TEST;
1135 }
1136
1137 int UtcDaliActorTranslateBy(void)
1138 {
1139   TestApplication application;
1140
1141   Actor actor = Actor::New();
1142   Vector3 vector(100.0f, 100.0f, 100.0f);
1143
1144   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1145
1146   actor.SetPosition(vector);
1147
1148   // flush the queue and render once
1149   application.SendNotification();
1150   application.Render();
1151
1152   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1153
1154   actor.TranslateBy(vector);
1155
1156   // flush the queue and render once
1157   application.SendNotification();
1158   application.Render();
1159
1160   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1161   END_TEST;
1162 }
1163
1164 int UtcDaliActorGetCurrentPosition(void)
1165 {
1166   TestApplication application;
1167
1168   Actor actor = Actor::New();
1169   Vector3 setVector(100.0f, 100.0f, 0.0f);
1170   actor.SetPosition(setVector);
1171
1172   // flush the queue and render once
1173   application.SendNotification();
1174   application.Render();
1175
1176   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1177   END_TEST;
1178 }
1179
1180 int UtcDaliActorGetCurrentWorldPosition(void)
1181 {
1182   TestApplication application;
1183
1184   Actor parent = Actor::New();
1185   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1186   parent.SetPosition( parentPosition );
1187   parent.SetParentOrigin( ParentOrigin::CENTER );
1188   parent.SetAnchorPoint( AnchorPoint::CENTER );
1189   Stage::GetCurrent().Add( parent );
1190
1191   Actor child = Actor::New();
1192   child.SetParentOrigin( ParentOrigin::CENTER );
1193   child.SetAnchorPoint( AnchorPoint::CENTER );
1194   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1195   child.SetPosition( childPosition );
1196   parent.Add( child );
1197
1198   // The actors should not have a world position yet
1199   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1200   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1201
1202   application.SendNotification();
1203   application.Render(0);
1204
1205   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1206   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1207
1208   // The actors should have a world position now
1209   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1210   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1211   END_TEST;
1212 }
1213
1214 int UtcDaliActorInheritPosition(void)
1215 {
1216   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1217   TestApplication application;
1218
1219   Actor parent = Actor::New();
1220   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1221   parent.SetPosition( parentPosition );
1222   parent.SetParentOrigin( ParentOrigin::CENTER );
1223   parent.SetAnchorPoint( AnchorPoint::CENTER );
1224   Stage::GetCurrent().Add( parent );
1225
1226   Actor child = Actor::New();
1227   child.SetParentOrigin( ParentOrigin::CENTER );
1228   child.SetAnchorPoint( AnchorPoint::CENTER );
1229   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1230   child.SetPosition( childPosition );
1231   parent.Add( child );
1232
1233   // The actors should not have a world position yet
1234   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1235   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1236
1237   // first test default, which is to inherit position
1238   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1239   application.SendNotification();
1240   application.Render(0); // should only really call Update as Render is not required to update scene
1241   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1242   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1243   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1244   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1245
1246
1247   //Change child position
1248   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1249   child.SetPosition( childOffset );
1250
1251   // Change inheritance mode to not inherit
1252   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1253   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1254   application.SendNotification();
1255   application.Render(0); // should only really call Update as Render is not required to update scene
1256   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1257   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1258   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1259   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1260   END_TEST;
1261 }
1262
1263 int UtcDaliActorSetInheritPosition(void)
1264 {
1265   tet_infoline("Testing Actor::SetInheritPosition");
1266   TestApplication application;
1267
1268   Actor parent = Actor::New();
1269   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1270   parent.SetPosition( parentPosition );
1271   parent.SetParentOrigin( ParentOrigin::CENTER );
1272   parent.SetAnchorPoint( AnchorPoint::CENTER );
1273   Stage::GetCurrent().Add( parent );
1274
1275   Actor child = Actor::New();
1276   child.SetParentOrigin( ParentOrigin::CENTER );
1277   child.SetAnchorPoint( AnchorPoint::CENTER );
1278   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1279   child.SetPosition( childPosition );
1280   parent.Add( child );
1281
1282   // The actors should not have a world position yet
1283   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1284   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1285
1286   // first test default, which is to inherit position
1287   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1288   application.SendNotification();
1289   application.Render(0); // should only really call Update as Render is not required to update scene
1290   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1291   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1292   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1293   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1294
1295   //Change child position
1296   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1297   child.SetPosition( childOffset );
1298
1299   // Use local position as world postion
1300   child.SetInheritPosition( false );
1301   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1302   application.SendNotification();
1303   application.Render(0); // should only really call Update as Render is not required to update scene
1304   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1305   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1306   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1307   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1308
1309   //Change back to inherit position from parent
1310   child.SetInheritPosition( true );
1311   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1312   application.SendNotification();
1313   application.Render(0); // should only really call Update as Render is not required to update scene
1314   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1315   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1316   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1317   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1318   END_TEST;
1319 }
1320
1321 // SetOrientation(float angleRadians, Vector3 axis)
1322 int UtcDaliActorSetOrientation01(void)
1323 {
1324   TestApplication application;
1325
1326   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1327   Actor actor = Actor::New();
1328
1329   actor.SetOrientation(rotation);
1330
1331   // flush the queue and render once
1332   application.SendNotification();
1333   application.Render();
1334
1335   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1336   END_TEST;
1337 }
1338
1339 int UtcDaliActorSetOrientation02(void)
1340 {
1341   TestApplication application;
1342
1343   Actor actor = Actor::New();
1344
1345   Radian angle( 0.785f );
1346   Vector3 axis(1.0f, 1.0f, 0.0f);
1347
1348   actor.SetOrientation( angle, axis);
1349   Quaternion rotation( angle, axis );
1350   // flush the queue and render once
1351   application.SendNotification();
1352   application.Render();
1353   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1354
1355   Stage::GetCurrent().Add( actor );
1356   actor.RotateBy( Degree( 360 ), axis);
1357   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1358
1359   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1360   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1361   // flush the queue and render once
1362   application.SendNotification();
1363   application.Render();
1364   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1365
1366   actor.SetOrientation( angle, axis);
1367   // flush the queue and render once
1368   application.SendNotification();
1369   application.Render();
1370   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1371
1372   Stage::GetCurrent().Remove( actor );
1373   END_TEST;
1374 }
1375
1376 // SetOrientation(float angleRadians, Vector3 axis)
1377 int UtcDaliActorSetOrientationProperty(void)
1378 {
1379   TestApplication application;
1380
1381   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1382   Actor actor = Actor::New();
1383
1384   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1385
1386   // flush the queue and render once
1387   application.SendNotification();
1388   application.Render();
1389
1390   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1391   END_TEST;
1392 }
1393
1394 // RotateBy(float angleRadians, Vector3 axis)
1395 int UtcDaliActorRotateBy01(void)
1396 {
1397   TestApplication application;
1398
1399   Actor actor = Actor::New();
1400
1401   Radian angle( M_PI * 0.25f );
1402   actor.RotateBy(( angle ), Vector3::ZAXIS);
1403   // flush the queue and render once
1404   application.SendNotification();
1405   application.Render();
1406   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1407
1408   Stage::GetCurrent().Add( actor );
1409
1410   actor.RotateBy( angle, Vector3::ZAXIS);
1411   // flush the queue and render once
1412   application.SendNotification();
1413   application.Render();
1414   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1415
1416   Stage::GetCurrent().Remove( actor );
1417   END_TEST;
1418 }
1419
1420 // RotateBy(Quaternion relativeRotation)
1421 int UtcDaliActorRotateBy02(void)
1422 {
1423   TestApplication application;
1424
1425   Actor actor = Actor::New();
1426
1427   Radian angle( M_PI * 0.25f );
1428   Quaternion rotation(angle, Vector3::ZAXIS);
1429   actor.RotateBy(rotation);
1430   // flush the queue and render once
1431   application.SendNotification();
1432   application.Render();
1433   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1434
1435   actor.RotateBy(rotation);
1436   // flush the queue and render once
1437   application.SendNotification();
1438   application.Render();
1439   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1440   END_TEST;
1441 }
1442
1443 int UtcDaliActorGetCurrentOrientation(void)
1444 {
1445   TestApplication application;
1446   Actor actor = Actor::New();
1447
1448   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1449   actor.SetOrientation(rotation);
1450   // flush the queue and render once
1451   application.SendNotification();
1452   application.Render();
1453   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1454   END_TEST;
1455 }
1456
1457 int UtcDaliActorGetCurrentWorldOrientation(void)
1458 {
1459   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1460   TestApplication application;
1461
1462   Actor parent = Actor::New();
1463   Radian rotationAngle( Degree(90.0f) );
1464   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1465   parent.SetOrientation( rotation );
1466   Stage::GetCurrent().Add( parent );
1467
1468   Actor child = Actor::New();
1469   child.SetOrientation( rotation );
1470   parent.Add( child );
1471
1472   // The actors should not have a world rotation yet
1473   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1474   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1475
1476   application.SendNotification();
1477   application.Render(0);
1478
1479   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1480   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1481
1482   // The actors should have a world rotation now
1483   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1484   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1485
1486   // turn off child rotation inheritance
1487   child.SetInheritOrientation( false );
1488   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1489   application.SendNotification();
1490   application.Render(0);
1491
1492   // The actors should have a world rotation now
1493   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1494   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1495   END_TEST;
1496 }
1497
1498 // SetScale(float scale)
1499 int UtcDaliActorSetScale01(void)
1500 {
1501   TestApplication application;
1502
1503   Actor actor = Actor::New();
1504
1505   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1506   actor.SetScale(0.25f);
1507
1508   Vector3 scale(10.0f, 10.0f, 10.0f);
1509   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1510
1511   actor.SetScale(scale.x);
1512
1513   // flush the queue and render once
1514   application.SendNotification();
1515   application.Render();
1516
1517   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1518   END_TEST;
1519 }
1520
1521 // SetScale(float scaleX, float scaleY, float scaleZ)
1522 int UtcDaliActorSetScale02(void)
1523 {
1524   TestApplication application;
1525   Vector3 scale(10.0f, 10.0f, 10.0f);
1526
1527   Actor actor = Actor::New();
1528
1529   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1530   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1531
1532   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1533
1534   actor.SetScale(scale.x, scale.y, scale.z);
1535   // flush the queue and render once
1536   application.SendNotification();
1537   application.Render();
1538   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1539
1540   // add to stage and test
1541   Stage::GetCurrent().Add( actor );
1542   actor.SetScale( 2.0f, 2.0f, 2.0f );
1543   // flush the queue and render once
1544   application.SendNotification();
1545   application.Render();
1546   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1547
1548   Stage::GetCurrent().Remove( actor );
1549
1550   END_TEST;
1551 }
1552
1553 // SetScale(Vector3 scale)
1554 int UtcDaliActorSetScale03(void)
1555 {
1556   TestApplication application;
1557   Vector3 scale(10.0f, 10.0f, 10.0f);
1558
1559   Actor actor = Actor::New();
1560
1561   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1562   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1563
1564   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1565
1566   actor.SetScale(scale);
1567
1568   // flush the queue and render once
1569   application.SendNotification();
1570   application.Render();
1571
1572   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1573   END_TEST;
1574 }
1575
1576 int UtcDaliActorSetScaleIndividual(void)
1577 {
1578   TestApplication application;
1579
1580   Actor actor = Actor::New();
1581
1582   Vector3 vector(0.7f, 0.8f, 0.9f);
1583   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1584
1585   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1586
1587   // flush the queue and render once
1588   application.SendNotification();
1589   application.Render();
1590
1591   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1592
1593   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1594
1595   // flush the queue and render once
1596   application.SendNotification();
1597   application.Render();
1598
1599   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1600
1601   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1602
1603   // flush the queue and render once
1604   application.SendNotification();
1605   application.Render();
1606
1607   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1608
1609   END_TEST;
1610 }
1611
1612 int UtcDaliActorScaleBy(void)
1613 {
1614   TestApplication application;
1615   Actor actor = Actor::New();
1616   Vector3 vector(100.0f, 100.0f, 100.0f);
1617
1618   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1619
1620   actor.SetScale(vector);
1621
1622   // flush the queue and render once
1623   application.SendNotification();
1624   application.Render();
1625
1626   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1627
1628   actor.ScaleBy(vector);
1629
1630   // flush the queue and render once
1631   application.SendNotification();
1632   application.Render();
1633
1634   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1635   END_TEST;
1636 }
1637
1638 int UtcDaliActorGetCurrentScale(void)
1639 {
1640   TestApplication application;
1641   Vector3 scale(12.0f, 1.0f, 2.0f);
1642
1643   Actor actor = Actor::New();
1644
1645   actor.SetScale(scale);
1646
1647   // flush the queue and render once
1648   application.SendNotification();
1649   application.Render();
1650
1651   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1652   END_TEST;
1653 }
1654
1655 int UtcDaliActorGetCurrentWorldScale(void)
1656 {
1657   TestApplication application;
1658
1659   Actor parent = Actor::New();
1660   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1661   parent.SetScale( parentScale );
1662   Stage::GetCurrent().Add( parent );
1663
1664   Actor child = Actor::New();
1665   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1666   child.SetScale( childScale );
1667   parent.Add( child );
1668
1669   // The actors should not have a scale yet
1670   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1671   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1672
1673   // The actors should not have a world scale yet
1674   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1675   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1676
1677   application.SendNotification();
1678   application.Render(0);
1679
1680   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1681   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1682
1683   // The actors should have a world scale now
1684   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1685   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1686   END_TEST;
1687 }
1688
1689 int UtcDaliActorInheritScale(void)
1690 {
1691   tet_infoline("Testing Actor::SetInheritScale");
1692   TestApplication application;
1693
1694   Actor parent = Actor::New();
1695   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1696   parent.SetScale( parentScale );
1697   Stage::GetCurrent().Add( parent );
1698
1699   Actor child = Actor::New();
1700   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1701   child.SetScale( childScale );
1702   parent.Add( child );
1703
1704   application.SendNotification();
1705   application.Render(0);
1706
1707   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1708   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1709
1710   child.SetInheritScale( false );
1711   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1712
1713   application.SendNotification();
1714   application.Render(0);
1715
1716   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1717   END_TEST;
1718 }
1719
1720 int UtcDaliActorSetVisible(void)
1721 {
1722   TestApplication application;
1723
1724   Actor actor = Actor::New();
1725   actor.SetVisible(false);
1726   // flush the queue and render once
1727   application.SendNotification();
1728   application.Render();
1729   DALI_TEST_CHECK(actor.IsVisible() == false);
1730
1731   actor.SetVisible(true);
1732   // flush the queue and render once
1733   application.SendNotification();
1734   application.Render();
1735   DALI_TEST_CHECK(actor.IsVisible() == true);
1736
1737   // put actor on stage
1738   Stage::GetCurrent().Add( actor );
1739   actor.SetVisible(false);
1740   // flush the queue and render once
1741   application.SendNotification();
1742   application.Render();
1743   DALI_TEST_CHECK(actor.IsVisible() == false);
1744   END_TEST;
1745 }
1746
1747 int UtcDaliActorIsVisible(void)
1748 {
1749   TestApplication application;
1750
1751   Actor actor = Actor::New();
1752
1753   DALI_TEST_CHECK(actor.IsVisible() == true);
1754   END_TEST;
1755 }
1756
1757 int UtcDaliActorSetOpacity(void)
1758 {
1759   TestApplication application;
1760
1761   Actor actor = Actor::New();
1762   // initial opacity is 1
1763   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1764
1765   actor.SetOpacity( 0.4f);
1766   // flush the queue and render once
1767   application.SendNotification();
1768   application.Render();
1769   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1770
1771   // change opacity, actor is on stage to change is not immediate
1772   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1773   // flush the queue and render once
1774   application.SendNotification();
1775   application.Render();
1776   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1777
1778   // put actor on stage
1779   Stage::GetCurrent().Add( actor );
1780
1781   // change opacity, actor is on stage to change is not immediate
1782   actor.SetOpacity( 0.9f );
1783   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1784   // flush the queue and render once
1785   application.SendNotification();
1786   application.Render();
1787   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1788
1789   // change opacity, actor is on stage to change is not immediate
1790   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1791   // flush the queue and render once
1792   application.SendNotification();
1793   application.Render();
1794   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1795   END_TEST;
1796 }
1797
1798 int UtcDaliActorGetCurrentOpacity(void)
1799 {
1800   TestApplication application;
1801
1802   Actor actor = Actor::New();
1803   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1804
1805   actor.SetOpacity(0.5f);
1806   // flush the queue and render once
1807   application.SendNotification();
1808   application.Render();
1809   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1810   END_TEST;
1811 }
1812
1813 int UtcDaliActorSetSensitive(void)
1814 {
1815   TestApplication application;
1816   Actor actor = Actor::New();
1817
1818   bool sensitive = !actor.IsSensitive();
1819
1820   actor.SetSensitive(sensitive);
1821
1822   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1823   END_TEST;
1824 }
1825
1826 int UtcDaliActorIsSensitive(void)
1827 {
1828   TestApplication application;
1829   Actor actor = Actor::New();
1830   actor.SetSensitive(false);
1831
1832   DALI_TEST_CHECK(false == actor.IsSensitive());
1833   END_TEST;
1834 }
1835
1836 int UtcDaliActorSetColor(void)
1837 {
1838   TestApplication application;
1839   Actor actor = Actor::New();
1840   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1841
1842   DALI_TEST_CHECK(color != actor.GetCurrentColor());
1843
1844   actor.SetColor(color);
1845   // flush the queue and render once
1846   application.SendNotification();
1847   application.Render();
1848   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1849
1850   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1851   // flush the queue and render once
1852   application.SendNotification();
1853   application.Render();
1854   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
1855
1856   Stage::GetCurrent().Add( actor );
1857   actor.SetColor( color );
1858   // flush the queue and render once
1859   application.SendNotification();
1860   application.Render();
1861   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
1862
1863   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1864   // flush the queue and render once
1865   application.SendNotification();
1866   application.Render();
1867   // Actor color is not clamped
1868   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
1869   // world color is clamped
1870   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
1871
1872   Stage::GetCurrent().Remove( actor );
1873   END_TEST;
1874 }
1875
1876 int UtcDaliActorSetColorIndividual(void)
1877 {
1878   TestApplication application;
1879
1880   Actor actor = Actor::New();
1881
1882   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1883   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1884
1885   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1886
1887   // flush the queue and render once
1888   application.SendNotification();
1889   application.Render();
1890
1891   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1892
1893   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1894
1895   // flush the queue and render once
1896   application.SendNotification();
1897   application.Render();
1898
1899   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1900
1901   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1902
1903   // flush the queue and render once
1904   application.SendNotification();
1905   application.Render();
1906
1907   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1908
1909   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1910
1911   // flush the queue and render once
1912   application.SendNotification();
1913   application.Render();
1914
1915   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1916
1917   END_TEST;
1918 }
1919
1920
1921 int UtcDaliActorGetCurrentColor(void)
1922 {
1923   TestApplication application;
1924   Actor actor = Actor::New();
1925   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1926
1927   actor.SetColor(color);
1928   // flush the queue and render once
1929   application.SendNotification();
1930   application.Render();
1931   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1932   END_TEST;
1933 }
1934
1935 int UtcDaliActorGetCurrentWorldColor(void)
1936 {
1937   tet_infoline("Actor::GetCurrentWorldColor");
1938   TestApplication application;
1939
1940   Actor parent = Actor::New();
1941   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1942   parent.SetColor( parentColor );
1943   Stage::GetCurrent().Add( parent );
1944
1945   Actor child = Actor::New();
1946   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1947   child.SetColor( childColor );
1948   parent.Add( child );
1949
1950   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1951   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1952
1953   // verify the default color mode
1954   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1955
1956   // The actors should not have a world color yet
1957   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1958   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1959
1960   application.SendNotification();
1961   application.Render(0);
1962
1963   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1964   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1965
1966   // The actors should have a world color now
1967   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1968   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1969
1970   // use own color
1971   child.SetColorMode( USE_OWN_COLOR );
1972   application.SendNotification();
1973   application.Render(0);
1974   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1975
1976   // use parent color
1977   child.SetColorMode( USE_PARENT_COLOR );
1978   application.SendNotification();
1979   application.Render(0);
1980   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1981   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1982
1983   // use parent alpha
1984   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1985   application.SendNotification();
1986   application.Render(0);
1987   Vector4 expectedColor( childColor );
1988   expectedColor.a *= parentColor.a;
1989   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1990   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1991   END_TEST;
1992 }
1993
1994 int UtcDaliActorSetColorMode(void)
1995 {
1996   tet_infoline("Actor::SetColorMode");
1997   TestApplication application;
1998   Actor actor = Actor::New();
1999   Actor child = Actor::New();
2000   actor.Add( child );
2001
2002   actor.SetColorMode( USE_OWN_COLOR );
2003   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2004
2005   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2006   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2007
2008   actor.SetColorMode( USE_PARENT_COLOR );
2009   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2010
2011   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2012   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2013   END_TEST;
2014 }
2015
2016 int UtcDaliActorScreenToLocal(void)
2017 {
2018   TestApplication application;
2019   Actor actor = Actor::New();
2020   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2021   actor.SetSize(100.0f, 100.0f);
2022   actor.SetPosition(10.0f, 10.0f);
2023   Stage::GetCurrent().Add(actor);
2024
2025   // flush the queue and render once
2026   application.SendNotification();
2027   application.Render();
2028
2029   float localX;
2030   float localY;
2031
2032   application.SendNotification();
2033   application.Render();
2034
2035   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2036
2037   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2038   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2039   END_TEST;
2040 }
2041
2042 int UtcDaliActorSetLeaveRequired(void)
2043 {
2044   TestApplication application;
2045
2046   Actor actor = Actor::New();
2047
2048   actor.SetLeaveRequired(false);
2049   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2050
2051   actor.SetLeaveRequired(true);
2052   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2053   END_TEST;
2054 }
2055
2056 int UtcDaliActorGetLeaveRequired(void)
2057 {
2058   TestApplication application;
2059
2060   Actor actor = Actor::New();
2061
2062   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2063   END_TEST;
2064 }
2065
2066 int UtcDaliActorSetKeyboardFocusable(void)
2067 {
2068   TestApplication application;
2069
2070   Actor actor = Actor::New();
2071
2072   actor.SetKeyboardFocusable(true);
2073   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2074
2075   actor.SetKeyboardFocusable(false);
2076   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2077   END_TEST;
2078 }
2079
2080 int UtcDaliActorIsKeyboardFocusable(void)
2081 {
2082   TestApplication application;
2083
2084   Actor actor = Actor::New();
2085
2086   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2087   END_TEST;
2088 }
2089
2090 int UtcDaliActorRemoveConstraints(void)
2091 {
2092   tet_infoline(" UtcDaliActorRemoveConstraints");
2093   TestApplication application;
2094
2095   gTestConstraintCalled = false;
2096
2097   Actor actor = Actor::New();
2098
2099   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2100   constraint.Apply();
2101   actor.RemoveConstraints();
2102
2103   DALI_TEST_CHECK( gTestConstraintCalled == false );
2104
2105   Stage::GetCurrent().Add( actor );
2106   constraint.Apply();
2107
2108   // flush the queue and render once
2109   application.SendNotification();
2110   application.Render();
2111
2112   actor.RemoveConstraints();
2113
2114   DALI_TEST_CHECK( gTestConstraintCalled == true );
2115   END_TEST;
2116 }
2117
2118 int UtcDaliActorRemoveConstraintTag(void)
2119 {
2120   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2121   TestApplication application;
2122
2123   Actor actor = Actor::New();
2124
2125   // 1. Apply Constraint1 and Constraint2, and test...
2126   unsigned int result1 = 0u;
2127   unsigned int result2 = 0u;
2128
2129   unsigned constraint1Tag = 1u;
2130   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2131   constraint1.SetTag( constraint1Tag );
2132   constraint1.Apply();
2133
2134   unsigned constraint2Tag = 2u;
2135   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2136   constraint2.SetTag( constraint2Tag );
2137   constraint2.Apply();
2138
2139   Stage::GetCurrent().Add( actor );
2140   // flush the queue and render once
2141   application.SendNotification();
2142   application.Render();
2143
2144   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2145   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2146
2147   // 2. Remove Constraint1 and test...
2148   result1 = 0;
2149   result2 = 0;
2150   actor.RemoveConstraints(constraint1Tag);
2151   // make color property dirty, which will trigger constraints to be reapplied.
2152   actor.SetColor( Color::WHITE );
2153   // flush the queue and render once
2154   application.SendNotification();
2155   application.Render();
2156
2157   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2158   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2159
2160   // 3. Re-Apply Constraint1 and test...
2161   result1 = 0;
2162   result2 = 0;
2163   constraint1.Apply();
2164   // make color property dirty, which will trigger constraints to be reapplied.
2165   actor.SetColor( Color::WHITE );
2166   // flush the queue and render once
2167   application.SendNotification();
2168   application.Render();
2169
2170   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2171   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2172
2173   // 2. Remove Constraint2 and test...
2174   result1 = 0;
2175   result2 = 0;
2176   actor.RemoveConstraints(constraint2Tag);
2177   // make color property dirty, which will trigger constraints to be reapplied.
2178   actor.SetColor( Color::WHITE );
2179   // flush the queue and render once
2180   application.SendNotification();
2181   application.Render();
2182
2183   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2184   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2185
2186   // 2. Remove Constraint1 as well and test...
2187   result1 = 0;
2188   result2 = 0;
2189   actor.RemoveConstraints(constraint1Tag);
2190   // make color property dirty, which will trigger constraints to be reapplied.
2191   actor.SetColor( Color::WHITE );
2192   // flush the queue and render once
2193   application.SendNotification();
2194   application.Render();
2195
2196   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2197   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2198   END_TEST;
2199 }
2200
2201 int UtcDaliActorTouchedSignal(void)
2202 {
2203   TestApplication application;
2204
2205   gTouchCallBackCalled = false;
2206
2207   // get the root layer
2208   Actor actor = Stage::GetCurrent().GetRootLayer();
2209   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2210
2211   application.SendNotification();
2212   application.Render();
2213
2214   // connect to its touch signal
2215   actor.TouchedSignal().Connect( TestCallback );
2216
2217   // simulate a touch event in the middle of the screen
2218   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2219   Dali::Integration::Point point;
2220   point.SetDeviceId( 1 );
2221   point.SetState( PointState::DOWN );
2222   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2223   Dali::Integration::TouchEvent event;
2224   event.AddPoint( point );
2225   application.ProcessEvent( event );
2226
2227   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2228   END_TEST;
2229 }
2230
2231 int UtcDaliActorHoveredSignal(void)
2232 {
2233   TestApplication application;
2234
2235   gHoverCallBackCalled = false;
2236
2237   // get the root layer
2238   Actor actor = Stage::GetCurrent().GetRootLayer();
2239   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2240
2241   application.SendNotification();
2242   application.Render();
2243
2244   // connect to its hover signal
2245   actor.HoveredSignal().Connect( TestCallback3 );
2246
2247   // simulate a hover event in the middle of the screen
2248   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2249   Dali::Integration::Point point;
2250   point.SetDeviceId( 1 );
2251   point.SetState( PointState::MOTION );
2252   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2253   Dali::Integration::HoverEvent event;
2254   event.AddPoint( point );
2255   application.ProcessEvent( event );
2256
2257   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2258   END_TEST;
2259 }
2260
2261 int UtcDaliActorOnOffStageSignal(void)
2262 {
2263   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2264
2265   TestApplication application;
2266
2267   // clean test data
2268   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2269   gActorNamesOnOffStage.clear();
2270
2271   Actor parent = Actor::New();
2272   parent.SetName( "parent" );
2273   parent.OnStageSignal().Connect( OnStageCallback );
2274   parent.OffStageSignal().Connect( OffStageCallback );
2275   // sanity check
2276   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2277   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2278
2279   // add parent to stage
2280   Stage::GetCurrent().Add( parent );
2281   // onstage emitted, offstage not
2282   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2283   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2284   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2285
2286   // test adding a child, should get onstage emitted
2287   // clean test data
2288   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2289   gActorNamesOnOffStage.clear();
2290
2291   Actor child = Actor::New();
2292   child.SetName( "child" );
2293   child.OnStageSignal().Connect( OnStageCallback );
2294   child.OffStageSignal().Connect( OffStageCallback );
2295   parent.Add( child ); // add child
2296   // onstage emitted, offstage not
2297   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2298   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2299   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2300
2301   // test removing parent from stage
2302   // clean test data
2303   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2304   gActorNamesOnOffStage.clear();
2305
2306   Stage::GetCurrent().Remove( parent );
2307   // onstage not emitted, offstage is
2308   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2309   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2310   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2311   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2312
2313   // test adding parent back to stage
2314   // clean test data
2315   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2316   gActorNamesOnOffStage.clear();
2317
2318   Stage::GetCurrent().Add( parent );
2319   // onstage emitted, offstage not
2320   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2321   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2322   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2323   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2324
2325   // test removing child
2326   // clean test data
2327   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2328   gActorNamesOnOffStage.clear();
2329
2330   parent.Remove( child );
2331   // onstage not emitted, offstage is
2332   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2333   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2334   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2335
2336   // test removing parent
2337   // clean test data
2338   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2339   gActorNamesOnOffStage.clear();
2340
2341   Stage::GetCurrent().Remove( parent );
2342   // onstage not emitted, offstage is
2343   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2344   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2345   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2346   END_TEST;
2347 }
2348
2349 int UtcDaliActorFindChildByName(void)
2350 {
2351   tet_infoline("Testing Dali::Actor::FindChildByName()");
2352   TestApplication application;
2353
2354   Actor parent = Actor::New();
2355   parent.SetName( "parent" );
2356   Actor first  = Actor::New();
2357   first .SetName( "first" );
2358   Actor second = Actor::New();
2359   second.SetName( "second" );
2360
2361   parent.Add(first);
2362   first.Add(second);
2363
2364   Actor found = parent.FindChildByName( "foo" );
2365   DALI_TEST_CHECK( !found );
2366
2367   found = parent.FindChildByName( "parent" );
2368   DALI_TEST_CHECK( found == parent );
2369
2370   found = parent.FindChildByName( "first" );
2371   DALI_TEST_CHECK( found == first );
2372
2373   found = parent.FindChildByName( "second" );
2374   DALI_TEST_CHECK( found == second );
2375   END_TEST;
2376 }
2377
2378 int UtcDaliActorFindChildById(void)
2379 {
2380   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2381   TestApplication application;
2382
2383   Actor parent = Actor::New();
2384   Actor first  = Actor::New();
2385   Actor second = Actor::New();
2386
2387   parent.Add(first);
2388   first.Add(second);
2389
2390   Actor found = parent.FindChildById( 100000 );
2391   DALI_TEST_CHECK( !found );
2392
2393   found = parent.FindChildById( parent.GetId() );
2394   DALI_TEST_CHECK( found == parent );
2395
2396   found = parent.FindChildById( first.GetId() );
2397   DALI_TEST_CHECK( found == first );
2398
2399   found = parent.FindChildById( second.GetId() );
2400   DALI_TEST_CHECK( found == second );
2401   END_TEST;
2402 }
2403
2404 int UtcDaliActorHitTest(void)
2405 {
2406   struct HitTestData
2407   {
2408   public:
2409     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2410     : mScale( scale ),
2411       mTouchPoint( touchPoint ),
2412       mResult( result )
2413     {}
2414
2415     Vector3 mScale;
2416     Vector2 mTouchPoint;
2417     bool mResult;
2418   };
2419
2420   TestApplication application;
2421   tet_infoline(" UtcDaliActorHitTest");
2422
2423   // Fill a vector with different hit tests.
2424   struct HitTestData* hitTestData[] = {
2425     //                    scale                     touch point           result
2426     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2427     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2428     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.
2429     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2430     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.
2431     NULL,
2432   };
2433
2434   // get the root layer
2435   Actor actor = Actor::New();
2436   actor.SetAnchorPoint( AnchorPoint::CENTER );
2437   actor.SetParentOrigin( ParentOrigin::CENTER );
2438
2439   Stage::GetCurrent().Add( actor );
2440
2441   gTouchCallBackCalled = false;
2442
2443   unsigned int index = 0;
2444   while( NULL != hitTestData[index] )
2445   {
2446     actor.SetSize( 1.f, 1.f );
2447     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2448
2449     // flush the queue and render once
2450     application.SendNotification();
2451     application.Render();
2452
2453     DALI_TEST_CHECK( !gTouchCallBackCalled );
2454
2455     // connect to its touch signal
2456     actor.TouchedSignal().Connect(TestCallback);
2457
2458     Dali::Integration::Point point;
2459     point.SetState( PointState::DOWN );
2460     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2461     Dali::Integration::TouchEvent event;
2462     event.AddPoint( point );
2463
2464     // flush the queue and render once
2465     application.SendNotification();
2466     application.Render();
2467     application.ProcessEvent( event );
2468
2469     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2470
2471     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2472       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2473                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2474                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2475                  hitTestData[index]->mResult );
2476
2477     gTouchCallBackCalled = false;
2478     ++index;
2479   }
2480   END_TEST;
2481 }
2482
2483 int UtcDaliActorSetDrawMode(void)
2484 {
2485   TestApplication app;
2486   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2487
2488   Actor a = Actor::New();
2489
2490   Stage::GetCurrent().Add(a);
2491   app.SendNotification();
2492   app.Render(0);
2493   app.SendNotification();
2494   app.Render(1);
2495
2496   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2497
2498   a.SetDrawMode( DrawMode::OVERLAY_2D );
2499   app.SendNotification();
2500   app.Render(1);
2501
2502   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2503
2504   a.SetDrawMode( DrawMode::NORMAL );
2505   app.SendNotification();
2506   app.Render(1);
2507
2508   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2509   END_TEST;
2510 }
2511
2512 int UtcDaliActorSetDrawModeOverlayRender(void)
2513 {
2514   TestApplication app;
2515   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2516
2517   app.SendNotification();
2518   app.Render(1);
2519
2520   std::vector<GLuint> ids;
2521   ids.push_back( 8 );   // first rendered actor
2522   ids.push_back( 9 );   // second rendered actor
2523   ids.push_back( 10 );  // third rendered actor
2524   app.GetGlAbstraction().SetNextTextureIds( ids );
2525
2526   BufferImage imageA = BufferImage::New(16, 16);
2527   BufferImage imageB = BufferImage::New(16, 16);
2528   BufferImage imageC = BufferImage::New(16, 16);
2529   Actor a = CreateRenderableActor( imageA );
2530   Actor b = CreateRenderableActor( imageB );
2531   Actor c = CreateRenderableActor( imageC );
2532
2533   // Render a,b,c as regular non-overlays. so order will be:
2534   // a (8)
2535   // b (9)
2536   // c (10)
2537   Stage::GetCurrent().Add(a);
2538   Stage::GetCurrent().Add(b);
2539   Stage::GetCurrent().Add(c);
2540
2541   app.SendNotification();
2542   app.Render(1);
2543
2544   // Should be 3 textures changes.
2545   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2546   typedef std::vector<GLuint>::size_type TextureSize;
2547   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2548   if( boundTextures.size() == 3 )
2549   {
2550     DALI_TEST_CHECK( boundTextures[0] == 8u );
2551     DALI_TEST_CHECK( boundTextures[1] == 9u );
2552     DALI_TEST_CHECK( boundTextures[2] == 10u );
2553   }
2554
2555   // Now texture ids have been set, we can monitor their render order.
2556   // render a as an overlay (last), so order will be:
2557   // b (9)
2558   // c (10)
2559   // a (8)
2560   a.SetDrawMode( DrawMode::OVERLAY_2D );
2561   app.GetGlAbstraction().ClearBoundTextures();
2562
2563   app.SendNotification();
2564   app.Render(1);
2565
2566   // Should be 3 texture changes.
2567   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2568   if( boundTextures.size() == 3 )
2569   {
2570     DALI_TEST_CHECK( boundTextures[0] == 9u );
2571     DALI_TEST_CHECK( boundTextures[1] == 10u );
2572     DALI_TEST_CHECK( boundTextures[2] == 8u );
2573   }
2574   END_TEST;
2575 }
2576
2577 int UtcDaliActorGetCurrentWorldMatrix(void)
2578 {
2579   TestApplication app;
2580   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2581
2582   Actor parent = Actor::New();
2583   parent.SetParentOrigin(ParentOrigin::CENTER);
2584   parent.SetAnchorPoint(AnchorPoint::CENTER);
2585   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2586   Radian rotationAngle(Degree(85.0f));
2587   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2588   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2589   parent.SetPosition( parentPosition );
2590   parent.SetOrientation( parentRotation );
2591   parent.SetScale( parentScale );
2592   Stage::GetCurrent().Add( parent );
2593
2594   Actor child = Actor::New();
2595   child.SetParentOrigin(ParentOrigin::CENTER);
2596   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2597   Radian childRotationAngle(Degree(23.0f));
2598   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2599   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2600   child.SetPosition( childPosition );
2601   child.SetOrientation( childRotation );
2602   child.SetScale( childScale );
2603   parent.Add( child );
2604
2605   app.SendNotification();
2606   app.Render(0);
2607   app.Render();
2608   app.SendNotification();
2609
2610   Matrix parentMatrix(false);
2611   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2612
2613   Matrix childMatrix(false);
2614   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2615
2616   //Child matrix should be the composition of child and parent
2617   Matrix childWorldMatrix(false);
2618   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2619
2620   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2621   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2622   END_TEST;
2623 }
2624
2625
2626
2627 int UtcDaliActorConstrainedToWorldMatrix(void)
2628 {
2629   TestApplication app;
2630   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2631
2632   Actor parent = Actor::New();
2633   parent.SetParentOrigin(ParentOrigin::CENTER);
2634   parent.SetAnchorPoint(AnchorPoint::CENTER);
2635   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2636   Radian rotationAngle(Degree(85.0f));
2637   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2638   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2639   parent.SetPosition( parentPosition );
2640   parent.SetOrientation( parentRotation );
2641   parent.SetScale( parentScale );
2642   Stage::GetCurrent().Add( parent );
2643
2644   Actor child = Actor::New();
2645   child.SetParentOrigin(ParentOrigin::CENTER);
2646   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2647   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2648   posConstraint.Apply();
2649
2650   Stage::GetCurrent().Add( child );
2651
2652   app.SendNotification();
2653   app.Render(0);
2654   app.Render();
2655   app.SendNotification();
2656
2657   Matrix parentMatrix(false);
2658   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2659
2660   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2661   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2662   END_TEST;
2663 }
2664
2665 int UtcDaliActorConstrainedToOrientation(void)
2666 {
2667   TestApplication app;
2668   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2669
2670   Actor parent = Actor::New();
2671   parent.SetParentOrigin(ParentOrigin::CENTER);
2672   parent.SetAnchorPoint(AnchorPoint::CENTER);
2673   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2674   Radian rotationAngle(Degree(85.0f));
2675   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2676   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2677   parent.SetPosition( parentPosition );
2678   parent.SetOrientation( parentRotation );
2679   parent.SetScale( parentScale );
2680   Stage::GetCurrent().Add( parent );
2681
2682   Actor child = Actor::New();
2683   child.SetParentOrigin(ParentOrigin::CENTER);
2684   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2685   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2686   posConstraint.Apply();
2687
2688   Stage::GetCurrent().Add( child );
2689
2690   app.SendNotification();
2691   app.Render(0);
2692   app.Render();
2693   app.SendNotification();
2694
2695   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2696   END_TEST;
2697 }
2698
2699 int UtcDaliActorUnparent(void)
2700 {
2701   TestApplication app;
2702   tet_infoline(" UtcDaliActorUnparent");
2703
2704   Actor parent = Actor::New();
2705   Stage::GetCurrent().Add( parent );
2706
2707   Actor child = Actor::New();
2708
2709   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2710   DALI_TEST_CHECK( !child.GetParent() );
2711
2712   // Test that calling Unparent with no parent is a NOOP
2713   child.Unparent();
2714
2715   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2716   DALI_TEST_CHECK( !child.GetParent() );
2717
2718   // Test that Unparent works
2719   parent.Add( child );
2720
2721   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2722   DALI_TEST_CHECK( parent == child.GetParent() );
2723
2724   child.Unparent();
2725
2726   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2727   DALI_TEST_CHECK( !child.GetParent() );
2728
2729   // Test that UnparentAndReset works
2730   parent.Add( child );
2731
2732   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2733   DALI_TEST_CHECK( parent == child.GetParent() );
2734
2735   UnparentAndReset( child );
2736
2737   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2738   DALI_TEST_CHECK( !child );
2739
2740   // Test that UnparentAndReset is a NOOP with empty handle
2741   UnparentAndReset( child );
2742
2743   DALI_TEST_CHECK( !child );
2744   END_TEST;
2745 }
2746
2747 int UtcDaliActorGetChildAt(void)
2748 {
2749   TestApplication app;
2750   tet_infoline(" UtcDaliActorGetChildAt");
2751
2752   Actor parent = Actor::New();
2753   Stage::GetCurrent().Add( parent );
2754
2755   Actor child0 = Actor::New();
2756   parent.Add( child0 );
2757
2758   Actor child1 = Actor::New();
2759   parent.Add( child1 );
2760
2761   Actor child2 = Actor::New();
2762   parent.Add( child2 );
2763
2764   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2765   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2766   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2767   END_TEST;
2768 }
2769
2770 int UtcDaliActorSetGetOverlay(void)
2771 {
2772   TestApplication app;
2773   tet_infoline(" UtcDaliActorSetGetOverlay");
2774
2775   Actor parent = Actor::New();
2776   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2777   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2778   END_TEST;
2779 }
2780
2781
2782 int UtcDaliActorCreateDestroy(void)
2783 {
2784   Actor* actor = new Actor;
2785   DALI_TEST_CHECK( actor );
2786   delete actor;
2787   END_TEST;
2788 }
2789
2790 namespace
2791 {
2792 struct PropertyStringIndex
2793 {
2794   const char * const name;
2795   const Property::Index index;
2796   const Property::Type type;
2797 };
2798
2799 const PropertyStringIndex PROPERTY_TABLE[] =
2800 {
2801   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2802   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2803   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2804   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2805   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2806   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2807   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2808   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2809   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2810   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2811   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2812   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2813   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2814   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2815   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2816   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2817   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2818   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2819   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2820   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2821   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2822   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2823   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2824   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2825   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2826   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2827   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2828   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2829   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2830   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2831   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2832   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2833   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2834   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2835   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2836   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2837   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2838   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2839   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2840   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2841   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2842   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
2843   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
2844   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
2845   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
2846   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
2847   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
2848   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
2849   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
2850   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
2851   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
2852   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
2853   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
2854   { "batchParent",              DevelActor::Property::BATCH_PARENT,        Property::BOOLEAN     },
2855   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
2856 };
2857 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2858 } // unnamed namespace
2859
2860 int UtcDaliActorProperties(void)
2861 {
2862   TestApplication app;
2863
2864   Actor actor = Actor::New();
2865
2866   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2867   {
2868     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2869     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2870     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2871     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2872   }
2873   END_TEST;
2874 }
2875
2876 int UtcDaliRelayoutProperties_ResizePolicies(void)
2877 {
2878   TestApplication app;
2879
2880   Actor actor = Actor::New();
2881
2882   // Defaults
2883   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2884   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2885
2886   // Set resize policy for all dimensions
2887   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2888   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2889   {
2890     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2891   }
2892
2893   // Set individual dimensions
2894   const char* const widthPolicy = "FILL_TO_PARENT";
2895   const char* const heightPolicy = "FIXED";
2896
2897   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2898   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2899
2900   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2901   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2902
2903   END_TEST;
2904 }
2905
2906 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2907 {
2908   TestApplication app;
2909
2910   Actor actor = Actor::New();
2911
2912   // Defaults
2913   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2914   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2915
2916   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2917   actor.SetSizeScalePolicy( policy );
2918   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2919
2920   // Set
2921   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2922   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2923
2924   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2925   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2926
2927   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2928   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2929
2930   END_TEST;
2931 }
2932
2933 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2934 {
2935   TestApplication app;
2936
2937   Actor actor = Actor::New();
2938
2939   // Defaults
2940   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2941   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2942
2943   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2944   actor.SetSizeModeFactor( sizeMode );
2945   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2946
2947   // Set
2948   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2949
2950   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2951   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2952
2953   END_TEST;
2954 }
2955
2956 int UtcDaliRelayoutProperties_DimensionDependency(void)
2957 {
2958   TestApplication app;
2959
2960   Actor actor = Actor::New();
2961
2962   // Defaults
2963   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2964   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2965
2966   // Set
2967   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2968   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2969
2970   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2971   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2972
2973   // Test setting another resize policy
2974   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2975   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2976
2977   END_TEST;
2978 }
2979
2980 int UtcDaliRelayoutProperties_Padding(void)
2981 {
2982   TestApplication app;
2983
2984   Actor actor = Actor::New();
2985
2986   // Data
2987   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2988
2989   // PADDING
2990   actor.SetProperty( Actor::Property::PADDING, padding );
2991   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2992
2993   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2994
2995   END_TEST;
2996 }
2997
2998 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2999 {
3000   TestApplication app;
3001
3002   Actor actor = Actor::New();
3003
3004   // Data
3005   Vector2 minSize( 1.0f, 2.0f );
3006
3007   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3008   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3009
3010   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3011
3012   Vector2 maxSize( 3.0f, 4.0f );
3013
3014   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3015   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3016
3017   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3018
3019   END_TEST;
3020 }
3021
3022 int UtcDaliActorGetHeightForWidth(void)
3023 {
3024   TestApplication app;
3025
3026   Actor actor = Actor::New();
3027
3028   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3029
3030   END_TEST;
3031 }
3032
3033 int UtcDaliActorGetWidthForHeight(void)
3034 {
3035   TestApplication app;
3036
3037   Actor actor = Actor::New();
3038
3039   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3040
3041   END_TEST;
3042 }
3043
3044 int UtcDaliActorGetRelayoutSize(void)
3045 {
3046   TestApplication app;
3047
3048   Actor actor = Actor::New();
3049
3050   // Add actor to stage
3051   Stage::GetCurrent().Add( actor );
3052
3053   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3054
3055   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3056   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3057
3058   // Flush the queue and render once
3059   app.SendNotification();
3060   app.Render();
3061
3062   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3063
3064   END_TEST;
3065 }
3066
3067 int UtcDaliActorSetPadding(void)
3068 {
3069   TestApplication app;
3070
3071   Actor actor = Actor::New();
3072
3073   Padding padding;
3074   actor.GetPadding( padding );
3075
3076   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3077   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3078   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3079   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3080
3081   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3082   actor.SetPadding( padding2 );
3083
3084   actor.GetPadding( padding );
3085
3086   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3087   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3088   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3089   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3090
3091   END_TEST;
3092 }
3093
3094 int UtcDaliActorSetMinimumSize(void)
3095 {
3096   TestApplication app;
3097
3098   Actor actor = Actor::New();
3099
3100   Vector2 size = actor.GetMinimumSize();
3101
3102   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3103   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3104
3105   Vector2 size2( 1.0f, 2.0f );
3106   actor.SetMinimumSize( size2 );
3107
3108   size = actor.GetMinimumSize();
3109
3110   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3111   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3112
3113   END_TEST;
3114 }
3115
3116 int UtcDaliActorSetMaximumSize(void)
3117 {
3118   TestApplication app;
3119
3120   Actor actor = Actor::New();
3121
3122   Vector2 size = actor.GetMaximumSize();
3123
3124   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3125   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3126
3127   Vector2 size2( 1.0f, 2.0f );
3128   actor.SetMaximumSize( size2 );
3129
3130   size = actor.GetMaximumSize();
3131
3132   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3133   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3134
3135   END_TEST;
3136 }
3137
3138 int UtcDaliActorOnRelayoutSignal(void)
3139 {
3140   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3141
3142   TestApplication application;
3143
3144   // Clean test data
3145   gOnRelayoutCallBackCalled = false;
3146   gActorNamesRelayout.clear();
3147
3148   Actor actor = Actor::New();
3149   actor.SetName( "actor" );
3150   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3151
3152   // Sanity check
3153   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3154
3155   // Add actor to stage
3156   Stage::GetCurrent().Add( actor );
3157
3158   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3159   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3160
3161   // Flush the queue and render once
3162   application.SendNotification();
3163   application.Render();
3164
3165   // OnRelayout emitted
3166   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3167   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3168
3169   END_TEST;
3170 }
3171
3172 int UtcDaliActorGetHierachyDepth(void)
3173 {
3174   TestApplication application;
3175   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3176
3177
3178   /* Build tree of actors:
3179    *
3180    *                      Depth
3181    *
3182    *       A (parent)       1
3183    *      / \
3184    *     B   C              2`
3185    *    / \   \
3186    *   D   E   F            3
3187    *
3188    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3189    */
3190   Stage stage( Stage::GetCurrent() );
3191
3192   Actor actorA = Actor::New();
3193   Actor actorB = Actor::New();
3194   Actor actorC = Actor::New();
3195   Actor actorD = Actor::New();
3196   Actor actorE = Actor::New();
3197   Actor actorF = Actor::New();
3198
3199   //Test that root actor has depth equal 0
3200   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3201
3202   //Test actors return depth -1 when not connected to the tree
3203   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3204   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3205   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3206   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3207   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3208   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3209
3210   //Create the hierarchy
3211   stage.Add( actorA );
3212   actorA.Add( actorB );
3213   actorA.Add( actorC );
3214   actorB.Add( actorD );
3215   actorB.Add( actorE );
3216   actorC.Add( actorF );
3217
3218   //Test actors return correct depth
3219   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3220   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3221   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3222   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3223   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3224   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3225
3226   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3227   actorA.Remove( actorB );
3228
3229   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3230   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3231   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3232
3233   //Removing actorA from the stage. All actors should have depth equal -1
3234   stage.Remove( actorA );
3235
3236   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3237   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3238   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3239   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3240   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3241   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3242
3243   END_TEST;
3244 }
3245
3246 int UtcDaliActorAnchorPointPropertyAsString(void)
3247 {
3248   TestApplication application;
3249
3250   Actor actor = Actor::New();
3251
3252   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3253   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3254
3255   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3256   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3257
3258   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3259   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3260
3261   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3262   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3263
3264   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3265   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3266
3267   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3268   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3269
3270   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3271   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3272
3273   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3274   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3275
3276   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3277   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3278
3279   // Invalid should not change anything
3280   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3281   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3282
3283   END_TEST;
3284 }
3285
3286 int UtcDaliActorParentOriginPropertyAsString(void)
3287 {
3288   TestApplication application;
3289
3290   Actor actor = Actor::New();
3291
3292   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3293   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3294
3295   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3296   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3297
3298   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3299   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3300
3301   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3302   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3303
3304   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3305   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3306
3307   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3308   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3309
3310   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3311   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3312
3313   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3314   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3315
3316   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3317   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3318
3319   // Invalid should not change anything
3320   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3321   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3322
3323   END_TEST;
3324 }
3325
3326 int UtcDaliActorColorModePropertyAsString(void)
3327 {
3328   TestApplication application;
3329
3330   Actor actor = Actor::New();
3331
3332   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3333   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3334
3335   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3336   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3337
3338   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3339   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3340
3341   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3342   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3343
3344   // Invalid should not change anything
3345   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3346   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3347
3348   END_TEST;
3349 }
3350
3351 int UtcDaliActorPositionInheritancePropertyAsString(void)
3352 {
3353   TestApplication application;
3354
3355   Actor actor = Actor::New();
3356
3357   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3358   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3359
3360   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3361   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3362
3363   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3364   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3365
3366   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3367   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3368
3369   // Invalid should not change anything
3370   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3371   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3372
3373   END_TEST;
3374 }
3375
3376 int UtcDaliActorDrawModePropertyAsString(void)
3377 {
3378   TestApplication application;
3379
3380   Actor actor = Actor::New();
3381
3382   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3383   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3384
3385   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3386   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3387
3388   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3389   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3390
3391   // Invalid should not change anything
3392   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3393   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3394
3395   END_TEST;
3396 }
3397
3398 int UtcDaliActorAddRendererP(void)
3399 {
3400   tet_infoline("Testing Actor::AddRenderer");
3401   TestApplication application;
3402
3403   Actor actor = Actor::New();
3404
3405   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3406
3407   Geometry geometry = CreateQuadGeometry();
3408   Shader shader = CreateShader();
3409   Renderer renderer = Renderer::New(geometry, shader);
3410
3411   actor.AddRenderer( renderer );
3412   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3413   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3414
3415   END_TEST;
3416 }
3417
3418 int UtcDaliActorAddRendererN(void)
3419 {
3420   tet_infoline("Testing Actor::AddRenderer");
3421   TestApplication application;
3422
3423   Actor actor = Actor::New();
3424   Renderer renderer;
3425
3426   // try illegal Add
3427   try
3428   {
3429     actor.AddRenderer( renderer );
3430     tet_printf("Assertion test failed - no Exception\n" );
3431     tet_result(TET_FAIL);
3432   }
3433   catch(Dali::DaliException& e)
3434   {
3435     DALI_TEST_PRINT_ASSERT( e );
3436     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3437     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3438   }
3439   catch(...)
3440   {
3441     tet_printf("Assertion test failed - wrong Exception\n" );
3442     tet_result(TET_FAIL);
3443   }
3444
3445   END_TEST;
3446 }
3447
3448 int UtcDaliActorAddRendererOnStage(void)
3449 {
3450   tet_infoline("Testing Actor::AddRenderer");
3451   TestApplication application;
3452
3453   Actor actor = Actor::New();
3454   Stage::GetCurrent().Add(actor);
3455
3456   application.SendNotification();
3457   application.Render(0);
3458
3459   Geometry geometry = CreateQuadGeometry();
3460   Shader shader = CreateShader();
3461   Renderer renderer = Renderer::New(geometry, shader);
3462
3463   application.SendNotification();
3464   application.Render(0);
3465
3466   try
3467   {
3468     actor.AddRenderer( renderer );
3469     tet_result(TET_PASS);
3470   }
3471   catch(...)
3472   {
3473     tet_result(TET_FAIL);
3474   }
3475
3476   END_TEST;
3477 }
3478
3479 int UtcDaliActorRemoveRendererP1(void)
3480 {
3481   tet_infoline("Testing Actor::RemoveRenderer");
3482   TestApplication application;
3483
3484   Actor actor = Actor::New();
3485
3486   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3487
3488   Geometry geometry = CreateQuadGeometry();
3489   Shader shader = CreateShader();
3490   Renderer renderer = Renderer::New(geometry, shader);
3491
3492   actor.AddRenderer( renderer );
3493   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3494   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3495
3496   actor.RemoveRenderer(renderer);
3497   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3498
3499
3500   END_TEST;
3501 }
3502
3503 int UtcDaliActorRemoveRendererP2(void)
3504 {
3505   tet_infoline("Testing Actor::RemoveRenderer");
3506   TestApplication application;
3507
3508   Actor actor = Actor::New();
3509
3510   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3511
3512   Geometry geometry = CreateQuadGeometry();
3513   Shader shader = CreateShader();
3514   Renderer renderer = Renderer::New(geometry, shader);
3515
3516   actor.AddRenderer( renderer );
3517   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3518   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3519
3520   actor.RemoveRenderer(0);
3521   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3522
3523
3524   END_TEST;
3525 }
3526
3527
3528 int UtcDaliActorRemoveRendererN(void)
3529 {
3530   tet_infoline("Testing Actor::RemoveRenderer");
3531   TestApplication application;
3532
3533   Actor actor = Actor::New();
3534
3535   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3536
3537   Geometry geometry = CreateQuadGeometry();
3538   Shader shader = CreateShader();
3539   Renderer renderer = Renderer::New(geometry, shader);
3540
3541   actor.AddRenderer( renderer );
3542   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3543   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3544
3545   actor.RemoveRenderer(10);
3546   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3547   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3548
3549   END_TEST;
3550 }
3551
3552 // Clipping test helper functions:
3553 Actor CreateActorWithContent()
3554 {
3555   BufferImage image = BufferImage::New( 16u, 16u );
3556   Actor actor = CreateRenderableActor( image );
3557
3558   // Setup dimensions and position so actor is not skipped by culling.
3559   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3560   actor.SetSize( 16.0f, 16.0f );
3561   actor.SetParentOrigin( ParentOrigin::CENTER );
3562   actor.SetAnchorPoint( AnchorPoint::CENTER );
3563
3564   return actor;
3565 }
3566
3567 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3568 {
3569   enabledDisableTrace.Reset();
3570   stencilTrace.Reset();
3571   enabledDisableTrace.Enable( true );
3572   stencilTrace.Enable( true );
3573
3574   application.SendNotification();
3575   application.Render();
3576
3577   enabledDisableTrace.Enable( false );
3578   stencilTrace.Enable( false );
3579 }
3580
3581 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3582 {
3583   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3584
3585   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3586   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3587   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3588   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3589 }
3590
3591 int UtcDaliActorPropertyClippingP(void)
3592 {
3593   // This test checks the clippingMode property.
3594   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3595   TestApplication application;
3596
3597   Actor actor = Actor::New();
3598
3599   // Check default clippingEnabled value.
3600   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3601
3602   int value = 0;
3603   bool getValueResult = getValue.Get( value );
3604   DALI_TEST_CHECK( getValueResult );
3605
3606   if( getValueResult )
3607   {
3608     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3609   }
3610
3611   // Check setting the property.
3612   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3613
3614   // Check the new value was set.
3615   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3616   getValueResult = getValue.Get( value );
3617   DALI_TEST_CHECK( getValueResult );
3618
3619   if( getValueResult )
3620   {
3621     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3622   }
3623
3624   END_TEST;
3625 }
3626
3627 int UtcDaliActorPropertyClippingN(void)
3628 {
3629   // Negative test case for Clipping.
3630   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3631   TestApplication application;
3632
3633   Actor actor = Actor::New();
3634
3635   // Check default clippingEnabled value.
3636   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3637
3638   int value = 0;
3639   bool getValueResult = getValue.Get( value );
3640   DALI_TEST_CHECK( getValueResult );
3641
3642   if( getValueResult )
3643   {
3644     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3645   }
3646
3647   // Check setting an invalid property value won't change the current property value.
3648   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3649
3650   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3651   getValueResult = getValue.Get( value );
3652   DALI_TEST_CHECK( getValueResult );
3653
3654   if( getValueResult )
3655   {
3656     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3657   }
3658
3659   END_TEST;
3660 }
3661
3662 int UtcDaliActorPropertyClippingActor(void)
3663 {
3664   // This test checks that an actor is correctly setup for clipping.
3665   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3666   TestApplication application;
3667
3668   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3669   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3670   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3671   size_t startIndex = 0u;
3672
3673   // Create a clipping actor.
3674   Actor actorDepth1Clip = CreateActorWithContent();
3675   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3676   Stage::GetCurrent().Add( actorDepth1Clip );
3677
3678   // Gather the call trace.
3679   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3680
3681   // Check we are writing to the color buffer.
3682   CheckColorMask( glAbstraction, true );
3683
3684   // Check the stencil buffer was enabled.
3685   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
3686
3687   // Check the stencil buffer was cleared.
3688   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3689
3690   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3691   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3692   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3693   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3694
3695   END_TEST;
3696 }
3697
3698 int UtcDaliActorPropertyClippingNestedChildren(void)
3699 {
3700   // This test checks that a hierarchy of actors are clipped correctly by
3701   // writing to and reading from the correct bit-planes of the stencil buffer.
3702   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3703   TestApplication application;
3704   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3705   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3706   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3707
3708   // Create a clipping actor.
3709   Actor actorDepth1Clip = CreateActorWithContent();
3710   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3711   Stage::GetCurrent().Add( actorDepth1Clip );
3712
3713   // Create a child actor.
3714   Actor childDepth2 = CreateActorWithContent();
3715   actorDepth1Clip.Add( childDepth2 );
3716
3717   // Create another clipping actor.
3718   Actor childDepth2Clip = CreateActorWithContent();
3719   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3720   childDepth2.Add( childDepth2Clip );
3721
3722   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3723   // This tests the sort algorithm.
3724   Actor childDepth3 = CreateActorWithContent();
3725   childDepth2Clip.Add( childDepth3 );
3726   Actor childDepth4 = CreateActorWithContent();
3727   childDepth3.Add( childDepth4 );
3728
3729   // Gather the call trace.
3730   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3731
3732   // Check we are writing to the color buffer.
3733   CheckColorMask( glAbstraction, true );
3734
3735   // Check the stencil buffer was enabled.
3736   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
3737
3738   // Perform the test twice, once for 2D layer, and once for 3D.
3739   for( unsigned int i = 0u ; i < 2u; ++i )
3740   {
3741     size_t startIndex = 0u;
3742
3743     // Check the stencil buffer was cleared.
3744     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3745
3746     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3747     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3748     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
3749     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3750
3751     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3752     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
3753     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3754
3755     // Check we are set up to write to the second bitplane of the stencil buffer (only).
3756     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3757     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
3758     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3759
3760     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
3761     // (Both must be set to pass the check).
3762     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3763     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3764
3765     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
3766     if( i == 0u )
3767     {
3768       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
3769       GenerateTrace( application, enabledDisableTrace, stencilTrace );
3770     }
3771   }
3772
3773   END_TEST;
3774 }
3775
3776 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
3777 {
3778   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
3779   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
3780   TestApplication application;
3781
3782   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3783   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3784   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3785
3786   // Create a clipping actor.
3787   Actor actorDepth1Clip = CreateActorWithContent();
3788   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3789   Stage::GetCurrent().Add( actorDepth1Clip );
3790
3791   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
3792   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
3793
3794   // Gather the call trace.
3795   GenerateTrace( application, enabledDisableTrace, stencilTrace );
3796
3797   // Check we are writing to the color buffer.
3798   CheckColorMask( glAbstraction, true );
3799
3800   // Check the stencil buffer was not enabled.
3801   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
3802
3803   // Check stencil functions are not called.
3804   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
3805   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
3806   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
3807
3808   END_TEST;
3809 }