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