Added property of layout direction for RTL/LTR support
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "assert.h"
19 #include <dali/public-api/dali-core.h>
20 #include <string>
21 #include <cfloat>   // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
27
28 //& set: DaliActor
29
30 using std::string;
31 using namespace Dali;
32
33
34 void utc_dali_actor_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_actor_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46 bool gTouchCallBackCalled=false;
47 bool gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
49
50 bool gHoverCallBackCalled=false;
51
52 static bool gTestConstraintCalled;
53
54 struct TestConstraint
55 {
56   void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
57   {
58     gTestConstraintCalled = true;
59   }
60 };
61
62 /**
63  * TestConstraint reference.
64  * When constraint is called, the resultRef is updated
65  * with the value supplied.
66  */
67 template<typename T>
68 struct TestConstraintRef
69 {
70   TestConstraintRef(unsigned int& resultRef, unsigned int value)
71   : mResultRef(resultRef),
72     mValue(value)
73   {
74   }
75
76   void operator()( T& current, const PropertyInputContainer& /* inputs */ )
77   {
78     mResultRef = mValue;
79   }
80
81   unsigned int& mResultRef;
82   unsigned int mValue;
83 };
84
85 static bool TestCallback(Actor actor, const TouchEvent& event)
86 {
87   gTouchCallBackCalled = true;
88   return false;
89   END_TEST;
90 }
91
92 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
93 {
94   gTouchCallBackCalled = true;
95   return true;
96   END_TEST;
97 }
98
99 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
100 {
101   gTouchCallBackCalled2 = true;
102   return true;
103   END_TEST;
104 }
105
106 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
107 {
108   gTouchCallBackCalled3 = true;
109   return true;
110   END_TEST;
111 }
112
113 static void ResetTouchCallbacks()
114 {
115   gTouchCallBackCalled = false;
116   gTouchCallBackCalled2 = false;
117   gTouchCallBackCalled3 = false;
118 }
119
120 static bool TestCallback3(Actor actor, const HoverEvent& event)
121 {
122   gHoverCallBackCalled = true;
123   return false;
124   END_TEST;
125 }
126
127 // validation stuff for onstage & offstage signals
128 static std::vector< std::string > gActorNamesOnOffStage;
129 static int gOnStageCallBackCalled;
130 void OnStageCallback( Actor actor )
131 {
132   ++gOnStageCallBackCalled;
133   gActorNamesOnOffStage.push_back( actor.GetName() );
134   DALI_TEST_CHECK( actor.OnStage() == true );
135 }
136 static int gOffStageCallBackCalled;
137 void OffStageCallback( Actor actor )
138 {
139   ++gOffStageCallBackCalled;
140   gActorNamesOnOffStage.push_back( actor.GetName() );
141   DALI_TEST_CHECK( actor.OnStage() == false );
142 }
143
144 struct PositionComponentConstraint
145 {
146   PositionComponentConstraint(){}
147
148   void operator()( Vector3& pos, const PropertyInputContainer& inputs )
149   {
150     const Matrix& m = inputs[0]->GetMatrix();
151     Vector3 scale;
152     Quaternion rot;
153     m.GetTransformComponents(pos, rot, scale);
154   }
155 };
156
157 struct OrientationComponentConstraint
158 {
159   OrientationComponentConstraint(){}
160
161   void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
162   {
163     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
164     Vector3 pos, scale;
165     Quaternion rot;
166     orientation = parentOrientation;
167   }
168 };
169 // OnRelayout
170
171 static bool gOnRelayoutCallBackCalled = false;
172 static std::vector< std::string > gActorNamesRelayout;
173
174 void OnRelayoutCallback( Actor actor )
175 {
176   gOnRelayoutCallBackCalled = true;
177   gActorNamesRelayout.push_back( actor.GetName() );
178 }
179
180 struct VisibilityChangedFunctorData
181 {
182   VisibilityChangedFunctorData()
183   : actor(),
184     visible( false ),
185     type( DevelActor::VisibilityChange::SELF ),
186     called( false )
187   {
188   }
189
190   void Reset()
191   {
192     actor.Reset();
193     visible = false;
194     type = DevelActor::VisibilityChange::SELF;
195     called = false;
196   }
197
198   void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
199   {
200     DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
201     DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
202     DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
203     DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
204   }
205
206   void Check( bool compareCalled, const std::string& location )
207   {
208     DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
209   }
210
211   Actor actor;
212   bool visible;
213   DevelActor::VisibilityChange::Type type;
214   bool called;
215 };
216
217 struct VisibilityChangedFunctor
218 {
219   VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
220
221   void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
222   {
223     data.actor = actor;
224     data.visible = visible;
225     data.type = type;
226     data.called = true;
227   }
228
229   VisibilityChangedFunctorData& data;
230 };
231
232 } // anonymous namespace
233
234
235 //& purpose: Testing New API
236 int UtcDaliActorNew(void)
237 {
238   TestApplication application;
239
240   Actor actor = Actor::New();
241
242   DALI_TEST_CHECK(actor);
243   END_TEST;
244 }
245
246 //& purpose: Testing Dali::Actor::DownCast()
247 int UtcDaliActorDownCastP(void)
248 {
249   TestApplication application;
250   tet_infoline("Testing Dali::Actor::DownCast()");
251
252   Actor actor = Actor::New();
253   BaseHandle object(actor);
254   Actor actor2 = Actor::DownCast(object);
255   DALI_TEST_CHECK(actor2);
256   END_TEST;
257 }
258
259 //& purpose: Testing Dali::Actor::DownCast()
260 int UtcDaliActorDownCastN(void)
261 {
262   TestApplication application;
263   tet_infoline("Testing Dali::Actor::DownCast()");
264
265   BaseHandle unInitializedObject;
266   Actor actor = Actor::DownCast(unInitializedObject);
267   DALI_TEST_CHECK(!actor);
268   END_TEST;
269 }
270
271 //& purpose: Testing Dali::Actor::GetName()
272 int UtcDaliActorGetName(void)
273 {
274   TestApplication application;
275
276   Actor actor = Actor::New();
277
278   DALI_TEST_CHECK(actor.GetName().empty());
279   END_TEST;
280 }
281
282 //& purpose: Testing Dali::Actor::SetName()
283 int UtcDaliActorSetName(void)
284 {
285   TestApplication application;
286
287   string str("ActorName");
288   Actor actor = Actor::New();
289
290   actor.SetName(str);
291   DALI_TEST_CHECK(actor.GetName() == str);
292   END_TEST;
293 }
294
295 int UtcDaliActorGetId(void)
296 {
297   tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
298   TestApplication application;
299
300   Actor first = Actor::New();
301   Actor second = Actor::New();
302   Actor third = Actor::New();
303
304   DALI_TEST_CHECK(first.GetId() != second.GetId());
305   DALI_TEST_CHECK(second.GetId() != third.GetId());
306   END_TEST;
307 }
308
309 int UtcDaliActorIsRoot(void)
310 {
311   TestApplication application;
312
313   Actor actor = Actor::New();
314   DALI_TEST_CHECK(!actor.IsRoot());
315
316   // get the root layer
317   actor = Stage::GetCurrent().GetLayer( 0 );
318   DALI_TEST_CHECK( actor.IsRoot() );
319   END_TEST;
320 }
321
322 int UtcDaliActorOnStage(void)
323 {
324   TestApplication application;
325
326   Actor actor = Actor::New();
327   DALI_TEST_CHECK( !actor.OnStage() );
328
329   // get the root layer
330   actor = Stage::GetCurrent().GetLayer( 0 );
331   DALI_TEST_CHECK( actor.OnStage() );
332   END_TEST;
333 }
334
335 int UtcDaliActorIsLayer(void)
336 {
337   TestApplication application;
338
339   Actor actor = Actor::New();
340   DALI_TEST_CHECK( !actor.IsLayer() );
341
342   // get the root layer
343   actor = Stage::GetCurrent().GetLayer( 0 );
344   DALI_TEST_CHECK( actor.IsLayer() );
345   END_TEST;
346 }
347
348 int UtcDaliActorGetLayer(void)
349 {
350   TestApplication application;
351
352   Actor actor = Actor::New();
353   Stage::GetCurrent().Add(actor);
354   Layer layer = actor.GetLayer();
355
356   DALI_TEST_CHECK(layer);
357
358   // get the root layers layer
359   actor = Stage::GetCurrent().GetLayer( 0 );
360   DALI_TEST_CHECK( actor.GetLayer() );
361   END_TEST;
362 }
363
364 int UtcDaliActorAddP(void)
365 {
366   tet_infoline("Testing Actor::Add");
367   TestApplication application;
368
369   Actor parent = Actor::New();
370   Actor child = Actor::New();
371
372   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
373
374   parent.Add(child);
375
376   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
377
378   Actor parent2 = Actor::New();
379   parent2.Add( child );
380
381   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
382   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
383
384   // try Adding to same parent again, works
385   parent2.Add( child );
386   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
387
388   // try reparenting an orphaned child
389   {
390     Actor temporaryParent = Actor::New();
391     temporaryParent.Add( child );
392     DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
393   }
394   // temporaryParent has now died, reparent the orphaned child
395   parent2.Add( child );
396   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
397
398   END_TEST;
399 }
400
401 int UtcDaliActorAddN(void)
402 {
403   tet_infoline("Testing Actor::Add");
404   TestApplication application;
405
406   Actor child = Actor::New();
407
408   Actor parent2 = Actor::New();
409   parent2.Add( child );
410
411   // try illegal Add
412   try
413   {
414     parent2.Add( parent2 );
415     tet_printf("Assertion test failed - no Exception\n" );
416     tet_result(TET_FAIL);
417   }
418   catch(Dali::DaliException& e)
419   {
420     DALI_TEST_PRINT_ASSERT( e );
421     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
422     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
423   }
424   catch(...)
425   {
426     tet_printf("Assertion test failed - wrong Exception\n" );
427     tet_result(TET_FAIL);
428   }
429
430   // try reparenting root
431   try
432   {
433     parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
434     tet_printf("Assertion test failed - no Exception\n" );
435     tet_result(TET_FAIL);
436   }
437   catch(Dali::DaliException& e)
438   {
439     DALI_TEST_PRINT_ASSERT( e );
440     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
441     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
442   }
443   catch(...)
444   {
445     tet_printf("Assertion test failed - wrong Exception\n" );
446     tet_result(TET_FAIL);
447   }
448
449   // try Add empty
450   try
451   {
452     Actor empty;
453     parent2.Add( empty );
454     tet_printf("Assertion test failed - no Exception\n" );
455     tet_result(TET_FAIL);
456   }
457   catch(Dali::DaliException& e)
458   {
459     DALI_TEST_PRINT_ASSERT( e );
460     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
461     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
462   }
463   catch(...)
464   {
465     tet_printf("Assertion test failed - wrong Exception\n" );
466     tet_result(TET_FAIL);
467   }
468
469   END_TEST;
470 }
471
472 int UtcDaliActorRemoveN(void)
473 {
474   tet_infoline("Testing Actor::Remove");
475   TestApplication application;
476
477   Actor parent = Actor::New();
478   Actor child = Actor::New();
479   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
480
481   parent.Add(child);
482   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
483
484   parent.Remove(child);
485   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
486
487   // remove again, no problem
488   parent.Remove(child);
489   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
490
491   // add child back
492   parent.Add(child);
493   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
494   // try Remove self, its a no-op
495   parent.Remove( parent );
496   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
497
498   // try Remove empty
499   try
500   {
501     Actor empty;
502     parent.Remove( empty );
503     tet_printf("Assertion test failed - no Exception\n" );
504     tet_result(TET_FAIL);
505   }
506   catch(Dali::DaliException& e)
507   {
508     DALI_TEST_PRINT_ASSERT( e );
509     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
510     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
511   }
512   catch(...)
513   {
514     tet_printf("Assertion test failed - wrong Exception\n" );
515     tet_result(TET_FAIL);
516   }
517   END_TEST;
518 }
519
520 int UtcDaliActorRemoveP(void)
521 {
522   TestApplication application;
523
524   Actor parent = Actor::New();
525   Actor child = Actor::New();
526   Actor random = Actor::New();
527
528   Stage::GetCurrent().Add( parent );
529
530   DALI_TEST_CHECK(parent.GetChildCount() == 0);
531
532   parent.Add(child);
533
534   DALI_TEST_CHECK(parent.GetChildCount() == 1);
535
536   parent.Remove(random);
537
538   DALI_TEST_CHECK(parent.GetChildCount() == 1);
539
540   Stage::GetCurrent().Remove( parent );
541
542   DALI_TEST_CHECK(parent.GetChildCount() == 1);
543   END_TEST;
544 }
545
546 int UtcDaliActorGetChildCount(void)
547 {
548   TestApplication application;
549
550   Actor parent = Actor::New();
551   Actor child = Actor::New();
552
553   DALI_TEST_CHECK(parent.GetChildCount() == 0);
554
555   parent.Add(child);
556
557   DALI_TEST_CHECK(parent.GetChildCount() == 1);
558   END_TEST;
559 }
560
561 int UtcDaliActorGetChildren01(void)
562 {
563   TestApplication application;
564
565   Actor parent = Actor::New();
566   Actor first  = Actor::New();
567   Actor second = Actor::New();
568   Actor third  = Actor::New();
569
570   parent.Add(first);
571   parent.Add(second);
572   parent.Add(third);
573
574   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
575   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
576   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
577   END_TEST;
578 }
579
580 int UtcDaliActorGetChildren02(void)
581 {
582   TestApplication application;
583
584   Actor parent = Actor::New();
585   Actor first  = Actor::New();
586   Actor second = Actor::New();
587   Actor third  = Actor::New();
588
589   parent.Add(first);
590   parent.Add(second);
591   parent.Add(third);
592
593   const Actor& constParent = parent;
594
595   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
596   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
597   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
598   END_TEST;
599 }
600
601 int UtcDaliActorGetParent01(void)
602 {
603   TestApplication application;
604
605   Actor parent = Actor::New();
606   Actor child = Actor::New();
607
608   parent.Add(child);
609
610   DALI_TEST_CHECK(child.GetParent() == parent);
611   END_TEST;
612 }
613
614 int UtcDaliActorGetParent02(void)
615 {
616   TestApplication application;
617
618   Actor actor = Actor::New();
619
620   DALI_TEST_CHECK(!actor.GetParent());
621   END_TEST;
622 }
623
624 int UtcDaliActorSetParentOrigin(void)
625 {
626   TestApplication application;
627
628   Actor actor = Actor::New();
629
630   Vector3 vector(0.7f, 0.8f, 0.9f);
631   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
632
633   actor.SetParentOrigin(vector);
634
635   // flush the queue and render once
636   application.SendNotification();
637   application.Render();
638
639   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
640
641   Stage::GetCurrent().Add( actor );
642
643   actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
644
645   // flush the queue and render once
646   application.SendNotification();
647   application.Render();
648
649   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
650
651   Stage::GetCurrent().Remove( actor );
652   END_TEST;
653 }
654
655 int UtcDaliActorSetParentOriginIndividual(void)
656 {
657   TestApplication application;
658
659   Actor actor = Actor::New();
660
661   Vector3 vector(0.7f, 0.8f, 0.9f);
662   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
663
664   actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
665
666   // flush the queue and render once
667   application.SendNotification();
668   application.Render();
669
670   DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
671
672   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
673
674   // flush the queue and render once
675   application.SendNotification();
676   application.Render();
677
678   DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
679
680   actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
681
682   // flush the queue and render once
683   application.SendNotification();
684   application.Render();
685
686   DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
687
688   END_TEST;
689 }
690
691 int UtcDaliActorGetCurrentParentOrigin(void)
692 {
693   TestApplication application;
694
695   Actor actor = Actor::New();
696
697   Vector3 vector(0.7f, 0.8f, 0.9f);
698   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
699
700   actor.SetParentOrigin(vector);
701
702   // flush the queue and render once
703   application.SendNotification();
704   application.Render();
705
706   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
707   END_TEST;
708 }
709
710 int UtcDaliActorSetAnchorPoint(void)
711 {
712   TestApplication application;
713
714   Actor actor = Actor::New();
715
716   Vector3 vector(0.7f, 0.8f, 0.9f);
717   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
718
719   actor.SetAnchorPoint(vector);
720
721   // flush the queue and render once
722   application.SendNotification();
723   application.Render();
724
725   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
726
727   Stage::GetCurrent().Add( actor );
728
729   actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
730   // flush the queue and render once
731   application.SendNotification();
732   application.Render();
733
734   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
735
736   Stage::GetCurrent().Remove( actor );
737   END_TEST;
738 }
739
740 int UtcDaliActorSetAnchorPointIndividual(void)
741 {
742   TestApplication application;
743
744   Actor actor = Actor::New();
745
746   Vector3 vector(0.7f, 0.8f, 0.9f);
747   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
748
749   actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
750
751   // flush the queue and render once
752   application.SendNotification();
753   application.Render();
754
755   DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
756
757   actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
758
759   // flush the queue and render once
760   application.SendNotification();
761   application.Render();
762
763   DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
764
765   actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
766
767   // flush the queue and render once
768   application.SendNotification();
769   application.Render();
770
771   DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
772
773   END_TEST;
774 }
775
776 int UtcDaliActorGetCurrentAnchorPoint(void)
777 {
778   TestApplication application;
779
780   Actor actor = Actor::New();
781
782   Vector3 vector(0.7f, 0.8f, 0.9f);
783   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
784
785   actor.SetAnchorPoint(vector);
786
787   // flush the queue and render once
788   application.SendNotification();
789   application.Render();
790
791   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
792   END_TEST;
793 }
794
795 // SetSize(float width, float height)
796 int UtcDaliActorSetSize01(void)
797 {
798   TestApplication application;
799
800   Actor actor = Actor::New();
801   Vector3 vector(100.0f, 100.0f, 0.0f);
802
803   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
804
805   actor.SetSize(vector.x, vector.y);
806
807   // Immediately retrieve the size after setting
808   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
809   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
810   DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
811   DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
812   DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
813
814   // Flush the queue and render once
815   application.SendNotification();
816   application.Render();
817
818   // Check the size in the new frame
819   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
820
821   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
822   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
823   DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
824   DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
825   DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
826
827   // Check async behaviour
828   currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
829   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
830   DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
831   DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
832   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
833
834   // Change the resize policy and check whether the size stays the same
835   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
836
837   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
838   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
839
840   // Set a new size after resize policy is changed and check the new size
841   actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
842
843   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
844   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
845
846   // Change the resize policy again and check whether the new size stays the same
847   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
848
849   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
850   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
851
852   // Set another new size after resize policy is changed and check the new size
853   actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
854
855   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
856   DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
857
858   END_TEST;
859 }
860
861 // SetSize(float width, float height, float depth)
862 int UtcDaliActorSetSize02(void)
863 {
864   TestApplication application;
865
866   Actor actor = Actor::New();
867   Vector3 vector(100.0f, 100.0f, 100.0f);
868
869   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
870
871   actor.SetSize(vector.x, vector.y, vector.z);
872
873   // Immediately check the size after setting
874   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
875   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
876
877   // flush the queue and render once
878   application.SendNotification();
879   application.Render();
880
881   // Check the size in the new frame
882   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
883
884   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
885   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
886
887   END_TEST;
888 }
889
890 // SetSize(Vector2 size)
891 int UtcDaliActorSetSize03(void)
892 {
893   TestApplication application;
894
895   Actor actor = Actor::New();
896   Vector3 vector(100.0f, 100.0f, 0.0f);
897
898   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
899
900   actor.SetSize(Vector2(vector.x, vector.y));
901
902   // Immediately check the size after setting
903   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
904   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
905
906   // flush the queue and render once
907   application.SendNotification();
908   application.Render();
909
910   // Check the size in the new frame
911   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
912
913   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
914   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
915
916   END_TEST;
917 }
918
919 // SetSize(Vector3 size)
920 int UtcDaliActorSetSize04(void)
921 {
922   TestApplication application;
923
924   Actor actor = Actor::New();
925   Vector3 vector(100.0f, 100.0f, 100.0f);
926
927   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
928
929   actor.SetSize(vector);
930
931   // Immediately check the size after setting
932   Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
933   DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
934
935   // flush the queue and render once
936   application.SendNotification();
937   application.Render();
938
939   // Check the size in the new frame
940   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
941
942   Stage::GetCurrent().Add( actor );
943   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
944
945   // Immediately check the size after setting
946   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
947   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
948
949   // flush the queue and render once
950   application.SendNotification();
951   application.Render();
952
953   // Check the size in the new frame
954   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
955
956   currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
957   DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
958
959   Stage::GetCurrent().Remove( actor );
960   END_TEST;
961 }
962
963 int UtcDaliActorSetSizeIndividual(void)
964 {
965   TestApplication application;
966
967   Actor actor = Actor::New();
968
969   Vector3 vector(0.7f, 0.8f, 0.9f);
970   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
971
972   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
973
974   // Immediately check the width after setting
975   float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
976   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
977
978   // flush the queue and render once
979   application.SendNotification();
980   application.Render();
981
982   // Check the width in the new frame
983   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
984
985   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
986   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
987
988   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
989
990   // Immediately check the height after setting
991   float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
992   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
993
994   // flush the queue and render once
995   application.SendNotification();
996   application.Render();
997
998   // Check the height in the new frame
999   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1000
1001   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1002   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1003
1004   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1005
1006   // Immediately check the depth after setting
1007   float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1008   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1009
1010   // flush the queue and render once
1011   application.SendNotification();
1012   application.Render();
1013
1014   // Check the depth in the new frame
1015   DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1016
1017   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1018   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1019
1020   // Change the resize policy and check whether the size stays the same
1021   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1022
1023   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1024   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1025
1026   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1027   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028
1029   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1030   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1031
1032   // Change the resize policy again and check whether the size stays the same
1033   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1034
1035   sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1036   DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1037
1038   sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1039   DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1040
1041   sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1042   DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043
1044   END_TEST;
1045 }
1046
1047 int UtcDaliActorSetSizeIndividual02(void)
1048 {
1049   TestApplication application;
1050
1051   Actor actor = Actor::New();
1052   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1053   Stage::GetCurrent().Add( actor );
1054
1055   Vector3 vector( 100.0f, 200.0f, 400.0f );
1056   DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1057
1058   actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1059   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1060
1061   actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1062   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1063
1064   actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1065   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1066
1067   // flush the queue and render once
1068   application.SendNotification();
1069   application.Render();
1070
1071   // Check the width in the new frame
1072   DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1073   DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1074
1075   END_TEST;
1076 }
1077
1078
1079 int UtcDaliActorGetCurrentSize(void)
1080 {
1081   TestApplication application;
1082
1083   Actor actor = Actor::New();
1084   Vector3 vector(100.0f, 100.0f, 20.0f);
1085
1086   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1087
1088   actor.SetSize(vector);
1089
1090   // flush the queue and render once
1091   application.SendNotification();
1092   application.Render();
1093
1094   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1095   END_TEST;
1096 }
1097
1098 int UtcDaliActorGetNaturalSize(void)
1099 {
1100   TestApplication application;
1101
1102   Actor actor = Actor::New();
1103   Vector3 vector( 0.0f, 0.0f, 0.0f );
1104
1105   DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1106
1107   END_TEST;
1108 }
1109
1110 int UtcDaliActorGetCurrentSizeImmediate(void)
1111 {
1112   TestApplication application;
1113
1114   Actor actor = Actor::New();
1115   Vector3 vector(100.0f, 100.0f, 20.0f);
1116
1117   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1118   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1119
1120   actor.SetSize(vector);
1121
1122   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1123   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1124
1125   // flush the queue and render once
1126   application.SendNotification();
1127   application.Render();
1128
1129   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1130   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1131
1132   // Animation
1133   // Build the animation
1134   const float durationSeconds = 2.0f;
1135   Animation animation = Animation::New( durationSeconds );
1136   const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1137   animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1138
1139   DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1140
1141   // Start the animation
1142   animation.Play();
1143
1144   application.SendNotification();
1145   application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1146
1147   DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1148
1149   END_TEST;
1150 }
1151
1152 // SetPosition(float x, float y)
1153 int UtcDaliActorSetPosition01(void)
1154 {
1155   TestApplication application;
1156
1157   Actor actor = Actor::New();
1158
1159   // Set to random to start off with
1160   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1161
1162   Vector3 vector(100.0f, 100.0f, 0.0f);
1163
1164   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1165
1166   actor.SetPosition(vector.x, vector.y);
1167   // flush the queue and render once
1168   application.SendNotification();
1169   application.Render();
1170   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1171
1172   Stage::GetCurrent().Add( actor );
1173   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1174   // flush the queue and render once
1175   application.SendNotification();
1176   application.Render();
1177   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1178
1179   actor.SetX( 1.0f );
1180   actor.SetY( 1.1f );
1181   actor.SetZ( 1.2f );
1182   // flush the queue and render once
1183   application.SendNotification();
1184   application.Render();
1185   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1186
1187   actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1188   // flush the queue and render once
1189   application.SendNotification();
1190   application.Render();
1191   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1192
1193   Stage::GetCurrent().Remove( actor );
1194   END_TEST;
1195 }
1196
1197 // SetPosition(float x, float y, float z)
1198 int UtcDaliActorSetPosition02(void)
1199 {
1200   TestApplication application;
1201
1202   Actor actor = Actor::New();
1203
1204   // Set to random to start off with
1205   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1206
1207   Vector3 vector(100.0f, 100.0f, 100.0f);
1208
1209   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1210
1211   actor.SetPosition(vector.x, vector.y, vector.z);
1212
1213   // flush the queue and render once
1214   application.SendNotification();
1215   application.Render();
1216
1217   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1218   END_TEST;
1219 }
1220
1221 // SetPosition(Vector3 position)
1222 int UtcDaliActorSetPosition03(void)
1223 {
1224   TestApplication application;
1225
1226   Actor actor = Actor::New();
1227
1228   // Set to random to start off with
1229   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1230
1231   Vector3 vector(100.0f, 100.0f, 100.0f);
1232
1233   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1234
1235   actor.SetPosition(vector);
1236
1237   // flush the queue and render once
1238   application.SendNotification();
1239   application.Render();
1240
1241   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1242   END_TEST;
1243 }
1244
1245 int UtcDaliActorSetX(void)
1246 {
1247   TestApplication application;
1248
1249   Actor actor = Actor::New();
1250
1251   Vector3 vector(100.0f, 0.0f, 0.0f);
1252
1253   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1254
1255   actor.SetX(100.0f);
1256
1257   // flush the queue and render once
1258   application.SendNotification();
1259   application.Render();
1260
1261   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1262   END_TEST;
1263 }
1264
1265 int UtcDaliActorSetY(void)
1266 {
1267   TestApplication application;
1268
1269   Actor actor = Actor::New();
1270
1271   Vector3 vector(0.0f, 100.0f, 0.0f);
1272
1273   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1274
1275   actor.SetY(100.0f);
1276
1277   // flush the queue and render once
1278   application.SendNotification();
1279   application.Render();
1280
1281   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1282   END_TEST;
1283 }
1284
1285 int UtcDaliActorSetZ(void)
1286 {
1287   TestApplication application;
1288
1289   Actor actor = Actor::New();
1290
1291   Vector3 vector(0.0f, 0.0f, 100.0f);
1292
1293   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1294
1295   actor.SetZ(100.0f);
1296
1297   // flush the queue and render once
1298   application.SendNotification();
1299   application.Render();
1300
1301   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1302   END_TEST;
1303 }
1304
1305 int UtcDaliActorSetPositionProperties(void)
1306 {
1307   TestApplication application;
1308
1309   Actor actor = Actor::New();
1310
1311   Vector3 vector(0.7f, 0.8f, 0.9f);
1312   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1313
1314   actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1315   DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1316   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1317
1318   // flush the queue and render once
1319   application.SendNotification();
1320   application.Render();
1321
1322   DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1323   DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1324   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1325   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1326   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1327
1328   actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1329   DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1330   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1331
1332   // flush the queue and render once
1333   application.SendNotification();
1334   application.Render();
1335
1336   DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1337   DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1338   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1339   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1340   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1341
1342   actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1343   DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1344   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1345
1346   // flush the queue and render once
1347   application.SendNotification();
1348   application.Render();
1349
1350   DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1351   DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1352   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1353   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1354   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1355
1356   END_TEST;
1357 }
1358
1359 int UtcDaliActorTranslateBy(void)
1360 {
1361   TestApplication application;
1362
1363   Actor actor = Actor::New();
1364   Vector3 vector(100.0f, 100.0f, 100.0f);
1365
1366   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1367
1368   actor.SetPosition(vector);
1369
1370   // flush the queue and render once
1371   application.SendNotification();
1372   application.Render();
1373
1374   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1375
1376   actor.TranslateBy(vector);
1377
1378   // flush the queue and render once
1379   application.SendNotification();
1380   application.Render();
1381
1382   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1383   END_TEST;
1384 }
1385
1386 int UtcDaliActorGetCurrentPosition(void)
1387 {
1388   TestApplication application;
1389
1390   Actor actor = Actor::New();
1391   Vector3 setVector(100.0f, 100.0f, 0.0f);
1392   actor.SetPosition(setVector);
1393
1394   // flush the queue and render once
1395   application.SendNotification();
1396   application.Render();
1397
1398   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1399   END_TEST;
1400 }
1401
1402 int UtcDaliActorGetCurrentWorldPosition(void)
1403 {
1404   TestApplication application;
1405
1406   Actor parent = Actor::New();
1407   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1408   parent.SetPosition( parentPosition );
1409   parent.SetParentOrigin( ParentOrigin::CENTER );
1410   parent.SetAnchorPoint( AnchorPoint::CENTER );
1411   Stage::GetCurrent().Add( parent );
1412
1413   Actor child = Actor::New();
1414   child.SetParentOrigin( ParentOrigin::CENTER );
1415   child.SetAnchorPoint( AnchorPoint::CENTER );
1416   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1417   child.SetPosition( childPosition );
1418   parent.Add( child );
1419
1420   // The actors should not have a world position yet
1421   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1422   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1423
1424   application.SendNotification();
1425   application.Render(0);
1426
1427   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1428   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1429
1430   // The actors should have a world position now
1431   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1432   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1433   END_TEST;
1434 }
1435
1436 int UtcDaliActorInheritPosition(void)
1437 {
1438   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1439   TestApplication application;
1440
1441   Actor parent = Actor::New();
1442   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1443   parent.SetPosition( parentPosition );
1444   parent.SetParentOrigin( ParentOrigin::CENTER );
1445   parent.SetAnchorPoint( AnchorPoint::CENTER );
1446   Stage::GetCurrent().Add( parent );
1447
1448   Actor child = Actor::New();
1449   child.SetParentOrigin( ParentOrigin::CENTER );
1450   child.SetAnchorPoint( AnchorPoint::CENTER );
1451   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1452   child.SetPosition( childPosition );
1453   parent.Add( child );
1454
1455   // The actors should not have a world position yet
1456   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1457   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1458
1459   // first test default, which is to inherit position
1460   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1461   application.SendNotification();
1462   application.Render(0); // should only really call Update as Render is not required to update scene
1463   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1464   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1465   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1466   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1467
1468
1469   //Change child position
1470   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1471   child.SetPosition( childOffset );
1472
1473   // Change inheritance mode to not inherit
1474   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1475   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1476   application.SendNotification();
1477   application.Render(0); // should only really call Update as Render is not required to update scene
1478   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1479   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1480   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1481   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1482   END_TEST;
1483 }
1484
1485 int UtcDaliActorSetInheritPosition(void)
1486 {
1487   tet_infoline("Testing Actor::SetInheritPosition");
1488   TestApplication application;
1489
1490   Actor parent = Actor::New();
1491   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1492   parent.SetPosition( parentPosition );
1493   parent.SetParentOrigin( ParentOrigin::CENTER );
1494   parent.SetAnchorPoint( AnchorPoint::CENTER );
1495   Stage::GetCurrent().Add( parent );
1496
1497   Actor child = Actor::New();
1498   child.SetParentOrigin( ParentOrigin::CENTER );
1499   child.SetAnchorPoint( AnchorPoint::CENTER );
1500   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1501   child.SetPosition( childPosition );
1502   parent.Add( child );
1503
1504   // The actors should not have a world position yet
1505   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1506   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1507
1508   // first test default, which is to inherit position
1509   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1510   application.SendNotification();
1511   application.Render(0); // should only really call Update as Render is not required to update scene
1512   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1513   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1514   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1515   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1516
1517   //Change child position
1518   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1519   child.SetPosition( childOffset );
1520
1521   // Use local position as world postion
1522   child.SetInheritPosition( false );
1523   DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1524   application.SendNotification();
1525   application.Render(0); // should only really call Update as Render is not required to update scene
1526   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1527   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1528   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1529   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1530
1531   //Change back to inherit position from parent
1532   child.SetInheritPosition( true );
1533   DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1534   application.SendNotification();
1535   application.Render(0); // should only really call Update as Render is not required to update scene
1536   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1537   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1538   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1539   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1540   END_TEST;
1541 }
1542
1543 // SetOrientation(float angleRadians, Vector3 axis)
1544 int UtcDaliActorSetOrientation01(void)
1545 {
1546   TestApplication application;
1547
1548   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1549   Actor actor = Actor::New();
1550
1551   actor.SetOrientation(rotation);
1552
1553   // flush the queue and render once
1554   application.SendNotification();
1555   application.Render();
1556
1557   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1558   END_TEST;
1559 }
1560
1561 int UtcDaliActorSetOrientation02(void)
1562 {
1563   TestApplication application;
1564
1565   Actor actor = Actor::New();
1566
1567   Radian angle( 0.785f );
1568   Vector3 axis(1.0f, 1.0f, 0.0f);
1569
1570   actor.SetOrientation( angle, axis);
1571   Quaternion rotation( angle, axis );
1572   // flush the queue and render once
1573   application.SendNotification();
1574   application.Render();
1575   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1576
1577   Stage::GetCurrent().Add( actor );
1578   actor.RotateBy( Degree( 360 ), axis);
1579   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1580
1581   actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1582   Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1583   // flush the queue and render once
1584   application.SendNotification();
1585   application.Render();
1586   DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1587
1588   actor.SetOrientation( angle, axis);
1589   // flush the queue and render once
1590   application.SendNotification();
1591   application.Render();
1592   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1593
1594   Stage::GetCurrent().Remove( actor );
1595   END_TEST;
1596 }
1597
1598 // SetOrientation(float angleRadians, Vector3 axis)
1599 int UtcDaliActorSetOrientationProperty(void)
1600 {
1601   TestApplication application;
1602
1603   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1604   Actor actor = Actor::New();
1605
1606   actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1607   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1608
1609   // flush the queue and render once
1610   application.SendNotification();
1611   application.Render();
1612
1613   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1614   DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1615   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1616   END_TEST;
1617 }
1618
1619 // RotateBy(float angleRadians, Vector3 axis)
1620 int UtcDaliActorRotateBy01(void)
1621 {
1622   TestApplication application;
1623
1624   Actor actor = Actor::New();
1625
1626   Radian angle( M_PI * 0.25f );
1627   actor.RotateBy(( angle ), Vector3::ZAXIS);
1628   // flush the queue and render once
1629   application.SendNotification();
1630   application.Render();
1631   DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1632
1633   Stage::GetCurrent().Add( actor );
1634
1635   actor.RotateBy( angle, Vector3::ZAXIS);
1636   // flush the queue and render once
1637   application.SendNotification();
1638   application.Render();
1639   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1640
1641   Stage::GetCurrent().Remove( actor );
1642   END_TEST;
1643 }
1644
1645 // RotateBy(Quaternion relativeRotation)
1646 int UtcDaliActorRotateBy02(void)
1647 {
1648   TestApplication application;
1649
1650   Actor actor = Actor::New();
1651
1652   Radian angle( M_PI * 0.25f );
1653   Quaternion rotation(angle, Vector3::ZAXIS);
1654   actor.RotateBy(rotation);
1655   // flush the queue and render once
1656   application.SendNotification();
1657   application.Render();
1658   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1659
1660   actor.RotateBy(rotation);
1661   // flush the queue and render once
1662   application.SendNotification();
1663   application.Render();
1664   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1665   END_TEST;
1666 }
1667
1668 int UtcDaliActorGetCurrentOrientation(void)
1669 {
1670   TestApplication application;
1671   Actor actor = Actor::New();
1672
1673   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1674   actor.SetOrientation(rotation);
1675   // flush the queue and render once
1676   application.SendNotification();
1677   application.Render();
1678   DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1679   END_TEST;
1680 }
1681
1682 int UtcDaliActorGetCurrentWorldOrientation(void)
1683 {
1684   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1685   TestApplication application;
1686
1687   Actor parent = Actor::New();
1688   Radian rotationAngle( Degree(90.0f) );
1689   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1690   parent.SetOrientation( rotation );
1691   Stage::GetCurrent().Add( parent );
1692
1693   Actor child = Actor::New();
1694   child.SetOrientation( rotation );
1695   parent.Add( child );
1696
1697   // The actors should not have a world rotation yet
1698   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1699   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1700
1701   application.SendNotification();
1702   application.Render(0);
1703
1704   DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1705   DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1706
1707   // The actors should have a world rotation now
1708   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1709   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1710
1711   // turn off child rotation inheritance
1712   child.SetInheritOrientation( false );
1713   DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1714   application.SendNotification();
1715   application.Render(0);
1716
1717   // The actors should have a world rotation now
1718   DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1719   DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1720   END_TEST;
1721 }
1722
1723 // SetScale(float scale)
1724 int UtcDaliActorSetScale01(void)
1725 {
1726   TestApplication application;
1727
1728   Actor actor = Actor::New();
1729
1730   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1731   actor.SetScale(0.25f);
1732
1733   Vector3 scale(10.0f, 10.0f, 10.0f);
1734   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1735
1736   actor.SetScale(scale.x);
1737
1738   // flush the queue and render once
1739   application.SendNotification();
1740   application.Render();
1741
1742   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1743   END_TEST;
1744 }
1745
1746 // SetScale(float scaleX, float scaleY, float scaleZ)
1747 int UtcDaliActorSetScale02(void)
1748 {
1749   TestApplication application;
1750   Vector3 scale(10.0f, 10.0f, 10.0f);
1751
1752   Actor actor = Actor::New();
1753
1754   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1755   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1756
1757   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1758
1759   actor.SetScale(scale.x, scale.y, scale.z);
1760   // flush the queue and render once
1761   application.SendNotification();
1762   application.Render();
1763   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1764
1765   // add to stage and test
1766   Stage::GetCurrent().Add( actor );
1767   actor.SetScale( 2.0f, 2.0f, 2.0f );
1768   // flush the queue and render once
1769   application.SendNotification();
1770   application.Render();
1771   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1772
1773   Stage::GetCurrent().Remove( actor );
1774
1775   END_TEST;
1776 }
1777
1778 // SetScale(Vector3 scale)
1779 int UtcDaliActorSetScale03(void)
1780 {
1781   TestApplication application;
1782   Vector3 scale(10.0f, 10.0f, 10.0f);
1783
1784   Actor actor = Actor::New();
1785
1786   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1787   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1788
1789   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1790
1791   actor.SetScale(scale);
1792
1793   // flush the queue and render once
1794   application.SendNotification();
1795   application.Render();
1796
1797   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1798   END_TEST;
1799 }
1800
1801 int UtcDaliActorSetScaleIndividual(void)
1802 {
1803   TestApplication application;
1804
1805   Actor actor = Actor::New();
1806
1807   Vector3 vector(0.7f, 0.8f, 0.9f);
1808   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1809
1810   actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1811   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1812
1813   // flush the queue and render once
1814   application.SendNotification();
1815   application.Render();
1816
1817   DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1818   DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1819   DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1820
1821   actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1822   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1823
1824   // flush the queue and render once
1825   application.SendNotification();
1826   application.Render();
1827
1828   DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1829   DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1830   DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1831
1832   actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1833   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1834
1835   // flush the queue and render once
1836   application.SendNotification();
1837   application.Render();
1838
1839   DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1840   DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1841   DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1842
1843   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1844   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1845
1846   END_TEST;
1847 }
1848
1849 int UtcDaliActorScaleBy(void)
1850 {
1851   TestApplication application;
1852   Actor actor = Actor::New();
1853   Vector3 vector(100.0f, 100.0f, 100.0f);
1854
1855   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1856
1857   actor.SetScale(vector);
1858
1859   // flush the queue and render once
1860   application.SendNotification();
1861   application.Render();
1862
1863   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1864
1865   actor.ScaleBy(vector);
1866
1867   // flush the queue and render once
1868   application.SendNotification();
1869   application.Render();
1870
1871   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1872   END_TEST;
1873 }
1874
1875 int UtcDaliActorGetCurrentScale(void)
1876 {
1877   TestApplication application;
1878   Vector3 scale(12.0f, 1.0f, 2.0f);
1879
1880   Actor actor = Actor::New();
1881
1882   actor.SetScale(scale);
1883
1884   // flush the queue and render once
1885   application.SendNotification();
1886   application.Render();
1887
1888   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1889   END_TEST;
1890 }
1891
1892 int UtcDaliActorGetCurrentWorldScale(void)
1893 {
1894   TestApplication application;
1895
1896   Actor parent = Actor::New();
1897   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1898   parent.SetScale( parentScale );
1899   Stage::GetCurrent().Add( parent );
1900
1901   Actor child = Actor::New();
1902   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1903   child.SetScale( childScale );
1904   parent.Add( child );
1905
1906   // The actors should not have a scale yet
1907   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1908   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1909
1910   // The actors should not have a world scale yet
1911   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1912   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1913
1914   application.SendNotification();
1915   application.Render(0);
1916
1917   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1918   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1919
1920   // The actors should have a world scale now
1921   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1922   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1923   END_TEST;
1924 }
1925
1926 int UtcDaliActorInheritScale(void)
1927 {
1928   tet_infoline("Testing Actor::SetInheritScale");
1929   TestApplication application;
1930
1931   Actor parent = Actor::New();
1932   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1933   parent.SetScale( parentScale );
1934   Stage::GetCurrent().Add( parent );
1935
1936   Actor child = Actor::New();
1937   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1938   child.SetScale( childScale );
1939   parent.Add( child );
1940
1941   application.SendNotification();
1942   application.Render(0);
1943
1944   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1945   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1946
1947   child.SetInheritScale( false );
1948   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1949
1950   application.SendNotification();
1951   application.Render(0);
1952
1953   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1954   END_TEST;
1955 }
1956
1957 int UtcDaliActorSetVisible(void)
1958 {
1959   TestApplication application;
1960
1961   Actor actor = Actor::New();
1962   actor.SetVisible(false);
1963   // flush the queue and render once
1964   application.SendNotification();
1965   application.Render();
1966   DALI_TEST_CHECK(actor.IsVisible() == false);
1967
1968   actor.SetVisible(true);
1969   // flush the queue and render once
1970   application.SendNotification();
1971   application.Render();
1972   DALI_TEST_CHECK(actor.IsVisible() == true);
1973
1974   // put actor on stage
1975   Stage::GetCurrent().Add( actor );
1976   actor.SetVisible(false);
1977   // flush the queue and render once
1978   application.SendNotification();
1979   application.Render();
1980   DALI_TEST_CHECK(actor.IsVisible() == false);
1981   END_TEST;
1982 }
1983
1984 int UtcDaliActorIsVisible(void)
1985 {
1986   TestApplication application;
1987
1988   Actor actor = Actor::New();
1989
1990   DALI_TEST_CHECK(actor.IsVisible() == true);
1991   END_TEST;
1992 }
1993
1994 int UtcDaliActorSetOpacity(void)
1995 {
1996   TestApplication application;
1997
1998   Actor actor = Actor::New();
1999   // initial opacity is 1
2000   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2001
2002   actor.SetOpacity( 0.4f);
2003   // flush the queue and render once
2004   application.SendNotification();
2005   application.Render();
2006   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2007
2008   // change opacity, actor is on stage to change is not immediate
2009   actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2010   // flush the queue and render once
2011   application.SendNotification();
2012   application.Render();
2013   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2014
2015   // put actor on stage
2016   Stage::GetCurrent().Add( actor );
2017
2018   // change opacity, actor is on stage to change is not immediate
2019   actor.SetOpacity( 0.9f );
2020   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2021   // flush the queue and render once
2022   application.SendNotification();
2023   application.Render();
2024   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2025
2026   // change opacity, actor is on stage to change is not immediate
2027   actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2028   // flush the queue and render once
2029   application.SendNotification();
2030   application.Render();
2031   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2032   END_TEST;
2033 }
2034
2035 int UtcDaliActorGetCurrentOpacity(void)
2036 {
2037   TestApplication application;
2038
2039   Actor actor = Actor::New();
2040   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2041
2042   actor.SetOpacity(0.5f);
2043   // flush the queue and render once
2044   application.SendNotification();
2045   application.Render();
2046   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2047   END_TEST;
2048 }
2049
2050 int UtcDaliActorSetSensitive(void)
2051 {
2052   TestApplication application;
2053   Actor actor = Actor::New();
2054
2055   bool sensitive = !actor.IsSensitive();
2056
2057   actor.SetSensitive(sensitive);
2058
2059   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2060   END_TEST;
2061 }
2062
2063 int UtcDaliActorIsSensitive(void)
2064 {
2065   TestApplication application;
2066   Actor actor = Actor::New();
2067   actor.SetSensitive(false);
2068
2069   DALI_TEST_CHECK(false == actor.IsSensitive());
2070   END_TEST;
2071 }
2072
2073 int UtcDaliActorSetColor(void)
2074 {
2075   TestApplication application;
2076   Actor actor = Actor::New();
2077   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2078
2079   DALI_TEST_CHECK(color != actor.GetCurrentColor());
2080
2081   actor.SetColor(color);
2082   // flush the queue and render once
2083   application.SendNotification();
2084   application.Render();
2085   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2086
2087   actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2088   // flush the queue and render once
2089   application.SendNotification();
2090   application.Render();
2091   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
2092
2093   Stage::GetCurrent().Add( actor );
2094   actor.SetColor( color );
2095   // flush the queue and render once
2096   application.SendNotification();
2097   application.Render();
2098   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
2099
2100   actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2101   // flush the queue and render once
2102   application.SendNotification();
2103   application.Render();
2104   // Actor color is not clamped
2105   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
2106   // world color is clamped
2107   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
2108
2109   Stage::GetCurrent().Remove( actor );
2110   END_TEST;
2111 }
2112
2113 int UtcDaliActorSetColorIndividual(void)
2114 {
2115   TestApplication application;
2116
2117   Actor actor = Actor::New();
2118
2119   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2120   DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2121
2122   actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2123   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2124
2125   // flush the queue and render once
2126   application.SendNotification();
2127   application.Render();
2128
2129   DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2130   DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2131   DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2132
2133   actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2134   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2135
2136   // flush the queue and render once
2137   application.SendNotification();
2138   application.Render();
2139
2140   DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2141   DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2142   DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2143
2144   actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2145   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2146
2147   // flush the queue and render once
2148   application.SendNotification();
2149   application.Render();
2150
2151   DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2152   DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2153   DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2154
2155
2156   actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2157   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2158
2159   // flush the queue and render once
2160   application.SendNotification();
2161   application.Render();
2162
2163   DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2164   DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2165   DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2166
2167   DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2168   DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2169
2170   actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2171
2172
2173   // flush the queue and render once
2174   application.SendNotification();
2175   application.Render();
2176
2177   DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2178
2179   END_TEST;
2180 }
2181
2182
2183 int UtcDaliActorGetCurrentColor(void)
2184 {
2185   TestApplication application;
2186   Actor actor = Actor::New();
2187   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2188
2189   actor.SetColor(color);
2190   // flush the queue and render once
2191   application.SendNotification();
2192   application.Render();
2193   DALI_TEST_CHECK(color == actor.GetCurrentColor());
2194   END_TEST;
2195 }
2196
2197 int UtcDaliActorGetCurrentWorldColor(void)
2198 {
2199   tet_infoline("Actor::GetCurrentWorldColor");
2200   TestApplication application;
2201
2202   Actor parent = Actor::New();
2203   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2204   parent.SetColor( parentColor );
2205   Stage::GetCurrent().Add( parent );
2206
2207   Actor child = Actor::New();
2208   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2209   child.SetColor( childColor );
2210   parent.Add( child );
2211
2212   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2213   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2214
2215   // verify the default color mode
2216   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2217
2218   // The actors should not have a world color yet
2219   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2220   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2221
2222   application.SendNotification();
2223   application.Render(0);
2224
2225   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2226   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2227
2228   // The actors should have a world color now
2229   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2230   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2231
2232   // use own color
2233   child.SetColorMode( USE_OWN_COLOR );
2234   application.SendNotification();
2235   application.Render(0);
2236   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2237
2238   // use parent color
2239   child.SetColorMode( USE_PARENT_COLOR );
2240   application.SendNotification();
2241   application.Render(0);
2242   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2243   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2244
2245   // use parent alpha
2246   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2247   application.SendNotification();
2248   application.Render(0);
2249   Vector4 expectedColor( childColor );
2250   expectedColor.a *= parentColor.a;
2251   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2252   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2253   END_TEST;
2254 }
2255
2256 int UtcDaliActorSetColorMode(void)
2257 {
2258   tet_infoline("Actor::SetColorMode");
2259   TestApplication application;
2260   Actor actor = Actor::New();
2261   Actor child = Actor::New();
2262   actor.Add( child );
2263
2264   actor.SetColorMode( USE_OWN_COLOR );
2265   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2266
2267   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2268   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2269
2270   actor.SetColorMode( USE_PARENT_COLOR );
2271   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2272
2273   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2274   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2275   END_TEST;
2276 }
2277
2278 int UtcDaliActorScreenToLocal(void)
2279 {
2280   TestApplication application;
2281   Actor actor = Actor::New();
2282   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2283   actor.SetSize(100.0f, 100.0f);
2284   actor.SetPosition(10.0f, 10.0f);
2285   Stage::GetCurrent().Add(actor);
2286
2287   // flush the queue and render once
2288   application.SendNotification();
2289   application.Render();
2290
2291   float localX;
2292   float localY;
2293
2294   application.SendNotification();
2295   application.Render();
2296
2297   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2298
2299   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2300   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2301   END_TEST;
2302 }
2303
2304 int UtcDaliActorSetLeaveRequired(void)
2305 {
2306   TestApplication application;
2307
2308   Actor actor = Actor::New();
2309
2310   actor.SetLeaveRequired(false);
2311   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2312
2313   actor.SetLeaveRequired(true);
2314   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2315   END_TEST;
2316 }
2317
2318 int UtcDaliActorGetLeaveRequired(void)
2319 {
2320   TestApplication application;
2321
2322   Actor actor = Actor::New();
2323
2324   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2325   END_TEST;
2326 }
2327
2328 int UtcDaliActorSetKeyboardFocusable(void)
2329 {
2330   TestApplication application;
2331
2332   Actor actor = Actor::New();
2333
2334   actor.SetKeyboardFocusable(true);
2335   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2336
2337   actor.SetKeyboardFocusable(false);
2338   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2339   END_TEST;
2340 }
2341
2342 int UtcDaliActorIsKeyboardFocusable(void)
2343 {
2344   TestApplication application;
2345
2346   Actor actor = Actor::New();
2347
2348   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2349   END_TEST;
2350 }
2351
2352 int UtcDaliActorRemoveConstraints(void)
2353 {
2354   tet_infoline(" UtcDaliActorRemoveConstraints");
2355   TestApplication application;
2356
2357   gTestConstraintCalled = false;
2358
2359   Actor actor = Actor::New();
2360
2361   Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2362   constraint.Apply();
2363   actor.RemoveConstraints();
2364
2365   DALI_TEST_CHECK( gTestConstraintCalled == false );
2366
2367   Stage::GetCurrent().Add( actor );
2368   constraint.Apply();
2369
2370   // flush the queue and render once
2371   application.SendNotification();
2372   application.Render();
2373
2374   actor.RemoveConstraints();
2375
2376   DALI_TEST_CHECK( gTestConstraintCalled == true );
2377   END_TEST;
2378 }
2379
2380 int UtcDaliActorRemoveConstraintTag(void)
2381 {
2382   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2383   TestApplication application;
2384
2385   Actor actor = Actor::New();
2386
2387   // 1. Apply Constraint1 and Constraint2, and test...
2388   unsigned int result1 = 0u;
2389   unsigned int result2 = 0u;
2390
2391   unsigned constraint1Tag = 1u;
2392   Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2393   constraint1.SetTag( constraint1Tag );
2394   constraint1.Apply();
2395
2396   unsigned constraint2Tag = 2u;
2397   Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2398   constraint2.SetTag( constraint2Tag );
2399   constraint2.Apply();
2400
2401   Stage::GetCurrent().Add( actor );
2402   // flush the queue and render once
2403   application.SendNotification();
2404   application.Render();
2405
2406   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2407   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2408
2409   // 2. Remove Constraint1 and test...
2410   result1 = 0;
2411   result2 = 0;
2412   actor.RemoveConstraints(constraint1Tag);
2413   // make color property dirty, which will trigger constraints to be reapplied.
2414   actor.SetColor( Color::WHITE );
2415   // flush the queue and render once
2416   application.SendNotification();
2417   application.Render();
2418
2419   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2420   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2421
2422   // 3. Re-Apply Constraint1 and test...
2423   result1 = 0;
2424   result2 = 0;
2425   constraint1.Apply();
2426   // make color property dirty, which will trigger constraints to be reapplied.
2427   actor.SetColor( Color::WHITE );
2428   // flush the queue and render once
2429   application.SendNotification();
2430   application.Render();
2431
2432   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2433   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2434
2435   // 2. Remove Constraint2 and test...
2436   result1 = 0;
2437   result2 = 0;
2438   actor.RemoveConstraints(constraint2Tag);
2439   // make color property dirty, which will trigger constraints to be reapplied.
2440   actor.SetColor( Color::WHITE );
2441   // flush the queue and render once
2442   application.SendNotification();
2443   application.Render();
2444
2445   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2446   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2447
2448   // 2. Remove Constraint1 as well and test...
2449   result1 = 0;
2450   result2 = 0;
2451   actor.RemoveConstraints(constraint1Tag);
2452   // make color property dirty, which will trigger constraints to be reapplied.
2453   actor.SetColor( Color::WHITE );
2454   // flush the queue and render once
2455   application.SendNotification();
2456   application.Render();
2457
2458   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2459   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2460   END_TEST;
2461 }
2462
2463 int UtcDaliActorTouchedSignal(void)
2464 {
2465   TestApplication application;
2466
2467   ResetTouchCallbacks();
2468
2469   // get the root layer
2470   Actor actor = Stage::GetCurrent().GetRootLayer();
2471   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2472
2473   application.SendNotification();
2474   application.Render();
2475
2476   // connect to its touch signal
2477   actor.TouchedSignal().Connect( TestCallback );
2478
2479   // simulate a touch event in the middle of the screen
2480   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2481   Dali::Integration::Point point;
2482   point.SetDeviceId( 1 );
2483   point.SetState( PointState::DOWN );
2484   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2485   Dali::Integration::TouchEvent touchEvent;
2486   touchEvent.AddPoint( point );
2487   application.ProcessEvent( touchEvent );
2488
2489   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2490   END_TEST;
2491 }
2492
2493 int UtcDaliActorHoveredSignal(void)
2494 {
2495   TestApplication application;
2496
2497   gHoverCallBackCalled = false;
2498
2499   // get the root layer
2500   Actor actor = Stage::GetCurrent().GetRootLayer();
2501   DALI_TEST_CHECK( gHoverCallBackCalled == false );
2502
2503   application.SendNotification();
2504   application.Render();
2505
2506   // connect to its hover signal
2507   actor.HoveredSignal().Connect( TestCallback3 );
2508
2509   // simulate a hover event in the middle of the screen
2510   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2511   Dali::Integration::Point point;
2512   point.SetDeviceId( 1 );
2513   point.SetState( PointState::MOTION );
2514   point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2515   Dali::Integration::HoverEvent hoverEvent;
2516   hoverEvent.AddPoint( point );
2517   application.ProcessEvent( hoverEvent );
2518
2519   DALI_TEST_CHECK( gHoverCallBackCalled == true );
2520   END_TEST;
2521 }
2522
2523 int UtcDaliActorOnOffStageSignal(void)
2524 {
2525   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2526
2527   TestApplication application;
2528
2529   // clean test data
2530   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2531   gActorNamesOnOffStage.clear();
2532
2533   Actor parent = Actor::New();
2534   parent.SetName( "parent" );
2535   parent.OnStageSignal().Connect( OnStageCallback );
2536   parent.OffStageSignal().Connect( OffStageCallback );
2537   // sanity check
2538   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2539   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2540
2541   // add parent to stage
2542   Stage::GetCurrent().Add( parent );
2543   // onstage emitted, offstage not
2544   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2545   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2546   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2547
2548   // test adding a child, should get onstage emitted
2549   // clean test data
2550   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2551   gActorNamesOnOffStage.clear();
2552
2553   Actor child = Actor::New();
2554   child.SetName( "child" );
2555   child.OnStageSignal().Connect( OnStageCallback );
2556   child.OffStageSignal().Connect( OffStageCallback );
2557   parent.Add( child ); // add child
2558   // onstage emitted, offstage not
2559   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2560   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2561   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2562
2563   // test removing parent from stage
2564   // clean test data
2565   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2566   gActorNamesOnOffStage.clear();
2567
2568   Stage::GetCurrent().Remove( parent );
2569   // onstage not emitted, offstage is
2570   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2571   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2572   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2573   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2574
2575   // test adding parent back to stage
2576   // clean test data
2577   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2578   gActorNamesOnOffStage.clear();
2579
2580   Stage::GetCurrent().Add( parent );
2581   // onstage emitted, offstage not
2582   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2583   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2584   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2585   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2586
2587   // test removing child
2588   // clean test data
2589   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2590   gActorNamesOnOffStage.clear();
2591
2592   parent.Remove( child );
2593   // onstage not emitted, offstage is
2594   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2595   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2596   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2597
2598   // test removing parent
2599   // clean test data
2600   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2601   gActorNamesOnOffStage.clear();
2602
2603   Stage::GetCurrent().Remove( parent );
2604   // onstage not emitted, offstage is
2605   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2606   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2607   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2608   END_TEST;
2609 }
2610
2611 int UtcDaliActorFindChildByName(void)
2612 {
2613   tet_infoline("Testing Dali::Actor::FindChildByName()");
2614   TestApplication application;
2615
2616   Actor parent = Actor::New();
2617   parent.SetName( "parent" );
2618   Actor first  = Actor::New();
2619   first .SetName( "first" );
2620   Actor second = Actor::New();
2621   second.SetName( "second" );
2622
2623   parent.Add(first);
2624   first.Add(second);
2625
2626   Actor found = parent.FindChildByName( "foo" );
2627   DALI_TEST_CHECK( !found );
2628
2629   found = parent.FindChildByName( "parent" );
2630   DALI_TEST_CHECK( found == parent );
2631
2632   found = parent.FindChildByName( "first" );
2633   DALI_TEST_CHECK( found == first );
2634
2635   found = parent.FindChildByName( "second" );
2636   DALI_TEST_CHECK( found == second );
2637   END_TEST;
2638 }
2639
2640 int UtcDaliActorFindChildById(void)
2641 {
2642   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2643   TestApplication application;
2644
2645   Actor parent = Actor::New();
2646   Actor first  = Actor::New();
2647   Actor second = Actor::New();
2648
2649   parent.Add(first);
2650   first.Add(second);
2651
2652   Actor found = parent.FindChildById( 100000 );
2653   DALI_TEST_CHECK( !found );
2654
2655   found = parent.FindChildById( parent.GetId() );
2656   DALI_TEST_CHECK( found == parent );
2657
2658   found = parent.FindChildById( first.GetId() );
2659   DALI_TEST_CHECK( found == first );
2660
2661   found = parent.FindChildById( second.GetId() );
2662   DALI_TEST_CHECK( found == second );
2663   END_TEST;
2664 }
2665
2666 int UtcDaliActorHitTest(void)
2667 {
2668   struct HitTestData
2669   {
2670   public:
2671     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2672     : mScale( scale ),
2673       mTouchPoint( touchPoint ),
2674       mResult( result )
2675     {}
2676
2677     Vector3 mScale;
2678     Vector2 mTouchPoint;
2679     bool mResult;
2680   };
2681
2682   TestApplication application;
2683   tet_infoline(" UtcDaliActorHitTest");
2684
2685   // Fill a vector with different hit tests.
2686   struct HitTestData* hitTestData[] = {
2687     //                    scale                     touch point           result
2688     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2689     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2690     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.
2691     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2692     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.
2693     NULL,
2694   };
2695
2696   // get the root layer
2697   Actor actor = Actor::New();
2698   actor.SetAnchorPoint( AnchorPoint::CENTER );
2699   actor.SetParentOrigin( ParentOrigin::CENTER );
2700
2701   Stage::GetCurrent().Add( actor );
2702
2703   ResetTouchCallbacks();
2704
2705   unsigned int index = 0;
2706   while( NULL != hitTestData[index] )
2707   {
2708     actor.SetSize( 1.f, 1.f );
2709     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2710
2711     // flush the queue and render once
2712     application.SendNotification();
2713     application.Render();
2714
2715     DALI_TEST_CHECK( !gTouchCallBackCalled );
2716
2717     // connect to its touch signal
2718     actor.TouchedSignal().Connect(TestCallback);
2719
2720     Dali::Integration::Point point;
2721     point.SetState( PointState::DOWN );
2722     point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2723     Dali::Integration::TouchEvent event;
2724     event.AddPoint( point );
2725
2726     // flush the queue and render once
2727     application.SendNotification();
2728     application.Render();
2729     application.ProcessEvent( event );
2730
2731     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2732
2733     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2734       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2735                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2736                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2737                  hitTestData[index]->mResult );
2738
2739     ResetTouchCallbacks();
2740     ++index;
2741   }
2742   END_TEST;
2743 }
2744
2745 int UtcDaliActorSetDrawMode(void)
2746 {
2747   TestApplication app;
2748   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2749
2750   Actor a = Actor::New();
2751
2752   Stage::GetCurrent().Add(a);
2753   app.SendNotification();
2754   app.Render(0);
2755   app.SendNotification();
2756   app.Render(1);
2757
2758   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2759
2760   a.SetDrawMode( DrawMode::OVERLAY_2D );
2761   app.SendNotification();
2762   app.Render(1);
2763
2764   DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2765
2766   a.SetDrawMode( DrawMode::NORMAL );
2767   app.SendNotification();
2768   app.Render(1);
2769
2770   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2771   END_TEST;
2772 }
2773
2774 int UtcDaliActorSetDrawModeOverlayRender(void)
2775 {
2776   TestApplication app;
2777   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2778
2779   app.SendNotification();
2780   app.Render(1);
2781
2782   std::vector<GLuint> ids;
2783   ids.push_back( 8 );   // first rendered actor
2784   ids.push_back( 9 );   // second rendered actor
2785   ids.push_back( 10 );  // third rendered actor
2786   app.GetGlAbstraction().SetNextTextureIds( ids );
2787
2788   BufferImage imageA = BufferImage::New(16, 16);
2789   BufferImage imageB = BufferImage::New(16, 16);
2790   BufferImage imageC = BufferImage::New(16, 16);
2791   Actor a = CreateRenderableActor( imageA );
2792   Actor b = CreateRenderableActor( imageB );
2793   Actor c = CreateRenderableActor( imageC );
2794
2795   app.SendNotification();
2796   app.Render(1);
2797
2798   //Textures are bound when first created. Clear bound textures vector
2799   app.GetGlAbstraction().ClearBoundTextures();
2800
2801   // Render a,b,c as regular non-overlays. so order will be:
2802   // a (8)
2803   // b (9)
2804   // c (10)
2805   Stage::GetCurrent().Add(a);
2806   Stage::GetCurrent().Add(b);
2807   Stage::GetCurrent().Add(c);
2808
2809   app.SendNotification();
2810   app.Render(1);
2811
2812   // Should be 3 textures changes.
2813   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2814   typedef std::vector<GLuint>::size_type TextureSize;
2815   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2816   if( boundTextures.size() == 3 )
2817   {
2818     DALI_TEST_CHECK( boundTextures[0] == 8u );
2819     DALI_TEST_CHECK( boundTextures[1] == 9u );
2820     DALI_TEST_CHECK( boundTextures[2] == 10u );
2821   }
2822
2823   // Now texture ids have been set, we can monitor their render order.
2824   // render a as an overlay (last), so order will be:
2825   // b (9)
2826   // c (10)
2827   // a (8)
2828   a.SetDrawMode( DrawMode::OVERLAY_2D );
2829   app.GetGlAbstraction().ClearBoundTextures();
2830
2831   app.SendNotification();
2832   app.Render(1);
2833
2834   // Should be 3 texture changes.
2835   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2836   if( boundTextures.size() == 3 )
2837   {
2838     DALI_TEST_CHECK( boundTextures[0] == 9u );
2839     DALI_TEST_CHECK( boundTextures[1] == 10u );
2840     DALI_TEST_CHECK( boundTextures[2] == 8u );
2841   }
2842   END_TEST;
2843 }
2844
2845 int UtcDaliActorGetCurrentWorldMatrix(void)
2846 {
2847   TestApplication app;
2848   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2849
2850   Actor parent = Actor::New();
2851   parent.SetParentOrigin(ParentOrigin::CENTER);
2852   parent.SetAnchorPoint(AnchorPoint::CENTER);
2853   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2854   Radian rotationAngle(Degree(85.0f));
2855   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2856   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2857   parent.SetPosition( parentPosition );
2858   parent.SetOrientation( parentRotation );
2859   parent.SetScale( parentScale );
2860   Stage::GetCurrent().Add( parent );
2861
2862   Actor child = Actor::New();
2863   child.SetParentOrigin(ParentOrigin::CENTER);
2864   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2865   Radian childRotationAngle(Degree(23.0f));
2866   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2867   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2868   child.SetPosition( childPosition );
2869   child.SetOrientation( childRotation );
2870   child.SetScale( childScale );
2871   parent.Add( child );
2872
2873   app.SendNotification();
2874   app.Render(0);
2875   app.Render();
2876   app.SendNotification();
2877
2878   Matrix parentMatrix(false);
2879   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2880
2881   Matrix childMatrix(false);
2882   childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2883
2884   //Child matrix should be the composition of child and parent
2885   Matrix childWorldMatrix(false);
2886   Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2887
2888   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2889   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2890   END_TEST;
2891 }
2892
2893
2894
2895 int UtcDaliActorConstrainedToWorldMatrix(void)
2896 {
2897   TestApplication app;
2898   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2899
2900   Actor parent = Actor::New();
2901   parent.SetParentOrigin(ParentOrigin::CENTER);
2902   parent.SetAnchorPoint(AnchorPoint::CENTER);
2903   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2904   Radian rotationAngle(Degree(85.0f));
2905   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2906   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2907   parent.SetPosition( parentPosition );
2908   parent.SetOrientation( parentRotation );
2909   parent.SetScale( parentScale );
2910   Stage::GetCurrent().Add( parent );
2911
2912   Actor child = Actor::New();
2913   child.SetParentOrigin(ParentOrigin::CENTER);
2914   Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2915   posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2916   posConstraint.Apply();
2917
2918   Stage::GetCurrent().Add( child );
2919
2920   app.SendNotification();
2921   app.Render(0);
2922   app.Render();
2923   app.SendNotification();
2924
2925   Matrix parentMatrix(false);
2926   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2927
2928   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2929   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2930   END_TEST;
2931 }
2932
2933 int UtcDaliActorConstrainedToOrientation(void)
2934 {
2935   TestApplication app;
2936   tet_infoline(" UtcDaliActorConstrainedToOrientation");
2937
2938   Actor parent = Actor::New();
2939   parent.SetParentOrigin(ParentOrigin::CENTER);
2940   parent.SetAnchorPoint(AnchorPoint::CENTER);
2941   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2942   Radian rotationAngle(Degree(85.0f));
2943   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2944   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2945   parent.SetPosition( parentPosition );
2946   parent.SetOrientation( parentRotation );
2947   parent.SetScale( parentScale );
2948   Stage::GetCurrent().Add( parent );
2949
2950   Actor child = Actor::New();
2951   child.SetParentOrigin(ParentOrigin::CENTER);
2952   Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2953   posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2954   posConstraint.Apply();
2955
2956   Stage::GetCurrent().Add( child );
2957
2958   app.SendNotification();
2959   app.Render(0);
2960   app.Render();
2961   app.SendNotification();
2962
2963   DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2964   END_TEST;
2965 }
2966
2967 int UtcDaliActorConstrainedToOpacity(void)
2968 {
2969   TestApplication app;
2970   tet_infoline(" UtcDaliActorConstrainedToOpacity");
2971
2972   Actor parent = Actor::New();
2973   parent.SetOpacity( 0.7f );
2974   Stage::GetCurrent().Add( parent );
2975
2976   Actor child = Actor::New();
2977   Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2978   opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2979   opacityConstraint.Apply();
2980
2981   Stage::GetCurrent().Add( child );
2982
2983   app.SendNotification();
2984   app.Render(0);
2985   app.Render();
2986   app.SendNotification();
2987
2988   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2989
2990   parent.SetOpacity( 0.3f );
2991
2992   app.SendNotification();
2993   app.Render(0);
2994   app.Render();
2995   app.SendNotification();
2996
2997   DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2998
2999   END_TEST;
3000 }
3001
3002 int UtcDaliActorUnparent(void)
3003 {
3004   TestApplication app;
3005   tet_infoline(" UtcDaliActorUnparent");
3006
3007   Actor parent = Actor::New();
3008   Stage::GetCurrent().Add( parent );
3009
3010   Actor child = Actor::New();
3011
3012   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3013   DALI_TEST_CHECK( !child.GetParent() );
3014
3015   // Test that calling Unparent with no parent is a NOOP
3016   child.Unparent();
3017
3018   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3019   DALI_TEST_CHECK( !child.GetParent() );
3020
3021   // Test that Unparent works
3022   parent.Add( child );
3023
3024   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3025   DALI_TEST_CHECK( parent == child.GetParent() );
3026
3027   child.Unparent();
3028
3029   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3030   DALI_TEST_CHECK( !child.GetParent() );
3031
3032   // Test that UnparentAndReset works
3033   parent.Add( child );
3034
3035   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3036   DALI_TEST_CHECK( parent == child.GetParent() );
3037
3038   UnparentAndReset( child );
3039
3040   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3041   DALI_TEST_CHECK( !child );
3042
3043   // Test that UnparentAndReset is a NOOP with empty handle
3044   UnparentAndReset( child );
3045
3046   DALI_TEST_CHECK( !child );
3047   END_TEST;
3048 }
3049
3050 int UtcDaliActorGetChildAt(void)
3051 {
3052   TestApplication app;
3053   tet_infoline(" UtcDaliActorGetChildAt");
3054
3055   Actor parent = Actor::New();
3056   Stage::GetCurrent().Add( parent );
3057
3058   Actor child0 = Actor::New();
3059   parent.Add( child0 );
3060
3061   Actor child1 = Actor::New();
3062   parent.Add( child1 );
3063
3064   Actor child2 = Actor::New();
3065   parent.Add( child2 );
3066
3067   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3068   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3069   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3070   END_TEST;
3071 }
3072
3073 int UtcDaliActorSetGetOverlay(void)
3074 {
3075   TestApplication app;
3076   tet_infoline(" UtcDaliActorSetGetOverlay");
3077
3078   Actor parent = Actor::New();
3079   parent.SetDrawMode(DrawMode::OVERLAY_2D );
3080   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3081   END_TEST;
3082 }
3083
3084
3085 int UtcDaliActorCreateDestroy(void)
3086 {
3087   Actor* actor = new Actor;
3088   DALI_TEST_CHECK( actor );
3089   delete actor;
3090   END_TEST;
3091 }
3092
3093 namespace
3094 {
3095 struct PropertyStringIndex
3096 {
3097   const char * const name;
3098   const Property::Index index;
3099   const Property::Type type;
3100 };
3101
3102 const PropertyStringIndex PROPERTY_TABLE[] =
3103 {
3104   { "parentOrigin",             Actor::Property::PARENT_ORIGIN,            Property::VECTOR3     },
3105   { "parentOriginX",            Actor::Property::PARENT_ORIGIN_X,          Property::FLOAT       },
3106   { "parentOriginY",            Actor::Property::PARENT_ORIGIN_Y,          Property::FLOAT       },
3107   { "parentOriginZ",            Actor::Property::PARENT_ORIGIN_Z,          Property::FLOAT       },
3108   { "anchorPoint",              Actor::Property::ANCHOR_POINT,             Property::VECTOR3     },
3109   { "anchorPointX",             Actor::Property::ANCHOR_POINT_X,           Property::FLOAT       },
3110   { "anchorPointY",             Actor::Property::ANCHOR_POINT_Y,           Property::FLOAT       },
3111   { "anchorPointZ",             Actor::Property::ANCHOR_POINT_Z,           Property::FLOAT       },
3112   { "size",                     Actor::Property::SIZE,                     Property::VECTOR3     },
3113   { "sizeWidth",                Actor::Property::SIZE_WIDTH,               Property::FLOAT       },
3114   { "sizeHeight",               Actor::Property::SIZE_HEIGHT,              Property::FLOAT       },
3115   { "sizeDepth",                Actor::Property::SIZE_DEPTH,               Property::FLOAT       },
3116   { "position",                 Actor::Property::POSITION,                 Property::VECTOR3     },
3117   { "positionX",                Actor::Property::POSITION_X,               Property::FLOAT       },
3118   { "positionY",                Actor::Property::POSITION_Y,               Property::FLOAT       },
3119   { "positionZ",                Actor::Property::POSITION_Z,               Property::FLOAT       },
3120   { "worldPosition",            Actor::Property::WORLD_POSITION,           Property::VECTOR3     },
3121   { "worldPositionX",           Actor::Property::WORLD_POSITION_X,         Property::FLOAT       },
3122   { "worldPositionY",           Actor::Property::WORLD_POSITION_Y,         Property::FLOAT       },
3123   { "worldPositionZ",           Actor::Property::WORLD_POSITION_Z,         Property::FLOAT       },
3124   { "orientation",              Actor::Property::ORIENTATION,              Property::ROTATION    },
3125   { "worldOrientation",         Actor::Property::WORLD_ORIENTATION,        Property::ROTATION    },
3126   { "scale",                    Actor::Property::SCALE,                    Property::VECTOR3     },
3127   { "scaleX",                   Actor::Property::SCALE_X,                  Property::FLOAT       },
3128   { "scaleY",                   Actor::Property::SCALE_Y,                  Property::FLOAT       },
3129   { "scaleZ",                   Actor::Property::SCALE_Z,                  Property::FLOAT       },
3130   { "worldScale",               Actor::Property::WORLD_SCALE,              Property::VECTOR3     },
3131   { "visible",                  Actor::Property::VISIBLE,                  Property::BOOLEAN     },
3132   { "color",                    Actor::Property::COLOR,                    Property::VECTOR4     },
3133   { "colorRed",                 Actor::Property::COLOR_RED,                Property::FLOAT       },
3134   { "colorGreen",               Actor::Property::COLOR_GREEN,              Property::FLOAT       },
3135   { "colorBlue",                Actor::Property::COLOR_BLUE,               Property::FLOAT       },
3136   { "colorAlpha",               Actor::Property::COLOR_ALPHA,              Property::FLOAT       },
3137   { "worldColor",               Actor::Property::WORLD_COLOR,              Property::VECTOR4     },
3138   { "worldMatrix",              Actor::Property::WORLD_MATRIX,             Property::MATRIX      },
3139   { "name",                     Actor::Property::NAME,                     Property::STRING      },
3140   { "sensitive",                Actor::Property::SENSITIVE,                Property::BOOLEAN     },
3141   { "leaveRequired",            Actor::Property::LEAVE_REQUIRED,           Property::BOOLEAN     },
3142   { "inheritOrientation",       Actor::Property::INHERIT_ORIENTATION,      Property::BOOLEAN     },
3143   { "inheritScale",             Actor::Property::INHERIT_SCALE,            Property::BOOLEAN     },
3144   { "colorMode",                Actor::Property::COLOR_MODE,               Property::STRING      },
3145   { "positionInheritance",      Actor::Property::POSITION_INHERITANCE,     Property::STRING      },
3146   { "drawMode",                 Actor::Property::DRAW_MODE,                Property::STRING      },
3147   { "sizeModeFactor",           Actor::Property::SIZE_MODE_FACTOR,         Property::VECTOR3     },
3148   { "widthResizePolicy",        Actor::Property::WIDTH_RESIZE_POLICY,      Property::STRING      },
3149   { "heightResizePolicy",       Actor::Property::HEIGHT_RESIZE_POLICY,     Property::STRING      },
3150   { "sizeScalePolicy",          Actor::Property::SIZE_SCALE_POLICY,        Property::STRING      },
3151   { "widthForHeight",           Actor::Property::WIDTH_FOR_HEIGHT,         Property::BOOLEAN     },
3152   { "heightForWidth",           Actor::Property::HEIGHT_FOR_WIDTH,         Property::BOOLEAN     },
3153   { "padding",                  Actor::Property::PADDING,                  Property::VECTOR4     },
3154   { "minimumSize",              Actor::Property::MINIMUM_SIZE,             Property::VECTOR2     },
3155   { "maximumSize",              Actor::Property::MAXIMUM_SIZE,             Property::VECTOR2     },
3156   { "inheritPosition",          Actor::Property::INHERIT_POSITION,         Property::BOOLEAN     },
3157   { "clippingMode",             Actor::Property::CLIPPING_MODE,            Property::STRING      },
3158   { "opacity",                  DevelActor::Property::OPACITY,             Property::FLOAT       },
3159 };
3160 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3161 } // unnamed namespace
3162
3163 int UtcDaliActorProperties(void)
3164 {
3165   TestApplication app;
3166
3167   Actor actor = Actor::New();
3168
3169   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3170   {
3171     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3172     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3173     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3174     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3175   }
3176   END_TEST;
3177 }
3178
3179 int UtcDaliRelayoutProperties_ResizePolicies(void)
3180 {
3181   TestApplication app;
3182
3183   Actor actor = Actor::New();
3184
3185   // Defaults
3186   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3187   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3188
3189   // Set resize policy for all dimensions
3190   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3191   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3192   {
3193     DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3194   }
3195
3196   // Set individual dimensions
3197   const char* const widthPolicy = "FILL_TO_PARENT";
3198   const char* const heightPolicy = "FIXED";
3199
3200   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3201   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3202
3203   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3204   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3205
3206   // Set individual dimensions using enums
3207   ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3208   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3209
3210   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3211   actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3212
3213   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3214   DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3215
3216   END_TEST;
3217 }
3218
3219 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3220 {
3221   TestApplication app;
3222
3223   Actor actor = Actor::New();
3224
3225   // Defaults
3226   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3227   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3228
3229   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3230   actor.SetSizeScalePolicy( policy );
3231   DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3232
3233   // Set
3234   const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3235   const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3236
3237   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3238   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3239
3240   actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3241   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3242
3243   END_TEST;
3244 }
3245
3246 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3247 {
3248   TestApplication app;
3249
3250   Actor actor = Actor::New();
3251
3252   // Defaults
3253   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3254   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3255
3256   Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3257   actor.SetSizeModeFactor( sizeMode );
3258   DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3259
3260   // Set
3261   Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3262
3263   actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3264   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3265
3266   END_TEST;
3267 }
3268
3269 int UtcDaliRelayoutProperties_DimensionDependency(void)
3270 {
3271   TestApplication app;
3272
3273   Actor actor = Actor::New();
3274
3275   // Defaults
3276   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3277   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3278
3279   // Set
3280   actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3281   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3282
3283   actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3284   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3285
3286   // Test setting another resize policy
3287   actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3288   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3289
3290   END_TEST;
3291 }
3292
3293 int UtcDaliRelayoutProperties_Padding(void)
3294 {
3295   TestApplication app;
3296
3297   Actor actor = Actor::New();
3298
3299   // Data
3300   Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3301
3302   // PADDING
3303   actor.SetProperty( Actor::Property::PADDING, padding );
3304   Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3305
3306   DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3307
3308   END_TEST;
3309 }
3310
3311 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3312 {
3313   TestApplication app;
3314
3315   Actor actor = Actor::New();
3316
3317   // Data
3318   Vector2 minSize( 1.0f, 2.0f );
3319
3320   actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3321   Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3322
3323   DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3324
3325   Vector2 maxSize( 3.0f, 4.0f );
3326
3327   actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3328   Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3329
3330   DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3331
3332   END_TEST;
3333 }
3334
3335 int UtcDaliActorGetHeightForWidth(void)
3336 {
3337   TestApplication app;
3338
3339   Actor actor = Actor::New();
3340
3341   DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3342
3343   END_TEST;
3344 }
3345
3346 int UtcDaliActorGetWidthForHeight(void)
3347 {
3348   TestApplication app;
3349
3350   Actor actor = Actor::New();
3351
3352   DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3353
3354   END_TEST;
3355 }
3356
3357 int UtcDaliActorGetRelayoutSize(void)
3358 {
3359   TestApplication app;
3360
3361   Actor actor = Actor::New();
3362
3363   // Add actor to stage
3364   Stage::GetCurrent().Add( actor );
3365
3366   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3367
3368   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3369   actor.SetSize( Vector2( 1.0f, 0.0f ) );
3370
3371   // Flush the queue and render once
3372   app.SendNotification();
3373   app.Render();
3374
3375   DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3376
3377   END_TEST;
3378 }
3379
3380 int UtcDaliActorSetPadding(void)
3381 {
3382   TestApplication app;
3383
3384   Actor actor = Actor::New();
3385
3386   Padding padding;
3387   actor.GetPadding( padding );
3388
3389   DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3390   DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3391   DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3392   DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3393
3394   Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3395   actor.SetPadding( padding2 );
3396
3397   actor.GetPadding( padding );
3398
3399   DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3400   DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3401   DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3402   DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3403
3404   END_TEST;
3405 }
3406
3407 int UtcDaliActorSetMinimumSize(void)
3408 {
3409   TestApplication app;
3410
3411   Actor actor = Actor::New();
3412
3413   Vector2 size = actor.GetMinimumSize();
3414
3415   DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3416   DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3417
3418   Vector2 size2( 1.0f, 2.0f );
3419   actor.SetMinimumSize( size2 );
3420
3421   size = actor.GetMinimumSize();
3422
3423   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3424   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3425
3426   END_TEST;
3427 }
3428
3429 int UtcDaliActorSetMaximumSize(void)
3430 {
3431   TestApplication app;
3432
3433   Actor actor = Actor::New();
3434
3435   Vector2 size = actor.GetMaximumSize();
3436
3437   DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3438   DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3439
3440   Vector2 size2( 1.0f, 2.0f );
3441   actor.SetMaximumSize( size2 );
3442
3443   size = actor.GetMaximumSize();
3444
3445   DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3446   DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3447
3448   END_TEST;
3449 }
3450
3451 int UtcDaliActorOnRelayoutSignal(void)
3452 {
3453   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3454
3455   TestApplication application;
3456
3457   // Clean test data
3458   gOnRelayoutCallBackCalled = false;
3459   gActorNamesRelayout.clear();
3460
3461   Actor actor = Actor::New();
3462   actor.SetName( "actor" );
3463   actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3464
3465   // Sanity check
3466   DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3467
3468   // Add actor to stage
3469   Stage::GetCurrent().Add( actor );
3470
3471   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3472   actor.SetSize( Vector2( 1.0f, 2.0 ) );
3473
3474   // Flush the queue and render once
3475   application.SendNotification();
3476   application.Render();
3477
3478   // OnRelayout emitted
3479   DALI_TEST_EQUALS(  gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3480   DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3481
3482   END_TEST;
3483 }
3484
3485 int UtcDaliActorGetHierachyDepth(void)
3486 {
3487   TestApplication application;
3488   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3489
3490
3491   /* Build tree of actors:
3492    *
3493    *                      Depth
3494    *
3495    *       A (parent)       1
3496    *      / \
3497    *     B   C              2`
3498    *    / \   \
3499    *   D   E   F            3
3500    *
3501    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3502    */
3503   Stage stage( Stage::GetCurrent() );
3504
3505   Actor actorA = Actor::New();
3506   Actor actorB = Actor::New();
3507   Actor actorC = Actor::New();
3508   Actor actorD = Actor::New();
3509   Actor actorE = Actor::New();
3510   Actor actorF = Actor::New();
3511
3512   //Test that root actor has depth equal 0
3513   DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3514
3515   //Test actors return depth -1 when not connected to the tree
3516   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3517   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3518   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3519   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3520   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3521   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3522
3523   //Create the hierarchy
3524   stage.Add( actorA );
3525   actorA.Add( actorB );
3526   actorA.Add( actorC );
3527   actorB.Add( actorD );
3528   actorB.Add( actorE );
3529   actorC.Add( actorF );
3530
3531   //Test actors return correct depth
3532   DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3533   DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3534   DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3535   DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3536   DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3537   DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3538
3539   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3540   actorA.Remove( actorB );
3541
3542   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3543   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3544   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3545
3546   //Removing actorA from the stage. All actors should have depth equal -1
3547   stage.Remove( actorA );
3548
3549   DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3550   DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3551   DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3552   DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3553   DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3554   DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3555
3556   END_TEST;
3557 }
3558
3559 int UtcDaliActorAnchorPointPropertyAsString(void)
3560 {
3561   TestApplication application;
3562
3563   Actor actor = Actor::New();
3564
3565   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3566   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3567
3568   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3569   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3570
3571   actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3572   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3573
3574   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3575   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3576
3577   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3578   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3579
3580   actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3581   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3582
3583   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3584   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3585
3586   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3587   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3588
3589   actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3590   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3591
3592   // Invalid should not change anything
3593   actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3594   DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3595
3596   END_TEST;
3597 }
3598
3599 int UtcDaliActorParentOriginPropertyAsString(void)
3600 {
3601   TestApplication application;
3602
3603   Actor actor = Actor::New();
3604
3605   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3606   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3607
3608   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3609   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3610
3611   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3612   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3613
3614   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3615   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3616
3617   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3618   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3619
3620   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3621   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3622
3623   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3624   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3625
3626   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3627   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3628
3629   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3630   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3631
3632   // Invalid should not change anything
3633   actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3634   DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3635
3636   END_TEST;
3637 }
3638
3639 int UtcDaliActorColorModePropertyAsString(void)
3640 {
3641   TestApplication application;
3642
3643   Actor actor = Actor::New();
3644
3645   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3646   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3647
3648   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3649   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3650
3651   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3652   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3653
3654   actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3655   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3656
3657   // Invalid should not change anything
3658   actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3659   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3660
3661   END_TEST;
3662 }
3663
3664 int UtcDaliActorPositionInheritancePropertyAsString(void)
3665 {
3666   TestApplication application;
3667
3668   Actor actor = Actor::New();
3669
3670   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3671   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3672
3673   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3674   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3675
3676   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3677   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3678
3679   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3680   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3681
3682   // Invalid should not change anything
3683   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3684   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3685
3686   END_TEST;
3687 }
3688
3689 int UtcDaliActorDrawModePropertyAsString(void)
3690 {
3691   TestApplication application;
3692
3693   Actor actor = Actor::New();
3694
3695   actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3696   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3697
3698   actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3699   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3700
3701   actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3702   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3703
3704   // Invalid should not change anything
3705   actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3706   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3707
3708   END_TEST;
3709 }
3710
3711 int UtcDaliActorColorModePropertyAsEnum(void)
3712 {
3713   TestApplication application;
3714
3715   Actor actor = Actor::New();
3716
3717   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3718   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3719
3720   actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3721   DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3722
3723   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3724   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3725
3726   actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3727   DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3728
3729   END_TEST;
3730 }
3731
3732 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3733 {
3734   TestApplication application;
3735
3736   Actor actor = Actor::New();
3737
3738   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3739   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3740
3741   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3742   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3743
3744   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3745   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3746
3747   actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3748   DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3749
3750   END_TEST;
3751 }
3752
3753 int UtcDaliActorDrawModePropertyAsEnum(void)
3754 {
3755   TestApplication application;
3756
3757   Actor actor = Actor::New();
3758
3759   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3760   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3761
3762   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3763   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3764
3765   actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3766   DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3767
3768   END_TEST;
3769 }
3770
3771 int UtcDaliActorAddRendererP(void)
3772 {
3773   tet_infoline("Testing Actor::AddRenderer");
3774   TestApplication application;
3775
3776   Actor actor = Actor::New();
3777
3778   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3779
3780   Geometry geometry = CreateQuadGeometry();
3781   Shader shader = CreateShader();
3782   Renderer renderer = Renderer::New(geometry, shader);
3783
3784   actor.AddRenderer( renderer );
3785   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3786   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3787
3788   END_TEST;
3789 }
3790
3791 int UtcDaliActorAddRendererN(void)
3792 {
3793   tet_infoline("Testing Actor::AddRenderer");
3794   TestApplication application;
3795
3796   Actor actor = Actor::New();
3797   Renderer renderer;
3798
3799   // try illegal Add
3800   try
3801   {
3802     actor.AddRenderer( renderer );
3803     tet_printf("Assertion test failed - no Exception\n" );
3804     tet_result(TET_FAIL);
3805   }
3806   catch(Dali::DaliException& e)
3807   {
3808     DALI_TEST_PRINT_ASSERT( e );
3809     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3810     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3811   }
3812   catch(...)
3813   {
3814     tet_printf("Assertion test failed - wrong Exception\n" );
3815     tet_result(TET_FAIL);
3816   }
3817
3818   END_TEST;
3819 }
3820
3821 int UtcDaliActorAddRendererOnStage(void)
3822 {
3823   tet_infoline("Testing Actor::AddRenderer");
3824   TestApplication application;
3825
3826   Actor actor = Actor::New();
3827   Stage::GetCurrent().Add(actor);
3828
3829   application.SendNotification();
3830   application.Render(0);
3831
3832   Geometry geometry = CreateQuadGeometry();
3833   Shader shader = CreateShader();
3834   Renderer renderer = Renderer::New(geometry, shader);
3835
3836   application.SendNotification();
3837   application.Render(0);
3838
3839   try
3840   {
3841     actor.AddRenderer( renderer );
3842     tet_result(TET_PASS);
3843   }
3844   catch(...)
3845   {
3846     tet_result(TET_FAIL);
3847   }
3848
3849   END_TEST;
3850 }
3851
3852 int UtcDaliActorRemoveRendererP1(void)
3853 {
3854   tet_infoline("Testing Actor::RemoveRenderer");
3855   TestApplication application;
3856
3857   Actor actor = Actor::New();
3858
3859   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3860
3861   {
3862     Geometry geometry = CreateQuadGeometry();
3863     Shader shader = CreateShader();
3864     Renderer renderer = Renderer::New(geometry, shader);
3865
3866     actor.AddRenderer( renderer );
3867     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3868     DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3869
3870     application.SendNotification();
3871     application.Render();
3872   }
3873
3874   {
3875     Renderer renderer = actor.GetRendererAt(0);
3876     actor.RemoveRenderer(renderer);
3877     DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3878
3879     application.SendNotification();
3880     application.Render();
3881   }
3882
3883   // Call one final time to ensure that the renderer is actually removed after
3884   // the handle goes out of scope, and excercises the deletion code path in
3885   // scene graph and render.
3886   application.SendNotification();
3887   application.Render();
3888
3889   END_TEST;
3890 }
3891
3892 int UtcDaliActorRemoveRendererP2(void)
3893 {
3894   tet_infoline("Testing Actor::RemoveRenderer");
3895   TestApplication application;
3896
3897   Actor actor = Actor::New();
3898
3899   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3900
3901   Geometry geometry = CreateQuadGeometry();
3902   Shader shader = CreateShader();
3903   Renderer renderer = Renderer::New(geometry, shader);
3904
3905   actor.AddRenderer( renderer );
3906   application.SendNotification();
3907   application.Render();
3908
3909   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3910   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3911
3912   actor.RemoveRenderer(0);
3913   application.SendNotification();
3914   application.Render();
3915
3916   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3917
3918   // Shut down whilst holding onto the renderer handle.
3919   END_TEST;
3920 }
3921
3922
3923 int UtcDaliActorRemoveRendererN(void)
3924 {
3925   tet_infoline("Testing Actor::RemoveRenderer");
3926   TestApplication application;
3927
3928   Actor actor = Actor::New();
3929
3930   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3931
3932   Geometry geometry = CreateQuadGeometry();
3933   Shader shader = CreateShader();
3934   Renderer renderer = Renderer::New(geometry, shader);
3935
3936   actor.AddRenderer( renderer );
3937   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3938   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3939
3940   actor.RemoveRenderer(10);
3941   DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3942   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3943
3944   END_TEST;
3945 }
3946
3947 // Clipping test helper functions:
3948 Actor CreateActorWithContent()
3949 {
3950   BufferImage image = BufferImage::New( 16u, 16u );
3951   Actor actor = CreateRenderableActor( image );
3952
3953   // Setup dimensions and position so actor is not skipped by culling.
3954   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3955   actor.SetSize( 16.0f, 16.0f );
3956   actor.SetParentOrigin( ParentOrigin::CENTER );
3957   actor.SetAnchorPoint( AnchorPoint::CENTER );
3958
3959   return actor;
3960 }
3961
3962 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3963 {
3964   enabledDisableTrace.Reset();
3965   stencilTrace.Reset();
3966   enabledDisableTrace.Enable( true );
3967   stencilTrace.Enable( true );
3968
3969   application.SendNotification();
3970   application.Render();
3971
3972   enabledDisableTrace.Enable( false );
3973   stencilTrace.Enable( false );
3974 }
3975
3976 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3977 {
3978   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3979
3980   DALI_TEST_EQUALS<bool>( colorMaskParams.red,   maskValue, TEST_LOCATION );
3981   DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3982   DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  maskValue, TEST_LOCATION );
3983   DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3984 }
3985
3986 int UtcDaliActorPropertyClippingP(void)
3987 {
3988   // This test checks the clippingMode property.
3989   tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3990   TestApplication application;
3991
3992   Actor actor = Actor::New();
3993
3994   // Check default clippingEnabled value.
3995   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3996
3997   int value = 0;
3998   bool getValueResult = getValue.Get( value );
3999   DALI_TEST_CHECK( getValueResult );
4000
4001   if( getValueResult )
4002   {
4003     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4004   }
4005
4006   // Check setting the property.
4007   actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4008
4009   // Check the new value was set.
4010   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4011   getValueResult = getValue.Get( value );
4012   DALI_TEST_CHECK( getValueResult );
4013
4014   if( getValueResult )
4015   {
4016     DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4017   }
4018
4019   END_TEST;
4020 }
4021
4022 int UtcDaliActorPropertyClippingN(void)
4023 {
4024   // Negative test case for Clipping.
4025   tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4026   TestApplication application;
4027
4028   Actor actor = Actor::New();
4029
4030   // Check default clippingEnabled value.
4031   Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4032
4033   int value = 0;
4034   bool getValueResult = getValue.Get( value );
4035   DALI_TEST_CHECK( getValueResult );
4036
4037   if( getValueResult )
4038   {
4039     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4040   }
4041
4042   // Check setting an invalid property value won't change the current property value.
4043   actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4044
4045   getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4046   getValueResult = getValue.Get( value );
4047   DALI_TEST_CHECK( getValueResult );
4048
4049   if( getValueResult )
4050   {
4051     DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4052   }
4053
4054   END_TEST;
4055 }
4056
4057 int UtcDaliActorPropertyClippingActor(void)
4058 {
4059   // This test checks that an actor is correctly setup for clipping.
4060   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4061   TestApplication application;
4062
4063   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4064   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4065   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4066   size_t startIndex = 0u;
4067
4068   // Create a clipping actor.
4069   Actor actorDepth1Clip = CreateActorWithContent();
4070   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4071   Stage::GetCurrent().Add( actorDepth1Clip );
4072
4073   // Gather the call trace.
4074   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4075
4076   // Check we are writing to the color buffer.
4077   CheckColorMask( glAbstraction, true );
4078
4079   // Check the stencil buffer was enabled.
4080   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4081
4082   // Check the stencil buffer was cleared.
4083   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4084
4085   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4086   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4087   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4088   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4089
4090   END_TEST;
4091 }
4092
4093 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4094 {
4095   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4096   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4097   TestApplication application;
4098
4099   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4100   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4101   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4102   size_t startIndex = 0u;
4103
4104   // Create a clipping actor.
4105   Actor actorDepth1Clip = CreateActorWithContent();
4106   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4107   Stage::GetCurrent().Add( actorDepth1Clip );
4108
4109   // Gather the call trace.
4110   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4111
4112   // Check we are writing to the color buffer.
4113   CheckColorMask( glAbstraction, true );
4114
4115   // Check the stencil buffer was enabled.
4116   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4117
4118   // Check the stencil buffer was cleared.
4119   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4120
4121   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4122   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );     // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4123   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4124   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4125
4126   // Now disable the clipping
4127   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4128
4129   // Gather the call trace.
4130   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4131
4132   // Check the stencil buffer was disabled.
4133   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) );                                   // 2960 is GL_STENCIL_TEST
4134
4135   // Ensure all values in stencil-mask are set to 1.
4136   startIndex = 0u;
4137   DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4138
4139   END_TEST;
4140 }
4141
4142
4143 int UtcDaliActorPropertyClippingNestedChildren(void)
4144 {
4145   // This test checks that a hierarchy of actors are clipped correctly by
4146   // writing to and reading from the correct bit-planes of the stencil buffer.
4147   tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4148   TestApplication application;
4149   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4150   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4151   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4152
4153   // Create a clipping actor.
4154   Actor actorDepth1Clip = CreateActorWithContent();
4155   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4156   Stage::GetCurrent().Add( actorDepth1Clip );
4157
4158   // Create a child actor.
4159   Actor childDepth2 = CreateActorWithContent();
4160   actorDepth1Clip.Add( childDepth2 );
4161
4162   // Create another clipping actor.
4163   Actor childDepth2Clip = CreateActorWithContent();
4164   childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4165   childDepth2.Add( childDepth2Clip );
4166
4167   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4168   // This tests the sort algorithm.
4169   Actor childDepth3 = CreateActorWithContent();
4170   childDepth2Clip.Add( childDepth3 );
4171   Actor childDepth4 = CreateActorWithContent();
4172   childDepth3.Add( childDepth4 );
4173
4174   // Gather the call trace.
4175   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4176
4177   // Check we are writing to the color buffer.
4178   CheckColorMask( glAbstraction, true );
4179
4180   // Check the stencil buffer was enabled.
4181   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );                                        // 2960 is GL_STENCIL_TEST
4182
4183   // Perform the test twice, once for 2D layer, and once for 3D.
4184   for( unsigned int i = 0u ; i < 2u; ++i )
4185   {
4186     size_t startIndex = 0u;
4187
4188     // Check the stencil buffer was cleared.
4189     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4190
4191     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4192     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 0", startIndex ) );        // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4193     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "1", startIndex ) );                // Write to the first bit-plane
4194     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4195
4196     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4197     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 1, 255", startIndex ) );      // 514 is GL_EQUAL
4198     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4199
4200     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4201     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 1", startIndex ) );        // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4202     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask",  "3", startIndex ) );                // Write to second (and previous) bit-planes
4203     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4204
4205     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4206     // (Both must be set to pass the check).
4207     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc",  "514, 3, 255", startIndex ) );      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4208     DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp",    "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4209
4210     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4211     if( i == 0u )
4212     {
4213       Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4214       GenerateTrace( application, enabledDisableTrace, stencilTrace );
4215     }
4216   }
4217
4218   END_TEST;
4219 }
4220
4221 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4222 {
4223   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4224   tet_infoline( "Testing Actor::Property::CLIPPING_MODE draw order" );
4225   TestApplication application;
4226   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4227   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4228
4229   /* We create a small tree of actors as follows:
4230
4231                            A
4232                           / \
4233      Clipping enabled -> B   D
4234                          |   |
4235                          C   E
4236
4237      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4238   */
4239   Actor actors[5];
4240   for( int i = 0; i < 5; ++i )
4241   {
4242     BufferImage image = BufferImage::New( 16u, 16u );
4243     Actor actor = CreateRenderableActor( image );
4244
4245     // Setup dimensions and position so actor is not skipped by culling.
4246     actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4247     actor.SetSize( 16.0f, 16.0f );
4248
4249     if( i == 0 )
4250     {
4251       actor.SetParentOrigin( ParentOrigin::CENTER );
4252     }
4253     else
4254     {
4255       float b = i > 2 ? 1.0f : -1.0f;
4256       actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4257     }
4258
4259     actors[i] = actor;
4260   }
4261
4262   // Enable clipping on the actor at the top of the left branch.
4263   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4264
4265   // Build the scene graph.
4266   Stage::GetCurrent().Add( actors[0] );
4267
4268   // Left branch:
4269   actors[0].Add( actors[1] );
4270   actors[1].Add( actors[2] );
4271
4272   // Right branch:
4273   actors[0].Add( actors[3] );
4274   actors[3].Add( actors[4] );
4275
4276   // Gather the call trace.
4277   enabledDisableTrace.Reset();
4278   enabledDisableTrace.Enable( true );
4279   application.SendNotification();
4280   application.Render();
4281   enabledDisableTrace.Enable( false );
4282
4283   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4284
4285      Note: Correct enable call trace:    StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4286            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4287   */
4288   size_t startIndex = 0u;
4289   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "3042", startIndex ) );
4290   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable",  "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4291   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4292
4293   // Swap the clipping actor from top of left branch to top of right branch.
4294   actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4295   actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4296
4297   // Gather the call trace.
4298   enabledDisableTrace.Reset();
4299   enabledDisableTrace.Enable( true );
4300   application.SendNotification();
4301   application.Render();
4302   enabledDisableTrace.Enable( false );
4303
4304   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4305   // This proves the draw order has remained the same.
4306   startIndex = 0u;
4307   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex(  "Enable",  "2960", startIndex ) );
4308   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4309
4310   END_TEST;
4311 }
4312
4313 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4314 {
4315   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4316   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4317   TestApplication application;
4318
4319   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4320   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4321   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4322
4323   // Create a clipping actor.
4324   Actor actorDepth1Clip = CreateActorWithContent();
4325   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4326   Stage::GetCurrent().Add( actorDepth1Clip );
4327
4328   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4329   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4330
4331   // Gather the call trace.
4332   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4333
4334   // Check we are writing to the color buffer.
4335   CheckColorMask( glAbstraction, true );
4336
4337   // Check the stencil buffer was not enabled.
4338   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4339
4340   // Check stencil functions are not called.
4341   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4342   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4343   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4344
4345   END_TEST;
4346 }
4347
4348 int UtcDaliGetPropertyN(void)
4349 {
4350   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4351   TestApplication app;
4352
4353   Actor actor = Actor::New();
4354
4355   unsigned int propertyCount = actor.GetPropertyCount();
4356   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4357   END_TEST;
4358 }
4359
4360 int UtcDaliActorRaiseLower(void)
4361 {
4362   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4363
4364   TestApplication application;
4365
4366   Stage stage( Stage::GetCurrent() );
4367
4368   Actor actorA = Actor::New();
4369   Actor actorB = Actor::New();
4370   Actor actorC = Actor::New();
4371
4372   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4373   actorA.SetParentOrigin( ParentOrigin::CENTER );
4374
4375   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4376   actorB.SetParentOrigin( ParentOrigin::CENTER );
4377
4378   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4379   actorC.SetParentOrigin( ParentOrigin::CENTER );
4380
4381   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4382   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4383
4384   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4385   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4386
4387   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4388   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4389
4390   stage.Add( actorA );
4391   stage.Add( actorB );
4392   stage.Add( actorC );
4393
4394   ResetTouchCallbacks();
4395
4396   application.SendNotification();
4397   application.Render();
4398
4399   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4400   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4401   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4402
4403   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4404   // Only top actor will get touched.
4405   actorA.TouchSignal().Connect( TestTouchCallback );
4406   actorB.TouchSignal().Connect( TestTouchCallback2 );
4407   actorC.TouchSignal().Connect( TestTouchCallback3 );
4408
4409   Dali::Integration::Point point;
4410   point.SetDeviceId( 1 );
4411   point.SetState( PointState::DOWN );
4412   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4413   Dali::Integration::TouchEvent touchEvent;
4414   touchEvent.AddPoint( point );
4415
4416   application.ProcessEvent( touchEvent );
4417
4418   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4419   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4420   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4421
4422   ResetTouchCallbacks();
4423
4424   tet_printf( "Testing Raising of Actor\n" );
4425
4426   int preActorOrder( 0 );
4427   int postActorOrder( 0 );
4428
4429   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4430   value.Get( preActorOrder );
4431
4432   DevelActor::Raise( actorB );
4433   // Ensure sort order is calculated before next touch event
4434   application.SendNotification();
4435
4436   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4437   value.Get( postActorOrder );
4438
4439   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4440
4441   application.ProcessEvent( touchEvent );
4442
4443   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4444   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4445   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4446
4447   ResetTouchCallbacks();
4448
4449   tet_printf( "Testing Lowering of Actor\n" );
4450
4451   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4452   value.Get( preActorOrder );
4453
4454   DevelActor::Lower( actorB );
4455   application.SendNotification(); // ensure sort order calculated before next touch event
4456
4457   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4458   value.Get( postActorOrder );
4459
4460   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4461
4462   application.ProcessEvent( touchEvent );
4463
4464   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4465   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4466   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4467
4468   ResetTouchCallbacks();
4469
4470   END_TEST;
4471 }
4472
4473 int UtcDaliActorRaiseToTopLowerToBottom(void)
4474 {
4475   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4476
4477   TestApplication application;
4478
4479   Stage stage( Stage::GetCurrent() );
4480
4481   Actor actorA = Actor::New();
4482   Actor actorB = Actor::New();
4483   Actor actorC = Actor::New();
4484
4485   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4486   // enables checking of which actor the uniform is assigned too
4487   Shader shaderA = CreateShader();
4488   shaderA.RegisterProperty( "uRendererColor",1.f);
4489
4490   Shader shaderB = CreateShader();
4491   shaderB.RegisterProperty( "uRendererColor", 2.f );
4492
4493   Shader shaderC = CreateShader();
4494   shaderC.RegisterProperty( "uRendererColor", 3.f );
4495
4496   Geometry geometry = CreateQuadGeometry();
4497
4498   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4499   Renderer rendererA = Renderer::New(geometry, shaderA);
4500   actorA.AddRenderer(rendererA);
4501
4502   Renderer rendererB = Renderer::New(geometry, shaderB);
4503   actorB.AddRenderer(rendererB);
4504
4505   Renderer rendererC = Renderer::New(geometry, shaderC);
4506   actorC.AddRenderer(rendererC);
4507
4508   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4509   actorA.SetParentOrigin( ParentOrigin::CENTER );
4510
4511   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4512   actorB.SetParentOrigin( ParentOrigin::CENTER );
4513
4514   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4515   actorC.SetParentOrigin( ParentOrigin::CENTER );
4516
4517   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4518   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4519
4520   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4521   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4522
4523   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4524   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4525
4526   stage.Add( actorA );
4527   stage.Add( actorB );
4528   stage.Add( actorC );
4529
4530   ResetTouchCallbacks();
4531
4532   // Set up gl abstraction trace so can query the set uniform order
4533   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4534   glAbstraction.EnableSetUniformCallTrace(true);
4535   glAbstraction.ResetSetUniformCallStack();
4536
4537   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4538
4539   application.SendNotification();
4540   application.Render();
4541
4542   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4543
4544
4545   // Test order of uniforms in stack
4546   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4547   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4548   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4549
4550   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4551
4552   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4553
4554   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4555   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4556   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4557
4558   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4559   // Only top actor will get touched.
4560   actorA.TouchSignal().Connect( TestTouchCallback );
4561   actorB.TouchSignal().Connect( TestTouchCallback2 );
4562   actorC.TouchSignal().Connect( TestTouchCallback3 );
4563
4564   Dali::Integration::Point point;
4565   point.SetDeviceId( 1 );
4566   point.SetState( PointState::DOWN );
4567   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4568   Dali::Integration::TouchEvent touchEvent;
4569   touchEvent.AddPoint( point );
4570
4571   application.ProcessEvent( touchEvent );
4572
4573   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4574   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4575   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4576
4577   ResetTouchCallbacks();
4578
4579   tet_printf( "RaiseToTop ActorA\n" );
4580
4581   DevelActor::RaiseToTop( actorA );
4582   application.SendNotification(); // ensure sorting order is calculated before next touch event
4583
4584   application.ProcessEvent( touchEvent );
4585
4586   glAbstraction.ResetSetUniformCallStack();
4587   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4588
4589   application.SendNotification();
4590   application.Render();
4591
4592   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4593
4594   // Test order of uniforms in stack
4595   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4596   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4597   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4598
4599   tet_infoline( "Testing A above C and B at bottom\n" );
4600   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4601
4602   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4603
4604   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4605   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4606   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4607
4608   ResetTouchCallbacks();
4609
4610   tet_printf( "RaiseToTop ActorB\n" );
4611
4612   DevelActor::RaiseToTop( actorB );
4613   application.SendNotification(); // Ensure sort order is calculated before next touch event
4614
4615   application.ProcessEvent( touchEvent );
4616
4617   glAbstraction.ResetSetUniformCallStack();
4618   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4619
4620   application.SendNotification();
4621   application.Render();
4622
4623   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4624
4625   // Test order of uniforms in stack
4626   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4627   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4628   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4629
4630   tet_infoline( "Testing B above A and C at bottom\n" );
4631   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4632
4633   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4634
4635   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4636   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4637   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4638
4639   ResetTouchCallbacks();
4640
4641   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4642
4643   DevelActor::LowerToBottom( actorA );
4644   application.SendNotification();
4645   application.Render();
4646
4647   DevelActor::LowerToBottom( actorB );
4648   application.SendNotification();
4649   application.Render();
4650
4651   application.ProcessEvent( touchEvent );
4652
4653   glAbstraction.ResetSetUniformCallStack();
4654   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4655
4656   application.SendNotification();
4657   application.Render();
4658
4659   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4660
4661   // Test order of uniforms in stack
4662   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4663   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4664   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4665
4666   tet_infoline( "Testing C above A and B at bottom\n" );
4667   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4668
4669   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4670
4671   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4672   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4673   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4674
4675   ResetTouchCallbacks();
4676
4677   END_TEST;
4678 }
4679
4680 int UtcDaliActorRaiseAbove(void)
4681 {
4682   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4683
4684   TestApplication application;
4685
4686   Stage stage( Stage::GetCurrent() );
4687
4688   Actor actorA = Actor::New();
4689   Actor actorB = Actor::New();
4690   Actor actorC = Actor::New();
4691
4692   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4693   actorA.SetParentOrigin( ParentOrigin::CENTER );
4694
4695   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4696   actorB.SetParentOrigin( ParentOrigin::CENTER );
4697
4698   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4699   actorC.SetParentOrigin( ParentOrigin::CENTER );
4700
4701   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4702   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4703
4704   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4705   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4706
4707   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4708   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4709
4710   stage.Add( actorA );
4711   stage.Add( actorB );
4712   stage.Add( actorC );
4713
4714   ResetTouchCallbacks();
4715
4716   application.SendNotification();
4717   application.Render();
4718
4719   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4720   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4721   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4722
4723   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4724   // Only top actor will get touched.
4725   actorA.TouchSignal().Connect( TestTouchCallback );
4726   actorB.TouchSignal().Connect( TestTouchCallback2 );
4727   actorC.TouchSignal().Connect( TestTouchCallback3 );
4728
4729   Dali::Integration::Point point;
4730   point.SetDeviceId( 1 );
4731   point.SetState( PointState::DOWN );
4732   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4733   Dali::Integration::TouchEvent touchEvent;
4734   touchEvent.AddPoint( point );
4735
4736   application.ProcessEvent( touchEvent );
4737
4738   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4739   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4740   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4741
4742   ResetTouchCallbacks();
4743
4744   tet_printf( "Raise actor B Above Actor C\n" );
4745
4746   DevelActor::RaiseAbove( actorB, actorC );
4747   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4748   application.SendNotification();
4749
4750   application.ProcessEvent( touchEvent );
4751
4752   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4753   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4754   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4755
4756   ResetTouchCallbacks();
4757
4758   tet_printf( "Raise actor A Above Actor B\n" );
4759
4760   DevelActor::RaiseAbove( actorA, actorB );
4761
4762   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4763   application.SendNotification();
4764
4765   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4766
4767   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4768   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4769   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4770
4771   ResetTouchCallbacks();
4772
4773   END_TEST;
4774 }
4775
4776 int UtcDaliActorLowerBelow(void)
4777 {
4778   tet_infoline( "UtcDaliActor LowerBelow test \n" );
4779
4780   TestApplication application;
4781
4782   Stage stage( Stage::GetCurrent() );
4783
4784   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4785   // enables checking of which actor the uniform is assigned too
4786   Shader shaderA = CreateShader();
4787   shaderA.RegisterProperty( "uRendererColor",1.f);
4788
4789   Shader shaderB = CreateShader();
4790   shaderB.RegisterProperty( "uRendererColor", 2.f );
4791
4792   Shader shaderC = CreateShader();
4793   shaderC.RegisterProperty( "uRendererColor", 3.f );
4794
4795   Actor actorA = Actor::New();
4796   Actor actorB = Actor::New();
4797   Actor actorC = Actor::New();
4798
4799   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4800   Geometry geometry = CreateQuadGeometry();
4801
4802   Renderer rendererA = Renderer::New(geometry, shaderA);
4803   actorA.AddRenderer(rendererA);
4804
4805   Renderer rendererB = Renderer::New(geometry, shaderB);
4806   actorB.AddRenderer(rendererB);
4807
4808   Renderer rendererC = Renderer::New(geometry, shaderC);
4809   actorC.AddRenderer(rendererC);
4810
4811   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4812   actorA.SetParentOrigin( ParentOrigin::CENTER );
4813
4814   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4815   actorB.SetParentOrigin( ParentOrigin::CENTER );
4816
4817   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4818   actorC.SetParentOrigin( ParentOrigin::CENTER );
4819
4820   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4821   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4822
4823   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4824   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4825
4826   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4827   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4828
4829   Actor container = Actor::New();
4830   container.SetParentOrigin( ParentOrigin::CENTER );
4831   container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
4832   stage.Add( container );
4833
4834   container.Add( actorA );
4835   container.Add( actorB );
4836   container.Add( actorC );
4837
4838   ResetTouchCallbacks();
4839
4840   // Set up gl abstraction trace so can query the set uniform order
4841   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4842   glAbstraction.EnableSetUniformCallTrace(true);
4843   glAbstraction.ResetSetUniformCallStack();
4844   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4845
4846   glAbstraction.ResetSetUniformCallStack();
4847
4848   application.SendNotification();
4849   application.Render();
4850
4851   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4852
4853   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4854
4855   // Test order of uniforms in stack
4856   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4857   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4858   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4859
4860   tet_infoline( "Testing C above B and A at bottom\n" );
4861   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4862
4863   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4864
4865   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4866   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4867   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4868
4869   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4870   // Only top actor will get touched.
4871   actorA.TouchSignal().Connect( TestTouchCallback );
4872   actorB.TouchSignal().Connect( TestTouchCallback2 );
4873   actorC.TouchSignal().Connect( TestTouchCallback3 );
4874
4875   Dali::Integration::Point point;
4876   point.SetDeviceId( 1 );
4877   point.SetState( PointState::DOWN );
4878   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4879   Dali::Integration::TouchEvent touchEvent;
4880   touchEvent.AddPoint( point );
4881
4882   tet_infoline( "UtcDaliActor Test Set up completed \n" );
4883
4884   application.ProcessEvent( touchEvent );
4885
4886   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4887   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4888   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4889
4890   ResetTouchCallbacks();
4891
4892   tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" );
4893
4894   DevelActor::LowerBelow( actorC, actorB );
4895   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4896   application.SendNotification();
4897   application.Render();
4898
4899   application.ProcessEvent( touchEvent ); // touch event
4900
4901   glAbstraction.ResetSetUniformCallStack();
4902   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4903
4904   application.SendNotification();
4905   application.Render();
4906
4907   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4908
4909   // Test order of uniforms in stack
4910   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4911   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4912   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4913
4914   tet_infoline( "Testing render order is A, C, B" );
4915   DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
4916   DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
4917
4918   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4919   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4920   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4921
4922   ResetTouchCallbacks();
4923
4924   tet_printf( "Lower actor C below Actor A leaving B on top\n" );
4925
4926   DevelActor::LowerBelow( actorC, actorA );
4927   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4928   application.SendNotification();
4929   application.Render();
4930
4931   application.ProcessEvent( touchEvent );
4932
4933   glAbstraction.ResetSetUniformCallStack();
4934   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4935
4936   application.Render();
4937   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4938
4939   // Test order of uniforms in stack
4940   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4941   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4942   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4943
4944   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4945   DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
4946
4947   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4948   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4949   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4950
4951   ResetTouchCallbacks();
4952
4953   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4954
4955   DevelActor::LowerBelow( actorB, actorC );
4956   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4957   application.SendNotification();
4958   application.Render();
4959
4960   application.ProcessEvent( touchEvent );
4961
4962   glAbstraction.ResetSetUniformCallStack();
4963   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4964
4965   application.Render();
4966   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4967
4968   // Test order of uniforms in stack
4969   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4970   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4971   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4972
4973   DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
4974   DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4975
4976   END_TEST;
4977 }
4978
4979
4980 int UtcDaliActorRaiseAboveDifferentParentsN(void)
4981 {
4982   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4983
4984   TestApplication application;
4985
4986   Stage stage( Stage::GetCurrent() );
4987
4988   Actor parentA = Actor::New();
4989   Actor parentB = Actor::New();
4990   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4991   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4992   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4993   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4994
4995   parentA.SetAnchorPoint( AnchorPoint::CENTER );
4996   parentA.SetParentOrigin( ParentOrigin::CENTER );
4997
4998   parentB.SetAnchorPoint( AnchorPoint::CENTER );
4999   parentB.SetParentOrigin( ParentOrigin::CENTER );
5000
5001   stage.Add( parentA );
5002   stage.Add( parentB );
5003
5004   Actor actorA = Actor::New();
5005   Actor actorB = Actor::New();
5006   Actor actorC = Actor::New();
5007
5008   parentA.Add( actorA );
5009   parentA.Add( actorB );
5010
5011   tet_printf( "Actor C added to different parent from A and B \n" );
5012   parentB.Add( actorC );
5013
5014   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5015   actorA.SetParentOrigin( ParentOrigin::CENTER );
5016
5017   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5018   actorB.SetParentOrigin( ParentOrigin::CENTER );
5019
5020   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5021   actorC.SetParentOrigin( ParentOrigin::CENTER );
5022
5023   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5024   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5025
5026   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5027   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5028
5029   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5030   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5031
5032   ResetTouchCallbacks();
5033
5034   application.SendNotification();
5035   application.Render();
5036
5037   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5038   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5039   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5040
5041   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5042   // Only top actor will get touched.
5043   actorA.TouchSignal().Connect( TestTouchCallback );
5044   actorB.TouchSignal().Connect( TestTouchCallback2 );
5045   actorC.TouchSignal().Connect( TestTouchCallback3 );
5046
5047   Dali::Integration::Point point;
5048   point.SetDeviceId( 1 );
5049   point.SetState( PointState::DOWN );
5050   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5051   Dali::Integration::TouchEvent touchEvent;
5052   touchEvent.AddPoint( point );
5053
5054   application.ProcessEvent( touchEvent );
5055
5056   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5057   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5058   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5059
5060   ResetTouchCallbacks();
5061
5062   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5063
5064   DevelActor::RaiseAbove( actorA, actorC );
5065   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5066   application.SendNotification();
5067
5068   application.ProcessEvent( touchEvent ); // touch event
5069
5070   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5071   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5072   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5073
5074   ResetTouchCallbacks();
5075
5076   END_TEST;
5077 }
5078
5079 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5080 {
5081   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5082
5083   TestApplication application;
5084
5085   Stage stage( Stage::GetCurrent() );
5086
5087   Actor actorA = Actor::New();
5088   Actor actorB = Actor::New();
5089   Actor actorC = Actor::New();
5090
5091   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5092   actorA.SetParentOrigin( ParentOrigin::CENTER );
5093
5094   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5095   actorB.SetParentOrigin( ParentOrigin::CENTER );
5096
5097   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5098   actorC.SetParentOrigin( ParentOrigin::CENTER );
5099
5100   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5101   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5102
5103   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5104   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5105
5106   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5107   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5108
5109   ResetTouchCallbacks();
5110
5111   application.SendNotification();
5112   application.Render();
5113
5114   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5115   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5116   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5117
5118   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5119   // Only top actor will get touched.
5120   actorA.TouchSignal().Connect( TestTouchCallback );
5121   actorB.TouchSignal().Connect( TestTouchCallback2 );
5122   actorC.TouchSignal().Connect( TestTouchCallback3 );
5123
5124   Dali::Integration::Point point;
5125   point.SetDeviceId( 1 );
5126   point.SetState( PointState::DOWN );
5127   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5128   Dali::Integration::TouchEvent touchEvent;
5129   touchEvent.AddPoint( point );
5130
5131   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5132
5133   DevelActor::RaiseAbove( actorA, actorC );
5134   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5135   application.SendNotification();
5136
5137   application.ProcessEvent( touchEvent );
5138
5139   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5140
5141   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5142   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5143   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5144
5145   ResetTouchCallbacks();
5146
5147   stage.Add ( actorB );
5148   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5149   DevelActor::LowerBelow( actorA, actorC );
5150
5151   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5152   application.SendNotification();
5153   application.Render();
5154
5155   application.ProcessEvent( touchEvent );
5156
5157   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5158   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5159   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5160   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5161
5162   ResetTouchCallbacks();
5163
5164   tet_printf( "Adding Actor A to stage, will be on top\n" );
5165
5166   stage.Add ( actorA );
5167   application.SendNotification();
5168   application.Render();
5169
5170   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5171   DevelActor::RaiseAbove( actorB, actorC );
5172   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5173   application.SendNotification();
5174
5175   application.ProcessEvent( touchEvent );
5176
5177   tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5178   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5179   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5180   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5181
5182   ResetTouchCallbacks();
5183
5184   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5185   DevelActor::LowerBelow( actorA, actorC );
5186   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5187   application.SendNotification();
5188
5189   application.ProcessEvent( touchEvent );
5190
5191   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5192   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5193   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5194   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5195
5196   ResetTouchCallbacks();
5197
5198   stage.Add ( actorC );
5199   DevelActor::RaiseAbove( actorA, actorC );
5200   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5201   application.SendNotification();
5202   application.Render();
5203
5204   application.ProcessEvent( touchEvent );
5205
5206   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5207   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5208   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5209   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5210
5211   END_TEST;
5212 }
5213
5214 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5215 {
5216   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5217
5218   TestApplication application;
5219
5220   Stage stage( Stage::GetCurrent() );
5221
5222   Actor actorA = Actor::New();
5223   Actor actorB = Actor::New();
5224   Actor actorC = Actor::New();
5225
5226   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5227   actorA.SetParentOrigin( ParentOrigin::CENTER );
5228
5229   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5230   actorB.SetParentOrigin( ParentOrigin::CENTER );
5231
5232   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5233   actorC.SetParentOrigin( ParentOrigin::CENTER );
5234
5235   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5236   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5237
5238   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5239   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5240
5241   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5242   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5243
5244   ResetTouchCallbacks();
5245
5246   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5247   // Only top actor will get touched.
5248   actorA.TouchSignal().Connect( TestTouchCallback );
5249   actorB.TouchSignal().Connect( TestTouchCallback2 );
5250   actorC.TouchSignal().Connect( TestTouchCallback3 );
5251
5252   Dali::Integration::Point point;
5253   point.SetDeviceId( 1 );
5254   point.SetState( PointState::DOWN );
5255   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5256   Dali::Integration::TouchEvent touchEvent;
5257   touchEvent.AddPoint( point );
5258
5259   stage.Add ( actorA );
5260   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5261   DevelActor::Raise( actorB );
5262
5263   application.SendNotification();
5264   application.Render();
5265
5266   application.ProcessEvent( touchEvent );
5267
5268   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5269
5270   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5271   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5272   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5273
5274   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5275   ResetTouchCallbacks();
5276
5277   DevelActor::Lower( actorC );
5278   // Sort actor tree before next touch event
5279   application.SendNotification();
5280   application.Render();
5281
5282   application.ProcessEvent( touchEvent );
5283
5284   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5285
5286   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5287   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5288   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5289   ResetTouchCallbacks();
5290
5291   tet_printf( "Lower actor C below B but C not parented\n" );
5292
5293   DevelActor::Lower( actorB );
5294   // Sort actor tree before next touch event
5295   application.SendNotification();
5296   application.Render();
5297
5298   application.ProcessEvent( touchEvent );
5299
5300   tet_printf( "Not parented so Lower should show no effect\n" );
5301
5302   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5303   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5304   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5305   ResetTouchCallbacks();
5306
5307   tet_printf( "Raise actor B to top\n" );
5308
5309   DevelActor::RaiseToTop( actorB );
5310   // Sort actor tree before next touch event
5311   application.SendNotification();
5312   application.Render();
5313
5314   application.ProcessEvent( touchEvent );
5315
5316   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5317
5318   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5319   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5320   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5321   ResetTouchCallbacks();
5322
5323   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5324
5325   stage.Add ( actorB );
5326
5327   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5328
5329   DevelActor::LowerToBottom( actorC );
5330   application.SendNotification();
5331   application.Render();
5332
5333   application.ProcessEvent( touchEvent );
5334
5335   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5336
5337   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5338   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5339   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5340   ResetTouchCallbacks();
5341
5342   END_TEST;
5343 }
5344
5345
5346 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5347 {
5348   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5349
5350   TestApplication application;
5351
5352   Stage stage( Stage::GetCurrent() );
5353
5354   Actor actorA = Actor::New();
5355   Actor actorB = Actor::New();
5356   Actor actorC = Actor::New();
5357
5358   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5359   actorA.SetParentOrigin( ParentOrigin::CENTER );
5360
5361   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5362   actorB.SetParentOrigin( ParentOrigin::CENTER );
5363
5364   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5365   actorC.SetParentOrigin( ParentOrigin::CENTER );
5366
5367   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5368   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5369
5370   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5371   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5372
5373   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5374   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5375
5376   stage.Add( actorA );
5377   stage.Add( actorB );
5378   stage.Add( actorC );
5379
5380   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5381   // Only top actor will get touched.
5382   actorA.TouchSignal().Connect( TestTouchCallback );
5383   actorB.TouchSignal().Connect( TestTouchCallback2 );
5384   actorC.TouchSignal().Connect( TestTouchCallback3 );
5385
5386   ResetTouchCallbacks();
5387
5388   application.SendNotification();
5389   application.Render();
5390
5391   Dali::Integration::Point point;
5392   point.SetDeviceId( 1 );
5393   point.SetState( PointState::DOWN );
5394   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5395   Dali::Integration::TouchEvent touchEvent;
5396   touchEvent.AddPoint( point );
5397
5398   application.ProcessEvent( touchEvent );
5399
5400   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5401   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5402   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5403
5404   ResetTouchCallbacks();
5405
5406   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5407
5408   DevelActor::RaiseAbove( actorA, actorA );
5409   application.SendNotification();
5410   application.Render();
5411
5412   application.ProcessEvent( touchEvent );
5413
5414   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5415
5416   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5417   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5418   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5419
5420   ResetTouchCallbacks();
5421
5422   DevelActor::RaiseAbove( actorA, actorC );
5423   application.SendNotification();
5424   application.Render();
5425
5426   application.ProcessEvent( touchEvent );
5427
5428   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5429   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5430   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5431   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5432
5433   END_TEST;
5434 }
5435
5436 int UtcDaliActorGetScreenPosition(void)
5437 {
5438   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5439
5440   TestApplication application;
5441
5442   Stage stage( Stage::GetCurrent() );
5443
5444   Actor actorA = Actor::New();
5445   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5446
5447   Vector2 size2( 10.0f, 20.0f );
5448   actorA.SetSize( size2 );
5449
5450   actorA.SetPosition( 0.f, 0.f );
5451
5452   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5453
5454   stage.Add( actorA );
5455
5456   application.SendNotification();
5457   application.Render();
5458
5459   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5460   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5461
5462   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
5463   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5464
5465   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5466   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5467
5468   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5469
5470   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5471
5472   application.SendNotification();
5473   application.Render();
5474
5475   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5476   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5477
5478   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
5479   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5480
5481   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5482   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5483
5484   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5485
5486   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5487
5488   application.SendNotification();
5489   application.Render();
5490
5491   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5492   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5493
5494   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
5495   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
5496
5497   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5498   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5499
5500   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5501
5502   actorA.SetPosition( 30.0, 0.0 );
5503
5504   application.SendNotification();
5505   application.Render();
5506
5507   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5508   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5509
5510   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
5511   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
5512
5513   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5514   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5515
5516   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5517
5518   actorA.SetPosition( 30.0, 420.0 );
5519
5520   application.SendNotification();
5521   application.Render();
5522
5523   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5524   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5525
5526   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5527   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
5528
5529   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
5530   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5531
5532
5533   END_TEST;
5534 }
5535
5536 int UtcDaliActorGetScreenPositionAfterScaling(void)
5537 {
5538   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5539
5540   TestApplication application;
5541
5542   Stage stage( Stage::GetCurrent() );
5543
5544   Actor actorA = Actor::New();
5545   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5546
5547   Vector2 size2( 10.0f, 20.0f );
5548   actorA.SetSize( size2 );
5549   actorA.SetScale( 1.5f );
5550   actorA.SetPosition( 0.f, 0.f );
5551
5552   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5553
5554   stage.Add( actorA );
5555
5556   application.SendNotification();
5557   application.Render();
5558
5559   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5560   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5561
5562   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5563   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5564
5565   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5566   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5567
5568   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5569
5570   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5571
5572   application.SendNotification();
5573   application.Render();
5574
5575   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5576   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5577
5578   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5579   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5580
5581   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
5582   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5583
5584   END_TEST;
5585 }
5586
5587 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5588 {
5589   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5590
5591   TestApplication application;
5592
5593   Stage stage( Stage::GetCurrent() );
5594
5595   Actor actorA = Actor::New();
5596   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5597   actorA.SetParentOrigin( ParentOrigin::CENTER );
5598   Vector2 size2( 10.0f, 20.0f );
5599   actorA.SetSize( size2 );
5600   actorA.SetPosition( 0.f, 0.f );
5601
5602   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5603
5604   stage.Add( actorA );
5605
5606   application.SendNotification();
5607   application.Render();
5608
5609   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5610   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5611
5612   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5613   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5614
5615   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
5616   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
5617
5618   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5619
5620   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5621   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5622
5623   application.SendNotification();
5624   application.Render();
5625
5626   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5627   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5628
5629   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5630   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5631
5632   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5633   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5634
5635   END_TEST;
5636   END_TEST;
5637 }
5638
5639 int UtcDaliActorGetScreenPositionWithChildActors(void)
5640 {
5641   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5642
5643   TestApplication application;
5644
5645   Stage stage( Stage::GetCurrent() );
5646
5647   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5648
5649   Actor actorA = Actor::New();
5650   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5651   actorA.SetParentOrigin( ParentOrigin::CENTER );
5652   Vector2 size1( 10.0f, 20.0f );
5653   actorA.SetSize( size1 );
5654   actorA.SetPosition( 0.f, 0.f );
5655
5656   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5657
5658   Actor parentActorA = Actor::New();
5659   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5660   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5661   Vector2 size2( 30.0f, 60.0f );
5662   parentActorA.SetSize( size2 );
5663   parentActorA.SetPosition( 0.f, 0.f );
5664
5665   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5666
5667   stage.Add( parentActorA );
5668   parentActorA.Add ( actorA );
5669
5670   application.SendNotification();
5671   application.Render();
5672
5673   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5674   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5675
5676   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5677   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5678
5679   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
5680   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
5681
5682   tet_infoline( "Test 2\n");
5683
5684   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5685
5686   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5687   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5688
5689   application.SendNotification();
5690   application.Render();
5691
5692   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5693   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5694
5695   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5696   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5697
5698   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
5699   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
5700
5701   END_TEST;
5702 }
5703
5704 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5705 {
5706   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5707
5708   TestApplication application;
5709
5710   Stage stage( Stage::GetCurrent() );
5711
5712   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5713
5714   Actor actorA = Actor::New();
5715   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5716   actorA.SetParentOrigin( ParentOrigin::CENTER );
5717   Vector2 size1( 10.0f, 20.0f );
5718   actorA.SetSize( size1 );
5719   actorA.SetPosition( 0.f, 0.f );
5720
5721   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5722
5723   Actor parentActorA = Actor::New();
5724   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5725   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5726   Vector2 size2( 30.0f, 60.0f );
5727   parentActorA.SetSize( size2 );
5728   parentActorA.SetPosition( 0.f, 0.f );
5729
5730   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5731
5732   Actor grandParentActorA = Actor::New();
5733   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5734   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5735   Vector2 size3( 60.0f, 120.0f );
5736   grandParentActorA.SetSize( size3 );
5737   grandParentActorA.SetPosition( 0.f, 0.f );
5738
5739   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5740
5741   stage.Add( grandParentActorA );
5742   grandParentActorA.Add ( parentActorA );
5743
5744   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5745
5746   parentActorA.Add ( actorA );
5747
5748   application.SendNotification();
5749   application.Render();
5750
5751   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5752   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5753
5754   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5755   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5756
5757   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
5758   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
5759
5760   END_TEST;
5761 }
5762
5763 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5764 {
5765   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5766
5767   TestApplication application;
5768
5769   Stage stage( Stage::GetCurrent() );
5770
5771   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5772
5773   Actor actorA = Actor::New();
5774   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5775   actorA.SetParentOrigin( ParentOrigin::CENTER );
5776   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5777   actorA.SetSize( 10.0f, 20.0f );
5778   stage.Add( actorA );
5779
5780   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5781
5782   Actor actorB = Actor::New();
5783   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5784   actorB.SetParentOrigin( ParentOrigin::CENTER );
5785   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5786   Vector2 actorBSize( 30.0f, 60.0f );
5787   actorB.SetSize( actorBSize );
5788   stage.Add( actorB );
5789
5790   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5791
5792   Actor actorC = Actor::New();
5793   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5794   actorC.SetParentOrigin( ParentOrigin::CENTER );
5795   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5796   Vector2 actorCSize( 60.0f, 120.0f );
5797   actorC.SetSize( actorCSize );
5798   stage.Add( actorC );
5799
5800   application.SendNotification();
5801   application.Render();
5802
5803   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5804
5805   Vector2 center( stage.GetSize() * 0.5f );
5806
5807   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5808   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5809   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5810
5811   tet_infoline( "Add scale to all actors" );
5812
5813   actorA.SetScale( 2.0f );
5814   actorB.SetScale( 2.0f );
5815   actorC.SetScale( 2.0f );
5816
5817   application.SendNotification();
5818   application.Render();
5819
5820   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5821   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5822   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5823
5824   END_TEST;
5825 }
5826
5827 int utcDaliActorPositionUsesAnchorPoint(void)
5828 {
5829   TestApplication application;
5830   tet_infoline( "Check default behaviour\n" );
5831
5832   Actor actor = Actor::New();
5833   actor.SetParentOrigin( ParentOrigin::CENTER );
5834   actor.SetAnchorPoint( AnchorPoint::CENTER );
5835   actor.SetSize( 100.0f, 100.0f );
5836   Stage::GetCurrent().Add( actor );
5837
5838   application.SendNotification();
5839   application.Render();
5840
5841   tet_infoline( "Check that the world position is in the center\n" );
5842   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5843
5844   tet_infoline( "Set the position uses anchor point property to false\n" );
5845   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5846
5847   application.SendNotification();
5848   application.Render();
5849
5850   tet_infoline( "Check that the world position has changed appropriately\n" );
5851   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5852
5853   END_TEST;
5854 }
5855
5856 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5857 {
5858   TestApplication application;
5859   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5860
5861   Actor actor = Actor::New();
5862   actor.SetParentOrigin( ParentOrigin::CENTER );
5863   actor.SetAnchorPoint( AnchorPoint::CENTER );
5864   actor.SetSize( 100.0f, 100.0f );
5865   actor.SetScale( 2.0f );
5866   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5867   Stage::GetCurrent().Add( actor );
5868
5869   application.SendNotification();
5870   application.Render();
5871
5872   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5873   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5874
5875   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5876   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5877   application.SendNotification();
5878   application.Render();
5879   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5880
5881   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5882   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5883   application.SendNotification();
5884   application.Render();
5885   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5886
5887   END_TEST;
5888 }
5889
5890 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5891 {
5892   TestApplication application;
5893   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5894
5895   Actor actor = Actor::New();
5896   actor.SetParentOrigin( ParentOrigin::CENTER );
5897   actor.SetAnchorPoint( AnchorPoint::CENTER );
5898   actor.SetSize( 100.0f, 100.0f );
5899   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5900   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5901   Stage::GetCurrent().Add( actor );
5902
5903   application.SendNotification();
5904   application.Render();
5905
5906   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5907   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5908
5909   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5910   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5911   application.SendNotification();
5912   application.Render();
5913   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5914
5915   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5916   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5917   application.SendNotification();
5918   application.Render();
5919   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5920
5921   END_TEST;
5922 }
5923
5924 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5925 {
5926   TestApplication application;
5927   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5928
5929   Actor actor = Actor::New();
5930   actor.SetParentOrigin( ParentOrigin::CENTER );
5931   actor.SetAnchorPoint( AnchorPoint::CENTER );
5932   actor.SetSize( 100.0f, 100.0f );
5933   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5934   actor.SetScale( 2.0f );
5935   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5936   Stage::GetCurrent().Add( actor );
5937
5938   application.SendNotification();
5939   application.Render();
5940
5941   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5942   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5943
5944   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5945   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5946   application.SendNotification();
5947   application.Render();
5948   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5949
5950   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5951   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5952   application.SendNotification();
5953   application.Render();
5954   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5955
5956   END_TEST;
5957 }
5958
5959 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5960 {
5961   TestApplication application;
5962   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5963
5964   Actor parent = Actor::New();
5965
5966   Stage::GetCurrent().Add( parent );
5967   Vector2 stageSize( Stage::GetCurrent().GetSize() );
5968
5969   Actor actor = Actor::New();
5970   actor.SetParentOrigin( ParentOrigin::CENTER );
5971   actor.SetAnchorPoint( AnchorPoint::CENTER );
5972   actor.SetSize( 100.0f, 100.0f );
5973   actor.SetInheritScale( false );
5974   actor.SetInheritOrientation( false );
5975   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5976   parent.Add( actor );
5977
5978   application.SendNotification();
5979   application.Render();
5980
5981   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5982
5983   tet_infoline( "Check the world position is in the right place\n" );
5984   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5985
5986   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5987   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5988   application.SendNotification();
5989   application.Render();
5990   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5991
5992   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5993   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5994   application.SendNotification();
5995   application.Render();
5996   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5997
5998   END_TEST;
5999 }
6000
6001 int utcDaliActorVisibilityChangeSignalSelf(void)
6002 {
6003   TestApplication application;
6004   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6005
6006   Actor actor = Actor::New();
6007
6008   VisibilityChangedFunctorData data;
6009   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6010
6011   actor.SetVisible( false );
6012
6013   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6014
6015   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6016   data.Reset();
6017
6018   actor.SetVisible( false );
6019   data.Check( false /* not called */, TEST_LOCATION );
6020
6021   tet_infoline( "Change the visibility using properties, ensure called" );
6022   data.Reset();
6023
6024   actor.SetProperty( Actor::Property::VISIBLE, true );
6025   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6026
6027   tet_infoline( "Set the visibility to current using properties, ensure not called" );
6028   data.Reset();
6029
6030   actor.SetProperty( Actor::Property::VISIBLE, true );
6031   data.Check( false /* not called */, TEST_LOCATION );
6032
6033   END_TEST;
6034 }
6035
6036 int utcDaliActorVisibilityChangeSignalChildren(void)
6037 {
6038   TestApplication application;
6039   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6040
6041   Actor parent = Actor::New();
6042   Actor child = Actor::New();
6043   parent.Add( child );
6044
6045   Actor grandChild = Actor::New();
6046   child.Add( grandChild );
6047
6048   VisibilityChangedFunctorData parentData;
6049   VisibilityChangedFunctorData childData;
6050   VisibilityChangedFunctorData grandChildData;
6051
6052   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6053   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6054   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6055
6056   parent.SetVisible( false );
6057   parentData.Check( false /* not called */, TEST_LOCATION );
6058   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6059   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6060
6061   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6062   parentData.Reset();
6063   childData.Reset();
6064   grandChildData.Reset();
6065
6066   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6067
6068   parent.SetVisible( true );
6069   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6070   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6071   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6072
6073   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6074   parentData.Reset();
6075   childData.Reset();
6076   grandChildData.Reset();
6077
6078   parent.SetVisible( true );
6079   parentData.Check( false /* not called */, TEST_LOCATION );
6080   childData.Check( false /* not called */, TEST_LOCATION );
6081   grandChildData.Check( false /* not called */, TEST_LOCATION );
6082
6083   END_TEST;
6084 }
6085
6086 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6087 {
6088   TestApplication application;
6089   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6090
6091   Actor actor = Actor::New();
6092   Stage::GetCurrent().Add( actor );
6093
6094   application.SendNotification();
6095   application.Render();
6096
6097   VisibilityChangedFunctorData data;
6098   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6099
6100   Animation animation = Animation::New( 1.0f );
6101   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6102
6103   data.Check( false, TEST_LOCATION );
6104   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6105   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6106
6107   tet_infoline( "Play the animation and check the property value" );
6108   animation.Play();
6109
6110   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6111   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6112
6113   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6114   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6115
6116   application.SendNotification();
6117   application.Render( 1100 ); // After the animation
6118
6119   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6120
6121   END_TEST;
6122 }
6123
6124 int UtcDaliActorLayoutDirectionProperty(void)
6125 {
6126   TestApplication application;
6127   tet_infoline( "Check layout direction property" );
6128
6129   Actor actor0 = Actor::New();
6130   DALI_TEST_EQUALS( actor0.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6131   Stage::GetCurrent().Add( actor0 );
6132
6133   application.SendNotification();
6134   application.Render();
6135
6136   Actor actor1 = Actor::New();
6137   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6138   Actor actor2 = Actor::New();
6139   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6140   Actor actor3 = Actor::New();
6141   DALI_TEST_EQUALS( actor3.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6142   Actor actor4 = Actor::New();
6143   DALI_TEST_EQUALS( actor4.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6144   Actor actor5 = Actor::New();
6145   DALI_TEST_EQUALS( actor5.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6146   Actor actor6 = Actor::New();
6147   DALI_TEST_EQUALS( actor6.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6148   Actor actor7 = Actor::New();
6149   DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6150   Actor actor8 = Actor::New();
6151   DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6152   Actor actor9 = Actor::New();
6153   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6154
6155   actor1.Add( actor2 );
6156   actor1.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6157   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6158   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6159
6160   actor0.Add( actor1 );
6161   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6162   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6163
6164   Stage::GetCurrent().Add( actor3 );
6165   actor3.Add( actor4 );
6166   actor4.Add( actor5 );
6167   actor5.Add( actor6 );
6168   actor5.Add( actor7 );
6169   actor7.Add( actor8 );
6170   actor8.Add( actor9 );
6171   actor3.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6172   actor5.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "LTR" );
6173
6174   DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE ), true, TEST_LOCATION );
6175   actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE, false );
6176   DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE ), false, TEST_LOCATION );
6177
6178   actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6179
6180   DALI_TEST_EQUALS( actor3.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6181   DALI_TEST_EQUALS( actor4.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6182   DALI_TEST_EQUALS( actor5.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6183   DALI_TEST_EQUALS( actor6.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6184   DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6185   DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6186   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6187
6188   actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6189   DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6190   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6191
6192   actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "LTR" );
6193   DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
6194   DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6195   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
6196
6197   END_TEST;
6198 }