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