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