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