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