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