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