[dali_1.2.41] Merge branch 'devel/master'
[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 UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4222 {
4223   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4224   tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4225   TestApplication application;
4226
4227   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4228   TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4229   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4230
4231   // Create a clipping actor.
4232   Actor actorDepth1Clip = CreateActorWithContent();
4233   actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4234   Stage::GetCurrent().Add( actorDepth1Clip );
4235
4236   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4237   actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4238
4239   // Gather the call trace.
4240   GenerateTrace( application, enabledDisableTrace, stencilTrace );
4241
4242   // Check we are writing to the color buffer.
4243   CheckColorMask( glAbstraction, true );
4244
4245   // Check the stencil buffer was not enabled.
4246   DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) );    // 2960 is GL_STENCIL_TEST
4247
4248   // Check stencil functions are not called.
4249   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4250   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4251   DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4252
4253   END_TEST;
4254 }
4255
4256 int UtcDaliGetPropertyN(void)
4257 {
4258   tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4259   TestApplication app;
4260
4261   Actor actor = Actor::New();
4262
4263   unsigned int propertyCount = actor.GetPropertyCount();
4264   DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4265   END_TEST;
4266 }
4267
4268 int UtcDaliActorRaiseLower(void)
4269 {
4270   tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4271
4272   TestApplication application;
4273
4274   Stage stage( Stage::GetCurrent() );
4275
4276   Actor actorA = Actor::New();
4277   Actor actorB = Actor::New();
4278   Actor actorC = Actor::New();
4279
4280   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4281   actorA.SetParentOrigin( ParentOrigin::CENTER );
4282
4283   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4284   actorB.SetParentOrigin( ParentOrigin::CENTER );
4285
4286   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4287   actorC.SetParentOrigin( ParentOrigin::CENTER );
4288
4289   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4290   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4291
4292   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4293   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4294
4295   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4296   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4297
4298   stage.Add( actorA );
4299   stage.Add( actorB );
4300   stage.Add( actorC );
4301
4302   ResetTouchCallbacks();
4303
4304   application.SendNotification();
4305   application.Render();
4306
4307   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4308   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4309   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4310
4311   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4312   // Only top actor will get touched.
4313   actorA.TouchSignal().Connect( TestTouchCallback );
4314   actorB.TouchSignal().Connect( TestTouchCallback2 );
4315   actorC.TouchSignal().Connect( TestTouchCallback3 );
4316
4317   Dali::Integration::Point point;
4318   point.SetDeviceId( 1 );
4319   point.SetState( PointState::DOWN );
4320   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4321   Dali::Integration::TouchEvent touchEvent;
4322   touchEvent.AddPoint( point );
4323
4324   application.ProcessEvent( touchEvent );
4325
4326   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4327   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4328   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4329
4330   ResetTouchCallbacks();
4331
4332   tet_printf( "Testing Raising of Actor\n" );
4333
4334   int preActorOrder( 0 );
4335   int postActorOrder( 0 );
4336
4337   Property::Value value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4338   value.Get( preActorOrder );
4339
4340   DevelActor::Raise( actorB );
4341   // Ensure sort order is calculated before next touch event
4342   application.SendNotification();
4343
4344   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4345   value.Get( postActorOrder );
4346
4347   tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4348
4349   application.ProcessEvent( touchEvent );
4350
4351   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4352   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true , TEST_LOCATION );
4353   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false, TEST_LOCATION );
4354
4355   ResetTouchCallbacks();
4356
4357   tet_printf( "Testing Lowering of Actor\n" );
4358
4359   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4360   value.Get( preActorOrder );
4361
4362   DevelActor::Lower( actorB );
4363   application.SendNotification(); // ensure sort order calculated before next touch event
4364
4365   value  = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4366   value.Get( postActorOrder );
4367
4368   tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4369
4370   application.ProcessEvent( touchEvent );
4371
4372   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4373   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false , TEST_LOCATION );
4374   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true, TEST_LOCATION );
4375
4376   ResetTouchCallbacks();
4377
4378   END_TEST;
4379 }
4380
4381 int UtcDaliActorRaiseToTopLowerToBottom(void)
4382 {
4383   tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4384
4385   TestApplication application;
4386
4387   Stage stage( Stage::GetCurrent() );
4388
4389   Actor actorA = Actor::New();
4390   Actor actorB = Actor::New();
4391   Actor actorC = Actor::New();
4392
4393   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4394   // enables checking of which actor the uniform is assigned too
4395   Shader shaderA = CreateShader();
4396   shaderA.RegisterProperty( "uRendererColor",1.f);
4397
4398   Shader shaderB = CreateShader();
4399   shaderB.RegisterProperty( "uRendererColor", 2.f );
4400
4401   Shader shaderC = CreateShader();
4402   shaderC.RegisterProperty( "uRendererColor", 3.f );
4403
4404   Geometry geometry = CreateQuadGeometry();
4405
4406   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4407   Renderer rendererA = Renderer::New(geometry, shaderA);
4408   actorA.AddRenderer(rendererA);
4409
4410   Renderer rendererB = Renderer::New(geometry, shaderB);
4411   actorB.AddRenderer(rendererB);
4412
4413   Renderer rendererC = Renderer::New(geometry, shaderC);
4414   actorC.AddRenderer(rendererC);
4415
4416   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4417   actorA.SetParentOrigin( ParentOrigin::CENTER );
4418
4419   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4420   actorB.SetParentOrigin( ParentOrigin::CENTER );
4421
4422   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4423   actorC.SetParentOrigin( ParentOrigin::CENTER );
4424
4425   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4426   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4427
4428   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4429   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4430
4431   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4432   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4433
4434   stage.Add( actorA );
4435   stage.Add( actorB );
4436   stage.Add( actorC );
4437
4438   ResetTouchCallbacks();
4439
4440   // Set up gl abstraction trace so can query the set uniform order
4441   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4442   glAbstraction.EnableSetUniformCallTrace(true);
4443   glAbstraction.ResetSetUniformCallStack();
4444
4445   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4446
4447   application.SendNotification();
4448   application.Render();
4449
4450   tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4451
4452
4453   // Test order of uniforms in stack
4454   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4455   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4456   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4457
4458   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4459
4460   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4461
4462   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4463   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4464   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4465
4466   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4467   // Only top actor will get touched.
4468   actorA.TouchSignal().Connect( TestTouchCallback );
4469   actorB.TouchSignal().Connect( TestTouchCallback2 );
4470   actorC.TouchSignal().Connect( TestTouchCallback3 );
4471
4472   Dali::Integration::Point point;
4473   point.SetDeviceId( 1 );
4474   point.SetState( PointState::DOWN );
4475   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4476   Dali::Integration::TouchEvent touchEvent;
4477   touchEvent.AddPoint( point );
4478
4479   application.ProcessEvent( touchEvent );
4480
4481   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4482   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4483   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4484
4485   ResetTouchCallbacks();
4486
4487   tet_printf( "RaiseToTop ActorA\n" );
4488
4489   DevelActor::RaiseToTop( actorA );
4490   application.SendNotification(); // ensure sorting order is calculated before next touch event
4491
4492   application.ProcessEvent( touchEvent );
4493
4494   glAbstraction.ResetSetUniformCallStack();
4495   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4496
4497   application.SendNotification();
4498   application.Render();
4499
4500   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4501
4502   // Test order of uniforms in stack
4503   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4504   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4505   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4506
4507   tet_infoline( "Testing A above C and B at bottom\n" );
4508   bool ACB = ( indexA > indexC) && ( indexC > indexB );
4509
4510   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4511
4512   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4513   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4514   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4515
4516   ResetTouchCallbacks();
4517
4518   tet_printf( "RaiseToTop ActorB\n" );
4519
4520   DevelActor::RaiseToTop( actorB );
4521   application.SendNotification(); // Ensure sort order is calculated before next touch event
4522
4523   application.ProcessEvent( touchEvent );
4524
4525   glAbstraction.ResetSetUniformCallStack();
4526   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4527
4528   application.SendNotification();
4529   application.Render();
4530
4531   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4532
4533   // Test order of uniforms in stack
4534   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4535   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4536   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4537
4538   tet_infoline( "Testing B above A and C at bottom\n" );
4539   bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4540
4541   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4542
4543   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4544   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4545   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4546
4547   ResetTouchCallbacks();
4548
4549   tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4550
4551   DevelActor::LowerToBottom( actorA );
4552   application.SendNotification();
4553   application.Render();
4554
4555   DevelActor::LowerToBottom( actorB );
4556   application.SendNotification();
4557   application.Render();
4558
4559   application.ProcessEvent( touchEvent );
4560
4561   glAbstraction.ResetSetUniformCallStack();
4562   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4563
4564   application.SendNotification();
4565   application.Render();
4566
4567   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4568
4569   // Test order of uniforms in stack
4570   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4571   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4572   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4573
4574   tet_infoline( "Testing C above A and B at bottom\n" );
4575   bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4576
4577   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4578
4579   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4580   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4581   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4582
4583   ResetTouchCallbacks();
4584
4585   END_TEST;
4586 }
4587
4588 int UtcDaliActorRaiseAbove(void)
4589 {
4590   tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4591
4592   TestApplication application;
4593
4594   Stage stage( Stage::GetCurrent() );
4595
4596   Actor actorA = Actor::New();
4597   Actor actorB = Actor::New();
4598   Actor actorC = Actor::New();
4599
4600   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4601   actorA.SetParentOrigin( ParentOrigin::CENTER );
4602
4603   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4604   actorB.SetParentOrigin( ParentOrigin::CENTER );
4605
4606   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4607   actorC.SetParentOrigin( ParentOrigin::CENTER );
4608
4609   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4610   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4611
4612   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4613   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4614
4615   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4616   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4617
4618   stage.Add( actorA );
4619   stage.Add( actorB );
4620   stage.Add( actorC );
4621
4622   ResetTouchCallbacks();
4623
4624   application.SendNotification();
4625   application.Render();
4626
4627   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4628   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4629   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4630
4631   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4632   // Only top actor will get touched.
4633   actorA.TouchSignal().Connect( TestTouchCallback );
4634   actorB.TouchSignal().Connect( TestTouchCallback2 );
4635   actorC.TouchSignal().Connect( TestTouchCallback3 );
4636
4637   Dali::Integration::Point point;
4638   point.SetDeviceId( 1 );
4639   point.SetState( PointState::DOWN );
4640   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4641   Dali::Integration::TouchEvent touchEvent;
4642   touchEvent.AddPoint( point );
4643
4644   application.ProcessEvent( touchEvent );
4645
4646   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4647   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4648   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
4649
4650   ResetTouchCallbacks();
4651
4652   tet_printf( "Raise actor B Above Actor C\n" );
4653
4654   DevelActor::RaiseAbove( actorB, actorC );
4655   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4656   application.SendNotification();
4657
4658   application.ProcessEvent( touchEvent );
4659
4660   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
4661   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
4662   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4663
4664   ResetTouchCallbacks();
4665
4666   tet_printf( "Raise actor A Above Actor B\n" );
4667
4668   DevelActor::RaiseAbove( actorA, actorB );
4669
4670   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4671   application.SendNotification();
4672
4673   application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4674
4675   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
4676   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
4677   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
4678
4679   ResetTouchCallbacks();
4680
4681   END_TEST;
4682 }
4683
4684 int UtcDaliActorLowerBelow(void)
4685 {
4686   tet_infoline( "UtcDaliActor LowerBelow test \n" );
4687
4688   TestApplication application;
4689
4690   Stage stage( Stage::GetCurrent() );
4691
4692   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4693   // enables checking of which actor the uniform is assigned too
4694   Shader shaderA = CreateShader();
4695   shaderA.RegisterProperty( "uRendererColor",1.f);
4696
4697   Shader shaderB = CreateShader();
4698   shaderB.RegisterProperty( "uRendererColor", 2.f );
4699
4700   Shader shaderC = CreateShader();
4701   shaderC.RegisterProperty( "uRendererColor", 3.f );
4702
4703   Actor actorA = Actor::New();
4704   Actor actorB = Actor::New();
4705   Actor actorC = Actor::New();
4706
4707   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4708   Geometry geometry = CreateQuadGeometry();
4709
4710   Renderer rendererA = Renderer::New(geometry, shaderA);
4711   actorA.AddRenderer(rendererA);
4712
4713   Renderer rendererB = Renderer::New(geometry, shaderB);
4714   actorB.AddRenderer(rendererB);
4715
4716   Renderer rendererC = Renderer::New(geometry, shaderC);
4717   actorC.AddRenderer(rendererC);
4718
4719   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4720   actorA.SetParentOrigin( ParentOrigin::CENTER );
4721
4722   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4723   actorB.SetParentOrigin( ParentOrigin::CENTER );
4724
4725   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4726   actorC.SetParentOrigin( ParentOrigin::CENTER );
4727
4728   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4729   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4730
4731   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4732   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4733
4734   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4735   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4736
4737   stage.Add( actorA );
4738   stage.Add( actorB );
4739   stage.Add( actorC );
4740
4741   ResetTouchCallbacks();
4742
4743   // Set up gl abstraction trace so can query the set uniform order
4744   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4745   glAbstraction.EnableSetUniformCallTrace(true);
4746   glAbstraction.ResetSetUniformCallStack();
4747   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4748
4749   glAbstraction.ResetSetUniformCallStack();
4750
4751   application.SendNotification();
4752   application.Render();
4753
4754   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4755
4756   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4757
4758   // Test order of uniforms in stack
4759   int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4760   int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4761   int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4762
4763   tet_infoline( "Testing C above B and A at bottom\n" );
4764   bool CBA = ( indexC > indexB) &&  ( indexB > indexA );
4765
4766   DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4767
4768   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4769   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4770   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4771
4772   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4773   // Only top actor will get touched.
4774   actorA.TouchSignal().Connect( TestTouchCallback );
4775   actorB.TouchSignal().Connect( TestTouchCallback2 );
4776   actorC.TouchSignal().Connect( TestTouchCallback3 );
4777
4778   Dali::Integration::Point point;
4779   point.SetDeviceId( 1 );
4780   point.SetState( PointState::DOWN );
4781   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4782   Dali::Integration::TouchEvent touchEvent;
4783   touchEvent.AddPoint( point );
4784
4785   tet_infoline( "UtcDaliActor Test Set up completed \n" );
4786
4787   application.ProcessEvent( touchEvent );
4788
4789   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4790   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4791   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4792
4793   ResetTouchCallbacks();
4794
4795   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" );
4796
4797   DevelActor::LowerBelow( actorC, actorB );
4798   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4799   application.SendNotification();
4800   application.Render();
4801
4802   application.ProcessEvent( touchEvent ); // touch event
4803
4804   glAbstraction.ResetSetUniformCallStack();
4805   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4806
4807   application.SendNotification();
4808   application.Render();
4809
4810   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4811
4812   // Test order of uniforms in stack
4813   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4814   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4815   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4816
4817   tet_infoline( "Testing B above A and C at bottom\n" );
4818   bool BAC = ( indexB > indexA) &&  ( indexA > indexC ); // B at TOP, then A then C at bottom
4819
4820   DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4821
4822   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4823   DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4824   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4825
4826   ResetTouchCallbacks();
4827
4828   tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4829
4830   DevelActor::LowerBelow( actorB, actorC );
4831   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4832   application.SendNotification();
4833   application.Render();
4834
4835   application.ProcessEvent( touchEvent );
4836
4837   glAbstraction.ResetSetUniformCallStack();
4838   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4839
4840   application.Render();
4841   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4842
4843   // Test order of uniforms in stack
4844   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4845   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4846   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4847
4848   bool ACB = ( indexA > indexC) &&  ( indexC > indexB ); // A on TOP, then C then B at bottom
4849
4850   DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4851
4852   DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4853   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4854   DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4855
4856   ResetTouchCallbacks();
4857
4858   tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4859
4860   DevelActor::LowerBelow( actorA, actorC );
4861   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4862   application.SendNotification();
4863   application.Render();
4864
4865   application.ProcessEvent( touchEvent );
4866
4867   glAbstraction.ResetSetUniformCallStack();
4868   glSetUniformStack = glAbstraction.GetSetUniformTrace();
4869
4870   application.Render();
4871   tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4872
4873   // Test order of uniforms in stack
4874   indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "3" );
4875   indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "2" );
4876   indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor",  "1" );
4877
4878   bool CAB = ( indexC > indexA) &&  ( indexA > indexB );
4879
4880   DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4881
4882   END_TEST;
4883 }
4884
4885 int UtcDaliActorMaxSiblingOrder(void)
4886 {
4887   tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4888
4889   TestApplication application;
4890
4891   int testOrders[] = { 0,1,3,5,17,998, 999 };
4892   int resultingOrders[] = { 0,1,2,3,4,6,5 };
4893
4894   const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4895
4896   Stage stage( Stage::GetCurrent() );
4897
4898   Actor parent = Actor::New();
4899
4900   for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4901   {
4902     Actor newActor = Actor::New();
4903     newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4904     parent.Add( newActor );
4905   }
4906   stage.Add( parent );
4907
4908   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4909   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4910   {
4911     Actor sibling = parent.GetChildAt( index );
4912     int siblingOrder = 0;
4913     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4914     value.Get( siblingOrder );
4915     tet_printf( "%d, ", siblingOrder );
4916   }
4917   tet_printf( "\n" );
4918
4919   Actor sibling = parent.GetChildAt( 5 );
4920   DevelActor::RaiseToTop( sibling );
4921
4922   // Ensure sorting happens at end of Core::ProcessEvents()
4923   application.SendNotification();
4924   application.Render();
4925
4926   tet_printf( "Sibling Order %d children :",  parent.GetChildCount() );
4927   for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4928   {
4929     Actor sibling = parent.GetChildAt( index );
4930     int siblingOrder = 0;
4931     Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4932     value.Get( siblingOrder );
4933     tet_printf( "%d, ", siblingOrder );
4934     DALI_TEST_EQUALS( siblingOrder,  resultingOrders[ index] , TEST_LOCATION );
4935   }
4936
4937   tet_printf( "\n" );
4938
4939   END_TEST;
4940 }
4941
4942 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4943 {
4944   tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4945
4946   TestApplication application;
4947
4948   Stage stage( Stage::GetCurrent() );
4949
4950   Actor parentA = Actor::New();
4951   Actor parentB = Actor::New();
4952   parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4953   parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4954   parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4955   parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4956
4957   parentA.SetAnchorPoint( AnchorPoint::CENTER );
4958   parentA.SetParentOrigin( ParentOrigin::CENTER );
4959
4960   parentB.SetAnchorPoint( AnchorPoint::CENTER );
4961   parentB.SetParentOrigin( ParentOrigin::CENTER );
4962
4963   stage.Add( parentA );
4964   stage.Add( parentB );
4965
4966   Actor actorA = Actor::New();
4967   Actor actorB = Actor::New();
4968   Actor actorC = Actor::New();
4969
4970   parentA.Add( actorA );
4971   parentA.Add( actorB );
4972
4973   tet_printf( "Actor C added to different parent from A and B \n" );
4974   parentB.Add( actorC );
4975
4976   actorA.SetAnchorPoint( AnchorPoint::CENTER );
4977   actorA.SetParentOrigin( ParentOrigin::CENTER );
4978
4979   actorB.SetAnchorPoint( AnchorPoint::CENTER );
4980   actorB.SetParentOrigin( ParentOrigin::CENTER );
4981
4982   actorC.SetAnchorPoint( AnchorPoint::CENTER );
4983   actorC.SetParentOrigin( ParentOrigin::CENTER );
4984
4985   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4986   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4987
4988   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4989   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4990
4991   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4992   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4993
4994   ResetTouchCallbacks();
4995
4996   application.SendNotification();
4997   application.Render();
4998
4999   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5000   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5001   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5002
5003   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5004   // Only top actor will get touched.
5005   actorA.TouchSignal().Connect( TestTouchCallback );
5006   actorB.TouchSignal().Connect( TestTouchCallback2 );
5007   actorC.TouchSignal().Connect( TestTouchCallback3 );
5008
5009   Dali::Integration::Point point;
5010   point.SetDeviceId( 1 );
5011   point.SetState( PointState::DOWN );
5012   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5013   Dali::Integration::TouchEvent touchEvent;
5014   touchEvent.AddPoint( point );
5015
5016   application.ProcessEvent( touchEvent );
5017
5018   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5019   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5020   DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5021
5022   ResetTouchCallbacks();
5023
5024   tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5025
5026   DevelActor::RaiseAbove( actorA, actorC );
5027   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5028   application.SendNotification();
5029
5030   application.ProcessEvent( touchEvent ); // touch event
5031
5032   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5033   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5034   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5035
5036   ResetTouchCallbacks();
5037
5038   END_TEST;
5039 }
5040
5041 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5042 {
5043   tet_infoline( "UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n" );
5044
5045   TestApplication application;
5046
5047   Stage stage( Stage::GetCurrent() );
5048
5049   Actor actorA = Actor::New();
5050   Actor actorB = Actor::New();
5051   Actor actorC = Actor::New();
5052
5053   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5054   actorA.SetParentOrigin( ParentOrigin::CENTER );
5055
5056   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5057   actorB.SetParentOrigin( ParentOrigin::CENTER );
5058
5059   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5060   actorC.SetParentOrigin( ParentOrigin::CENTER );
5061
5062   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5063   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5064
5065   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5066   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5067
5068   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5069   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5070
5071   ResetTouchCallbacks();
5072
5073   application.SendNotification();
5074   application.Render();
5075
5076   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5077   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5078   DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5079
5080   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5081   // Only top actor will get touched.
5082   actorA.TouchSignal().Connect( TestTouchCallback );
5083   actorB.TouchSignal().Connect( TestTouchCallback2 );
5084   actorC.TouchSignal().Connect( TestTouchCallback3 );
5085
5086   Dali::Integration::Point point;
5087   point.SetDeviceId( 1 );
5088   point.SetState( PointState::DOWN );
5089   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5090   Dali::Integration::TouchEvent touchEvent;
5091   touchEvent.AddPoint( point );
5092
5093   tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5094
5095   DevelActor::RaiseAbove( actorA, actorC );
5096   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5097   application.SendNotification();
5098
5099   application.ProcessEvent( touchEvent );
5100
5101   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5102
5103   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5104   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5105   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5106
5107   ResetTouchCallbacks();
5108
5109   stage.Add ( actorB );
5110   tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5111   DevelActor::LowerBelow( actorA, actorC );
5112
5113   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5114   application.SendNotification();
5115   application.Render();
5116
5117   application.ProcessEvent( touchEvent );
5118
5119   tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5120   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5121   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5122   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5123
5124   ResetTouchCallbacks();
5125
5126   tet_printf( "Adding Actor A to stage, will be on top\n" );
5127
5128   stage.Add ( actorA );
5129   application.SendNotification();
5130   application.Render();
5131
5132   tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5133   DevelActor::RaiseAbove( actorB, 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( "C not parented so RaiseAbove should show no effect\n" );
5140   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5141   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5142   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5143
5144   ResetTouchCallbacks();
5145
5146   tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5147   DevelActor::LowerBelow( actorA, actorC );
5148   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5149   application.SendNotification();
5150
5151   application.ProcessEvent( touchEvent );
5152
5153   tet_printf( "C not parented so LowerBelow should show no effect\n" );
5154   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5155   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5156   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5157
5158   ResetTouchCallbacks();
5159
5160   stage.Add ( actorC );
5161   DevelActor::RaiseAbove( actorA, actorC );
5162   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5163   application.SendNotification();
5164   application.Render();
5165
5166   application.ProcessEvent( touchEvent );
5167
5168   tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5169   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5170   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5171   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5172
5173   END_TEST;
5174 }
5175
5176 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5177 {
5178   tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5179
5180   TestApplication application;
5181
5182   Stage stage( Stage::GetCurrent() );
5183
5184   Actor actorA = Actor::New();
5185   Actor actorB = Actor::New();
5186   Actor actorC = Actor::New();
5187
5188   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5189   actorA.SetParentOrigin( ParentOrigin::CENTER );
5190
5191   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5192   actorB.SetParentOrigin( ParentOrigin::CENTER );
5193
5194   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5195   actorC.SetParentOrigin( ParentOrigin::CENTER );
5196
5197   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5198   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5199
5200   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5201   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5202
5203   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5204   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5205
5206   ResetTouchCallbacks();
5207
5208   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5209   // Only top actor will get touched.
5210   actorA.TouchSignal().Connect( TestTouchCallback );
5211   actorB.TouchSignal().Connect( TestTouchCallback2 );
5212   actorC.TouchSignal().Connect( TestTouchCallback3 );
5213
5214   Dali::Integration::Point point;
5215   point.SetDeviceId( 1 );
5216   point.SetState( PointState::DOWN );
5217   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5218   Dali::Integration::TouchEvent touchEvent;
5219   touchEvent.AddPoint( point );
5220
5221   stage.Add ( actorA );
5222   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5223   DevelActor::Raise( actorB );
5224
5225   application.SendNotification();
5226   application.Render();
5227
5228   application.ProcessEvent( touchEvent );
5229
5230   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5231
5232   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5233   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5234   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5235
5236   tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5237   ResetTouchCallbacks();
5238
5239   DevelActor::Lower( actorC );
5240   // Sort actor tree before next touch event
5241   application.SendNotification();
5242   application.Render();
5243
5244   application.ProcessEvent( touchEvent );
5245
5246   tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5247
5248   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5249   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5250   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5251   ResetTouchCallbacks();
5252
5253   tet_printf( "Lower actor C below B but C not parented\n" );
5254
5255   DevelActor::Lower( actorB );
5256   // Sort actor tree before next touch event
5257   application.SendNotification();
5258   application.Render();
5259
5260   application.ProcessEvent( touchEvent );
5261
5262   tet_printf( "Not parented so Lower should show no effect\n" );
5263
5264   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5265   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5266   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5267   ResetTouchCallbacks();
5268
5269   tet_printf( "Raise actor B to top\n" );
5270
5271   DevelActor::RaiseToTop( actorB );
5272   // Sort actor tree before next touch event
5273   application.SendNotification();
5274   application.Render();
5275
5276   application.ProcessEvent( touchEvent );
5277
5278   tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5279
5280   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5281   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5282   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5283   ResetTouchCallbacks();
5284
5285   tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5286
5287   stage.Add ( actorB );
5288
5289   tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5290
5291   DevelActor::LowerToBottom( actorC );
5292   application.SendNotification();
5293   application.Render();
5294
5295   application.ProcessEvent( touchEvent );
5296
5297   tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5298
5299   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5300   DALI_TEST_EQUALS( gTouchCallBackCalled2,  true, TEST_LOCATION );
5301   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5302   ResetTouchCallbacks();
5303
5304   END_TEST;
5305 }
5306
5307
5308 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5309 {
5310   tet_infoline( "UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n" );
5311
5312   TestApplication application;
5313
5314   Stage stage( Stage::GetCurrent() );
5315
5316   Actor actorA = Actor::New();
5317   Actor actorB = Actor::New();
5318   Actor actorC = Actor::New();
5319
5320   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5321   actorA.SetParentOrigin( ParentOrigin::CENTER );
5322
5323   actorB.SetAnchorPoint( AnchorPoint::CENTER );
5324   actorB.SetParentOrigin( ParentOrigin::CENTER );
5325
5326   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5327   actorC.SetParentOrigin( ParentOrigin::CENTER );
5328
5329   actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5330   actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5331
5332   actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5333   actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5334
5335   actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5336   actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5337
5338   stage.Add( actorA );
5339   stage.Add( actorB );
5340   stage.Add( actorC );
5341
5342   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5343   // Only top actor will get touched.
5344   actorA.TouchSignal().Connect( TestTouchCallback );
5345   actorB.TouchSignal().Connect( TestTouchCallback2 );
5346   actorC.TouchSignal().Connect( TestTouchCallback3 );
5347
5348   ResetTouchCallbacks();
5349
5350   application.SendNotification();
5351   application.Render();
5352
5353   Dali::Integration::Point point;
5354   point.SetDeviceId( 1 );
5355   point.SetState( PointState::DOWN );
5356   point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5357   Dali::Integration::TouchEvent touchEvent;
5358   touchEvent.AddPoint( point );
5359
5360   application.ProcessEvent( touchEvent );
5361
5362   DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5363   DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5364   DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5365
5366   ResetTouchCallbacks();
5367
5368   tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5369
5370   DevelActor::RaiseAbove( actorA, actorA );
5371   application.SendNotification();
5372   application.Render();
5373
5374   application.ProcessEvent( touchEvent );
5375
5376   tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5377
5378   DALI_TEST_EQUALS( gTouchCallBackCalled,  false, TEST_LOCATION );
5379   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5380   DALI_TEST_EQUALS( gTouchCallBackCalled3,  true , TEST_LOCATION );
5381
5382   ResetTouchCallbacks();
5383
5384   DevelActor::RaiseAbove( actorA, actorC );
5385   application.SendNotification();
5386   application.Render();
5387
5388   application.ProcessEvent( touchEvent );
5389
5390   tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5391   DALI_TEST_EQUALS( gTouchCallBackCalled,  true, TEST_LOCATION );
5392   DALI_TEST_EQUALS( gTouchCallBackCalled2,  false, TEST_LOCATION );
5393   DALI_TEST_EQUALS( gTouchCallBackCalled3,  false , TEST_LOCATION );
5394
5395   END_TEST;
5396 }
5397
5398 int UtcDaliActorGetScreenPosition(void)
5399 {
5400   tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5401
5402   TestApplication application;
5403
5404   Stage stage( Stage::GetCurrent() );
5405
5406   Actor actorA = Actor::New();
5407   actorA.SetAnchorPoint( AnchorPoint::CENTER );
5408
5409   Vector2 size2( 10.0f, 20.0f );
5410   actorA.SetSize( size2 );
5411
5412   actorA.SetPosition( 0.f, 0.f );
5413
5414   tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5415
5416   stage.Add( actorA );
5417
5418   application.SendNotification();
5419   application.Render();
5420
5421   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5422   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5423
5424   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n",  actorWorldPosition.x, actorWorldPosition.y  );
5425   tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5426
5427   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5428   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5429
5430   tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5431
5432   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5433
5434   application.SendNotification();
5435   application.Render();
5436
5437   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5438   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5439
5440   tet_printf( "Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y );
5441   tet_printf( "Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5442
5443   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5444   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5445
5446   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5447
5448   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5449
5450   application.SendNotification();
5451   application.Render();
5452
5453   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5454   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5455
5456   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n",  actorWorldPosition.x, actorWorldPosition.y );
5457   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y );
5458
5459   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5460   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5461
5462   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5463
5464   actorA.SetPosition( 30.0, 0.0 );
5465
5466   application.SendNotification();
5467   application.Render();
5468
5469   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5470   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5471
5472   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n",  actorWorldPosition.x, actorWorldPosition.y );
5473   tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y );
5474
5475   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5476   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5477
5478   tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5479
5480   actorA.SetPosition( 30.0, 420.0 );
5481
5482   application.SendNotification();
5483   application.Render();
5484
5485   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5486   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5487
5488   DALI_TEST_EQUALS( actorScreenPosition.x,  30lu , TEST_LOCATION );
5489   DALI_TEST_EQUALS( actorScreenPosition.y,  420lu , TEST_LOCATION );
5490
5491   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n",  actorWorldPosition.x, actorWorldPosition.y );
5492   tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5493
5494
5495   END_TEST;
5496 }
5497
5498 int UtcDaliActorGetScreenPositionAfterScaling(void)
5499 {
5500   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5501
5502   TestApplication application;
5503
5504   Stage stage( Stage::GetCurrent() );
5505
5506   Actor actorA = Actor::New();
5507   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5508
5509   Vector2 size2( 10.0f, 20.0f );
5510   actorA.SetSize( size2 );
5511   actorA.SetScale( 1.5f );
5512   actorA.SetPosition( 0.f, 0.f );
5513
5514   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5515
5516   stage.Add( actorA );
5517
5518   application.SendNotification();
5519   application.Render();
5520
5521   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5522   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5523
5524   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5525   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5526
5527   DALI_TEST_EQUALS( actorScreenPosition.x,  0lu , TEST_LOCATION );
5528   DALI_TEST_EQUALS( actorScreenPosition.y,  0lu , TEST_LOCATION );
5529
5530   tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5531
5532   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5533
5534   application.SendNotification();
5535   application.Render();
5536
5537   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5538   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5539
5540   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5541   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5542
5543   DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f  , TEST_LOCATION );
5544   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5545
5546   END_TEST;
5547 }
5548
5549 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5550 {
5551   tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5552
5553   TestApplication application;
5554
5555   Stage stage( Stage::GetCurrent() );
5556
5557   Actor actorA = Actor::New();
5558   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5559   actorA.SetParentOrigin( ParentOrigin::CENTER );
5560   Vector2 size2( 10.0f, 20.0f );
5561   actorA.SetSize( size2 );
5562   actorA.SetPosition( 0.f, 0.f );
5563
5564   tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5565
5566   stage.Add( actorA );
5567
5568   application.SendNotification();
5569   application.Render();
5570
5571   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5572   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5573
5574   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5575   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5576
5577   DALI_TEST_EQUALS( actorScreenPosition.x,  240.0f , TEST_LOCATION );
5578   DALI_TEST_EQUALS( actorScreenPosition.y,  400.0f , TEST_LOCATION );
5579
5580   tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5581
5582   actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5583   actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5584
5585   application.SendNotification();
5586   application.Render();
5587
5588   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5589   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5590
5591   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n",  actorWorldPosition.x, actorWorldPosition.y  );
5592   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5593
5594   DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5595   DALI_TEST_EQUALS( actorScreenPosition.y,  0.0f , TEST_LOCATION );
5596
5597   END_TEST;
5598   END_TEST;
5599 }
5600
5601 int UtcDaliActorGetScreenPositionWithChildActors(void)
5602 {
5603   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5604
5605   TestApplication application;
5606
5607   Stage stage( Stage::GetCurrent() );
5608
5609   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5610
5611   Actor actorA = Actor::New();
5612   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5613   actorA.SetParentOrigin( ParentOrigin::CENTER );
5614   Vector2 size1( 10.0f, 20.0f );
5615   actorA.SetSize( size1 );
5616   actorA.SetPosition( 0.f, 0.f );
5617
5618   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5619
5620   Actor parentActorA = Actor::New();
5621   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5622   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5623   Vector2 size2( 30.0f, 60.0f );
5624   parentActorA.SetSize( size2 );
5625   parentActorA.SetPosition( 0.f, 0.f );
5626
5627   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5628
5629   stage.Add( parentActorA );
5630   parentActorA.Add ( actorA );
5631
5632   application.SendNotification();
5633   application.Render();
5634
5635   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5636   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5637
5638   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5639   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5640
5641   DALI_TEST_EQUALS( actorScreenPosition.x,  255.0f , TEST_LOCATION );
5642   DALI_TEST_EQUALS( actorScreenPosition.y,  430.0f , TEST_LOCATION );
5643
5644   tet_infoline( "Test 2\n");
5645
5646   tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5647
5648   parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5649   parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5650
5651   application.SendNotification();
5652   application.Render();
5653
5654   actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5655   actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5656
5657   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5658   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5659
5660   DALI_TEST_EQUALS( actorScreenPosition.x,  15.0f , TEST_LOCATION );
5661   DALI_TEST_EQUALS( actorScreenPosition.y,  -30.0f , TEST_LOCATION );
5662
5663   END_TEST;
5664 }
5665
5666 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5667 {
5668   tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5669
5670   TestApplication application;
5671
5672   Stage stage( Stage::GetCurrent() );
5673
5674   tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5675
5676   Actor actorA = Actor::New();
5677   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5678   actorA.SetParentOrigin( ParentOrigin::CENTER );
5679   Vector2 size1( 10.0f, 20.0f );
5680   actorA.SetSize( size1 );
5681   actorA.SetPosition( 0.f, 0.f );
5682
5683   tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5684
5685   Actor parentActorA = Actor::New();
5686   parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5687   parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5688   Vector2 size2( 30.0f, 60.0f );
5689   parentActorA.SetSize( size2 );
5690   parentActorA.SetPosition( 0.f, 0.f );
5691
5692   tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5693
5694   Actor grandParentActorA = Actor::New();
5695   grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5696   grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5697   Vector2 size3( 60.0f, 120.0f );
5698   grandParentActorA.SetSize( size3 );
5699   grandParentActorA.SetPosition( 0.f, 0.f );
5700
5701   tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5702
5703   stage.Add( grandParentActorA );
5704   grandParentActorA.Add ( parentActorA );
5705
5706   tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5707
5708   parentActorA.Add ( actorA );
5709
5710   application.SendNotification();
5711   application.Render();
5712
5713   Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5714   Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5715
5716   tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n",  actorWorldPosition.x, actorWorldPosition.y  );
5717   tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5718
5719   DALI_TEST_EQUALS( actorScreenPosition.x,  45.0f , TEST_LOCATION );
5720   DALI_TEST_EQUALS( actorScreenPosition.y,  770.0f , TEST_LOCATION );
5721
5722   END_TEST;
5723 }
5724
5725 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5726 {
5727   tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5728
5729   TestApplication application;
5730
5731   Stage stage( Stage::GetCurrent() );
5732
5733   tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5734
5735   Actor actorA = Actor::New();
5736   actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5737   actorA.SetParentOrigin( ParentOrigin::CENTER );
5738   actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5739   actorA.SetSize( 10.0f, 20.0f );
5740   stage.Add( actorA );
5741
5742   tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5743
5744   Actor actorB = Actor::New();
5745   actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5746   actorB.SetParentOrigin( ParentOrigin::CENTER );
5747   actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5748   Vector2 actorBSize( 30.0f, 60.0f );
5749   actorB.SetSize( actorBSize );
5750   stage.Add( actorB );
5751
5752   tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5753
5754   Actor actorC = Actor::New();
5755   actorC.SetAnchorPoint( AnchorPoint::CENTER );
5756   actorC.SetParentOrigin( ParentOrigin::CENTER );
5757   actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5758   Vector2 actorCSize( 60.0f, 120.0f );
5759   actorC.SetSize( actorCSize );
5760   stage.Add( actorC );
5761
5762   application.SendNotification();
5763   application.Render();
5764
5765   tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5766
5767   Vector2 center( stage.GetSize() * 0.5f );
5768
5769   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5770   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5771   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5772
5773   tet_infoline( "Add scale to all actors" );
5774
5775   actorA.SetScale( 2.0f );
5776   actorB.SetScale( 2.0f );
5777   actorC.SetScale( 2.0f );
5778
5779   application.SendNotification();
5780   application.Render();
5781
5782   DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5783   DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5784   DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5785
5786   END_TEST;
5787 }
5788
5789 int utcDaliActorPositionUsesAnchorPoint(void)
5790 {
5791   TestApplication application;
5792   tet_infoline( "Check default behaviour\n" );
5793
5794   Actor actor = Actor::New();
5795   actor.SetParentOrigin( ParentOrigin::CENTER );
5796   actor.SetAnchorPoint( AnchorPoint::CENTER );
5797   actor.SetSize( 100.0f, 100.0f );
5798   Stage::GetCurrent().Add( actor );
5799
5800   application.SendNotification();
5801   application.Render();
5802
5803   tet_infoline( "Check that the world position is in the center\n" );
5804   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5805
5806   tet_infoline( "Set the position uses anchor point property to false\n" );
5807   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5808
5809   application.SendNotification();
5810   application.Render();
5811
5812   tet_infoline( "Check that the world position has changed appropriately\n" );
5813   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5814
5815   END_TEST;
5816 }
5817
5818 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5819 {
5820   TestApplication application;
5821   tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5822
5823   Actor actor = Actor::New();
5824   actor.SetParentOrigin( ParentOrigin::CENTER );
5825   actor.SetAnchorPoint( AnchorPoint::CENTER );
5826   actor.SetSize( 100.0f, 100.0f );
5827   actor.SetScale( 2.0f );
5828   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5829   Stage::GetCurrent().Add( actor );
5830
5831   application.SendNotification();
5832   application.Render();
5833
5834   tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5835   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5836
5837   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5838   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5839   application.SendNotification();
5840   application.Render();
5841   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5842
5843   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5844   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5845   application.SendNotification();
5846   application.Render();
5847   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5848
5849   END_TEST;
5850 }
5851
5852 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5853 {
5854   TestApplication application;
5855   tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5856
5857   Actor actor = Actor::New();
5858   actor.SetParentOrigin( ParentOrigin::CENTER );
5859   actor.SetAnchorPoint( AnchorPoint::CENTER );
5860   actor.SetSize( 100.0f, 100.0f );
5861   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5862   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5863   Stage::GetCurrent().Add( actor );
5864
5865   application.SendNotification();
5866   application.Render();
5867
5868   tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5869   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5870
5871   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5872   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5873   application.SendNotification();
5874   application.Render();
5875   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5876
5877   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5878   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5879   application.SendNotification();
5880   application.Render();
5881   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5882
5883   END_TEST;
5884 }
5885
5886 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5887 {
5888   TestApplication application;
5889   tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5890
5891   Actor actor = Actor::New();
5892   actor.SetParentOrigin( ParentOrigin::CENTER );
5893   actor.SetAnchorPoint( AnchorPoint::CENTER );
5894   actor.SetSize( 100.0f, 100.0f );
5895   actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5896   actor.SetScale( 2.0f );
5897   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5898   Stage::GetCurrent().Add( actor );
5899
5900   application.SendNotification();
5901   application.Render();
5902
5903   tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5904   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5905
5906   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5907   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5908   application.SendNotification();
5909   application.Render();
5910   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5911
5912   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5913   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5914   application.SendNotification();
5915   application.Render();
5916   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5917
5918   END_TEST;
5919 }
5920
5921 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5922 {
5923   TestApplication application;
5924   tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5925
5926   Actor parent = Actor::New();
5927
5928   Stage::GetCurrent().Add( parent );
5929   Vector2 stageSize( Stage::GetCurrent().GetSize() );
5930
5931   Actor actor = Actor::New();
5932   actor.SetParentOrigin( ParentOrigin::CENTER );
5933   actor.SetAnchorPoint( AnchorPoint::CENTER );
5934   actor.SetSize( 100.0f, 100.0f );
5935   actor.SetInheritScale( false );
5936   actor.SetInheritOrientation( false );
5937   actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5938   parent.Add( actor );
5939
5940   application.SendNotification();
5941   application.Render();
5942
5943   const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5944
5945   tet_infoline( "Check the world position is in the right place\n" );
5946   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5947
5948   tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5949   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5950   application.SendNotification();
5951   application.Render();
5952   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5953
5954   tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5955   actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5956   application.SendNotification();
5957   application.Render();
5958   DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5959
5960   END_TEST;
5961 }
5962
5963 int utcDaliActorVisibilityChangeSignalSelf(void)
5964 {
5965   TestApplication application;
5966   tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5967
5968   Actor actor = Actor::New();
5969
5970   VisibilityChangedFunctorData data;
5971   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5972
5973   actor.SetVisible( false );
5974
5975   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5976
5977   tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5978   data.Reset();
5979
5980   actor.SetVisible( false );
5981   data.Check( false /* not called */, TEST_LOCATION );
5982
5983   tet_infoline( "Change the visibility using properties, ensure called" );
5984   data.Reset();
5985
5986   actor.SetProperty( Actor::Property::VISIBLE, true );
5987   data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5988
5989   tet_infoline( "Set the visibility to current using properties, ensure not called" );
5990   data.Reset();
5991
5992   actor.SetProperty( Actor::Property::VISIBLE, true );
5993   data.Check( false /* not called */, TEST_LOCATION );
5994
5995   END_TEST;
5996 }
5997
5998 int utcDaliActorVisibilityChangeSignalChildren(void)
5999 {
6000   TestApplication application;
6001   tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6002
6003   Actor parent = Actor::New();
6004   Actor child = Actor::New();
6005   parent.Add( child );
6006
6007   Actor grandChild = Actor::New();
6008   child.Add( grandChild );
6009
6010   VisibilityChangedFunctorData parentData;
6011   VisibilityChangedFunctorData childData;
6012   VisibilityChangedFunctorData grandChildData;
6013
6014   tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6015   DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6016   DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6017
6018   parent.SetVisible( false );
6019   parentData.Check( false /* not called */, TEST_LOCATION );
6020   childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6021   grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6022
6023   tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6024   parentData.Reset();
6025   childData.Reset();
6026   grandChildData.Reset();
6027
6028   DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6029
6030   parent.SetVisible( true );
6031   parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6032   childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6033   grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6034
6035   tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6036   parentData.Reset();
6037   childData.Reset();
6038   grandChildData.Reset();
6039
6040   parent.SetVisible( true );
6041   parentData.Check( false /* not called */, TEST_LOCATION );
6042   childData.Check( false /* not called */, TEST_LOCATION );
6043   grandChildData.Check( false /* not called */, TEST_LOCATION );
6044
6045   END_TEST;
6046 }
6047
6048 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6049 {
6050   TestApplication application;
6051   tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6052
6053   Actor actor = Actor::New();
6054   Stage::GetCurrent().Add( actor );
6055
6056   application.SendNotification();
6057   application.Render();
6058
6059   VisibilityChangedFunctorData data;
6060   DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6061
6062   Animation animation = Animation::New( 1.0f );
6063   animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6064
6065   data.Check( false, TEST_LOCATION );
6066   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6067   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6068
6069   tet_infoline( "Play the animation and check the property value" );
6070   animation.Play();
6071
6072   data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6073   DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6074
6075   tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6076   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6077
6078   application.SendNotification();
6079   application.Render( 1100 ); // After the animation
6080
6081   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6082
6083   END_TEST;
6084 }