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