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