f4f3fcc79c4389ddd590e5d529019a5ca933a5ea
[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::STENCIL );
2504   app.SendNotification();
2505   app.Render(1);
2506
2507   DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2508
2509   a.SetDrawMode( DrawMode::NORMAL );
2510   app.SendNotification();
2511   app.Render(1);
2512
2513   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2514   END_TEST;
2515 }
2516
2517 int UtcDaliActorSetDrawModeOverlayRender(void)
2518 {
2519   TestApplication app;
2520   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2521
2522   app.SendNotification();
2523   app.Render(1);
2524
2525   std::vector<GLuint> ids;
2526   ids.push_back( 8 );   // first rendered actor
2527   ids.push_back( 9 );   // second rendered actor
2528   ids.push_back( 10 );  // third rendered actor
2529   app.GetGlAbstraction().SetNextTextureIds( ids );
2530
2531   BufferImage imageA = BufferImage::New(16, 16);
2532   BufferImage imageB = BufferImage::New(16, 16);
2533   BufferImage imageC = BufferImage::New(16, 16);
2534   Actor a = CreateRenderableActor( imageA );
2535   Actor b = CreateRenderableActor( imageB );
2536   Actor c = CreateRenderableActor( imageC );
2537
2538   // Render a,b,c as regular non-overlays. so order will be:
2539   // a (8)
2540   // b (9)
2541   // c (10)
2542   Stage::GetCurrent().Add(a);
2543   Stage::GetCurrent().Add(b);
2544   Stage::GetCurrent().Add(c);
2545
2546   app.SendNotification();
2547   app.Render(1);
2548
2549   // Should be 3 textures changes.
2550   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2551   typedef std::vector<GLuint>::size_type TextureSize;
2552   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2553   if( boundTextures.size() == 3 )
2554   {
2555     DALI_TEST_CHECK( boundTextures[0] == 8u );
2556     DALI_TEST_CHECK( boundTextures[1] == 9u );
2557     DALI_TEST_CHECK( boundTextures[2] == 10u );
2558   }
2559
2560   // Now texture ids have been set, we can monitor their render order.
2561   // render a as an overlay (last), so order will be:
2562   // b (9)
2563   // c (10)
2564   // a (8)
2565   a.SetDrawMode( DrawMode::OVERLAY_2D );
2566   app.GetGlAbstraction().ClearBoundTextures();
2567
2568   app.SendNotification();
2569   app.Render(1);
2570
2571   // Should be 3 texture changes.
2572   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2573   if( boundTextures.size() == 3 )
2574   {
2575     DALI_TEST_CHECK( boundTextures[0] == 9u );
2576     DALI_TEST_CHECK( boundTextures[1] == 10u );
2577     DALI_TEST_CHECK( boundTextures[2] == 8u );
2578   }
2579   END_TEST;
2580 }
2581
2582 int UtcDaliActorGetCurrentWorldMatrix(void)
2583 {
2584   TestApplication app;
2585   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2586
2587   Actor parent = Actor::New();
2588   parent.SetParentOrigin(ParentOrigin::CENTER);
2589   parent.SetAnchorPoint(AnchorPoint::CENTER);
2590   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2591   Radian rotationAngle(Degree(85.0f));
2592   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2593   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2594   parent.SetPosition( parentPosition );
2595   parent.SetOrientation( parentRotation );
2596   parent.SetScale( parentScale );
2597   Stage::GetCurrent().Add( parent );
2598
2599   Actor child = Actor::New();
2600   child.SetParentOrigin(ParentOrigin::CENTER);
2601   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2602   Radian childRotationAngle(Degree(23.0f));
2603   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2604   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2605   child.SetPosition( childPosition );
2606   child.SetOrientation( childRotation );
2607   child.SetScale( childScale );
2608   parent.Add( child );
2609
2610   app.SendNotification();
2611   app.Render(0);
2612   app.Render();
2613   app.SendNotification();
2614
2615   Matrix parentMatrix(false);
2616   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2617
2618   Matrix childMatrix(false);
2619   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2620
2621   //Child matrix should be the composition of child and parent
2622   Matrix childWorldMatrix(false);
2623   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2624
2625   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2626   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2627   END_TEST;
2628 }
2629
2630
2631
2632 int UtcDaliActorConstrainedToWorldMatrix(void)
2633 {
2634   TestApplication app;
2635   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2636
2637   Actor parent = Actor::New();
2638   parent.SetParentOrigin(ParentOrigin::CENTER);
2639   parent.SetAnchorPoint(AnchorPoint::CENTER);
2640   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2641   Radian rotationAngle(Degree(85.0f));
2642   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2643   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2644   parent.SetPosition( parentPosition );
2645   parent.SetOrientation( parentRotation );
2646   parent.SetScale( parentScale );
2647   Stage::GetCurrent().Add( parent );
2648
2649   Actor child = Actor::New();
2650   child.SetParentOrigin(ParentOrigin::CENTER);
2651   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2652   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2653   posConstraint.Apply();
2654
2655   Stage::GetCurrent().Add( child );
2656
2657   app.SendNotification();
2658   app.Render(0);
2659   app.Render();
2660   app.SendNotification();
2661
2662   Matrix parentMatrix(false);
2663   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2664
2665   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2666   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2667   END_TEST;
2668 }
2669
2670 int UtcDaliActorConstrainedToOrientation(void)
2671 {
2672   TestApplication app;
2673   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2674
2675   Actor parent = Actor::New();
2676   parent.SetParentOrigin(ParentOrigin::CENTER);
2677   parent.SetAnchorPoint(AnchorPoint::CENTER);
2678   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2679   Radian rotationAngle(Degree(85.0f));
2680   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2681   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2682   parent.SetPosition( parentPosition );
2683   parent.SetOrientation( parentRotation );
2684   parent.SetScale( parentScale );
2685   Stage::GetCurrent().Add( parent );
2686
2687   Actor child = Actor::New();
2688   child.SetParentOrigin(ParentOrigin::CENTER);
2689   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2690   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2691   posConstraint.Apply();
2692
2693   Stage::GetCurrent().Add( child );
2694
2695   app.SendNotification();
2696   app.Render(0);
2697   app.Render();
2698   app.SendNotification();
2699
2700   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2701   END_TEST;
2702 }
2703
2704 int UtcDaliActorUnparent(void)
2705 {
2706   TestApplication app;
2707   tet_infoline(" UtcDaliActorUnparent");
2708
2709   Actor parent = Actor::New();
2710   Stage::GetCurrent().Add( parent );
2711
2712   Actor child = Actor::New();
2713
2714   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2715   DALI_TEST_CHECK( !child.GetParent() );
2716
2717   // Test that calling Unparent with no parent is a NOOP
2718   child.Unparent();
2719
2720   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2721   DALI_TEST_CHECK( !child.GetParent() );
2722
2723   // Test that Unparent works
2724   parent.Add( child );
2725
2726   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2727   DALI_TEST_CHECK( parent == child.GetParent() );
2728
2729   child.Unparent();
2730
2731   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2732   DALI_TEST_CHECK( !child.GetParent() );
2733
2734   // Test that UnparentAndReset works
2735   parent.Add( child );
2736
2737   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2738   DALI_TEST_CHECK( parent == child.GetParent() );
2739
2740   UnparentAndReset( child );
2741
2742   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2743   DALI_TEST_CHECK( !child );
2744
2745   // Test that UnparentAndReset is a NOOP with empty handle
2746   UnparentAndReset( child );
2747
2748   DALI_TEST_CHECK( !child );
2749   END_TEST;
2750 }
2751
2752 int UtcDaliActorGetChildAt(void)
2753 {
2754   TestApplication app;
2755   tet_infoline(" UtcDaliActorGetChildAt");
2756
2757   Actor parent = Actor::New();
2758   Stage::GetCurrent().Add( parent );
2759
2760   Actor child0 = Actor::New();
2761   parent.Add( child0 );
2762
2763   Actor child1 = Actor::New();
2764   parent.Add( child1 );
2765
2766   Actor child2 = Actor::New();
2767   parent.Add( child2 );
2768
2769   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2770   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2771   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2772   END_TEST;
2773 }
2774
2775 int UtcDaliActorSetGetOverlay(void)
2776 {
2777   TestApplication app;
2778   tet_infoline(" UtcDaliActorSetGetOverlay");
2779
2780   Actor parent = Actor::New();
2781   parent.SetDrawMode(DrawMode::OVERLAY_2D );
2782   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2783   END_TEST;
2784 }
2785
2786
2787 int UtcDaliActorCreateDestroy(void)
2788 {
2789   Actor* actor = new Actor;
2790   DALI_TEST_CHECK( actor );
2791   delete actor;
2792   END_TEST;
2793 }
2794
2795 namespace
2796 {
2797 struct PropertyStringIndex
2798 {
2799   const char * const name;
2800   const Property::Index index;
2801   const Property::Type type;
2802 };
2803
2804 const PropertyStringIndex PROPERTY_TABLE[] =
2805 {
2806   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
2807   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
2808   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
2809   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
2810   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
2811   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
2812   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
2813   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
2814   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
2815   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
2816   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
2817   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
2818   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
2819   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
2820   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
2821   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
2822   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
2823   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
2824   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
2825   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
2826   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
2827   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
2828   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
2829   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
2830   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
2831   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
2832   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
2833   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
2834   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
2835   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
2836   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
2837   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
2838   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
2839   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
2840   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
2841   { "name",                     Actor::Property::NAME,                     Property::STRING      },
2842   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
2843   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
2844   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
2845   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
2846   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
2847   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
2848   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
2849   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
2850   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
2851   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
2852   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
2853   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
2854   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
2855   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
2856   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
2857   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
2858 };
2859 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2860 } // unnamed namespace
2861
2862 int UtcDaliActorProperties(void)
2863 {
2864   TestApplication app;
2865
2866   Actor actor = Actor::New();
2867
2868   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2869   {
2870     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2871     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2872     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2873     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2874   }
2875   END_TEST;
2876 }
2877
2878 int UtcDaliRelayoutProperties_ResizePolicies(void)
2879 {
2880   TestApplication app;
2881
2882   Actor actor = Actor::New();
2883
2884   // Defaults
2885   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2886   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2887
2888   // Set resize policy for all dimensions
2889   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2890   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2891   {
2892     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2893   }
2894
2895   // Set individual dimensions
2896   const char* const widthPolicy = "FILL_TO_PARENT";
2897   const char* const heightPolicy = "FIXED";
2898
2899   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2900   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2901
2902   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2903   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2904
2905   END_TEST;
2906 }
2907
2908 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2909 {
2910   TestApplication app;
2911
2912   Actor actor = Actor::New();
2913
2914   // Defaults
2915   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2916   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2917
2918   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2919   actor.SetSizeScalePolicy( policy );
2920   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2921
2922   // Set
2923   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2924   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2925
2926   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2927   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2928
2929   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2930   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2931
2932   END_TEST;
2933 }
2934
2935 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2936 {
2937   TestApplication app;
2938
2939   Actor actor = Actor::New();
2940
2941   // Defaults
2942   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2943   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2944
2945   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2946   actor.SetSizeModeFactor( sizeMode );
2947   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2948
2949   // Set
2950   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2951
2952   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2953   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2954
2955   END_TEST;
2956 }
2957
2958 int UtcDaliRelayoutProperties_DimensionDependency(void)
2959 {
2960   TestApplication app;
2961
2962   Actor actor = Actor::New();
2963
2964   // Defaults
2965   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2966   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2967
2968   // Set
2969   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2970   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2971
2972   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2973   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2974
2975   // Test setting another resize policy
2976   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2977   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2978
2979   END_TEST;
2980 }
2981
2982 int UtcDaliRelayoutProperties_Padding(void)
2983 {
2984   TestApplication app;
2985
2986   Actor actor = Actor::New();
2987
2988   // Data
2989   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2990
2991   // PADDING
2992   actor.SetProperty( Actor::Property::PADDING, padding );
2993   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2994
2995   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2996
2997   END_TEST;
2998 }
2999
3000 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3001 {
3002   TestApplication app;
3003
3004   Actor actor = Actor::New();
3005
3006   // Data
3007   Vector2 minSize( 1.0f, 2.0f );
3008
3009   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3010   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3011
3012   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3013
3014   Vector2 maxSize( 3.0f, 4.0f );
3015
3016   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3017   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3018
3019   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3020
3021   END_TEST;
3022 }
3023
3024 int UtcDaliActorGetHeightForWidth(void)
3025 {
3026   TestApplication app;
3027
3028   Actor actor = Actor::New();
3029
3030   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3031
3032   END_TEST;
3033 }
3034
3035 int UtcDaliActorGetWidthForHeight(void)
3036 {
3037   TestApplication app;
3038
3039   Actor actor = Actor::New();
3040
3041   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3042
3043   END_TEST;
3044 }
3045
3046 int UtcDaliActorGetRelayoutSize(void)
3047 {
3048   TestApplication app;
3049
3050   Actor actor = Actor::New();
3051
3052   // Add actor to stage
3053   Stage::GetCurrent().Add( actor );
3054
3055   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3056
3057   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3058   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3059
3060   // Flush the queue and render once
3061   app.SendNotification();
3062   app.Render();
3063
3064   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3065
3066   END_TEST;
3067 }
3068
3069 int UtcDaliActorSetPadding(void)
3070 {
3071   TestApplication app;
3072
3073   Actor actor = Actor::New();
3074
3075   Padding padding;
3076   actor.GetPadding( padding );
3077
3078   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3079   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3080   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3081   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3082
3083   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3084   actor.SetPadding( padding2 );
3085
3086   actor.GetPadding( padding );
3087
3088   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3089   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3090   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3091   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3092
3093   END_TEST;
3094 }
3095
3096 int UtcDaliActorSetMinimumSize(void)
3097 {
3098   TestApplication app;
3099
3100   Actor actor = Actor::New();
3101
3102   Vector2 size = actor.GetMinimumSize();
3103
3104   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3105   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3106
3107   Vector2 size2( 1.0f, 2.0f );
3108   actor.SetMinimumSize( size2 );
3109
3110   size = actor.GetMinimumSize();
3111
3112   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3113   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3114
3115   END_TEST;
3116 }
3117
3118 int UtcDaliActorSetMaximumSize(void)
3119 {
3120   TestApplication app;
3121
3122   Actor actor = Actor::New();
3123
3124   Vector2 size = actor.GetMaximumSize();
3125
3126   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3127   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3128
3129   Vector2 size2( 1.0f, 2.0f );
3130   actor.SetMaximumSize( size2 );
3131
3132   size = actor.GetMaximumSize();
3133
3134   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3135   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3136
3137   END_TEST;
3138 }
3139
3140 int UtcDaliActorOnRelayoutSignal(void)
3141 {
3142   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3143
3144   TestApplication application;
3145
3146   // Clean test data
3147   gOnRelayoutCallBackCalled = false;
3148   gActorNamesRelayout.clear();
3149
3150   Actor actor = Actor::New();
3151   actor.SetName( "actor" );
3152   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3153
3154   // Sanity check
3155   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3156
3157   // Add actor to stage
3158   Stage::GetCurrent().Add( actor );
3159
3160   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3161   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3162
3163   // Flush the queue and render once
3164   application.SendNotification();
3165   application.Render();
3166
3167   // OnRelayout emitted
3168   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3169   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3170
3171   END_TEST;
3172 }
3173
3174 int UtcDaliActorGetHierachyDepth(void)
3175 {
3176   TestApplication application;
3177   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3178
3179
3180   /* Build tree of actors:
3181    *
3182    *                      Depth
3183    *
3184    *       A (parent)       1
3185    *      / \
3186    *     B   C              2`
3187    *    / \   \
3188    *   D   E   F            3
3189    *
3190    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3191    */
3192   Stage stage( Stage::GetCurrent() );
3193
3194   Actor actorA = Actor::New();
3195   Actor actorB = Actor::New();
3196   Actor actorC = Actor::New();
3197   Actor actorD = Actor::New();
3198   Actor actorE = Actor::New();
3199   Actor actorF = Actor::New();
3200
3201   //Test that root actor has depth equal 0
3202   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3203
3204   //Test actors return depth -1 when not connected to the tree
3205   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3206   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3207   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3208   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3209   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3210   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3211
3212   //Create the hierarchy
3213   stage.Add( actorA );
3214   actorA.Add( actorB );
3215   actorA.Add( actorC );
3216   actorB.Add( actorD );
3217   actorB.Add( actorE );
3218   actorC.Add( actorF );
3219
3220   //Test actors return correct depth
3221   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3222   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3223   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3224   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3225   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3226   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3227
3228   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3229   actorA.Remove( actorB );
3230
3231   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3232   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3233   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3234
3235   //Removing actorA from the stage. All actors should have depth equal -1
3236   stage.Remove( actorA );
3237
3238   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3239   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3240   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3241   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3242   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3243   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3244
3245   END_TEST;
3246 }
3247
3248 int UtcDaliActorAnchorPointPropertyAsString(void)
3249 {
3250   TestApplication application;
3251
3252   Actor actor = Actor::New();
3253
3254   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3255   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3256
3257   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3258   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3259
3260   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3261   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3262
3263   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3264   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3265
3266   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3267   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3268
3269   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3270   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3271
3272   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3273   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3274
3275   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3276   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3277
3278   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3279   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3280
3281   // Invalid should not change anything
3282   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3283   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3284
3285   END_TEST;
3286 }
3287
3288 int UtcDaliActorParentOriginPropertyAsString(void)
3289 {
3290   TestApplication application;
3291
3292   Actor actor = Actor::New();
3293
3294   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3295   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3296
3297   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3298   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3299
3300   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3301   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3302
3303   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3304   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3305
3306   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3307   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3308
3309   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3310   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3311
3312   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3313   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3314
3315   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3316   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3317
3318   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3319   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3320
3321   // Invalid should not change anything
3322   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3323   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3324
3325   END_TEST;
3326 }
3327
3328 int UtcDaliActorColorModePropertyAsString(void)
3329 {
3330   TestApplication application;
3331
3332   Actor actor = Actor::New();
3333
3334   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3335   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3336
3337   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3338   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3339
3340   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3341   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3342
3343   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3344   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3345
3346   // Invalid should not change anything
3347   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3348   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3349
3350   END_TEST;
3351 }
3352
3353 int UtcDaliActorPositionInheritancePropertyAsString(void)
3354 {
3355   TestApplication application;
3356
3357   Actor actor = Actor::New();
3358
3359   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3360   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3361
3362   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3363   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3364
3365   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3366   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3367
3368   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3369   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3370
3371   // Invalid should not change anything
3372   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3373   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3374
3375   END_TEST;
3376 }
3377
3378 int UtcDaliActorDrawModePropertyAsString(void)
3379 {
3380   TestApplication application;
3381
3382   Actor actor = Actor::New();
3383
3384   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3385   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3386
3387   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3388   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3389
3390   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3391   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3392
3393   // Invalid should not change anything
3394   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3395   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3396
3397   END_TEST;
3398 }
3399
3400 int UtcDaliActorAddRendererP(void)
3401 {
3402   tet_infoline("Testing Actor::AddRenderer");
3403   TestApplication application;
3404
3405   Actor actor = Actor::New();
3406
3407   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3408
3409   Geometry geometry = CreateQuadGeometry();
3410   Shader shader = CreateShader();
3411   Renderer renderer = Renderer::New(geometry, shader);
3412
3413   actor.AddRenderer( renderer );
3414   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3415   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3416
3417   END_TEST;
3418 }
3419
3420 int UtcDaliActorAddRendererN(void)
3421 {
3422   tet_infoline("Testing Actor::AddRenderer");
3423   TestApplication application;
3424
3425   Actor actor = Actor::New();
3426   Renderer renderer;
3427
3428   // try illegal Add
3429   try
3430   {
3431     actor.AddRenderer( renderer );
3432     tet_printf("Assertion test failed - no Exception\n" );
3433     tet_result(TET_FAIL);
3434   }
3435   catch(Dali::DaliException& e)
3436   {
3437     DALI_TEST_PRINT_ASSERT( e );
3438     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3439     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3440   }
3441   catch(...)
3442   {
3443     tet_printf("Assertion test failed - wrong Exception\n" );
3444     tet_result(TET_FAIL);
3445   }
3446
3447   END_TEST;
3448 }
3449
3450 int UtcDaliActorAddRendererOnStage(void)
3451 {
3452   tet_infoline("Testing Actor::AddRenderer");
3453   TestApplication application;
3454
3455   Actor actor = Actor::New();
3456   Stage::GetCurrent().Add(actor);
3457
3458   application.SendNotification();
3459   application.Render(0);
3460
3461   Geometry geometry = CreateQuadGeometry();
3462   Shader shader = CreateShader();
3463   Renderer renderer = Renderer::New(geometry, shader);
3464
3465   application.SendNotification();
3466   application.Render(0);
3467
3468   try
3469   {
3470     actor.AddRenderer( renderer );
3471     tet_result(TET_PASS);
3472   }
3473   catch(...)
3474   {
3475     tet_result(TET_FAIL);
3476   }
3477
3478   END_TEST;
3479 }
3480
3481 int UtcDaliActorRemoveRendererP1(void)
3482 {
3483   tet_infoline("Testing Actor::RemoveRenderer");
3484   TestApplication application;
3485
3486   Actor actor = Actor::New();
3487
3488   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3489
3490   Geometry geometry = CreateQuadGeometry();
3491   Shader shader = CreateShader();
3492   Renderer renderer = Renderer::New(geometry, shader);
3493
3494   actor.AddRenderer( renderer );
3495   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3496   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3497
3498   actor.RemoveRenderer(renderer);
3499   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3500
3501
3502   END_TEST;
3503 }
3504
3505 int UtcDaliActorRemoveRendererP2(void)
3506 {
3507   tet_infoline("Testing Actor::RemoveRenderer");
3508   TestApplication application;
3509
3510   Actor actor = Actor::New();
3511
3512   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3513
3514   Geometry geometry = CreateQuadGeometry();
3515   Shader shader = CreateShader();
3516   Renderer renderer = Renderer::New(geometry, shader);
3517
3518   actor.AddRenderer( renderer );
3519   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3520   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3521
3522   actor.RemoveRenderer(0);
3523   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3524
3525
3526   END_TEST;
3527 }
3528
3529
3530 int UtcDaliActorRemoveRendererN(void)
3531 {
3532   tet_infoline("Testing Actor::RemoveRenderer");
3533   TestApplication application;
3534
3535   Actor actor = Actor::New();
3536
3537   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3538
3539   Geometry geometry = CreateQuadGeometry();
3540   Shader shader = CreateShader();
3541   Renderer renderer = Renderer::New(geometry, shader);
3542
3543   actor.AddRenderer( renderer );
3544   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3545   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3546
3547   actor.RemoveRenderer(10);
3548   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3549   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3550
3551   END_TEST;
3552 }