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