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