dc23be2c8df497d1f8d0242ef67c163e418f2d62
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2020 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 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
20
21 #include <dali-test-suite-utils.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/common/capabilities.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/public-api/dali-core.h>
28 #include <mesh-builder.h>
29
30 #include <cfloat> // For FLT_MAX
31 #include <string>
32
33 #include "assert.h"
34
35 //& set: DaliActor
36
37 using std::string;
38 using namespace Dali;
39
40 void utc_dali_actor_startup(void)
41 {
42   test_return_value = TET_UNDEF;
43 }
44
45 void utc_dali_actor_cleanup(void)
46 {
47   test_return_value = TET_PASS;
48 }
49
50 namespace
51 {
52 bool gTouchCallBackCalled  = false;
53 bool gTouchCallBackCalled2 = false;
54 bool gTouchCallBackCalled3 = false;
55
56 bool gHoverCallBackCalled = false;
57
58 static bool gTestConstraintCalled;
59
60 LayoutDirection::Type gLayoutDirectionType;
61
62 struct TestConstraint
63 {
64   void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
65   {
66     gTestConstraintCalled = true;
67   }
68 };
69
70 /**
71  * TestConstraint reference.
72  * When constraint is called, the resultRef is updated
73  * with the value supplied.
74  */
75 template<typename T>
76 struct TestConstraintRef
77 {
78   TestConstraintRef(unsigned int& resultRef, unsigned int value)
79   : mResultRef(resultRef),
80     mValue(value)
81   {
82   }
83
84   void operator()(T& current, const PropertyInputContainer& /* inputs */)
85   {
86     mResultRef = mValue;
87   }
88
89   unsigned int& mResultRef;
90   unsigned int  mValue;
91 };
92
93 static bool TestTouchCallback(Actor, const TouchEvent&)
94 {
95   gTouchCallBackCalled = true;
96   return true;
97   END_TEST;
98 }
99
100 static bool TestTouchCallback2(Actor, const TouchEvent&)
101 {
102   gTouchCallBackCalled2 = true;
103   return true;
104   END_TEST;
105 }
106
107 static bool TestTouchCallback3(Actor, const TouchEvent&)
108 {
109   gTouchCallBackCalled3 = true;
110   return true;
111   END_TEST;
112 }
113
114 static void ResetTouchCallbacks()
115 {
116   gTouchCallBackCalled  = false;
117   gTouchCallBackCalled2 = false;
118   gTouchCallBackCalled3 = false;
119 }
120
121 static bool TestCallback3(Actor actor, const HoverEvent& event)
122 {
123   gHoverCallBackCalled = true;
124   return false;
125   END_TEST;
126 }
127
128 // validation stuff for onstage & offstage signals
129 static std::vector<std::string> gActorNamesOnOffScene;
130 static int                      gOnSceneCallBackCalled;
131 void                            OnSceneCallback(Actor actor)
132 {
133   ++gOnSceneCallBackCalled;
134   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
135   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
136 }
137 static int gOffSceneCallBackCalled;
138 void       OffSceneCallback(Actor actor)
139 {
140   ++gOffSceneCallBackCalled;
141   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
142   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
143 }
144
145 struct PositionComponentConstraint
146 {
147   PositionComponentConstraint()
148   {
149   }
150
151   void operator()(Vector3& pos, const PropertyInputContainer& inputs)
152   {
153     const Matrix& m = inputs[0]->GetMatrix();
154     Vector3       scale;
155     Quaternion    rot;
156     m.GetTransformComponents(pos, rot, scale);
157   }
158 };
159
160 struct OrientationComponentConstraint
161 {
162   OrientationComponentConstraint()
163   {
164   }
165
166   void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
167   {
168     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
169     Vector3           pos, scale;
170     Quaternion        rot;
171     orientation = parentOrientation;
172   }
173 };
174 // OnRelayout
175
176 static bool                     gOnRelayoutCallBackCalled = false;
177 static std::vector<std::string> gActorNamesRelayout;
178
179 void OnRelayoutCallback(Actor actor)
180 {
181   gOnRelayoutCallBackCalled = true;
182   gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
183 }
184
185 struct VisibilityChangedFunctorData
186 {
187   VisibilityChangedFunctorData()
188   : actor(),
189     visible(false),
190     type(DevelActor::VisibilityChange::SELF),
191     called(false)
192   {
193   }
194
195   void Reset()
196   {
197     actor.Reset();
198     visible = false;
199     type    = DevelActor::VisibilityChange::SELF;
200     called  = false;
201   }
202
203   void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
204   {
205     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
206     DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
207     DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
208     DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
209   }
210
211   void Check(bool compareCalled, const std::string& location)
212   {
213     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
214   }
215
216   Actor                              actor;
217   bool                               visible;
218   DevelActor::VisibilityChange::Type type;
219   bool                               called;
220 };
221
222 struct VisibilityChangedFunctor
223 {
224   VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
225   : data(dataVar)
226   {
227   }
228
229   void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
230   {
231     data.actor   = actor;
232     data.visible = visible;
233     data.type    = type;
234     data.called  = true;
235   }
236
237   VisibilityChangedFunctorData& data;
238 };
239
240 struct VisibilityChangedVoidFunctor
241 {
242   VisibilityChangedVoidFunctor(bool& signalCalled)
243   : mSignalCalled(signalCalled)
244   {
245   }
246
247   void operator()()
248   {
249     mSignalCalled = true;
250   }
251
252   bool& mSignalCalled;
253 };
254
255 struct ChildOrderChangedFunctor
256 {
257   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
258   : mSignalCalled(signalCalled),
259     mActor(actor)
260   {
261   }
262
263   void operator()(Actor actor)
264   {
265     mSignalCalled = true;
266     mActor        = actor;
267   }
268
269   bool&  mSignalCalled;
270   Actor& mActor;
271 };
272
273 struct CulledPropertyNotificationFunctor
274 {
275   CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
276   : mSignalCalled(signalCalled),
277     mPropertyNotification(propertyNotification)
278   {
279   }
280
281   void operator()(PropertyNotification& source)
282   {
283     mSignalCalled         = true;
284     mPropertyNotification = source;
285   }
286
287   bool&                 mSignalCalled;
288   PropertyNotification& mPropertyNotification;
289 };
290
291 } // anonymous namespace
292
293 //& purpose: Testing New API
294 int UtcDaliActorNew(void)
295 {
296   TestApplication application;
297
298   Actor actor = Actor::New();
299
300   DALI_TEST_CHECK(actor);
301   END_TEST;
302 }
303
304 //& purpose: Testing Dali::Actor::DownCast()
305 int UtcDaliActorDownCastP(void)
306 {
307   TestApplication application;
308   tet_infoline("Testing Dali::Actor::DownCast()");
309
310   Actor      actor = Actor::New();
311   BaseHandle object(actor);
312   Actor      actor2 = Actor::DownCast(object);
313   DALI_TEST_CHECK(actor2);
314   END_TEST;
315 }
316
317 //& purpose: Testing Dali::Actor::DownCast()
318 int UtcDaliActorDownCastN(void)
319 {
320   TestApplication application;
321   tet_infoline("Testing Dali::Actor::DownCast()");
322
323   BaseHandle unInitializedObject;
324   Actor      actor = Actor::DownCast(unInitializedObject);
325   DALI_TEST_CHECK(!actor);
326   END_TEST;
327 }
328
329 int UtcDaliActorMoveConstructor(void)
330 {
331   TestApplication application;
332
333   Actor actor = Actor::New();
334   DALI_TEST_CHECK(actor);
335
336   int id = actor.GetProperty<int>(Actor::Property::ID);
337
338   Actor moved = std::move(actor);
339   DALI_TEST_CHECK(moved);
340   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
341   DALI_TEST_CHECK(!actor);
342
343   END_TEST;
344 }
345
346 int UtcDaliActorMoveAssignment(void)
347 {
348   TestApplication application;
349
350   Actor actor = Actor::New();
351   DALI_TEST_CHECK(actor);
352
353   int id = actor.GetProperty<int>(Actor::Property::ID);
354
355   Actor moved;
356   moved = std::move(actor);
357   DALI_TEST_CHECK(moved);
358   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
359   DALI_TEST_CHECK(!actor);
360
361   END_TEST;
362 }
363
364 //& purpose: Testing Dali::Actor::GetName()
365 int UtcDaliActorGetName(void)
366 {
367   TestApplication application;
368
369   Actor actor = Actor::New();
370
371   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
372   END_TEST;
373 }
374
375 //& purpose: Testing Dali::Actor::SetName()
376 int UtcDaliActorSetName(void)
377 {
378   TestApplication application;
379
380   string str("ActorName");
381   Actor  actor = Actor::New();
382
383   actor.SetProperty(Actor::Property::NAME, str);
384   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
385   END_TEST;
386 }
387
388 int UtcDaliActorGetId(void)
389 {
390   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
391   TestApplication application;
392
393   Actor first  = Actor::New();
394   Actor second = Actor::New();
395   Actor third  = Actor::New();
396
397   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
398   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
399   END_TEST;
400 }
401
402 int UtcDaliActorIsRoot(void)
403 {
404   TestApplication application;
405
406   Actor actor = Actor::New();
407   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
408
409   // get the root layer
410   actor = application.GetScene().GetLayer(0);
411   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
412   END_TEST;
413 }
414
415 int UtcDaliActorOnScene(void)
416 {
417   TestApplication application;
418
419   Actor actor = Actor::New();
420   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
421
422   // get the root layer
423   actor = application.GetScene().GetLayer(0);
424   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
425   END_TEST;
426 }
427
428 int UtcDaliActorIsLayer(void)
429 {
430   TestApplication application;
431
432   Actor actor = Actor::New();
433   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
434
435   // get the root layer
436   actor = application.GetScene().GetLayer(0);
437   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
438   END_TEST;
439 }
440
441 int UtcDaliActorGetLayer(void)
442 {
443   TestApplication application;
444
445   Actor actor = Actor::New();
446   application.GetScene().Add(actor);
447   Layer layer = actor.GetLayer();
448
449   DALI_TEST_CHECK(layer);
450
451   // get the root layers layer
452   actor = application.GetScene().GetLayer(0);
453   DALI_TEST_CHECK(actor.GetLayer());
454   END_TEST;
455 }
456
457 int UtcDaliActorAddP(void)
458 {
459   tet_infoline("Testing Actor::Add");
460   TestApplication application;
461
462   Actor parent = Actor::New();
463   Actor child  = Actor::New();
464
465   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
466
467   parent.Add(child);
468
469   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
470
471   Actor parent2 = Actor::New();
472   parent2.Add(child);
473
474   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
475   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
476
477   // try Adding to same parent again, works
478   parent2.Add(child);
479   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
480
481   // try reparenting an orphaned child
482   {
483     Actor temporaryParent = Actor::New();
484     temporaryParent.Add(child);
485     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
486   }
487   // temporaryParent has now died, reparent the orphaned child
488   parent2.Add(child);
489   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
490
491   END_TEST;
492 }
493
494 int UtcDaliActorAddN(void)
495 {
496   tet_infoline("Testing Actor::Add");
497   TestApplication application;
498
499   Actor child = Actor::New();
500
501   Actor parent2 = Actor::New();
502   parent2.Add(child);
503
504   // try illegal Add
505   try
506   {
507     parent2.Add(parent2);
508     tet_printf("Assertion test failed - no Exception\n");
509     tet_result(TET_FAIL);
510   }
511   catch(Dali::DaliException& e)
512   {
513     DALI_TEST_PRINT_ASSERT(e);
514     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
515     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
516   }
517   catch(...)
518   {
519     tet_printf("Assertion test failed - wrong Exception\n");
520     tet_result(TET_FAIL);
521   }
522
523   // try reparenting root
524   try
525   {
526     parent2.Add(application.GetScene().GetLayer(0));
527     tet_printf("Assertion test failed - no Exception\n");
528     tet_result(TET_FAIL);
529   }
530   catch(Dali::DaliException& e)
531   {
532     DALI_TEST_PRINT_ASSERT(e);
533     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
534     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
535   }
536   catch(...)
537   {
538     tet_printf("Assertion test failed - wrong Exception\n");
539     tet_result(TET_FAIL);
540   }
541
542   // try Add empty
543   try
544   {
545     Actor empty;
546     parent2.Add(empty);
547     tet_printf("Assertion test failed - no Exception\n");
548     tet_result(TET_FAIL);
549   }
550   catch(Dali::DaliException& e)
551   {
552     DALI_TEST_PRINT_ASSERT(e);
553     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
554     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
555   }
556   catch(...)
557   {
558     tet_printf("Assertion test failed - wrong Exception\n");
559     tet_result(TET_FAIL);
560   }
561
562   END_TEST;
563 }
564
565 int UtcDaliActorRemoveN(void)
566 {
567   tet_infoline("Testing Actor::Remove");
568   TestApplication application;
569
570   Actor parent = Actor::New();
571   Actor child  = Actor::New();
572   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
573
574   parent.Add(child);
575   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
576
577   parent.Remove(child);
578   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
579
580   // remove again, no problem
581   parent.Remove(child);
582   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
583
584   // add child back
585   parent.Add(child);
586   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
587   // try Remove self, its a no-op
588   parent.Remove(parent);
589   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
590
591   // try Remove empty
592   try
593   {
594     Actor empty;
595     parent.Remove(empty);
596     tet_printf("Assertion test failed - no Exception\n");
597     tet_result(TET_FAIL);
598   }
599   catch(Dali::DaliException& e)
600   {
601     DALI_TEST_PRINT_ASSERT(e);
602     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
603     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
604   }
605   catch(...)
606   {
607     tet_printf("Assertion test failed - wrong Exception\n");
608     tet_result(TET_FAIL);
609   }
610   END_TEST;
611 }
612
613 int UtcDaliActorRemoveP(void)
614 {
615   TestApplication application;
616
617   Actor parent = Actor::New();
618   Actor child  = Actor::New();
619   Actor random = Actor::New();
620
621   application.GetScene().Add(parent);
622
623   DALI_TEST_CHECK(parent.GetChildCount() == 0);
624
625   parent.Add(child);
626
627   DALI_TEST_CHECK(parent.GetChildCount() == 1);
628
629   parent.Remove(random);
630
631   DALI_TEST_CHECK(parent.GetChildCount() == 1);
632
633   application.GetScene().Remove(parent);
634
635   DALI_TEST_CHECK(parent.GetChildCount() == 1);
636   END_TEST;
637 }
638
639 int UtcDaliActorGetChildCount(void)
640 {
641   TestApplication application;
642
643   Actor parent = Actor::New();
644   Actor child  = Actor::New();
645
646   DALI_TEST_CHECK(parent.GetChildCount() == 0);
647
648   parent.Add(child);
649
650   DALI_TEST_CHECK(parent.GetChildCount() == 1);
651   END_TEST;
652 }
653
654 int UtcDaliActorGetChildren01(void)
655 {
656   TestApplication application;
657
658   Actor parent = Actor::New();
659   Actor first  = Actor::New();
660   Actor second = Actor::New();
661   Actor third  = Actor::New();
662
663   parent.Add(first);
664   parent.Add(second);
665   parent.Add(third);
666
667   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
668   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
669   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
670   END_TEST;
671 }
672
673 int UtcDaliActorGetChildren02(void)
674 {
675   TestApplication application;
676
677   Actor parent = Actor::New();
678   Actor first  = Actor::New();
679   Actor second = Actor::New();
680   Actor third  = Actor::New();
681
682   parent.Add(first);
683   parent.Add(second);
684   parent.Add(third);
685
686   const Actor& constParent = parent;
687
688   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
689   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
690   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
691   END_TEST;
692 }
693
694 int UtcDaliActorGetParent01(void)
695 {
696   TestApplication application;
697
698   Actor parent = Actor::New();
699   Actor child  = Actor::New();
700
701   parent.Add(child);
702
703   DALI_TEST_CHECK(child.GetParent() == parent);
704   END_TEST;
705 }
706
707 int UtcDaliActorGetParent02(void)
708 {
709   TestApplication application;
710
711   Actor actor = Actor::New();
712
713   DALI_TEST_CHECK(!actor.GetParent());
714   END_TEST;
715 }
716
717 int UtcDaliActorCustomProperty(void)
718 {
719   TestApplication application;
720
721   Actor actor = Actor::New();
722   application.GetScene().Add(actor);
723
724   float           startValue(1.0f);
725   Property::Index index = actor.RegisterProperty("testProperty", startValue);
726   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
727
728   application.SendNotification();
729   application.Render(0);
730   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
731
732   actor.SetProperty(index, 5.0f);
733
734   application.SendNotification();
735   application.Render(0);
736   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
737   END_TEST;
738 }
739
740 int UtcDaliActorCustomPropertyIntToFloat(void)
741 {
742   TestApplication application;
743
744   Actor actor = Actor::New();
745   application.GetScene().Add(actor);
746
747   float           startValue(5.0f);
748   Property::Index index = actor.RegisterProperty("testProperty", startValue);
749   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
750
751   application.SendNotification();
752   application.Render(0);
753   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
754
755   actor.SetProperty(index, int(1));
756
757   application.SendNotification();
758   application.Render(0);
759   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
760   END_TEST;
761 }
762
763 int UtcDaliActorCustomPropertyFloatToInt(void)
764 {
765   TestApplication application;
766
767   Actor actor = Actor::New();
768   application.GetScene().Add(actor);
769
770   int             startValue(5);
771   Property::Index index = actor.RegisterProperty("testProperty", startValue);
772   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
773
774   application.SendNotification();
775   application.Render(0);
776   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
777
778   actor.SetProperty(index, float(1.5));
779
780   application.SendNotification();
781   application.Render(0);
782   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
783   END_TEST;
784 }
785
786 int UtcDaliActorSetParentOrigin(void)
787 {
788   TestApplication application;
789
790   Actor actor = Actor::New();
791
792   Vector3 vector(0.7f, 0.8f, 0.9f);
793   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
794
795   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
796
797   // flush the queue and render once
798   application.SendNotification();
799   application.Render();
800
801   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
802
803   application.GetScene().Add(actor);
804
805   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
806
807   // flush the queue and render once
808   application.SendNotification();
809   application.Render();
810
811   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
812
813   application.GetScene().Remove(actor);
814   END_TEST;
815 }
816
817 int UtcDaliActorSetParentOriginIndividual(void)
818 {
819   TestApplication application;
820
821   Actor actor = Actor::New();
822
823   Vector3 vector(0.7f, 0.8f, 0.9f);
824   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
825
826   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
827
828   // flush the queue and render once
829   application.SendNotification();
830   application.Render();
831
832   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
833
834   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
835
836   // flush the queue and render once
837   application.SendNotification();
838   application.Render();
839
840   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
841
842   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
843
844   // flush the queue and render once
845   application.SendNotification();
846   application.Render();
847
848   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
849
850   END_TEST;
851 }
852
853 int UtcDaliActorGetCurrentParentOrigin(void)
854 {
855   TestApplication application;
856
857   Actor actor = Actor::New();
858
859   Vector3 vector(0.7f, 0.8f, 0.9f);
860   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
861
862   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
863
864   // flush the queue and render once
865   application.SendNotification();
866   application.Render();
867
868   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
869   END_TEST;
870 }
871
872 int UtcDaliActorSetAnchorPoint(void)
873 {
874   TestApplication application;
875
876   Actor actor = Actor::New();
877
878   Vector3 vector(0.7f, 0.8f, 0.9f);
879   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
880
881   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
882
883   // flush the queue and render once
884   application.SendNotification();
885   application.Render();
886
887   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
888
889   application.GetScene().Add(actor);
890
891   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
892   // flush the queue and render once
893   application.SendNotification();
894   application.Render();
895
896   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
897
898   application.GetScene().Remove(actor);
899   END_TEST;
900 }
901
902 int UtcDaliActorSetAnchorPointIndividual(void)
903 {
904   TestApplication application;
905
906   Actor actor = Actor::New();
907
908   Vector3 vector(0.7f, 0.8f, 0.9f);
909   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
910
911   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
912
913   // flush the queue and render once
914   application.SendNotification();
915   application.Render();
916
917   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
918
919   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
920
921   // flush the queue and render once
922   application.SendNotification();
923   application.Render();
924
925   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
926
927   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
928
929   // flush the queue and render once
930   application.SendNotification();
931   application.Render();
932
933   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
934
935   END_TEST;
936 }
937
938 int UtcDaliActorGetCurrentAnchorPoint(void)
939 {
940   TestApplication application;
941
942   Actor actor = Actor::New();
943
944   Vector3 vector(0.7f, 0.8f, 0.9f);
945   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
946
947   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
948
949   // flush the queue and render once
950   application.SendNotification();
951   application.Render();
952
953   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
954   END_TEST;
955 }
956
957 int UtcDaliActorSetSize01(void)
958 {
959   TestApplication application;
960
961   Actor   actor = Actor::New();
962   Vector3 vector(100.0f, 100.0f, 0.0f);
963
964   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
965
966   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
967
968   // Immediately retrieve the size after setting
969   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
970   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
971   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
972   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
973   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
974
975   // Flush the queue and render once
976   application.SendNotification();
977   application.Render();
978
979   // Check the size in the new frame
980   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
981
982   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
983   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
984   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
985   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
986   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
987
988   // Check async behaviour
989   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
990   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
991   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
992   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
993   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
994
995   // Change the resize policy and check whether the size stays the same
996   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
997
998   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
999   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1000
1001   // Set a new size after resize policy is changed and check the new size
1002   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1003
1004   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1005   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1006
1007   // Change the resize policy again and check whether the new size stays the same
1008   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1009
1010   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1011   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1012
1013   // Set another new size after resize policy is changed and check the new size
1014   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1015
1016   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1017   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1018
1019   END_TEST;
1020 }
1021
1022 int UtcDaliActorSetSize02(void)
1023 {
1024   TestApplication application;
1025
1026   Actor   actor = Actor::New();
1027   Vector3 vector(100.0f, 100.0f, 100.0f);
1028
1029   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1030
1031   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1032
1033   // Immediately check the size after setting
1034   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1035   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1036
1037   // flush the queue and render once
1038   application.SendNotification();
1039   application.Render();
1040
1041   // Check the size in the new frame
1042   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1043
1044   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1045   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1046
1047   END_TEST;
1048 }
1049
1050 // SetSize(Vector2 size)
1051 int UtcDaliActorSetSize03(void)
1052 {
1053   TestApplication application;
1054
1055   Actor   actor = Actor::New();
1056   Vector3 vector(100.0f, 100.0f, 0.0f);
1057
1058   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1059
1060   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1061
1062   // Immediately check the size after setting
1063   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1064   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1065
1066   // flush the queue and render once
1067   application.SendNotification();
1068   application.Render();
1069
1070   // Check the size in the new frame
1071   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1072
1073   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1074   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1075
1076   END_TEST;
1077 }
1078
1079 // SetSize(Vector3 size)
1080 int UtcDaliActorSetSize04(void)
1081 {
1082   TestApplication application;
1083
1084   Actor   actor = Actor::New();
1085   Vector3 vector(100.0f, 100.0f, 100.0f);
1086
1087   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1088
1089   actor.SetProperty(Actor::Property::SIZE, vector);
1090
1091   // Immediately check the size after setting
1092   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1093   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1094
1095   // flush the queue and render once
1096   application.SendNotification();
1097   application.Render();
1098
1099   // Check the size in the new frame
1100   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1101
1102   application.GetScene().Add(actor);
1103   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1104
1105   // Immediately check the size after setting
1106   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1107   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1108
1109   // flush the queue and render once
1110   application.SendNotification();
1111   application.Render();
1112
1113   // Check the size in the new frame
1114   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1115
1116   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1117   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1118
1119   application.GetScene().Remove(actor);
1120   END_TEST;
1121 }
1122
1123 int UtcDaliActorSetSizeIndividual(void)
1124 {
1125   TestApplication application;
1126
1127   Actor actor = Actor::New();
1128
1129   Vector3 vector(0.7f, 0.8f, 0.9f);
1130   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1131
1132   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1133
1134   // Immediately check the width after setting
1135   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1136   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1137
1138   // flush the queue and render once
1139   application.SendNotification();
1140   application.Render();
1141
1142   // Check the width in the new frame
1143   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1144
1145   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1146   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1147
1148   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1149
1150   // Immediately check the height after setting
1151   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1152   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1153
1154   // flush the queue and render once
1155   application.SendNotification();
1156   application.Render();
1157
1158   // Check the height in the new frame
1159   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1160
1161   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1162   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1163
1164   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1165
1166   // Immediately check the depth after setting
1167   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1168   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1169
1170   // flush the queue and render once
1171   application.SendNotification();
1172   application.Render();
1173
1174   // Check the depth in the new frame
1175   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1176
1177   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1178   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1179
1180   // Change the resize policy and check whether the size stays the same
1181   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1182
1183   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1184   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1185
1186   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1187   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1188
1189   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1190   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1191
1192   // Change the resize policy again and check whether the size stays the same
1193   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1194
1195   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1196   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1197
1198   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1199   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1200
1201   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1202   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1203
1204   END_TEST;
1205 }
1206
1207 int UtcDaliActorSetSizeIndividual02(void)
1208 {
1209   TestApplication application;
1210
1211   Actor actor = Actor::New();
1212   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1213   application.GetScene().Add(actor);
1214
1215   Vector3 vector(100.0f, 200.0f, 400.0f);
1216   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1217
1218   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1219   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1220
1221   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1222   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1223
1224   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1225   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1226
1227   // flush the queue and render once
1228   application.SendNotification();
1229   application.Render();
1230
1231   // Check the width in the new frame
1232   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1233   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1234
1235   END_TEST;
1236 }
1237
1238 int UtcDaliActorGetCurrentSize(void)
1239 {
1240   TestApplication application;
1241
1242   Actor   actor = Actor::New();
1243   Vector3 vector(100.0f, 100.0f, 20.0f);
1244
1245   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1246
1247   actor.SetProperty(Actor::Property::SIZE, vector);
1248
1249   // flush the queue and render once
1250   application.SendNotification();
1251   application.Render();
1252
1253   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1254   END_TEST;
1255 }
1256
1257 int UtcDaliActorGetNaturalSize(void)
1258 {
1259   TestApplication application;
1260
1261   Actor   actor = Actor::New();
1262   Vector3 vector(0.0f, 0.0f, 0.0f);
1263
1264   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1265
1266   END_TEST;
1267 }
1268
1269 int UtcDaliActorGetCurrentSizeImmediate(void)
1270 {
1271   TestApplication application;
1272
1273   Actor   actor = Actor::New();
1274   Vector3 vector(100.0f, 100.0f, 20.0f);
1275
1276   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1277   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1278
1279   actor.SetProperty(Actor::Property::SIZE, vector);
1280
1281   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1282   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1283
1284   // flush the queue and render once
1285   application.SendNotification();
1286   application.Render();
1287
1288   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1289   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1290
1291   // Animation
1292   // Build the animation
1293   const float   durationSeconds = 2.0f;
1294   Animation     animation       = Animation::New(durationSeconds);
1295   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1296   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1297
1298   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1299
1300   application.GetScene().Add(actor);
1301
1302   // Start the animation
1303   animation.Play();
1304
1305   application.SendNotification();
1306   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1307
1308   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1309
1310   END_TEST;
1311 }
1312
1313 int UtcDaliActorCalculateScreenExtents(void)
1314 {
1315   TestApplication application;
1316
1317   Actor actor = Actor::New();
1318
1319   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1320   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1321
1322   application.SendNotification();
1323   application.Render();
1324
1325   auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1326   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1327   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1328   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1329   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1330   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1331
1332   application.GetScene().Remove(actor);
1333   END_TEST;
1334 }
1335
1336 // SetPosition(float x, float y)
1337 int UtcDaliActorSetPosition01(void)
1338 {
1339   TestApplication application;
1340
1341   Actor actor = Actor::New();
1342
1343   // Set to random to start off with
1344   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1345
1346   Vector3 vector(100.0f, 100.0f, 0.0f);
1347
1348   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1349
1350   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1351   // flush the queue and render once
1352   application.SendNotification();
1353   application.Render();
1354   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1355
1356   application.GetScene().Add(actor);
1357   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1358   // flush the queue and render once
1359   application.SendNotification();
1360   application.Render();
1361   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1362
1363   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1364   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1365   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1366   // flush the queue and render once
1367   application.SendNotification();
1368   application.Render();
1369   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1370
1371   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1372   // flush the queue and render once
1373   application.SendNotification();
1374   application.Render();
1375   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1376
1377   application.GetScene().Remove(actor);
1378   END_TEST;
1379 }
1380
1381 // SetPosition(float x, float y, float z)
1382 int UtcDaliActorSetPosition02(void)
1383 {
1384   TestApplication application;
1385
1386   Actor actor = Actor::New();
1387
1388   // Set to random to start off with
1389   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1390
1391   Vector3 vector(100.0f, 100.0f, 100.0f);
1392
1393   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1394
1395   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1396
1397   // flush the queue and render once
1398   application.SendNotification();
1399   application.Render();
1400
1401   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1402   END_TEST;
1403 }
1404
1405 // SetPosition(Vector3 position)
1406 int UtcDaliActorSetPosition03(void)
1407 {
1408   TestApplication application;
1409
1410   Actor actor = Actor::New();
1411
1412   // Set to random to start off with
1413   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1414
1415   Vector3 vector(100.0f, 100.0f, 100.0f);
1416
1417   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1418
1419   actor.SetProperty(Actor::Property::POSITION, vector);
1420
1421   // flush the queue and render once
1422   application.SendNotification();
1423   application.Render();
1424
1425   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1426   END_TEST;
1427 }
1428
1429 int UtcDaliActorSetX(void)
1430 {
1431   TestApplication application;
1432
1433   Actor actor = Actor::New();
1434
1435   Vector3 vector(100.0f, 0.0f, 0.0f);
1436
1437   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1438
1439   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1440
1441   // flush the queue and render once
1442   application.SendNotification();
1443   application.Render();
1444
1445   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1446   END_TEST;
1447 }
1448
1449 int UtcDaliActorSetY(void)
1450 {
1451   TestApplication application;
1452
1453   Actor actor = Actor::New();
1454
1455   Vector3 vector(0.0f, 100.0f, 0.0f);
1456
1457   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1458
1459   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1460
1461   // flush the queue and render once
1462   application.SendNotification();
1463   application.Render();
1464
1465   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1466   END_TEST;
1467 }
1468
1469 int UtcDaliActorSetZ(void)
1470 {
1471   TestApplication application;
1472
1473   Actor actor = Actor::New();
1474
1475   Vector3 vector(0.0f, 0.0f, 100.0f);
1476
1477   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1478
1479   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1480
1481   // flush the queue and render once
1482   application.SendNotification();
1483   application.Render();
1484
1485   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1486   END_TEST;
1487 }
1488
1489 int UtcDaliActorSetPositionProperties(void)
1490 {
1491   TestApplication application;
1492
1493   Actor actor = Actor::New();
1494
1495   Vector3 vector(0.7f, 0.8f, 0.9f);
1496   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1497
1498   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1499   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1500   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1501
1502   // flush the queue and render once
1503   application.SendNotification();
1504   application.Render();
1505
1506   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1507   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1508   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1509   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1510   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1511
1512   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1513   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1514   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1515
1516   // flush the queue and render once
1517   application.SendNotification();
1518   application.Render();
1519
1520   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1521   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1522   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1523   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1524   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1525
1526   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1527   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1528   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1529
1530   // flush the queue and render once
1531   application.SendNotification();
1532   application.Render();
1533
1534   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1535   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1536   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1537   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1538   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1539
1540   END_TEST;
1541 }
1542
1543 int UtcDaliActorTranslateBy(void)
1544 {
1545   TestApplication application;
1546
1547   Actor   actor = Actor::New();
1548   Vector3 vector(100.0f, 100.0f, 100.0f);
1549
1550   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1551
1552   actor.SetProperty(Actor::Property::POSITION, vector);
1553
1554   // flush the queue and render once
1555   application.SendNotification();
1556   application.Render();
1557
1558   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1559
1560   actor.TranslateBy(vector);
1561
1562   // flush the queue and render once
1563   application.SendNotification();
1564   application.Render();
1565
1566   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1567   END_TEST;
1568 }
1569
1570 int UtcDaliActorGetCurrentPosition(void)
1571 {
1572   TestApplication application;
1573
1574   Actor   actor = Actor::New();
1575   Vector3 setVector(100.0f, 100.0f, 0.0f);
1576   actor.SetProperty(Actor::Property::POSITION, setVector);
1577
1578   // flush the queue and render once
1579   application.SendNotification();
1580   application.Render();
1581
1582   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1583   END_TEST;
1584 }
1585
1586 int UtcDaliActorGetCurrentWorldPosition(void)
1587 {
1588   TestApplication application;
1589
1590   Actor   parent = Actor::New();
1591   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1592   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1593   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1594   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1595   application.GetScene().Add(parent);
1596
1597   Actor child = Actor::New();
1598   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1599   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1600   Vector3 childPosition(6.0f, 6.0f, 6.0f);
1601   child.SetProperty(Actor::Property::POSITION, childPosition);
1602   parent.Add(child);
1603
1604   // The actors should not have a world position yet
1605   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1606   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1607
1608   application.SendNotification();
1609   application.Render(0);
1610
1611   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1612   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1613
1614   // The actors should have a world position now
1615   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1616   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1617   END_TEST;
1618 }
1619
1620 int UtcDaliActorSetInheritPosition(void)
1621 {
1622   tet_infoline("Testing Actor::SetInheritPosition");
1623   TestApplication application;
1624
1625   Actor   parent = Actor::New();
1626   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1627   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1628   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1629   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1630   application.GetScene().Add(parent);
1631
1632   Actor child = Actor::New();
1633   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1634   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1635   Vector3 childPosition(10.0f, 11.0f, 12.0f);
1636   child.SetProperty(Actor::Property::POSITION, childPosition);
1637   parent.Add(child);
1638
1639   // The actors should not have a world position yet
1640   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1641   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1642
1643   // first test default, which is to inherit position
1644   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1645   application.SendNotification();
1646   application.Render(0); // should only really call Update as Render is not required to update scene
1647   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1648   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1649   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1650   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1651
1652   //Change child position
1653   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1654   child.SetProperty(Actor::Property::POSITION, childOffset);
1655
1656   // Use local position as world postion
1657   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1658   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1659   application.SendNotification();
1660   application.Render(0); // should only really call Update as Render is not required to update scene
1661   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1662   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1663   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1664   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1665
1666   //Change back to inherit position from parent
1667   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1668   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1669   application.SendNotification();
1670   application.Render(0); // should only really call Update as Render is not required to update scene
1671   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1672   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1673   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1674   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1675   END_TEST;
1676 }
1677
1678 int UtcDaliActorInheritOpacity(void)
1679 {
1680   tet_infoline("Testing Actor::Inherit Opacity");
1681   TestApplication application;
1682
1683   Actor parent = Actor::New();
1684   Actor child  = Actor::New();
1685   parent.Add(child);
1686   application.GetScene().Add(parent);
1687
1688   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1689   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1690
1691   // flush the queue and render once
1692   application.SendNotification();
1693   application.Render();
1694
1695   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1696
1697   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1698   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1699
1700   application.SendNotification();
1701   application.Render();
1702
1703   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1704   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1705   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1706   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1707   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1708   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1709
1710   END_TEST;
1711 }
1712
1713 // SetOrientation(float angleRadians, Vector3 axis)
1714 int UtcDaliActorSetOrientation01(void)
1715 {
1716   TestApplication application;
1717
1718   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1719   Actor      actor = Actor::New();
1720
1721   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1722
1723   // flush the queue and render once
1724   application.SendNotification();
1725   application.Render();
1726
1727   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1728   END_TEST;
1729 }
1730
1731 int UtcDaliActorSetOrientation02(void)
1732 {
1733   TestApplication application;
1734
1735   Actor actor = Actor::New();
1736
1737   Radian  angle(0.785f);
1738   Vector3 axis(1.0f, 1.0f, 0.0f);
1739
1740   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1741   Quaternion rotation(angle, axis);
1742   // flush the queue and render once
1743   application.SendNotification();
1744   application.Render();
1745   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1746
1747   application.GetScene().Add(actor);
1748   actor.RotateBy(Degree(360), axis);
1749   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1750
1751   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1752   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1753   // flush the queue and render once
1754   application.SendNotification();
1755   application.Render();
1756   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1757
1758   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1759   // flush the queue and render once
1760   application.SendNotification();
1761   application.Render();
1762   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1763
1764   application.GetScene().Remove(actor);
1765   END_TEST;
1766 }
1767
1768 // SetOrientation(float angleRadians, Vector3 axis)
1769 int UtcDaliActorSetOrientationProperty(void)
1770 {
1771   TestApplication application;
1772
1773   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1774   Actor      actor = Actor::New();
1775
1776   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1777   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1778
1779   // flush the queue and render once
1780   application.SendNotification();
1781   application.Render();
1782
1783   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1784   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1785   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1786   END_TEST;
1787 }
1788
1789 // RotateBy(float angleRadians, Vector3 axis)
1790 int UtcDaliActorRotateBy01(void)
1791 {
1792   TestApplication application;
1793
1794   Actor actor = Actor::New();
1795
1796   Radian angle(M_PI * 0.25f);
1797   actor.RotateBy((angle), Vector3::ZAXIS);
1798   // flush the queue and render once
1799   application.SendNotification();
1800   application.Render();
1801   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1802
1803   application.GetScene().Add(actor);
1804
1805   actor.RotateBy(angle, Vector3::ZAXIS);
1806   // flush the queue and render once
1807   application.SendNotification();
1808   application.Render();
1809   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1810
1811   application.GetScene().Remove(actor);
1812   END_TEST;
1813 }
1814
1815 // RotateBy(Quaternion relativeRotation)
1816 int UtcDaliActorRotateBy02(void)
1817 {
1818   TestApplication application;
1819
1820   Actor actor = Actor::New();
1821
1822   Radian     angle(M_PI * 0.25f);
1823   Quaternion rotation(angle, Vector3::ZAXIS);
1824   actor.RotateBy(rotation);
1825   // flush the queue and render once
1826   application.SendNotification();
1827   application.Render();
1828   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1829
1830   actor.RotateBy(rotation);
1831   // flush the queue and render once
1832   application.SendNotification();
1833   application.Render();
1834   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1835   END_TEST;
1836 }
1837
1838 int UtcDaliActorGetCurrentOrientation(void)
1839 {
1840   TestApplication application;
1841   Actor           actor = Actor::New();
1842
1843   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1844   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1845   // flush the queue and render once
1846   application.SendNotification();
1847   application.Render();
1848   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1849   END_TEST;
1850 }
1851
1852 int UtcDaliActorGetCurrentWorldOrientation(void)
1853 {
1854   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1855   TestApplication application;
1856
1857   Actor      parent = Actor::New();
1858   Radian     rotationAngle(Degree(90.0f));
1859   Quaternion rotation(rotationAngle, Vector3::YAXIS);
1860   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1861   application.GetScene().Add(parent);
1862
1863   Actor child = Actor::New();
1864   child.SetProperty(Actor::Property::ORIENTATION, rotation);
1865   parent.Add(child);
1866
1867   // The actors should not have a world rotation yet
1868   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1869   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1870
1871   application.SendNotification();
1872   application.Render(0);
1873
1874   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1875   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1876
1877   // The actors should have a world rotation now
1878   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1879   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1880
1881   // turn off child rotation inheritance
1882   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1883   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1884   application.SendNotification();
1885   application.Render(0);
1886
1887   // The actors should have a world rotation now
1888   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1889   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1890   END_TEST;
1891 }
1892
1893 // SetScale(float scale)
1894 int UtcDaliActorSetScale01(void)
1895 {
1896   TestApplication application;
1897
1898   Actor actor = Actor::New();
1899
1900   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1901   actor.SetProperty(Actor::Property::SCALE, 0.25f);
1902
1903   Vector3 scale(10.0f, 10.0f, 10.0f);
1904   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1905
1906   actor.SetProperty(Actor::Property::SCALE, scale.x);
1907
1908   // flush the queue and render once
1909   application.SendNotification();
1910   application.Render();
1911
1912   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1913   END_TEST;
1914 }
1915
1916 // SetScale(float scaleX, float scaleY, float scaleZ)
1917 int UtcDaliActorSetScale02(void)
1918 {
1919   TestApplication application;
1920   Vector3         scale(10.0f, 10.0f, 10.0f);
1921
1922   Actor actor = Actor::New();
1923
1924   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1925   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1926
1927   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1928
1929   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1930   // flush the queue and render once
1931   application.SendNotification();
1932   application.Render();
1933   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1934
1935   // add to stage and test
1936   application.GetScene().Add(actor);
1937   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1938   // flush the queue and render once
1939   application.SendNotification();
1940   application.Render();
1941   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1942
1943   application.GetScene().Remove(actor);
1944
1945   END_TEST;
1946 }
1947
1948 // SetScale(Vector3 scale)
1949 int UtcDaliActorSetScale03(void)
1950 {
1951   TestApplication application;
1952   Vector3         scale(10.0f, 10.0f, 10.0f);
1953
1954   Actor actor = Actor::New();
1955
1956   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1957   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1958
1959   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1960
1961   actor.SetProperty(Actor::Property::SCALE, scale);
1962
1963   // flush the queue and render once
1964   application.SendNotification();
1965   application.Render();
1966
1967   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1968   END_TEST;
1969 }
1970
1971 int UtcDaliActorSetScaleIndividual(void)
1972 {
1973   TestApplication application;
1974
1975   Actor actor = Actor::New();
1976
1977   Vector3 vector(0.7f, 0.8f, 0.9f);
1978   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1979
1980   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1981   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1982
1983   // flush the queue and render once
1984   application.SendNotification();
1985   application.Render();
1986
1987   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1988   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1989   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1990
1991   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
1992   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1993
1994   // flush the queue and render once
1995   application.SendNotification();
1996   application.Render();
1997
1998   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
1999   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2000   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2001
2002   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2003   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2004
2005   // flush the queue and render once
2006   application.SendNotification();
2007   application.Render();
2008
2009   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2010   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2011   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2012
2013   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2014   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2015
2016   END_TEST;
2017 }
2018
2019 int UtcDaliActorScaleBy(void)
2020 {
2021   TestApplication application;
2022   Actor           actor = Actor::New();
2023   Vector3         vector(100.0f, 100.0f, 100.0f);
2024
2025   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2026
2027   actor.SetProperty(Actor::Property::SCALE, vector);
2028
2029   // flush the queue and render once
2030   application.SendNotification();
2031   application.Render();
2032
2033   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2034
2035   actor.ScaleBy(vector);
2036
2037   // flush the queue and render once
2038   application.SendNotification();
2039   application.Render();
2040
2041   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2042   END_TEST;
2043 }
2044
2045 int UtcDaliActorGetCurrentScale(void)
2046 {
2047   TestApplication application;
2048   Vector3         scale(12.0f, 1.0f, 2.0f);
2049
2050   Actor actor = Actor::New();
2051
2052   actor.SetProperty(Actor::Property::SCALE, scale);
2053
2054   // flush the queue and render once
2055   application.SendNotification();
2056   application.Render();
2057
2058   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2059   END_TEST;
2060 }
2061
2062 int UtcDaliActorGetCurrentWorldScale(void)
2063 {
2064   TestApplication application;
2065
2066   Actor   parent = Actor::New();
2067   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2068   parent.SetProperty(Actor::Property::SCALE, parentScale);
2069   application.GetScene().Add(parent);
2070
2071   Actor   child = Actor::New();
2072   Vector3 childScale(2.0f, 2.0f, 2.0f);
2073   child.SetProperty(Actor::Property::SCALE, childScale);
2074   parent.Add(child);
2075
2076   // The actors should not have a scale yet
2077   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2078   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2079
2080   // The actors should not have a world scale yet
2081   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2082   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2083
2084   application.SendNotification();
2085   application.Render(0);
2086
2087   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2088   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2089
2090   // The actors should have a world scale now
2091   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2092   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2093   END_TEST;
2094 }
2095
2096 int UtcDaliActorInheritScale(void)
2097 {
2098   tet_infoline("Testing Actor::SetInheritScale");
2099   TestApplication application;
2100
2101   Actor   parent = Actor::New();
2102   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2103   parent.SetProperty(Actor::Property::SCALE, parentScale);
2104   application.GetScene().Add(parent);
2105
2106   Actor   child = Actor::New();
2107   Vector3 childScale(2.0f, 2.0f, 2.0f);
2108   child.SetProperty(Actor::Property::SCALE, childScale);
2109   parent.Add(child);
2110
2111   application.SendNotification();
2112   application.Render(0);
2113
2114   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2115   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2116
2117   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2118   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2119
2120   application.SendNotification();
2121   application.Render(0);
2122
2123   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2124   END_TEST;
2125 }
2126
2127 int UtcDaliActorSetVisible(void)
2128 {
2129   TestApplication application;
2130
2131   Actor actor = Actor::New();
2132   actor.SetProperty(Actor::Property::VISIBLE, false);
2133   // flush the queue and render once
2134   application.SendNotification();
2135   application.Render();
2136   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2137
2138   actor.SetProperty(Actor::Property::VISIBLE, true);
2139   // flush the queue and render once
2140   application.SendNotification();
2141   application.Render();
2142   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2143
2144   // put actor on stage
2145   application.GetScene().Add(actor);
2146   actor.SetProperty(Actor::Property::VISIBLE, false);
2147   // flush the queue and render once
2148   application.SendNotification();
2149   application.Render();
2150   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2151   END_TEST;
2152 }
2153
2154 int UtcDaliActorIsVisible(void)
2155 {
2156   TestApplication application;
2157
2158   Actor actor = Actor::New();
2159
2160   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2161   END_TEST;
2162 }
2163
2164 int UtcDaliActorSetOpacity(void)
2165 {
2166   TestApplication application;
2167
2168   Actor actor = Actor::New();
2169   // initial opacity is 1
2170   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2171
2172   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2173   // flush the queue and render once
2174   application.SendNotification();
2175   application.Render();
2176   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2177
2178   // change opacity, actor is on stage to change is not immediate
2179   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2180   // flush the queue and render once
2181   application.SendNotification();
2182   application.Render();
2183   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2184
2185   // put actor on stage
2186   application.GetScene().Add(actor);
2187
2188   // change opacity, actor is on stage to change is not immediate
2189   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2190   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2191   // flush the queue and render once
2192   application.SendNotification();
2193   application.Render();
2194   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2195
2196   // change opacity, actor is on stage to change is not immediate
2197   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2198   // flush the queue and render once
2199   application.SendNotification();
2200   application.Render();
2201   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2202   END_TEST;
2203 }
2204
2205 int UtcDaliActorGetCurrentOpacity(void)
2206 {
2207   TestApplication application;
2208
2209   Actor actor = Actor::New();
2210   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2211
2212   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2213   // flush the queue and render once
2214   application.SendNotification();
2215   application.Render();
2216   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2217   END_TEST;
2218 }
2219
2220 int UtcDaliActorSetSensitive(void)
2221 {
2222   TestApplication application;
2223   Actor           actor = Actor::New();
2224
2225   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2226
2227   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2228
2229   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2230   END_TEST;
2231 }
2232
2233 int UtcDaliActorIsSensitive(void)
2234 {
2235   TestApplication application;
2236   Actor           actor = Actor::New();
2237   actor.SetProperty(Actor::Property::SENSITIVE, false);
2238
2239   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2240   END_TEST;
2241 }
2242
2243 int UtcDaliActorSetColor(void)
2244 {
2245   TestApplication application;
2246   Actor           actor = Actor::New();
2247   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2248
2249   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2250
2251   actor.SetProperty(Actor::Property::COLOR, color);
2252   // flush the queue and render once
2253   application.SendNotification();
2254   application.Render();
2255   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2256
2257   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2258   // flush the queue and render once
2259   application.SendNotification();
2260   application.Render();
2261   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2262
2263   application.GetScene().Add(actor);
2264   actor.SetProperty(Actor::Property::COLOR, color);
2265   // flush the queue and render once
2266   application.SendNotification();
2267   application.Render();
2268   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2269
2270   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2271   // flush the queue and render once
2272   application.SendNotification();
2273   application.Render();
2274   // Actor color is not clamped
2275   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2276   // world color is clamped
2277   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2278
2279   actor.SetProperty(Actor::Property::COLOR, color);
2280   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2281
2282   Vector3 newColor(1.0f, 0.0f, 0.0f);
2283   actor.SetProperty(Actor::Property::COLOR, newColor);
2284   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2285
2286   application.GetScene().Remove(actor);
2287   END_TEST;
2288 }
2289
2290 int UtcDaliActorSetColorIndividual(void)
2291 {
2292   TestApplication application;
2293
2294   Actor actor = Actor::New();
2295
2296   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2297   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2298
2299   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2300   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2301
2302   // flush the queue and render once
2303   application.SendNotification();
2304   application.Render();
2305
2306   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2307   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2308   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2309
2310   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2311   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2312
2313   // flush the queue and render once
2314   application.SendNotification();
2315   application.Render();
2316
2317   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2318   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2319   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2320
2321   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2322   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2323
2324   // flush the queue and render once
2325   application.SendNotification();
2326   application.Render();
2327
2328   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2329   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2330   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2331
2332   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2333   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2334
2335   // flush the queue and render once
2336   application.SendNotification();
2337   application.Render();
2338
2339   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2340   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2341   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2342
2343   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2344   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2345
2346   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2347
2348   // flush the queue and render once
2349   application.SendNotification();
2350   application.Render();
2351
2352   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2353
2354   END_TEST;
2355 }
2356
2357 int UtcDaliActorGetCurrentColor(void)
2358 {
2359   TestApplication application;
2360   Actor           actor = Actor::New();
2361   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2362
2363   actor.SetProperty(Actor::Property::COLOR, color);
2364   // flush the queue and render once
2365   application.SendNotification();
2366   application.Render();
2367   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2368   END_TEST;
2369 }
2370
2371 int UtcDaliActorGetCurrentWorldColor(void)
2372 {
2373   tet_infoline("Actor::GetCurrentWorldColor");
2374   TestApplication application;
2375
2376   Actor   parent = Actor::New();
2377   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2378   parent.SetProperty(Actor::Property::COLOR, parentColor);
2379   application.GetScene().Add(parent);
2380
2381   Actor   child = Actor::New();
2382   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2383   child.SetProperty(Actor::Property::COLOR, childColor);
2384   parent.Add(child);
2385
2386   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2387   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2388
2389   // verify the default color mode
2390   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2391
2392   // The actors should not have a world color yet
2393   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2394   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2395
2396   application.SendNotification();
2397   application.Render(0);
2398
2399   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2400   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2401
2402   // The actors should have a world color now
2403   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2404   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2405
2406   // use own color
2407   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2408   application.SendNotification();
2409   application.Render(0);
2410   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2411
2412   // use parent color
2413   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2414   application.SendNotification();
2415   application.Render(0);
2416   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2417   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2418
2419   // use parent alpha
2420   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2421   application.SendNotification();
2422   application.Render(0);
2423   Vector4 expectedColor(childColor);
2424   expectedColor.a *= parentColor.a;
2425   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2426   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2427   END_TEST;
2428 }
2429
2430 int UtcDaliActorSetColorMode(void)
2431 {
2432   tet_infoline("Actor::SetColorMode");
2433   TestApplication application;
2434   Actor           actor = Actor::New();
2435   Actor           child = Actor::New();
2436   actor.Add(child);
2437
2438   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2439   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2440
2441   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2442   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2443
2444   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2445   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2446
2447   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2448   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2449   END_TEST;
2450 }
2451
2452 int UtcDaliActorScreenToLocal(void)
2453 {
2454   TestApplication application;
2455   Actor           actor = Actor::New();
2456   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2457   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2458   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2459   application.GetScene().Add(actor);
2460
2461   // flush the queue and render once
2462   application.SendNotification();
2463   application.Render();
2464
2465   float localX;
2466   float localY;
2467
2468   application.SendNotification();
2469   application.Render();
2470
2471   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2472
2473   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2474   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2475   END_TEST;
2476 }
2477
2478 int UtcDaliActorSetLeaveRequired(void)
2479 {
2480   TestApplication application;
2481
2482   Actor actor = Actor::New();
2483
2484   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2485   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2486
2487   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2488   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2489   END_TEST;
2490 }
2491
2492 int UtcDaliActorGetLeaveRequired(void)
2493 {
2494   TestApplication application;
2495
2496   Actor actor = Actor::New();
2497
2498   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2499   END_TEST;
2500 }
2501
2502 int UtcDaliActorSetKeyboardFocusable(void)
2503 {
2504   TestApplication application;
2505
2506   Actor actor = Actor::New();
2507
2508   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2509   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2510
2511   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2512   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2513   END_TEST;
2514 }
2515
2516 int UtcDaliActorIsKeyboardFocusable(void)
2517 {
2518   TestApplication application;
2519
2520   Actor actor = Actor::New();
2521
2522   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2523   END_TEST;
2524 }
2525
2526 int UtcDaliActorRemoveConstraints(void)
2527 {
2528   tet_infoline(" UtcDaliActorRemoveConstraints");
2529   TestApplication application;
2530
2531   gTestConstraintCalled = false;
2532
2533   Actor actor = Actor::New();
2534
2535   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2536   constraint.Apply();
2537   actor.RemoveConstraints();
2538
2539   DALI_TEST_CHECK(gTestConstraintCalled == false);
2540
2541   application.GetScene().Add(actor);
2542   constraint.Apply();
2543
2544   // flush the queue and render once
2545   application.SendNotification();
2546   application.Render();
2547
2548   actor.RemoveConstraints();
2549
2550   DALI_TEST_CHECK(gTestConstraintCalled == true);
2551   END_TEST;
2552 }
2553
2554 int UtcDaliActorRemoveConstraintTag(void)
2555 {
2556   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2557   TestApplication application;
2558
2559   Actor actor = Actor::New();
2560
2561   // 1. Apply Constraint1 and Constraint2, and test...
2562   unsigned int result1 = 0u;
2563   unsigned int result2 = 0u;
2564
2565   unsigned   constraint1Tag = 1u;
2566   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2567   constraint1.SetTag(constraint1Tag);
2568   constraint1.Apply();
2569
2570   unsigned   constraint2Tag = 2u;
2571   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2572   constraint2.SetTag(constraint2Tag);
2573   constraint2.Apply();
2574
2575   application.GetScene().Add(actor);
2576   // flush the queue and render once
2577   application.SendNotification();
2578   application.Render();
2579
2580   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2581   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2582
2583   // 2. Remove Constraint1 and test...
2584   result1 = 0;
2585   result2 = 0;
2586   actor.RemoveConstraints(constraint1Tag);
2587   // make color property dirty, which will trigger constraints to be reapplied.
2588   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2589   // flush the queue and render once
2590   application.SendNotification();
2591   application.Render();
2592
2593   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2594   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2595
2596   // 3. Re-Apply Constraint1 and test...
2597   result1 = 0;
2598   result2 = 0;
2599   constraint1.Apply();
2600   // make color property dirty, which will trigger constraints to be reapplied.
2601   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2602   // flush the queue and render once
2603   application.SendNotification();
2604   application.Render();
2605
2606   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2607   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2608
2609   // 2. Remove Constraint2 and test...
2610   result1 = 0;
2611   result2 = 0;
2612   actor.RemoveConstraints(constraint2Tag);
2613   // make color property dirty, which will trigger constraints to be reapplied.
2614   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2615   // flush the queue and render once
2616   application.SendNotification();
2617   application.Render();
2618
2619   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2620   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2621
2622   // 2. Remove Constraint1 as well and test...
2623   result1 = 0;
2624   result2 = 0;
2625   actor.RemoveConstraints(constraint1Tag);
2626   // make color property dirty, which will trigger constraints to be reapplied.
2627   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2628   // flush the queue and render once
2629   application.SendNotification();
2630   application.Render();
2631
2632   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2633   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2634   END_TEST;
2635 }
2636
2637 int UtcDaliActorTouchedSignal(void)
2638 {
2639   TestApplication application;
2640
2641   ResetTouchCallbacks();
2642
2643   // get the root layer
2644   Actor actor = application.GetScene().GetRootLayer();
2645   DALI_TEST_CHECK(gTouchCallBackCalled == false);
2646
2647   application.SendNotification();
2648   application.Render();
2649
2650   // connect to its touch signal
2651   actor.TouchedSignal().Connect(TestTouchCallback);
2652
2653   // simulate a touch event in the middle of the screen
2654   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2655   Dali::Integration::Point point;
2656   point.SetDeviceId(1);
2657   point.SetState(PointState::DOWN);
2658   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2659   Dali::Integration::TouchEvent touchEvent;
2660   touchEvent.AddPoint(point);
2661   application.ProcessEvent(touchEvent);
2662
2663   DALI_TEST_CHECK(gTouchCallBackCalled == true);
2664   END_TEST;
2665 }
2666
2667 int UtcDaliActorHoveredSignal(void)
2668 {
2669   TestApplication application;
2670
2671   gHoverCallBackCalled = false;
2672
2673   // get the root layer
2674   Actor actor = application.GetScene().GetRootLayer();
2675   DALI_TEST_CHECK(gHoverCallBackCalled == false);
2676
2677   application.SendNotification();
2678   application.Render();
2679
2680   // connect to its hover signal
2681   actor.HoveredSignal().Connect(TestCallback3);
2682
2683   // simulate a hover event in the middle of the screen
2684   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2685   Dali::Integration::Point point;
2686   point.SetDeviceId(1);
2687   point.SetState(PointState::MOTION);
2688   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2689   Dali::Integration::HoverEvent hoverEvent;
2690   hoverEvent.AddPoint(point);
2691   application.ProcessEvent(hoverEvent);
2692
2693   DALI_TEST_CHECK(gHoverCallBackCalled == true);
2694   END_TEST;
2695 }
2696
2697 int UtcDaliActorOnOffSceneSignal(void)
2698 {
2699   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2700
2701   TestApplication application;
2702
2703   // clean test data
2704   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2705   gActorNamesOnOffScene.clear();
2706
2707   Actor parent = Actor::New();
2708   parent.SetProperty(Actor::Property::NAME, "parent");
2709   parent.OnSceneSignal().Connect(OnSceneCallback);
2710   parent.OffSceneSignal().Connect(OffSceneCallback);
2711   // sanity check
2712   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2713   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2714
2715   // add parent to the scene
2716   application.GetScene().Add(parent);
2717   // onstage emitted, offstage not
2718   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2719   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2720   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2721
2722   // test adding a child, should get onstage emitted
2723   // clean test data
2724   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2725   gActorNamesOnOffScene.clear();
2726
2727   Actor child = Actor::New();
2728   child.SetProperty(Actor::Property::NAME, "child");
2729   child.OnSceneSignal().Connect(OnSceneCallback);
2730   child.OffSceneSignal().Connect(OffSceneCallback);
2731   parent.Add(child); // add child
2732   // onscene emitted, offscene not
2733   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2734   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2735   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2736
2737   // test removing parent from the scene
2738   // clean test data
2739   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2740   gActorNamesOnOffScene.clear();
2741
2742   application.GetScene().Remove(parent);
2743   // onscene not emitted, offscene is
2744   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2745   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2746   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2747   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2748
2749   // test adding parent back to the scene
2750   // clean test data
2751   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2752   gActorNamesOnOffScene.clear();
2753
2754   application.GetScene().Add(parent);
2755   // onscene emitted, offscene not
2756   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2757   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2758   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2759   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2760
2761   // test removing child
2762   // clean test data
2763   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2764   gActorNamesOnOffScene.clear();
2765
2766   parent.Remove(child);
2767   // onscene not emitted, offscene is
2768   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2769   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2770   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2771
2772   // test removing parent
2773   // clean test data
2774   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2775   gActorNamesOnOffScene.clear();
2776
2777   application.GetScene().Remove(parent);
2778   // onscene not emitted, offscene is
2779   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2780   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2781   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2782   END_TEST;
2783 }
2784
2785 int UtcDaliActorFindChildByName(void)
2786 {
2787   tet_infoline("Testing Dali::Actor::FindChildByName()");
2788   TestApplication application;
2789
2790   Actor parent = Actor::New();
2791   parent.SetProperty(Actor::Property::NAME, "parent");
2792   Actor first = Actor::New();
2793   first.SetProperty(Actor::Property::NAME, "first");
2794   Actor second = Actor::New();
2795   second.SetProperty(Actor::Property::NAME, "second");
2796
2797   parent.Add(first);
2798   first.Add(second);
2799
2800   Actor found = parent.FindChildByName("foo");
2801   DALI_TEST_CHECK(!found);
2802
2803   found = parent.FindChildByName("parent");
2804   DALI_TEST_CHECK(found == parent);
2805
2806   found = parent.FindChildByName("first");
2807   DALI_TEST_CHECK(found == first);
2808
2809   found = parent.FindChildByName("second");
2810   DALI_TEST_CHECK(found == second);
2811   END_TEST;
2812 }
2813
2814 int UtcDaliActorFindChildById(void)
2815 {
2816   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2817   TestApplication application;
2818
2819   Actor parent = Actor::New();
2820   Actor first  = Actor::New();
2821   Actor second = Actor::New();
2822
2823   parent.Add(first);
2824   first.Add(second);
2825
2826   Actor found = parent.FindChildById(100000);
2827   DALI_TEST_CHECK(!found);
2828
2829   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2830   DALI_TEST_CHECK(found == parent);
2831
2832   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2833   DALI_TEST_CHECK(found == first);
2834
2835   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2836   DALI_TEST_CHECK(found == second);
2837   END_TEST;
2838 }
2839
2840 int UtcDaliActorHitTest(void)
2841 {
2842   struct HitTestData
2843   {
2844   public:
2845     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2846     : mScale(scale),
2847       mTouchPoint(touchPoint),
2848       mResult(result)
2849     {
2850     }
2851
2852     Vector3 mScale;
2853     Vector2 mTouchPoint;
2854     bool    mResult;
2855   };
2856
2857   TestApplication application;
2858   tet_infoline(" UtcDaliActorHitTest");
2859
2860   // Fill a vector with different hit tests.
2861   struct HitTestData* hitTestData[] = {
2862     //                    scale                     touch point           result
2863     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
2864     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2865     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.
2866     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2867     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.
2868     NULL,
2869   };
2870
2871   // get the root layer
2872   Actor actor = Actor::New();
2873   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2874   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2875
2876   application.GetScene().Add(actor);
2877
2878   ResetTouchCallbacks();
2879
2880   unsigned int index = 0;
2881   while(NULL != hitTestData[index])
2882   {
2883     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2884     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2885
2886     // flush the queue and render once
2887     application.SendNotification();
2888     application.Render();
2889
2890     DALI_TEST_CHECK(!gTouchCallBackCalled);
2891
2892     // connect to its touch signal
2893     actor.TouchedSignal().Connect(TestTouchCallback);
2894
2895     Dali::Integration::Point point;
2896     point.SetState(PointState::DOWN);
2897     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2898     Dali::Integration::TouchEvent event;
2899     event.AddPoint(point);
2900
2901     // flush the queue and render once
2902     application.SendNotification();
2903     application.Render();
2904     application.ProcessEvent(event);
2905
2906     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2907
2908     if(gTouchCallBackCalled != hitTestData[index]->mResult)
2909       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2910                  hitTestData[index]->mScale.x,
2911                  hitTestData[index]->mScale.y,
2912                  hitTestData[index]->mScale.z,
2913                  hitTestData[index]->mTouchPoint.x,
2914                  hitTestData[index]->mTouchPoint.y,
2915                  hitTestData[index]->mResult);
2916
2917     ResetTouchCallbacks();
2918     ++index;
2919   }
2920   END_TEST;
2921 }
2922
2923 int UtcDaliActorSetDrawMode(void)
2924 {
2925   TestApplication application;
2926   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2927
2928   Actor a = Actor::New();
2929
2930   application.GetScene().Add(a);
2931   application.SendNotification();
2932   application.Render(0);
2933   application.SendNotification();
2934   application.Render(1);
2935
2936   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2937
2938   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2939   application.SendNotification();
2940   application.Render(1);
2941
2942   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2943
2944   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2945   application.SendNotification();
2946   application.Render(1);
2947
2948   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2949   END_TEST;
2950 }
2951
2952 int UtcDaliActorSetDrawModeOverlayRender(void)
2953 {
2954   TestApplication application;
2955   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2956
2957   application.SendNotification();
2958   application.Render(1);
2959
2960   std::vector<GLuint> ids;
2961   ids.push_back(8);  // first rendered actor
2962   ids.push_back(9);  // second rendered actor
2963   ids.push_back(10); // third rendered actor
2964   application.GetGlAbstraction().SetNextTextureIds(ids);
2965
2966   Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2967   Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2968   Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2969   Actor   a      = CreateRenderableActor(imageA);
2970   Actor   b      = CreateRenderableActor(imageB);
2971   Actor   c      = CreateRenderableActor(imageC);
2972
2973   application.SendNotification();
2974   application.Render(1);
2975
2976   //Textures are bound when first created. Clear bound textures vector
2977   application.GetGlAbstraction().ClearBoundTextures();
2978
2979   // Render a,b,c as regular non-overlays. so order will be:
2980   // a (8)
2981   // b (9)
2982   // c (10)
2983   application.GetScene().Add(a);
2984   application.GetScene().Add(b);
2985   application.GetScene().Add(c);
2986
2987   application.SendNotification();
2988   application.Render(1);
2989
2990   // Should be 3 textures changes.
2991   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
2992   typedef std::vector<GLuint>::size_type TextureSize;
2993   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
2994   if(boundTextures.size() == 3)
2995   {
2996     DALI_TEST_CHECK(boundTextures[0] == 8u);
2997     DALI_TEST_CHECK(boundTextures[1] == 9u);
2998     DALI_TEST_CHECK(boundTextures[2] == 10u);
2999   }
3000
3001   // Now texture ids have been set, we can monitor their render order.
3002   // render a as an overlay (last), so order will be:
3003   // b (9)
3004   // c (10)
3005   // a (8)
3006   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3007   application.GetGlAbstraction().ClearBoundTextures();
3008
3009   application.SendNotification();
3010   application.Render(1);
3011
3012   // Should be 3 texture changes.
3013   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3014   if(boundTextures.size() == 3)
3015   {
3016     DALI_TEST_CHECK(boundTextures[0] == 9u);
3017     DALI_TEST_CHECK(boundTextures[1] == 10u);
3018     DALI_TEST_CHECK(boundTextures[2] == 8u);
3019   }
3020   END_TEST;
3021 }
3022
3023 int UtcDaliActorGetCurrentWorldMatrix(void)
3024 {
3025   TestApplication application;
3026   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3027
3028   Actor parent = Actor::New();
3029   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3030   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3031   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3032   Radian     rotationAngle(Degree(85.0f));
3033   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3034   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3035   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3036   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3037   parent.SetProperty(Actor::Property::SCALE, parentScale);
3038   application.GetScene().Add(parent);
3039
3040   Actor child = Actor::New();
3041   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3042   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3043   Radian     childRotationAngle(Degree(23.0f));
3044   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3045   Vector3    childScale(2.0f, 2.0f, 2.0f);
3046   child.SetProperty(Actor::Property::POSITION, childPosition);
3047   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3048   child.SetProperty(Actor::Property::SCALE, childScale);
3049   parent.Add(child);
3050
3051   application.SendNotification();
3052   application.Render(0);
3053   application.Render();
3054   application.SendNotification();
3055
3056   Matrix parentMatrix(false);
3057   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3058
3059   Matrix childMatrix(false);
3060   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3061
3062   //Child matrix should be the composition of child and parent
3063   Matrix childWorldMatrix(false);
3064   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3065
3066   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3067   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3068   END_TEST;
3069 }
3070
3071 int UtcDaliActorConstrainedToWorldMatrix(void)
3072 {
3073   TestApplication application;
3074   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3075
3076   Actor parent = Actor::New();
3077   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3078   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3079   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3080   Radian     rotationAngle(Degree(85.0f));
3081   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3082   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3083   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3084   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3085   parent.SetProperty(Actor::Property::SCALE, parentScale);
3086   application.GetScene().Add(parent);
3087
3088   Actor child = Actor::New();
3089   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3090   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3091   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3092   posConstraint.Apply();
3093
3094   application.GetScene().Add(child);
3095
3096   application.SendNotification();
3097   application.Render(0);
3098   application.Render();
3099   application.SendNotification();
3100
3101   Matrix parentMatrix(false);
3102   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3103
3104   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3105   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3106   END_TEST;
3107 }
3108
3109 int UtcDaliActorConstrainedToOrientation(void)
3110 {
3111   TestApplication application;
3112   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3113
3114   Actor parent = Actor::New();
3115   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3116   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3117   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3118   Radian     rotationAngle(Degree(85.0f));
3119   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3120   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3121   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3122   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3123   parent.SetProperty(Actor::Property::SCALE, parentScale);
3124   application.GetScene().Add(parent);
3125
3126   Actor child = Actor::New();
3127   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3128   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3129   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3130   posConstraint.Apply();
3131
3132   application.GetScene().Add(child);
3133
3134   application.SendNotification();
3135   application.Render(0);
3136   application.Render();
3137   application.SendNotification();
3138
3139   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3140   END_TEST;
3141 }
3142
3143 int UtcDaliActorConstrainedToOpacity(void)
3144 {
3145   TestApplication application;
3146   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3147
3148   Actor parent = Actor::New();
3149   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3150   application.GetScene().Add(parent);
3151
3152   Actor      child             = Actor::New();
3153   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3154   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3155   opacityConstraint.Apply();
3156
3157   application.GetScene().Add(child);
3158
3159   application.SendNotification();
3160   application.Render(0);
3161   application.Render();
3162   application.SendNotification();
3163
3164   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3165
3166   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3167
3168   application.SendNotification();
3169   application.Render(0);
3170   application.Render();
3171   application.SendNotification();
3172
3173   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3174
3175   END_TEST;
3176 }
3177
3178 int UtcDaliActorUnparent(void)
3179 {
3180   TestApplication application;
3181   tet_infoline(" UtcDaliActorUnparent");
3182
3183   Actor parent = Actor::New();
3184   application.GetScene().Add(parent);
3185
3186   Actor child = Actor::New();
3187
3188   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3189   DALI_TEST_CHECK(!child.GetParent());
3190
3191   // Test that calling Unparent with no parent is a NOOP
3192   child.Unparent();
3193
3194   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3195   DALI_TEST_CHECK(!child.GetParent());
3196
3197   // Test that Unparent works
3198   parent.Add(child);
3199
3200   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3201   DALI_TEST_CHECK(parent == child.GetParent());
3202
3203   child.Unparent();
3204
3205   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3206   DALI_TEST_CHECK(!child.GetParent());
3207
3208   // Test that UnparentAndReset works
3209   parent.Add(child);
3210
3211   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3212   DALI_TEST_CHECK(parent == child.GetParent());
3213
3214   UnparentAndReset(child);
3215
3216   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3217   DALI_TEST_CHECK(!child);
3218
3219   // Test that UnparentAndReset is a NOOP with empty handle
3220   UnparentAndReset(child);
3221
3222   DALI_TEST_CHECK(!child);
3223   END_TEST;
3224 }
3225
3226 int UtcDaliActorGetChildAt(void)
3227 {
3228   TestApplication application;
3229   tet_infoline(" UtcDaliActorGetChildAt");
3230
3231   Actor parent = Actor::New();
3232   application.GetScene().Add(parent);
3233
3234   Actor child0 = Actor::New();
3235   parent.Add(child0);
3236
3237   Actor child1 = Actor::New();
3238   parent.Add(child1);
3239
3240   Actor child2 = Actor::New();
3241   parent.Add(child2);
3242
3243   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3244   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3245   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3246   END_TEST;
3247 }
3248
3249 int UtcDaliActorSetGetOverlay(void)
3250 {
3251   TestApplication application;
3252   tet_infoline(" UtcDaliActorSetGetOverlay");
3253
3254   Actor parent = Actor::New();
3255   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3256   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3257   END_TEST;
3258 }
3259
3260 int UtcDaliActorCreateDestroy(void)
3261 {
3262   Actor* actor = new Actor;
3263   DALI_TEST_CHECK(actor);
3264   delete actor;
3265   END_TEST;
3266 }
3267
3268 namespace
3269 {
3270 struct PropertyStringIndex
3271 {
3272   const char* const     name;
3273   const Property::Index index;
3274   const Property::Type  type;
3275 };
3276
3277 const PropertyStringIndex PROPERTY_TABLE[] =
3278   {
3279     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3280     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3281     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3282     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3283     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3284     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3285     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3286     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3287     {"size", Actor::Property::SIZE, Property::VECTOR3},
3288     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3289     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3290     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3291     {"position", Actor::Property::POSITION, Property::VECTOR3},
3292     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3293     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3294     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3295     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3296     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3297     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3298     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3299     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3300     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3301     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3302     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3303     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3304     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3305     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3306     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3307     {"color", Actor::Property::COLOR, Property::VECTOR4},
3308     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3309     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3310     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3311     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3312     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3313     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3314     {"name", Actor::Property::NAME, Property::STRING},
3315     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3316     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3317     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3318     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3319     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3320     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3321     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3322     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3323     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3324     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3325     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3326     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3327     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3328     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3329     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3330     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3331     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3332     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3333 };
3334 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3335 } // unnamed namespace
3336
3337 int UtcDaliActorProperties(void)
3338 {
3339   TestApplication application;
3340
3341   Actor actor = Actor::New();
3342
3343   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3344   {
3345     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3346     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3347     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3348     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3349   }
3350   END_TEST;
3351 }
3352
3353 int UtcDaliRelayoutProperties_ResizePolicies(void)
3354 {
3355   TestApplication application;
3356
3357   Actor actor = Actor::New();
3358
3359   // Defaults
3360   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3361   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3362
3363   // Set resize policy for all dimensions
3364   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3365   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3366   {
3367     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3368   }
3369
3370   // Set individual dimensions
3371   const char* const widthPolicy  = "FILL_TO_PARENT";
3372   const char* const heightPolicy = "FIXED";
3373
3374   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3375   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3376
3377   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3378   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3379
3380   // Set individual dimensions using enums
3381   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3382   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3383
3384   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3385   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3386
3387   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3388   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3389
3390   END_TEST;
3391 }
3392
3393 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3394 {
3395   TestApplication application;
3396
3397   Actor actor = Actor::New();
3398
3399   // Defaults
3400   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3401
3402   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3403   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3404   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3405
3406   // Set
3407   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3408   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3409
3410   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3411   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3412
3413   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3414   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3415
3416   END_TEST;
3417 }
3418
3419 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3420 {
3421   TestApplication application;
3422
3423   Actor actor = Actor::New();
3424
3425   // Defaults
3426   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3427   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3428
3429   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3430   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3431   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3432
3433   // Set
3434   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3435
3436   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3437   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3438
3439   END_TEST;
3440 }
3441
3442 int UtcDaliRelayoutProperties_DimensionDependency(void)
3443 {
3444   TestApplication application;
3445
3446   Actor actor = Actor::New();
3447
3448   // Defaults
3449   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3450   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3451
3452   // Set
3453   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3454   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3455
3456   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3457   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3458
3459   // Test setting another resize policy
3460   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3461   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3462
3463   END_TEST;
3464 }
3465
3466 int UtcDaliRelayoutProperties_Padding(void)
3467 {
3468   TestApplication application;
3469
3470   Actor actor = Actor::New();
3471
3472   // Data
3473   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3474
3475   // PADDING
3476   actor.SetProperty(Actor::Property::PADDING, padding);
3477   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3478
3479   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3480
3481   END_TEST;
3482 }
3483
3484 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3485 {
3486   TestApplication application;
3487
3488   Actor actor = Actor::New();
3489
3490   // Data
3491   Vector2 minSize(1.0f, 2.0f);
3492
3493   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3494   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3495
3496   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3497
3498   Vector2 maxSize(3.0f, 4.0f);
3499
3500   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3501   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3502
3503   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3504
3505   END_TEST;
3506 }
3507
3508 int UtcDaliActorGetHeightForWidth(void)
3509 {
3510   TestApplication application;
3511
3512   Actor actor = Actor::New();
3513
3514   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3515
3516   END_TEST;
3517 }
3518
3519 int UtcDaliActorGetWidthForHeight(void)
3520 {
3521   TestApplication application;
3522
3523   Actor actor = Actor::New();
3524
3525   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3526
3527   END_TEST;
3528 }
3529
3530 int UtcDaliActorGetRelayoutSize(void)
3531 {
3532   TestApplication application;
3533
3534   Actor actor = Actor::New();
3535
3536   // Add actor to stage
3537   application.GetScene().Add(actor);
3538
3539   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3540
3541   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3542   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3543
3544   // Flush the queue and render once
3545   application.SendNotification();
3546   application.Render();
3547
3548   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3549
3550   END_TEST;
3551 }
3552
3553 int UtcDaliActorSetPadding(void)
3554 {
3555   TestApplication application;
3556
3557   Actor actor = Actor::New();
3558
3559   Padding padding;
3560   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3561
3562   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3563   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3564   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3565   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3566
3567   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3568   actor.SetProperty(Actor::Property::PADDING, padding2);
3569
3570   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3571
3572   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3573   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3574   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3575   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3576
3577   END_TEST;
3578 }
3579
3580 int UtcDaliActorSetMinimumSize(void)
3581 {
3582   TestApplication application;
3583
3584   Actor actor = Actor::New();
3585
3586   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3587
3588   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3589   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3590
3591   Vector2 size2(1.0f, 2.0f);
3592   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3593
3594   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3595
3596   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3597   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3598
3599   END_TEST;
3600 }
3601
3602 int UtcDaliActorSetMaximumSize(void)
3603 {
3604   TestApplication application;
3605
3606   Actor actor = Actor::New();
3607
3608   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3609
3610   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3611   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3612
3613   Vector2 size2(1.0f, 2.0f);
3614   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3615
3616   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3617
3618   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3619   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3620
3621   END_TEST;
3622 }
3623
3624 int UtcDaliActorOnRelayoutSignal(void)
3625 {
3626   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3627
3628   TestApplication application;
3629
3630   // Clean test data
3631   gOnRelayoutCallBackCalled = false;
3632   gActorNamesRelayout.clear();
3633
3634   Actor actor = Actor::New();
3635   actor.SetProperty(Actor::Property::NAME, "actor");
3636   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3637
3638   // Sanity check
3639   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3640
3641   // Add actor to stage
3642   application.GetScene().Add(actor);
3643
3644   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3645   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3646
3647   // Flush the queue and render once
3648   application.SendNotification();
3649   application.Render();
3650
3651   // OnRelayout emitted
3652   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3653   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3654
3655   END_TEST;
3656 }
3657
3658 int UtcDaliActorGetHierachyDepth(void)
3659 {
3660   TestApplication application;
3661   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3662
3663   /* Build tree of actors:
3664    *
3665    *                      Depth
3666    *
3667    *       A (parent)       1
3668    *      / \
3669    *     B   C              2`
3670    *    / \   \
3671    *   D   E   F            3
3672    *
3673    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3674    */
3675   Integration::Scene stage(application.GetScene());
3676
3677   Actor actorA = Actor::New();
3678   Actor actorB = Actor::New();
3679   Actor actorC = Actor::New();
3680   Actor actorD = Actor::New();
3681   Actor actorE = Actor::New();
3682   Actor actorF = Actor::New();
3683
3684   //Test that root actor has depth equal 0
3685   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3686
3687   //Test actors return depth -1 when not connected to the tree
3688   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3689   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3690   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3691   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3692   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3693   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3694
3695   //Create the hierarchy
3696   stage.Add(actorA);
3697   actorA.Add(actorB);
3698   actorA.Add(actorC);
3699   actorB.Add(actorD);
3700   actorB.Add(actorE);
3701   actorC.Add(actorF);
3702
3703   //Test actors return correct depth
3704   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3705   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3707   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3708   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3709   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3710
3711   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3712   actorA.Remove(actorB);
3713
3714   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3715   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3716   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3717
3718   //Removing actorA from the stage. All actors should have depth equal -1
3719   stage.Remove(actorA);
3720
3721   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3722   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3723   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3724   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3725   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3726   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3727
3728   END_TEST;
3729 }
3730
3731 int UtcDaliActorAnchorPointPropertyAsString(void)
3732 {
3733   TestApplication application;
3734
3735   Actor actor = Actor::New();
3736
3737   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3738   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3739
3740   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3741   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3742
3743   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3744   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3745
3746   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3747   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3748
3749   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3750   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3751
3752   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3753   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3754
3755   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3756   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3757
3758   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3759   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3760
3761   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3762   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3763
3764   // Invalid should not change anything
3765   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3766   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3767
3768   END_TEST;
3769 }
3770
3771 int UtcDaliActorParentOriginPropertyAsString(void)
3772 {
3773   TestApplication application;
3774
3775   Actor actor = Actor::New();
3776
3777   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3778   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3779
3780   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3781   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3782
3783   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3784   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3785
3786   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3787   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3788
3789   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3790   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3791
3792   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3793   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3794
3795   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3796   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3797
3798   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3799   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3800
3801   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3802   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3803
3804   // Invalid should not change anything
3805   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3806   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3807
3808   END_TEST;
3809 }
3810
3811 int UtcDaliActorColorModePropertyAsString(void)
3812 {
3813   TestApplication application;
3814
3815   Actor actor = Actor::New();
3816
3817   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3818   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3819
3820   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3821   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3822
3823   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3824   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3825
3826   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3827   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3828
3829   // Invalid should not change anything
3830   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3831   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3832
3833   END_TEST;
3834 }
3835
3836 int UtcDaliActorDrawModePropertyAsString(void)
3837 {
3838   TestApplication application;
3839
3840   Actor actor = Actor::New();
3841
3842   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3843   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3844
3845   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3846   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3847
3848   // Invalid should not change anything
3849   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3850   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3851
3852   END_TEST;
3853 }
3854
3855 int UtcDaliActorColorModePropertyAsEnum(void)
3856 {
3857   TestApplication application;
3858
3859   Actor actor = Actor::New();
3860
3861   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3862   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3863
3864   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3865   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3866
3867   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3868   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3869
3870   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3871   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3872
3873   END_TEST;
3874 }
3875
3876 int UtcDaliActorDrawModePropertyAsEnum(void)
3877 {
3878   TestApplication application;
3879
3880   Actor actor = Actor::New();
3881
3882   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3883   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3884
3885   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3886   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3887
3888   END_TEST;
3889 }
3890
3891 int UtcDaliActorAddRendererP(void)
3892 {
3893   tet_infoline("Testing Actor::AddRenderer");
3894   TestApplication application;
3895
3896   Actor actor = Actor::New();
3897
3898   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3899
3900   Geometry geometry = CreateQuadGeometry();
3901   Shader   shader   = CreateShader();
3902   Renderer renderer = Renderer::New(geometry, shader);
3903
3904   actor.AddRenderer(renderer);
3905   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3906   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3907
3908   END_TEST;
3909 }
3910
3911 int UtcDaliActorAddRendererN01(void)
3912 {
3913   tet_infoline("Testing Actor::AddRenderer");
3914   TestApplication application;
3915
3916   Actor    actor = Actor::New();
3917   Renderer renderer;
3918
3919   // try illegal Add
3920   try
3921   {
3922     actor.AddRenderer(renderer);
3923     tet_printf("Assertion test failed - no Exception\n");
3924     tet_result(TET_FAIL);
3925   }
3926   catch(Dali::DaliException& e)
3927   {
3928     DALI_TEST_PRINT_ASSERT(e);
3929     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3930     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3931   }
3932   catch(...)
3933   {
3934     tet_printf("Assertion test failed - wrong Exception\n");
3935     tet_result(TET_FAIL);
3936   }
3937
3938   END_TEST;
3939 }
3940
3941 int UtcDaliActorAddRendererN02(void)
3942 {
3943   tet_infoline("UtcDaliActorAddRendererN02");
3944
3945   Actor    actor;
3946   Renderer renderer;
3947
3948   {
3949     TestApplication application;
3950
3951     Geometry geometry = CreateQuadGeometry();
3952     Shader   shader   = CreateShader();
3953     renderer          = Renderer::New(geometry, shader);
3954
3955     actor = Actor::New();
3956   }
3957
3958   // try illegal AddRenderer
3959   try
3960   {
3961     actor.AddRenderer(renderer);
3962     tet_printf("Assertion test failed - no Exception\n");
3963     tet_result(TET_FAIL);
3964   }
3965   catch(Dali::DaliException& e)
3966   {
3967     DALI_TEST_PRINT_ASSERT(e);
3968     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3969   }
3970   catch(...)
3971   {
3972     tet_printf("Assertion test failed - wrong Exception\n");
3973     tet_result(TET_FAIL);
3974   }
3975
3976   END_TEST;
3977 }
3978
3979 int UtcDaliActorAddRendererOnScene(void)
3980 {
3981   tet_infoline("Testing Actor::AddRenderer");
3982   TestApplication application;
3983
3984   Actor actor = Actor::New();
3985   application.GetScene().Add(actor);
3986
3987   application.SendNotification();
3988   application.Render(0);
3989
3990   Geometry geometry = CreateQuadGeometry();
3991   Shader   shader   = CreateShader();
3992   Renderer renderer = Renderer::New(geometry, shader);
3993
3994   application.SendNotification();
3995   application.Render(0);
3996
3997   try
3998   {
3999     actor.AddRenderer(renderer);
4000     tet_result(TET_PASS);
4001   }
4002   catch(...)
4003   {
4004     tet_result(TET_FAIL);
4005   }
4006
4007   END_TEST;
4008 }
4009
4010 int UtcDaliActorRemoveRendererP1(void)
4011 {
4012   tet_infoline("Testing Actor::RemoveRenderer");
4013   TestApplication application;
4014
4015   Actor actor = Actor::New();
4016
4017   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4018
4019   {
4020     Geometry geometry = CreateQuadGeometry();
4021     Shader   shader   = CreateShader();
4022     Renderer renderer = Renderer::New(geometry, shader);
4023
4024     actor.AddRenderer(renderer);
4025     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4026     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4027
4028     application.SendNotification();
4029     application.Render();
4030   }
4031
4032   {
4033     Renderer renderer = actor.GetRendererAt(0);
4034     actor.RemoveRenderer(renderer);
4035     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4036
4037     application.SendNotification();
4038     application.Render();
4039   }
4040
4041   // Call one final time to ensure that the renderer is actually removed after
4042   // the handle goes out of scope, and excercises the deletion code path in
4043   // scene graph and render.
4044   application.SendNotification();
4045   application.Render();
4046
4047   END_TEST;
4048 }
4049
4050 int UtcDaliActorRemoveRendererP2(void)
4051 {
4052   tet_infoline("Testing Actor::RemoveRenderer");
4053   TestApplication application;
4054
4055   Actor actor = Actor::New();
4056
4057   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4058
4059   Geometry geometry = CreateQuadGeometry();
4060   Shader   shader   = CreateShader();
4061   Renderer renderer = Renderer::New(geometry, shader);
4062
4063   actor.AddRenderer(renderer);
4064   application.SendNotification();
4065   application.Render();
4066
4067   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4068   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4069
4070   actor.RemoveRenderer(0);
4071   application.SendNotification();
4072   application.Render();
4073
4074   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4075
4076   // Shut down whilst holding onto the renderer handle.
4077   END_TEST;
4078 }
4079
4080 int UtcDaliActorRemoveRendererN(void)
4081 {
4082   tet_infoline("Testing Actor::RemoveRenderer");
4083   TestApplication application;
4084
4085   Actor actor = Actor::New();
4086
4087   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4088
4089   Geometry geometry = CreateQuadGeometry();
4090   Shader   shader   = CreateShader();
4091   Renderer renderer = Renderer::New(geometry, shader);
4092
4093   actor.AddRenderer(renderer);
4094   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4095   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4096
4097   actor.RemoveRenderer(10);
4098   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4099   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4100
4101   END_TEST;
4102 }
4103
4104 // Clipping test helper functions:
4105 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4106 {
4107   Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4108   Actor   actor = CreateRenderableActor(image);
4109
4110   // Setup dimensions and position so actor is not skipped by culling.
4111   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4112   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4113   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4114   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4115
4116   return actor;
4117 }
4118
4119 Actor CreateActorWithContent16x16()
4120 {
4121   return CreateActorWithContent(16, 16);
4122 }
4123
4124 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4125 {
4126   enabledDisableTrace.Reset();
4127   stencilTrace.Reset();
4128   enabledDisableTrace.Enable(true);
4129   stencilTrace.Enable(true);
4130
4131   application.SendNotification();
4132   application.Render();
4133
4134   enabledDisableTrace.Enable(false);
4135   stencilTrace.Enable(false);
4136 }
4137
4138 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4139 {
4140   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4141
4142   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4143   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4144   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4145   DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4146 }
4147
4148 int UtcDaliActorPropertyClippingP(void)
4149 {
4150   // This test checks the clippingMode property.
4151   tet_infoline("Testing Actor::Property::ClippingMode: P");
4152   TestApplication application;
4153
4154   Actor actor = Actor::New();
4155
4156   // Check default clippingEnabled value.
4157   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4158
4159   int  value          = 0;
4160   bool getValueResult = getValue.Get(value);
4161   DALI_TEST_CHECK(getValueResult);
4162
4163   if(getValueResult)
4164   {
4165     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4166   }
4167
4168   // Check setting the property to the stencil mode.
4169   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4170
4171   // Check the new value was set.
4172   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4173   getValueResult = getValue.Get(value);
4174   DALI_TEST_CHECK(getValueResult);
4175
4176   if(getValueResult)
4177   {
4178     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4179   }
4180
4181   // Check setting the property to the scissor mode.
4182   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4183
4184   // Check the new value was set.
4185   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4186   getValueResult = getValue.Get(value);
4187   DALI_TEST_CHECK(getValueResult);
4188
4189   if(getValueResult)
4190   {
4191     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4192   }
4193   END_TEST;
4194 }
4195
4196 int UtcDaliActorPropertyClippingN(void)
4197 {
4198   // Negative test case for Clipping.
4199   tet_infoline("Testing Actor::Property::ClippingMode: N");
4200   TestApplication application;
4201
4202   Actor actor = Actor::New();
4203
4204   // Check default clippingEnabled value.
4205   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4206
4207   int  value          = 0;
4208   bool getValueResult = getValue.Get(value);
4209   DALI_TEST_CHECK(getValueResult);
4210
4211   if(getValueResult)
4212   {
4213     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4214   }
4215
4216   // Check setting an invalid property value won't change the current property value.
4217   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4218
4219   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4220   getValueResult = getValue.Get(value);
4221   DALI_TEST_CHECK(getValueResult);
4222
4223   if(getValueResult)
4224   {
4225     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4226   }
4227
4228   END_TEST;
4229 }
4230
4231 int UtcDaliActorPropertyClippingActor(void)
4232 {
4233   // This test checks that an actor is correctly setup for clipping.
4234   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4235   TestApplication application;
4236
4237   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4238   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4239   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4240   size_t             startIndex          = 0u;
4241
4242   // Create a clipping actor.
4243   Actor actorDepth1Clip = CreateActorWithContent16x16();
4244   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4245   application.GetScene().Add(actorDepth1Clip);
4246
4247   // Gather the call trace.
4248   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4249
4250   // Check we are writing to the color buffer.
4251   CheckColorMask(glAbstraction, true);
4252
4253   // Check the stencil buffer was enabled.
4254   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4255
4256   // Check the stencil buffer was cleared.
4257   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4258
4259   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4260   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4261   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4262   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4263
4264   END_TEST;
4265 }
4266
4267 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4268 {
4269   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4270   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4271   TestApplication application;
4272
4273   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4274   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4275   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4276   size_t             startIndex          = 0u;
4277
4278   // Create a clipping actor.
4279   Actor actorDepth1Clip = CreateActorWithContent16x16();
4280   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4281   application.GetScene().Add(actorDepth1Clip);
4282
4283   // Gather the call trace.
4284   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4285
4286   // Check we are writing to the color buffer.
4287   CheckColorMask(glAbstraction, true);
4288
4289   // Check the stencil buffer was enabled.
4290   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4291
4292   // Check the stencil buffer was cleared.
4293   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4294
4295   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4296   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4297   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4298   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4299
4300   // Now disable the clipping
4301   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4302
4303   // Gather the call trace.
4304   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4305
4306   // Check the stencil buffer was disabled.
4307   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
4308
4309   // Ensure all values in stencil-mask are set to 1.
4310   startIndex = 0u;
4311   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4312
4313   END_TEST;
4314 }
4315
4316 int UtcDaliActorPropertyClippingNestedChildren(void)
4317 {
4318   // This test checks that a hierarchy of actors are clipped correctly by
4319   // writing to and reading from the correct bit-planes of the stencil buffer.
4320   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4321   TestApplication    application;
4322   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4323   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4324   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4325
4326   // Create a clipping actor.
4327   Actor actorDepth1Clip = CreateActorWithContent16x16();
4328   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4329   application.GetScene().Add(actorDepth1Clip);
4330
4331   // Create a child actor.
4332   Actor childDepth2 = CreateActorWithContent16x16();
4333   actorDepth1Clip.Add(childDepth2);
4334
4335   // Create another clipping actor.
4336   Actor childDepth2Clip = CreateActorWithContent16x16();
4337   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4338   childDepth2.Add(childDepth2Clip);
4339
4340   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4341   // This tests the sort algorithm.
4342   Actor childDepth3 = CreateActorWithContent16x16();
4343   childDepth2Clip.Add(childDepth3);
4344   Actor childDepth4 = CreateActorWithContent16x16();
4345   childDepth3.Add(childDepth4);
4346
4347   // Gather the call trace.
4348   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4349
4350   // Check we are writing to the color buffer.
4351   CheckColorMask(glAbstraction, true);
4352
4353   // Check the stencil buffer was enabled.
4354   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4355
4356   // Perform the test twice, once for 2D layer, and once for 3D.
4357   for(unsigned int i = 0u; i < 2u; ++i)
4358   {
4359     size_t startIndex = 0u;
4360
4361     // Check the stencil buffer was cleared.
4362     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4363
4364     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4365     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4366     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4367     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4368
4369     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4370     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 255", startIndex));    // 514 is GL_EQUAL
4371     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4372
4373     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4374     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4375     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4376     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4377
4378     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4379     // (Both must be set to pass the check).
4380     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 255", startIndex));    // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4381     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4382
4383     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4384     if(i == 0u)
4385     {
4386       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4387       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4388     }
4389   }
4390
4391   END_TEST;
4392 }
4393
4394 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4395 {
4396   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4397   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4398   TestApplication    application;
4399   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4400   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4401
4402   /* We create a small tree of actors as follows:
4403
4404                            A
4405                           / \
4406      Clipping enabled -> B   D
4407                          |   |
4408                          C   E
4409
4410      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4411   */
4412   Actor actors[5];
4413   for(int i = 0; i < 5; ++i)
4414   {
4415     Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4416     Actor   actor = CreateRenderableActor(image);
4417
4418     // Setup dimensions and position so actor is not skipped by culling.
4419     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4420     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4421
4422     if(i == 0)
4423     {
4424       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4425     }
4426     else
4427     {
4428       float b = i > 2 ? 1.0f : -1.0f;
4429       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4430     }
4431
4432     actors[i] = actor;
4433   }
4434
4435   // Enable clipping on the actor at the top of the left branch.
4436   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4437
4438   // Build the scene graph.
4439   application.GetScene().Add(actors[0]);
4440
4441   // Left branch:
4442   actors[0].Add(actors[1]);
4443   actors[1].Add(actors[2]);
4444
4445   // Right branch:
4446   actors[0].Add(actors[3]);
4447   actors[3].Add(actors[4]);
4448
4449   // Gather the call trace.
4450   enabledDisableTrace.Reset();
4451   enabledDisableTrace.Enable(true);
4452   application.SendNotification();
4453   application.Render();
4454   enabledDisableTrace.Enable(false);
4455
4456   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4457
4458      Note: Correct enable call trace:    StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4459            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4460   */
4461   size_t startIndex = 0u;
4462   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
4463   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
4464   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4465
4466   // Swap the clipping actor from top of left branch to top of right branch.
4467   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4468   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4469
4470   // Gather the call trace.
4471   enabledDisableTrace.Reset();
4472   enabledDisableTrace.Enable(true);
4473   application.SendNotification();
4474   application.Render();
4475   enabledDisableTrace.Enable(false);
4476
4477   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4478   // This proves the draw order has remained the same.
4479   startIndex = 0u;
4480   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
4481   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4482
4483   END_TEST;
4484 }
4485
4486 int UtcDaliActorPropertyScissorClippingActor(void)
4487 {
4488   // This test checks that an actor is correctly setup for clipping.
4489   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4490   TestApplication application;
4491
4492   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4493   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4494   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4495
4496   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4497   const Vector2 imageSize(16.0f, 16.0f);
4498
4499   // Create a clipping actor.
4500   Actor clippingActorA = CreateActorWithContent16x16();
4501   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4502   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4503   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4504   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4505   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4506   application.GetScene().Add(clippingActorA);
4507
4508   // Gather the call trace.
4509   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4510
4511   // Check we are writing to the color buffer.
4512   CheckColorMask(glAbstraction, true);
4513
4514   // Check scissor test was enabled.
4515   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4516
4517   // Check the scissor was set, and the coordinates are correct.
4518   std::stringstream compareParametersString;
4519   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4520   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4521
4522   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4523   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4524
4525   // Gather the call trace.
4526   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4527
4528   // Check the scissor was set, and the coordinates are correct.
4529   compareParametersString.str(std::string());
4530   compareParametersString.clear();
4531   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4532   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4533
4534   END_TEST;
4535 }
4536
4537 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4538 {
4539   // This test checks that an actor is correctly setup for clipping.
4540   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4541   TestApplication application;
4542
4543   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4544   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4545   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4546
4547   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4548   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4549   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4550
4551   // Create a clipping actors.
4552   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4553   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4554
4555   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4556   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4557   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4558
4559   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4560   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4561   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4562
4563   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4564   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4565
4566   application.GetScene().Add(clippingActorA);
4567   application.GetScene().Add(clippingActorB);
4568
4569   // Gather the call trace.
4570   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4571
4572   // Check we are writing to the color buffer.
4573   CheckColorMask(glAbstraction, true);
4574
4575   // Check scissor test was enabled.
4576   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4577
4578   // Check the scissor was set, and the coordinates are correct.
4579   std::stringstream compareParametersString;
4580
4581   std::string clipA("0, 500, 480, 200");
4582   std::string clipB("0, 380, 480, 40");
4583
4584   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4585   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4586
4587   END_TEST;
4588 }
4589
4590 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4591 {
4592   // This test checks that an actor is correctly setup for clipping.
4593   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4594   TestApplication application;
4595
4596   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4597   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4598   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4599
4600   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4601   const Vector2 imageSize(16.0f, 16.0f);
4602
4603   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4604
4605      A is drawn first - with scissor clipping on
4606      B is drawn second - also with scissor clipping on
4607      C is the generated clipping region, the intersection ( A ∩ B )
4608
4609            ┏━━━━━━━┓                   ┌───────┐
4610            ┃     B ┃                   │     B │
4611        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4612        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4613        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4614        │ A     │                   ┊ A     ┊
4615        └───────┘                   └┄┄┄┄┄┄┄┘
4616
4617      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4618   */
4619
4620   // Create a clipping actor.
4621   Actor clippingActorA = CreateActorWithContent16x16();
4622   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4623   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4624   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4625   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4626   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4627   application.GetScene().Add(clippingActorA);
4628
4629   // Create a child clipping actor.
4630   Actor clippingActorB = CreateActorWithContent16x16();
4631   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4632   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4633   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4634   clippingActorA.Add(clippingActorB);
4635
4636   // positionModifiers is an array of positions to position B around.
4637   // expect is an array of expected scissor clip coordinate results.
4638   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4639   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4640
4641   // Loop through each overlap combination.
4642   for(unsigned int test = 0u; test < 4u; ++test)
4643   {
4644     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4645     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4646     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4647
4648     // Gather the call trace.
4649     GenerateTrace(application, enabledDisableTrace, scissorTrace);
4650
4651     // Check we are writing to the color buffer.
4652     CheckColorMask(glAbstraction, true);
4653
4654     // Check scissor test was enabled.
4655     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4656
4657     // Check the scissor was set, and the coordinates are correct.
4658     const Vector4&    expectResults(expect[test]);
4659     std::stringstream compareParametersString;
4660     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4661     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4662   }
4663
4664   END_TEST;
4665 }
4666
4667 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4668 {
4669   // This test checks that an actor is correctly setup for clipping.
4670   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4671   TestApplication application;
4672
4673   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4674   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4675   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4676
4677   /* Create a nest of 2 scissors and siblings of the parent.
4678
4679             stage
4680               |
4681         ┌─────┐─────┐
4682         A     C     D
4683         |           |
4684         B           E
4685   */
4686
4687   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4688   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4689   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4690   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4691   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4692   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4693
4694   // Create a clipping actors.
4695   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4696   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4697   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4698   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4699   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4700
4701   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4702   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4703   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4704
4705   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4706   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4707   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4708
4709   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4710   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4711   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4712
4713   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4714   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4715   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4716
4717   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4718   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4719
4720   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4721   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4722   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4723   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4724   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4725
4726   application.GetScene().Add(clippingActorA);
4727   clippingActorA.Add(clippingActorB);
4728   application.GetScene().Add(clippingActorC);
4729   application.GetScene().Add(clippingActorD);
4730   clippingActorD.Add(clippingActorE);
4731
4732   // Gather the call trace.
4733   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4734
4735   // Check we are writing to the color buffer.
4736   CheckColorMask(glAbstraction, true);
4737
4738   // Check scissor test was enabled.
4739   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4740
4741   // Check the scissor was set, and the coordinates are correct.
4742   std::string clipA("0, 500, 480, 200");
4743   std::string clipB("0, 580, 480, 40");
4744   std::string clipC("0, 200, 480, 200");
4745   std::string clipD("0, 300, 480, 200");
4746
4747   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4748   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4749   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4750   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4751   DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4752
4753   END_TEST;
4754 }
4755
4756 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4757 {
4758   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4759   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4760   TestApplication application;
4761
4762   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4763   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4764   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4765
4766   // Create a clipping actor.
4767   Actor actorDepth1Clip = CreateActorWithContent16x16();
4768   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4769   application.GetScene().Add(actorDepth1Clip);
4770
4771   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4772   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4773
4774   // Gather the call trace.
4775   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4776
4777   // Check we are writing to the color buffer.
4778   CheckColorMask(glAbstraction, true);
4779
4780   // Check the stencil buffer was not enabled.
4781   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4782
4783   // Check stencil functions are not called.
4784   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4785   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4786   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4787
4788   // Check that scissor clipping is overriden by the renderer properties.
4789   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4790
4791   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4792
4793   // Gather the call trace.
4794   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4795
4796   // Check the stencil buffer was not enabled.
4797   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4798
4799   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4800
4801   END_TEST;
4802 }
4803
4804 int UtcDaliGetPropertyN(void)
4805 {
4806   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4807   TestApplication application;
4808
4809   Actor actor = Actor::New();
4810
4811   unsigned int propertyCount = actor.GetPropertyCount();
4812   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4813   END_TEST;
4814 }
4815
4816 int UtcDaliActorRaiseLower(void)
4817 {
4818   tet_infoline("UtcDaliActor Raise and Lower test\n");
4819
4820   TestApplication application;
4821
4822   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4823
4824   Integration::Scene stage(application.GetScene());
4825
4826   Actor actorA = Actor::New();
4827   Actor actorB = Actor::New();
4828   Actor actorC = Actor::New();
4829
4830   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4831   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4832
4833   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4834   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4835
4836   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4837   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4838
4839   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4840   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4841
4842   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4843   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4844
4845   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4846   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4847
4848   stage.Add(actorA);
4849   stage.Add(actorB);
4850   stage.Add(actorC);
4851
4852   ResetTouchCallbacks();
4853
4854   application.SendNotification();
4855   application.Render();
4856
4857   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4858   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4859   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4860
4861   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4862   // Only top actor will get touched.
4863   actorA.TouchedSignal().Connect(TestTouchCallback);
4864   actorB.TouchedSignal().Connect(TestTouchCallback2);
4865   actorC.TouchedSignal().Connect(TestTouchCallback3);
4866
4867   // Connect ChildOrderChangedSignal
4868   bool                     orderChangedSignal(false);
4869   Actor                    orderChangedActor;
4870   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4871   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4872
4873   Dali::Integration::Point point;
4874   point.SetDeviceId(1);
4875   point.SetState(PointState::DOWN);
4876   point.SetScreenPosition(Vector2(10.f, 10.f));
4877   Dali::Integration::TouchEvent touchEvent;
4878   touchEvent.AddPoint(point);
4879
4880   application.ProcessEvent(touchEvent);
4881
4882   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4883   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4884   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4885
4886   ResetTouchCallbacks();
4887
4888   tet_printf("Testing Raising of Actor\n");
4889
4890   int preActorOrder(0);
4891   int postActorOrder(0);
4892
4893   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4894   value.Get(preActorOrder);
4895
4896   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4897   actorB.Raise();
4898   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4899   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4900
4901   // Ensure sort order is calculated before next touch event
4902   application.SendNotification();
4903
4904   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4905   value.Get(postActorOrder);
4906
4907   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4908
4909   application.ProcessEvent(touchEvent);
4910
4911   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4912   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4913   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4914
4915   ResetTouchCallbacks();
4916
4917   tet_printf("Testing Lowering of Actor\n");
4918
4919   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4920   value.Get(preActorOrder);
4921
4922   orderChangedSignal = false;
4923
4924   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4925   actorB.Lower();
4926   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4927   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4928
4929   application.SendNotification(); // ensure sort order calculated before next touch event
4930
4931   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4932   value.Get(postActorOrder);
4933
4934   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4935
4936   application.ProcessEvent(touchEvent);
4937
4938   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4939   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4940   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4941
4942   ResetTouchCallbacks();
4943
4944   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4945
4946   END_TEST;
4947 }
4948
4949 int UtcDaliActorRaiseToTopLowerToBottom(void)
4950 {
4951   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4952
4953   TestApplication application;
4954
4955   Integration::Scene stage(application.GetScene());
4956
4957   Actor actorA = Actor::New();
4958   Actor actorB = Actor::New();
4959   Actor actorC = Actor::New();
4960
4961   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4962   // enables checking of which actor the uniform is assigned too
4963   Shader shaderA = CreateShader();
4964   shaderA.RegisterProperty("uRendererColor", 1.f);
4965
4966   Shader shaderB = CreateShader();
4967   shaderB.RegisterProperty("uRendererColor", 2.f);
4968
4969   Shader shaderC = CreateShader();
4970   shaderC.RegisterProperty("uRendererColor", 3.f);
4971
4972   Geometry geometry = CreateQuadGeometry();
4973
4974   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4975   Renderer rendererA = Renderer::New(geometry, shaderA);
4976   actorA.AddRenderer(rendererA);
4977
4978   Renderer rendererB = Renderer::New(geometry, shaderB);
4979   actorB.AddRenderer(rendererB);
4980
4981   Renderer rendererC = Renderer::New(geometry, shaderC);
4982   actorC.AddRenderer(rendererC);
4983
4984   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4985   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4986
4987   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4988   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4989
4990   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4991   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4992
4993   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4994   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4995
4996   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4997   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4998
4999   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5000   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5001
5002   stage.Add(actorA);
5003   stage.Add(actorB);
5004   stage.Add(actorC);
5005
5006   ResetTouchCallbacks();
5007
5008   // Connect ChildOrderChangedSignal
5009   bool                     orderChangedSignal(false);
5010   Actor                    orderChangedActor;
5011   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5012   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5013
5014   // Set up gl abstraction trace so can query the set uniform order
5015   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5016   glAbstraction.EnableSetUniformCallTrace(true);
5017   glAbstraction.ResetSetUniformCallStack();
5018
5019   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5020
5021   application.SendNotification();
5022   application.Render();
5023
5024   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5025
5026   // Test order of uniforms in stack
5027   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5028   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5029   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5030
5031   bool CBA = (indexC > indexB) && (indexB > indexA);
5032
5033   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5034
5035   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5036   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5037   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5038
5039   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5040   // Only top actor will get touched.
5041   actorA.TouchedSignal().Connect(TestTouchCallback);
5042   actorB.TouchedSignal().Connect(TestTouchCallback2);
5043   actorC.TouchedSignal().Connect(TestTouchCallback3);
5044
5045   Dali::Integration::Point point;
5046   point.SetDeviceId(1);
5047   point.SetState(PointState::DOWN);
5048   point.SetScreenPosition(Vector2(10.f, 10.f));
5049   Dali::Integration::TouchEvent touchEvent;
5050   touchEvent.AddPoint(point);
5051
5052   application.ProcessEvent(touchEvent);
5053
5054   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5055   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5056   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5057
5058   ResetTouchCallbacks();
5059
5060   tet_printf("RaiseToTop ActorA\n");
5061
5062   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5063   actorA.RaiseToTop();
5064   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5065   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5066
5067   application.SendNotification(); // ensure sorting order is calculated before next touch event
5068
5069   application.ProcessEvent(touchEvent);
5070
5071   glAbstraction.ResetSetUniformCallStack();
5072   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5073
5074   application.SendNotification();
5075   application.Render();
5076
5077   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5078
5079   // Test order of uniforms in stack
5080   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5081   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5082   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5083
5084   tet_infoline("Testing A above C and B at bottom\n");
5085   bool ACB = (indexA > indexC) && (indexC > indexB);
5086
5087   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5088
5089   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5090   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5091   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5092
5093   ResetTouchCallbacks();
5094
5095   tet_printf("RaiseToTop ActorB\n");
5096
5097   orderChangedSignal = false;
5098
5099   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5100   actorB.RaiseToTop();
5101   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5102   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5103
5104   application.SendNotification(); // Ensure sort order is calculated before next touch event
5105
5106   application.ProcessEvent(touchEvent);
5107
5108   glAbstraction.ResetSetUniformCallStack();
5109   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5110
5111   application.SendNotification();
5112   application.Render();
5113
5114   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5115
5116   // Test order of uniforms in stack
5117   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5118   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5119   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5120
5121   tet_infoline("Testing B above A and C at bottom\n");
5122   bool BAC = (indexB > indexA) && (indexA > indexC);
5123
5124   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5125
5126   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5127   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5128   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5129
5130   ResetTouchCallbacks();
5131
5132   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5133
5134   orderChangedSignal = false;
5135
5136   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5137   actorA.LowerToBottom();
5138   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5139   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5140
5141   application.SendNotification();
5142   application.Render();
5143
5144   orderChangedSignal = false;
5145
5146   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5147   actorB.LowerToBottom();
5148   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5149   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5150
5151   application.SendNotification();
5152   application.Render();
5153
5154   application.ProcessEvent(touchEvent);
5155
5156   glAbstraction.ResetSetUniformCallStack();
5157   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5158
5159   application.SendNotification();
5160   application.Render();
5161
5162   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5163
5164   // Test order of uniforms in stack
5165   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5166   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5167   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5168
5169   tet_infoline("Testing C above A and B at bottom\n");
5170   bool CAB = (indexC > indexA) && (indexA > indexB);
5171
5172   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5173
5174   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5175   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5176   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5177
5178   ResetTouchCallbacks();
5179
5180   END_TEST;
5181 }
5182
5183 int UtcDaliActorRaiseAbove(void)
5184 {
5185   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5186
5187   TestApplication application;
5188
5189   Integration::Scene stage(application.GetScene());
5190
5191   Actor actorA = Actor::New();
5192   Actor actorB = Actor::New();
5193   Actor actorC = Actor::New();
5194
5195   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5196   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5197
5198   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5199   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5200
5201   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5202   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5203
5204   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5205   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5206
5207   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5208   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5209
5210   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5211   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5212
5213   stage.Add(actorA);
5214   stage.Add(actorB);
5215   stage.Add(actorC);
5216
5217   ResetTouchCallbacks();
5218
5219   application.SendNotification();
5220   application.Render();
5221
5222   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5223   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5224   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5225
5226   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5227   // Only top actor will get touched.
5228   actorA.TouchedSignal().Connect(TestTouchCallback);
5229   actorB.TouchedSignal().Connect(TestTouchCallback2);
5230   actorC.TouchedSignal().Connect(TestTouchCallback3);
5231
5232   bool                     orderChangedSignal(false);
5233   Actor                    orderChangedActor;
5234   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5235   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5236
5237   Dali::Integration::Point point;
5238   point.SetDeviceId(1);
5239   point.SetState(PointState::DOWN);
5240   point.SetScreenPosition(Vector2(10.f, 10.f));
5241   Dali::Integration::TouchEvent touchEvent;
5242   touchEvent.AddPoint(point);
5243
5244   application.ProcessEvent(touchEvent);
5245
5246   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5247   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5248   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5249
5250   ResetTouchCallbacks();
5251
5252   tet_printf("Raise actor B Above Actor C\n");
5253
5254   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5255   actorB.RaiseAbove(actorC);
5256   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5257   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5258
5259   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5260   application.SendNotification();
5261   application.ProcessEvent(touchEvent);
5262
5263   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5264   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5265   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5266
5267   ResetTouchCallbacks();
5268
5269   tet_printf("Raise actor A Above Actor B\n");
5270
5271   orderChangedSignal = false;
5272
5273   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5274   actorA.RaiseAbove(actorB);
5275   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5276   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5277
5278   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5279   application.SendNotification();
5280
5281   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5282
5283   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5284   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5285   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5286
5287   ResetTouchCallbacks();
5288
5289   END_TEST;
5290 }
5291
5292 int UtcDaliActorRaiseAbove2(void)
5293 {
5294   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5295
5296   TestApplication application;
5297
5298   Integration::Scene stage(application.GetScene());
5299
5300   Actor actorA = Actor::New();
5301   Actor actorB = Actor::New();
5302   Actor actorC = Actor::New();
5303
5304   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5305   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5306
5307   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5308   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5309
5310   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5311   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5312
5313   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5314   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5315
5316   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5317   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5318
5319   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5320   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5321
5322   stage.Add(actorA);
5323   stage.Add(actorB);
5324   stage.Add(actorC);
5325
5326   ResetTouchCallbacks();
5327
5328   application.SendNotification();
5329   application.Render();
5330
5331   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5332   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5333   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5334
5335   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5336   // Only top actor will get touched.
5337   actorA.TouchedSignal().Connect(TestTouchCallback);
5338   actorB.TouchedSignal().Connect(TestTouchCallback2);
5339   actorC.TouchedSignal().Connect(TestTouchCallback3);
5340
5341   bool                     orderChangedSignal(false);
5342   Actor                    orderChangedActor;
5343   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5344   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5345
5346   Dali::Integration::Point point;
5347   point.SetDeviceId(1);
5348   point.SetState(PointState::DOWN);
5349   point.SetScreenPosition(Vector2(10.f, 10.f));
5350   Dali::Integration::TouchEvent touchEvent;
5351   touchEvent.AddPoint(point);
5352
5353   application.ProcessEvent(touchEvent);
5354
5355   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5356   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5357   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5358
5359   ResetTouchCallbacks();
5360
5361   tet_printf("Raise actor B Above Actor C\n");
5362
5363   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5364   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5365   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5366   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5367   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5368
5369   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5370   application.SendNotification();
5371   application.ProcessEvent(touchEvent);
5372
5373   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5374   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5375   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5376
5377   ResetTouchCallbacks();
5378
5379   tet_printf("Raise actor A Above Actor B\n");
5380
5381   orderChangedSignal = false;
5382
5383   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5384   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5385   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5386   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5387   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5388
5389   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5390   application.SendNotification();
5391
5392   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5393
5394   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5395   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5396   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5397
5398   ResetTouchCallbacks();
5399
5400   END_TEST;
5401 }
5402
5403 int UtcDaliActorLowerBelow(void)
5404 {
5405   tet_infoline("UtcDaliActor LowerBelow test \n");
5406
5407   TestApplication application;
5408
5409   Integration::Scene stage(application.GetScene());
5410
5411   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5412   // enables checking of which actor the uniform is assigned too
5413   Shader shaderA = CreateShader();
5414   shaderA.RegisterProperty("uRendererColor", 1.f);
5415
5416   Shader shaderB = CreateShader();
5417   shaderB.RegisterProperty("uRendererColor", 2.f);
5418
5419   Shader shaderC = CreateShader();
5420   shaderC.RegisterProperty("uRendererColor", 3.f);
5421
5422   Actor actorA = Actor::New();
5423   Actor actorB = Actor::New();
5424   Actor actorC = Actor::New();
5425
5426   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5427   Geometry geometry = CreateQuadGeometry();
5428
5429   Renderer rendererA = Renderer::New(geometry, shaderA);
5430   actorA.AddRenderer(rendererA);
5431
5432   Renderer rendererB = Renderer::New(geometry, shaderB);
5433   actorB.AddRenderer(rendererB);
5434
5435   Renderer rendererC = Renderer::New(geometry, shaderC);
5436   actorC.AddRenderer(rendererC);
5437
5438   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5439   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5440
5441   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5442   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5443
5444   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5445   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5446
5447   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5448   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5449
5450   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5451   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5452
5453   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5454   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5455
5456   Actor container = Actor::New();
5457   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5458   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5459   stage.Add(container);
5460
5461   container.Add(actorA);
5462   container.Add(actorB);
5463   container.Add(actorC);
5464
5465   ResetTouchCallbacks();
5466
5467   // Connect ChildOrderChangedSignal
5468   bool                     orderChangedSignal(false);
5469   Actor                    orderChangedActor;
5470   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5471   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5472
5473   // Set up gl abstraction trace so can query the set uniform order
5474   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5475   glAbstraction.EnableSetUniformCallTrace(true);
5476   glAbstraction.ResetSetUniformCallStack();
5477   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5478
5479   glAbstraction.ResetSetUniformCallStack();
5480
5481   application.SendNotification();
5482   application.Render();
5483
5484   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5485
5486   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5487
5488   // Test order of uniforms in stack
5489   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5490   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5491   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5492
5493   tet_infoline("Testing C above B and A at bottom\n");
5494   bool CBA = (indexC > indexB) && (indexB > indexA);
5495
5496   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5497
5498   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5499   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5500   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5501
5502   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5503   // Only top actor will get touched.
5504   actorA.TouchedSignal().Connect(TestTouchCallback);
5505   actorB.TouchedSignal().Connect(TestTouchCallback2);
5506   actorC.TouchedSignal().Connect(TestTouchCallback3);
5507
5508   Dali::Integration::Point point;
5509   point.SetDeviceId(1);
5510   point.SetState(PointState::DOWN);
5511   point.SetScreenPosition(Vector2(10.f, 10.f));
5512   Dali::Integration::TouchEvent touchEvent;
5513   touchEvent.AddPoint(point);
5514
5515   tet_infoline("UtcDaliActor Test Set up completed \n");
5516
5517   application.ProcessEvent(touchEvent);
5518
5519   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5520   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5521   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5522
5523   ResetTouchCallbacks();
5524
5525   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");
5526
5527   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5528   actorC.LowerBelow(actorB);
5529   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5530   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5531
5532   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5533   application.SendNotification();
5534   application.Render();
5535
5536   application.ProcessEvent(touchEvent); // touch event
5537
5538   glAbstraction.ResetSetUniformCallStack();
5539   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5540
5541   application.SendNotification();
5542   application.Render();
5543
5544   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5545
5546   // Test order of uniforms in stack
5547   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5548   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5549   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5550
5551   tet_infoline("Testing render order is A, C, B");
5552   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5553   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5554
5555   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5556   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5557   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5558
5559   ResetTouchCallbacks();
5560
5561   tet_printf("Lower actor C below Actor A leaving B on top\n");
5562
5563   orderChangedSignal = false;
5564
5565   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5566   actorC.LowerBelow(actorA);
5567   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5568   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5569
5570   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5571   application.SendNotification();
5572   application.Render();
5573
5574   application.ProcessEvent(touchEvent);
5575
5576   glAbstraction.ResetSetUniformCallStack();
5577   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5578
5579   application.Render();
5580   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5581
5582   // Test order of uniforms in stack
5583   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5584   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5585   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5586
5587   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5588   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5589
5590   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5591   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5592   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5593
5594   ResetTouchCallbacks();
5595
5596   tet_printf("Lower actor B below Actor C leaving A on top\n");
5597
5598   orderChangedSignal = false;
5599
5600   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5601   actorB.LowerBelow(actorC);
5602   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5603   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5604
5605   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5606   application.SendNotification();
5607   application.Render();
5608
5609   application.ProcessEvent(touchEvent);
5610
5611   glAbstraction.ResetSetUniformCallStack();
5612   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5613
5614   application.Render();
5615   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5616
5617   // Test order of uniforms in stack
5618   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5619   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5620   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5621
5622   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5623   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5624
5625   END_TEST;
5626 }
5627
5628 int UtcDaliActorLowerBelow2(void)
5629 {
5630   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5631
5632   TestApplication application;
5633
5634   Integration::Scene stage(application.GetScene());
5635
5636   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5637   // enables checking of which actor the uniform is assigned too
5638   Shader shaderA = CreateShader();
5639   shaderA.RegisterProperty("uRendererColor", 1.f);
5640
5641   Shader shaderB = CreateShader();
5642   shaderB.RegisterProperty("uRendererColor", 2.f);
5643
5644   Shader shaderC = CreateShader();
5645   shaderC.RegisterProperty("uRendererColor", 3.f);
5646
5647   Actor actorA = Actor::New();
5648   Actor actorB = Actor::New();
5649   Actor actorC = Actor::New();
5650
5651   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5652   Geometry geometry = CreateQuadGeometry();
5653
5654   Renderer rendererA = Renderer::New(geometry, shaderA);
5655   actorA.AddRenderer(rendererA);
5656
5657   Renderer rendererB = Renderer::New(geometry, shaderB);
5658   actorB.AddRenderer(rendererB);
5659
5660   Renderer rendererC = Renderer::New(geometry, shaderC);
5661   actorC.AddRenderer(rendererC);
5662
5663   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5664   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5665
5666   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5667   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5668
5669   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5670   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5671
5672   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5673   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5674
5675   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5676   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5677
5678   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5679   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5680
5681   Actor container = Actor::New();
5682   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5683   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5684   stage.Add(container);
5685
5686   container.Add(actorA);
5687   container.Add(actorB);
5688   container.Add(actorC);
5689
5690   ResetTouchCallbacks();
5691
5692   // Connect ChildOrderChangedSignal
5693   bool                     orderChangedSignal(false);
5694   Actor                    orderChangedActor;
5695   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5696   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5697
5698   // Set up gl abstraction trace so can query the set uniform order
5699   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5700   glAbstraction.EnableSetUniformCallTrace(true);
5701   glAbstraction.ResetSetUniformCallStack();
5702   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5703
5704   glAbstraction.ResetSetUniformCallStack();
5705
5706   application.SendNotification();
5707   application.Render();
5708
5709   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5710
5711   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5712
5713   // Test order of uniforms in stack
5714   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5715   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5716   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5717
5718   tet_infoline("Testing C above B and A at bottom\n");
5719   bool CBA = (indexC > indexB) && (indexB > indexA);
5720
5721   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5722
5723   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5724   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5725   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5726
5727   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5728   // Only top actor will get touched.
5729   actorA.TouchedSignal().Connect(TestTouchCallback);
5730   actorB.TouchedSignal().Connect(TestTouchCallback2);
5731   actorC.TouchedSignal().Connect(TestTouchCallback3);
5732
5733   Dali::Integration::Point point;
5734   point.SetDeviceId(1);
5735   point.SetState(PointState::DOWN);
5736   point.SetScreenPosition(Vector2(10.f, 10.f));
5737   Dali::Integration::TouchEvent touchEvent;
5738   touchEvent.AddPoint(point);
5739
5740   tet_infoline("UtcDaliActor Test Set up completed \n");
5741
5742   application.ProcessEvent(touchEvent);
5743
5744   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5745   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5746   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5747
5748   ResetTouchCallbacks();
5749
5750   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");
5751
5752   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5753   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5754   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5755   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5756
5757   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5758   application.SendNotification();
5759   application.Render();
5760
5761   application.ProcessEvent(touchEvent); // touch event
5762
5763   glAbstraction.ResetSetUniformCallStack();
5764   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5765
5766   application.SendNotification();
5767   application.Render();
5768
5769   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5770
5771   // Test order of uniforms in stack
5772   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5773   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5774   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5775
5776   tet_infoline("Testing render order is A, C, B");
5777   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5778   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5779
5780   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5781   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5782   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5783
5784   ResetTouchCallbacks();
5785
5786   tet_printf("Lower actor C below Actor A leaving B on top\n");
5787
5788   orderChangedSignal = false;
5789
5790   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5791   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
5792   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5793   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5794
5795   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5796   application.SendNotification();
5797   application.Render();
5798
5799   application.ProcessEvent(touchEvent);
5800
5801   glAbstraction.ResetSetUniformCallStack();
5802   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5803
5804   application.Render();
5805   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5806
5807   // Test order of uniforms in stack
5808   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5809   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5810   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5811
5812   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5813   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5814
5815   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5816   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5817   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5818
5819   ResetTouchCallbacks();
5820
5821   tet_printf("Lower actor B below Actor C leaving A on top\n");
5822
5823   orderChangedSignal = false;
5824
5825   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5826   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
5827   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5828   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5829
5830   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5831   application.SendNotification();
5832   application.Render();
5833
5834   application.ProcessEvent(touchEvent);
5835
5836   glAbstraction.ResetSetUniformCallStack();
5837   glSetUniformStack = glAbstraction.GetSetUniformTrace();
5838
5839   application.Render();
5840   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5841
5842   // Test order of uniforms in stack
5843   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5844   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5845   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5846
5847   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5848   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5849
5850   END_TEST;
5851 }
5852
5853 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5854 {
5855   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5856
5857   TestApplication application;
5858
5859   Integration::Scene stage(application.GetScene());
5860
5861   Actor parentA = Actor::New();
5862   Actor parentB = Actor::New();
5863   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5864   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5865   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5866   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5867
5868   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5869   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5870
5871   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5872   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5873
5874   stage.Add(parentA);
5875   stage.Add(parentB);
5876
5877   Actor actorA = Actor::New();
5878   Actor actorB = Actor::New();
5879   Actor actorC = Actor::New();
5880
5881   parentA.Add(actorA);
5882   parentA.Add(actorB);
5883
5884   tet_printf("Actor C added to different parent from A and B \n");
5885   parentB.Add(actorC);
5886
5887   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5888   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5889
5890   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5891   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5892
5893   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5894   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5895
5896   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5897   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5898
5899   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5900   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5901
5902   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5903   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5904
5905   ResetTouchCallbacks();
5906
5907   // Connect ChildOrderChangedSignal
5908   bool                     orderChangedSignal(false);
5909   Actor                    orderChangedActor;
5910   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5911   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5912
5913   application.SendNotification();
5914   application.Render();
5915
5916   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5917   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5918   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5919
5920   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5921   // Only top actor will get touched.
5922   actorA.TouchedSignal().Connect(TestTouchCallback);
5923   actorB.TouchedSignal().Connect(TestTouchCallback2);
5924   actorC.TouchedSignal().Connect(TestTouchCallback3);
5925
5926   Dali::Integration::Point point;
5927   point.SetDeviceId(1);
5928   point.SetState(PointState::DOWN);
5929   point.SetScreenPosition(Vector2(10.f, 10.f));
5930   Dali::Integration::TouchEvent touchEvent;
5931   touchEvent.AddPoint(point);
5932
5933   application.ProcessEvent(touchEvent);
5934
5935   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5936   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5937   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5938
5939   ResetTouchCallbacks();
5940
5941   tet_printf("Raise actor A Above Actor C which have different parents\n");
5942
5943   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5944   actorA.RaiseAbove(actorC);
5945   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5946
5947   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5948   application.SendNotification();
5949
5950   application.ProcessEvent(touchEvent); // touch event
5951
5952   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5953   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5954   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5955
5956   ResetTouchCallbacks();
5957
5958   END_TEST;
5959 }
5960
5961 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5962 {
5963   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
5964
5965   TestApplication application;
5966
5967   Integration::Scene stage(application.GetScene());
5968
5969   Actor actorA = Actor::New();
5970   Actor actorB = Actor::New();
5971   Actor actorC = Actor::New();
5972
5973   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5974   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5975
5976   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5977   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5978
5979   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5980   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5981
5982   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5983   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5984
5985   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5986   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5987
5988   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5989   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5990
5991   ResetTouchCallbacks();
5992
5993   // Connect ChildOrderChangedSignal
5994   bool                     orderChangedSignal(false);
5995   Actor                    orderChangedActor;
5996   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5997   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5998
5999   application.SendNotification();
6000   application.Render();
6001
6002   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6003   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6004   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6005
6006   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6007   // Only top actor will get touched.
6008   actorA.TouchedSignal().Connect(TestTouchCallback);
6009   actorB.TouchedSignal().Connect(TestTouchCallback2);
6010   actorC.TouchedSignal().Connect(TestTouchCallback3);
6011
6012   Dali::Integration::Point point;
6013   point.SetDeviceId(1);
6014   point.SetState(PointState::DOWN);
6015   point.SetScreenPosition(Vector2(10.f, 10.f));
6016   Dali::Integration::TouchEvent touchEvent;
6017   touchEvent.AddPoint(point);
6018
6019   tet_printf("Raise actor A Above Actor C which have no parents\n");
6020
6021   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6022   actorA.RaiseAbove(actorC);
6023   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6024
6025   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6026   application.SendNotification();
6027
6028   application.ProcessEvent(touchEvent);
6029
6030   tet_printf("Not parented so RaiseAbove should show no effect\n");
6031
6032   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6033   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6034   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6035
6036   ResetTouchCallbacks();
6037
6038   orderChangedSignal = false;
6039
6040   stage.Add(actorB);
6041   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6042
6043   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6044   actorA.LowerBelow(actorC);
6045   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6046
6047   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6048   application.SendNotification();
6049   application.Render();
6050
6051   application.ProcessEvent(touchEvent);
6052
6053   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6054   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6055   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6056   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6057
6058   ResetTouchCallbacks();
6059
6060   orderChangedSignal = false;
6061
6062   tet_printf("Adding Actor A to stage, will be on top\n");
6063
6064   stage.Add(actorA);
6065   application.SendNotification();
6066   application.Render();
6067
6068   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6069
6070   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6071   actorB.RaiseAbove(actorC);
6072   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6073
6074   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6075   application.SendNotification();
6076
6077   application.ProcessEvent(touchEvent);
6078
6079   tet_printf("C not parented so RaiseAbove should show no effect\n");
6080   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6081   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6082   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6083
6084   ResetTouchCallbacks();
6085
6086   orderChangedSignal = false;
6087
6088   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6089
6090   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6091   actorA.LowerBelow(actorC);
6092   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6093
6094   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6095   application.SendNotification();
6096
6097   application.ProcessEvent(touchEvent);
6098
6099   tet_printf("C not parented so LowerBelow should show no effect\n");
6100   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6101   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6102   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6103
6104   ResetTouchCallbacks();
6105
6106   orderChangedSignal = false;
6107
6108   stage.Add(actorC);
6109
6110   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6111   actorA.RaiseAbove(actorC);
6112   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6113   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6114
6115   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6116   application.SendNotification();
6117   application.Render();
6118
6119   application.ProcessEvent(touchEvent);
6120
6121   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6122   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6123   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6124   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6125
6126   END_TEST;
6127 }
6128
6129 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6130 {
6131   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6132
6133   TestApplication application;
6134
6135   Integration::Scene stage(application.GetScene());
6136
6137   Actor actorA = Actor::New();
6138   Actor actorB = Actor::New();
6139   Actor actorC = Actor::New();
6140
6141   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6142   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6143
6144   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6145   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6146
6147   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6148   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6149
6150   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6151   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6152
6153   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6154   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6155
6156   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6157   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6158
6159   ResetTouchCallbacks();
6160
6161   // Connect ChildOrderChangedSignal
6162   bool                     orderChangedSignal(false);
6163   Actor                    orderChangedActor;
6164   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6165   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6166
6167   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6168   // Only top actor will get touched.
6169   actorA.TouchedSignal().Connect(TestTouchCallback);
6170   actorB.TouchedSignal().Connect(TestTouchCallback2);
6171   actorC.TouchedSignal().Connect(TestTouchCallback3);
6172
6173   Dali::Integration::Point point;
6174   point.SetDeviceId(1);
6175   point.SetState(PointState::DOWN);
6176   point.SetScreenPosition(Vector2(10.f, 10.f));
6177   Dali::Integration::TouchEvent touchEvent;
6178   touchEvent.AddPoint(point);
6179
6180   stage.Add(actorA);
6181   tet_printf("Raise actor B Above Actor C but B not parented\n");
6182
6183   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6184   actorB.Raise();
6185   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6186
6187   application.SendNotification();
6188   application.Render();
6189
6190   application.ProcessEvent(touchEvent);
6191
6192   tet_printf("Not parented so RaiseAbove should show no effect\n");
6193
6194   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6195   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6196   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6197
6198   tet_printf("Raise actor B Above Actor C but B not parented\n");
6199   ResetTouchCallbacks();
6200
6201   orderChangedSignal = false;
6202
6203   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6204   actorC.Lower();
6205   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6206
6207   // Sort actor tree before next touch event
6208   application.SendNotification();
6209   application.Render();
6210
6211   application.ProcessEvent(touchEvent);
6212
6213   tet_printf("Not parented so RaiseAbove should show no effect\n");
6214
6215   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6216   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6217   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6218   ResetTouchCallbacks();
6219
6220   orderChangedSignal = false;
6221
6222   tet_printf("Lower actor C below B but C not parented\n");
6223
6224   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6225   actorB.Lower();
6226   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6227
6228   // Sort actor tree before next touch event
6229   application.SendNotification();
6230   application.Render();
6231
6232   application.ProcessEvent(touchEvent);
6233
6234   tet_printf("Not parented so Lower should show no effect\n");
6235
6236   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6237   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6238   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6239   ResetTouchCallbacks();
6240
6241   orderChangedSignal = false;
6242
6243   tet_printf("Raise actor B to top\n");
6244
6245   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6246   actorB.RaiseToTop();
6247   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6248
6249   // Sort actor tree before next touch event
6250   application.SendNotification();
6251   application.Render();
6252
6253   application.ProcessEvent(touchEvent);
6254
6255   tet_printf("Not parented so RaiseToTop should show no effect\n");
6256
6257   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6258   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6259   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6260   ResetTouchCallbacks();
6261
6262   orderChangedSignal = false;
6263
6264   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6265
6266   stage.Add(actorB);
6267
6268   tet_printf("Lower actor C to Bottom, B stays at top\n");
6269
6270   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6271   actorC.LowerToBottom();
6272   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6273
6274   application.SendNotification();
6275   application.Render();
6276
6277   application.ProcessEvent(touchEvent);
6278
6279   tet_printf("Not parented so LowerToBottom should show no effect\n");
6280
6281   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6282   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6283   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6284   ResetTouchCallbacks();
6285
6286   END_TEST;
6287 }
6288
6289 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6290 {
6291   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6292
6293   TestApplication application;
6294
6295   Integration::Scene stage(application.GetScene());
6296
6297   Actor actorA = Actor::New();
6298   Actor actorB = Actor::New();
6299   Actor actorC = Actor::New();
6300
6301   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6302   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6303
6304   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6305   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6306
6307   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6308   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6309
6310   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6311   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6312
6313   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6314   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6315
6316   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6317   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6318
6319   stage.Add(actorA);
6320   stage.Add(actorB);
6321   stage.Add(actorC);
6322
6323   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6324   // Only top actor will get touched.
6325   actorA.TouchedSignal().Connect(TestTouchCallback);
6326   actorB.TouchedSignal().Connect(TestTouchCallback2);
6327   actorC.TouchedSignal().Connect(TestTouchCallback3);
6328
6329   ResetTouchCallbacks();
6330
6331   // Connect ChildOrderChangedSignal
6332   bool                     orderChangedSignal(false);
6333   Actor                    orderChangedActor;
6334   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6335   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6336
6337   application.SendNotification();
6338   application.Render();
6339
6340   Dali::Integration::Point point;
6341   point.SetDeviceId(1);
6342   point.SetState(PointState::DOWN);
6343   point.SetScreenPosition(Vector2(10.f, 10.f));
6344   Dali::Integration::TouchEvent touchEvent;
6345   touchEvent.AddPoint(point);
6346
6347   application.ProcessEvent(touchEvent);
6348
6349   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6350   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6351   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6352
6353   ResetTouchCallbacks();
6354
6355   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6356
6357   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6358   actorA.RaiseAbove(actorA);
6359   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6360   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6361
6362   application.SendNotification();
6363   application.Render();
6364
6365   application.ProcessEvent(touchEvent);
6366
6367   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6368
6369   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6370   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6371   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6372
6373   ResetTouchCallbacks();
6374
6375   orderChangedSignal = false;
6376
6377   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6378   actorA.RaiseAbove(actorC);
6379   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6380   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6381
6382   application.SendNotification();
6383   application.Render();
6384
6385   application.ProcessEvent(touchEvent);
6386
6387   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6388   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6389   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6390   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6391
6392   END_TEST;
6393 }
6394
6395 int UtcDaliActorGetScreenPosition(void)
6396 {
6397   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6398
6399   TestApplication application;
6400
6401   Integration::Scene stage(application.GetScene());
6402
6403   Actor actorA = Actor::New();
6404   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6405
6406   Vector2 size2(10.0f, 20.0f);
6407   actorA.SetProperty(Actor::Property::SIZE, size2);
6408
6409   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6410
6411   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6412
6413   stage.Add(actorA);
6414
6415   application.SendNotification();
6416   application.Render();
6417
6418   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6419   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6420
6421   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6422   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6423
6424   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6425   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6426
6427   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6428
6429   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6430
6431   application.SendNotification();
6432   application.Render();
6433
6434   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6435   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6436
6437   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6438   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6439
6440   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6441   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6442
6443   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6444
6445   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6446
6447   application.SendNotification();
6448   application.Render();
6449
6450   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6451   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6452
6453   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
6454   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
6455
6456   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6457   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6458
6459   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6460
6461   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6462
6463   application.SendNotification();
6464   application.Render();
6465
6466   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6467   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6468
6469   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6470   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
6471
6472   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6473   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6474
6475   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6476
6477   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6478
6479   application.SendNotification();
6480   application.Render();
6481
6482   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6483   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6484
6485   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6486   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6487
6488   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6489   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6490
6491   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6492
6493   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6494   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6495
6496   Actor actorB = Actor::New();
6497   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6498   actorB.SetProperty(Actor::Property::SIZE, size2);
6499   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6500   actorA.Add(actorB);
6501
6502   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6503
6504   application.SendNotification();
6505   application.Render();
6506
6507   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6508
6509   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6510   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6511
6512   END_TEST;
6513 }
6514
6515 int UtcDaliActorGetScreenPositionAfterScaling(void)
6516 {
6517   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6518
6519   TestApplication application;
6520
6521   Integration::Scene stage(application.GetScene());
6522
6523   Actor actorA = Actor::New();
6524   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6525
6526   Vector2 size2(10.0f, 20.0f);
6527   actorA.SetProperty(Actor::Property::SIZE, size2);
6528   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6529   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6530
6531   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6532
6533   stage.Add(actorA);
6534
6535   application.SendNotification();
6536   application.Render();
6537
6538   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6539   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6540
6541   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6542   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6543
6544   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6545   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6546
6547   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6548
6549   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6550
6551   application.SendNotification();
6552   application.Render();
6553
6554   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6555   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6556
6557   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6558   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6559
6560   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6561   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6562
6563   END_TEST;
6564 }
6565
6566 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6567 {
6568   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6569
6570   TestApplication application;
6571
6572   Integration::Scene stage(application.GetScene());
6573
6574   Actor actorA = Actor::New();
6575   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6576   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6577   Vector2 size2(10.0f, 20.0f);
6578   actorA.SetProperty(Actor::Property::SIZE, size2);
6579   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6580
6581   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6582
6583   stage.Add(actorA);
6584
6585   application.SendNotification();
6586   application.Render();
6587
6588   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6589   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6590
6591   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6592   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6593
6594   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6595   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6596
6597   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6598
6599   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6600   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6601
6602   application.SendNotification();
6603   application.Render();
6604
6605   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6606   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6607
6608   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6609   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6610
6611   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6612   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6613
6614   END_TEST;
6615   END_TEST;
6616 }
6617
6618 int UtcDaliActorGetScreenPositionWithChildActors(void)
6619 {
6620   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6621
6622   TestApplication application;
6623
6624   Integration::Scene stage(application.GetScene());
6625
6626   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6627
6628   Actor actorA = Actor::New();
6629   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6630   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6631   Vector2 size1(10.0f, 20.0f);
6632   actorA.SetProperty(Actor::Property::SIZE, size1);
6633   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6634
6635   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6636
6637   Actor parentActorA = Actor::New();
6638   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6639   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6640   Vector2 size2(30.0f, 60.0f);
6641   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6642   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6643
6644   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6645
6646   stage.Add(parentActorA);
6647   parentActorA.Add(actorA);
6648
6649   application.SendNotification();
6650   application.Render();
6651
6652   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6653   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6654
6655   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6656   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6657
6658   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6659   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6660
6661   tet_infoline("Test 2\n");
6662
6663   tet_infoline("change parent anchor point and parent origin then check screen position \n");
6664
6665   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6666   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6667
6668   application.SendNotification();
6669   application.Render();
6670
6671   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6672   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6673
6674   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6675   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6676
6677   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6678   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6679
6680   END_TEST;
6681 }
6682
6683 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6684 {
6685   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6686
6687   TestApplication application;
6688
6689   Integration::Scene stage(application.GetScene());
6690
6691   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6692
6693   Actor actorA = Actor::New();
6694   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6695   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6696   Vector2 size1(10.0f, 20.0f);
6697   actorA.SetProperty(Actor::Property::SIZE, size1);
6698   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6699
6700   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6701
6702   Actor parentActorA = Actor::New();
6703   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6704   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6705   Vector2 size2(30.0f, 60.0f);
6706   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6707   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6708
6709   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6710
6711   Actor grandParentActorA = Actor::New();
6712   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6713   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6714   Vector2 size3(60.0f, 120.0f);
6715   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6716   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6717
6718   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6719
6720   stage.Add(grandParentActorA);
6721   grandParentActorA.Add(parentActorA);
6722
6723   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6724
6725   parentActorA.Add(actorA);
6726
6727   application.SendNotification();
6728   application.Render();
6729
6730   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6731   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6732
6733   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6734   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6735
6736   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6737   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6738
6739   END_TEST;
6740 }
6741
6742 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6743 {
6744   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6745
6746   TestApplication application;
6747
6748   Integration::Scene stage(application.GetScene());
6749
6750   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6751
6752   Actor actorA = Actor::New();
6753   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6754   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6755   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6756   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6757   stage.Add(actorA);
6758
6759   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6760
6761   Actor actorB = Actor::New();
6762   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6763   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6764   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6765   Vector2 actorBSize(30.0f, 60.0f);
6766   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6767   stage.Add(actorB);
6768
6769   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6770
6771   Actor actorC = Actor::New();
6772   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6773   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6774   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6775   Vector2 actorCSize(60.0f, 120.0f);
6776   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6777   stage.Add(actorC);
6778
6779   application.SendNotification();
6780   application.Render();
6781
6782   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6783
6784   Vector2 center(stage.GetSize() * 0.5f);
6785
6786   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6787   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6788   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6789
6790   tet_infoline("Add scale to all actors");
6791
6792   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6793   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6794   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6795
6796   application.SendNotification();
6797   application.Render();
6798
6799   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6800   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6801   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6802
6803   END_TEST;
6804 }
6805
6806 int utcDaliActorPositionUsesAnchorPoint(void)
6807 {
6808   TestApplication application;
6809   tet_infoline("Check default behaviour\n");
6810
6811   Actor actor = Actor::New();
6812   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6813   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6814   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6815   application.GetScene().Add(actor);
6816
6817   application.SendNotification();
6818   application.Render();
6819
6820   tet_infoline("Check that the world position is in the center\n");
6821   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6822
6823   tet_infoline("Set the position uses anchor point property to false\n");
6824   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6825
6826   application.SendNotification();
6827   application.Render();
6828
6829   tet_infoline("Check that the world position has changed appropriately\n");
6830   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6831
6832   END_TEST;
6833 }
6834
6835 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6836 {
6837   TestApplication application;
6838   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6839
6840   Actor actor = Actor::New();
6841   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6842   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6843   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6844   actor.SetProperty(Actor::Property::SCALE, 2.0f);
6845   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6846   application.GetScene().Add(actor);
6847
6848   application.SendNotification();
6849   application.Render();
6850
6851   tet_infoline("Check the world position is the same as it would be without a scale\n");
6852   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6853
6854   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6855   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6856   application.SendNotification();
6857   application.Render();
6858   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6859
6860   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6861   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6862   application.SendNotification();
6863   application.Render();
6864   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6865
6866   END_TEST;
6867 }
6868
6869 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6870 {
6871   TestApplication application;
6872   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6873
6874   Actor actor = Actor::New();
6875   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6876   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6877   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6878   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6879   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6880   application.GetScene().Add(actor);
6881
6882   application.SendNotification();
6883   application.Render();
6884
6885   tet_infoline("Check the world position is the same as it would be without a rotation\n");
6886   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6887
6888   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6889   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6890   application.SendNotification();
6891   application.Render();
6892   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6893
6894   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6895   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6896   application.SendNotification();
6897   application.Render();
6898   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6899
6900   END_TEST;
6901 }
6902
6903 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6904 {
6905   TestApplication application;
6906   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6907
6908   Actor actor = Actor::New();
6909   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6910   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6911   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6912   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6913   actor.SetProperty(Actor::Property::SCALE, 2.0f);
6914   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6915   application.GetScene().Add(actor);
6916
6917   application.SendNotification();
6918   application.Render();
6919
6920   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6921   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6922
6923   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6924   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6925   application.SendNotification();
6926   application.Render();
6927   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6928
6929   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6930   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6931   application.SendNotification();
6932   application.Render();
6933   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6934
6935   END_TEST;
6936 }
6937
6938 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6939 {
6940   TestApplication application;
6941   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6942
6943   Actor parent = Actor::New();
6944
6945   application.GetScene().Add(parent);
6946   Vector2 stageSize(application.GetScene().GetSize());
6947
6948   Actor actor = Actor::New();
6949   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6950   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6951   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6952   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6953   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6954   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6955   parent.Add(actor);
6956
6957   application.SendNotification();
6958   application.Render();
6959
6960   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6961
6962   tet_infoline("Check the world position is in the right place\n");
6963   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6964
6965   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6966   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6967   application.SendNotification();
6968   application.Render();
6969   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6970
6971   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6972   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6973   application.SendNotification();
6974   application.Render();
6975   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6976
6977   END_TEST;
6978 }
6979
6980 int utcDaliActorVisibilityChangeSignalSelf(void)
6981 {
6982   TestApplication application;
6983   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6984
6985   Actor actor = Actor::New();
6986
6987   VisibilityChangedFunctorData data;
6988   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6989
6990   actor.SetProperty(Actor::Property::VISIBLE, false);
6991
6992   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6993
6994   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6995   data.Reset();
6996
6997   actor.SetProperty(Actor::Property::VISIBLE, false);
6998   data.Check(false /* not called */, TEST_LOCATION);
6999
7000   tet_infoline("Change the visibility using properties, ensure called");
7001   data.Reset();
7002
7003   actor.SetProperty(Actor::Property::VISIBLE, true);
7004   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7005
7006   tet_infoline("Set the visibility to current using properties, ensure not called");
7007   data.Reset();
7008
7009   actor.SetProperty(Actor::Property::VISIBLE, true);
7010   data.Check(false /* not called */, TEST_LOCATION);
7011
7012   END_TEST;
7013 }
7014
7015 int utcDaliActorVisibilityChangeSignalChildren(void)
7016 {
7017   TestApplication application;
7018   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7019
7020   Actor parent = Actor::New();
7021   Actor child  = Actor::New();
7022   parent.Add(child);
7023
7024   Actor grandChild = Actor::New();
7025   child.Add(grandChild);
7026
7027   VisibilityChangedFunctorData parentData;
7028   VisibilityChangedFunctorData childData;
7029   VisibilityChangedFunctorData grandChildData;
7030
7031   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7032   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7033   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7034
7035   parent.SetProperty(Actor::Property::VISIBLE, false);
7036   parentData.Check(false /* not called */, TEST_LOCATION);
7037   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7038   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7039
7040   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7041   parentData.Reset();
7042   childData.Reset();
7043   grandChildData.Reset();
7044
7045   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7046
7047   parent.SetProperty(Actor::Property::VISIBLE, true);
7048   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7049   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7050   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7051
7052   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7053   parentData.Reset();
7054   childData.Reset();
7055   grandChildData.Reset();
7056
7057   parent.SetProperty(Actor::Property::VISIBLE, true);
7058   parentData.Check(false /* not called */, TEST_LOCATION);
7059   childData.Check(false /* not called */, TEST_LOCATION);
7060   grandChildData.Check(false /* not called */, TEST_LOCATION);
7061
7062   END_TEST;
7063 }
7064
7065 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7066 {
7067   TestApplication application;
7068   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7069
7070   Actor actor = Actor::New();
7071   application.GetScene().Add(actor);
7072
7073   application.SendNotification();
7074   application.Render();
7075
7076   VisibilityChangedFunctorData data;
7077   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7078
7079   Animation animation = Animation::New(1.0f);
7080   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7081
7082   data.Check(false, TEST_LOCATION);
7083   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7084   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7085
7086   tet_infoline("Play the animation and check the property value");
7087   animation.Play();
7088
7089   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7090   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7091
7092   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7093   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7094
7095   application.SendNotification();
7096   application.Render(1100); // After the animation
7097
7098   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7099
7100   END_TEST;
7101 }
7102
7103 int utcDaliActorVisibilityChangeSignalByName(void)
7104 {
7105   TestApplication application;
7106   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7107
7108   Actor actor = Actor::New();
7109
7110   bool signalCalled = false;
7111   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7112   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7113   actor.SetProperty(Actor::Property::VISIBLE, false);
7114   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7115
7116   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7117   signalCalled = false;
7118   actor.SetProperty(Actor::Property::VISIBLE, false);
7119   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7120
7121   tet_infoline("Change the visibility using properties, ensure called");
7122   actor.SetProperty(Actor::Property::VISIBLE, true);
7123   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7124
7125   tet_infoline("Set the visibility to current using properties, ensure not called");
7126   signalCalled = false;
7127
7128   actor.SetProperty(Actor::Property::VISIBLE, true);
7129   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7130
7131   END_TEST;
7132 }
7133
7134 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7135 {
7136   gLayoutDirectionType = type;
7137 }
7138
7139 int UtcDaliActorLayoutDirectionProperty(void)
7140 {
7141   TestApplication application;
7142   tet_infoline("Check layout direction property");
7143
7144   Actor actor0 = Actor::New();
7145   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7146   application.GetScene().Add(actor0);
7147
7148   application.SendNotification();
7149   application.Render();
7150
7151   Actor actor1 = Actor::New();
7152   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7153   Actor actor2 = Actor::New();
7154   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7155   Actor actor3 = Actor::New();
7156   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7157   Actor actor4 = Actor::New();
7158   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7159   Actor actor5 = Actor::New();
7160   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7161   Actor actor6 = Actor::New();
7162   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7163   Actor actor7 = Actor::New();
7164   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7165   Actor actor8 = Actor::New();
7166   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7167   Actor actor9 = Actor::New();
7168   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7169
7170   actor1.Add(actor2);
7171   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7172   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7173
7174   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7175   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7176   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7177
7178   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7179   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7180   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7181
7182   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7183   actor0.Add(actor1);
7184   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7185   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7186
7187   application.GetScene().Add(actor3);
7188   actor3.Add(actor4);
7189   actor4.Add(actor5);
7190   actor5.Add(actor6);
7191   actor5.Add(actor7);
7192   actor7.Add(actor8);
7193   actor8.Add(actor9);
7194   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7195   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7196
7197   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7198   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7199   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7200
7201   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7202
7203   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7204   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7205   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7206   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7207   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7208   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7209   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7210
7211   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7212   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7213   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7214
7215   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7216   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7217   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7218   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7219
7220   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7221   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7222   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7223
7224   END_TEST;
7225 }
7226
7227 struct LayoutDirectionFunctor
7228 {
7229   LayoutDirectionFunctor(bool& signalCalled)
7230   : mSignalCalled(signalCalled)
7231   {
7232   }
7233
7234   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7235   : mSignalCalled(rhs.mSignalCalled)
7236   {
7237   }
7238
7239   void operator()()
7240   {
7241     mSignalCalled = true;
7242   }
7243
7244   bool& mSignalCalled;
7245 };
7246
7247 int UtcDaliActorLayoutDirectionSignal(void)
7248 {
7249   TestApplication application;
7250   tet_infoline("Check changing layout direction property sends a signal");
7251
7252   Actor actor = Actor::New();
7253   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7254   application.GetScene().Add(actor);
7255   bool                   signalCalled = false;
7256   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7257
7258   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7259   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7260
7261   // Test that writing the same value doesn't send a signal
7262   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7263   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7264
7265   // Test that writing a different value sends the signal
7266   signalCalled = false;
7267   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7268   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7269
7270   signalCalled = false;
7271   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7272   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7273
7274   END_TEST;
7275 }
7276
7277 struct ChildAddedSignalCheck
7278 {
7279   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7280   : mSignalReceived(signalReceived),
7281     mChildHandle(childHandle)
7282   {
7283   }
7284
7285   void operator()(Actor childHandle)
7286   {
7287     mSignalReceived = true;
7288     mChildHandle    = childHandle;
7289   }
7290   void operator()()
7291   {
7292     mSignalReceived = true;
7293     mChildHandle    = Actor();
7294   }
7295
7296   bool&  mSignalReceived;
7297   Actor& mChildHandle;
7298 };
7299
7300 int UtcDaliChildAddedSignalP1(void)
7301 {
7302   TestApplication application;
7303   auto            stage = application.GetScene();
7304
7305   bool  signalReceived = false;
7306   Actor childActor;
7307
7308   ChildAddedSignalCheck signal(signalReceived, childActor);
7309   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7310   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7311
7312   auto actorA = Actor::New();
7313   stage.Add(actorA);
7314   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7315   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7316   signalReceived = false;
7317
7318   auto actorB = Actor::New();
7319   stage.Add(actorB);
7320   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7321   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7322
7323   END_TEST;
7324 }
7325
7326 int UtcDaliChildAddedSignalP2(void)
7327 {
7328   TestApplication application;
7329   auto            stage = application.GetScene();
7330
7331   bool  signalReceived = false;
7332   Actor childActor;
7333
7334   ChildAddedSignalCheck signal(signalReceived, childActor);
7335   tet_infoline("Connect to childAdded signal by name");
7336
7337   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7338   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7339
7340   auto actorA = Actor::New();
7341   stage.Add(actorA);
7342   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7343
7344   // Can't test which actor was added; signal signature is void() when connecting via name.
7345   signalReceived = false;
7346
7347   auto actorB = Actor::New();
7348   stage.Add(actorB);
7349   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7350
7351   END_TEST;
7352 }
7353
7354 int UtcDaliChildAddedSignalN(void)
7355 {
7356   TestApplication application;
7357   auto            stage = application.GetScene();
7358
7359   bool  signalReceived = false;
7360   Actor childActor;
7361
7362   ChildAddedSignalCheck signal(signalReceived, childActor);
7363   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7364   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7365
7366   auto actorA = Actor::New();
7367   stage.Add(actorA);
7368   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7369   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7370   signalReceived = false;
7371
7372   auto actorB = Actor::New();
7373   actorA.Add(actorB);
7374   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7375   END_TEST;
7376 }
7377
7378 struct ChildRemovedSignalCheck
7379 {
7380   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7381   : mSignalReceived(signalReceived),
7382     mChildHandle(childHandle)
7383   {
7384   }
7385
7386   void operator()(Actor childHandle)
7387   {
7388     mSignalReceived = true;
7389     mChildHandle    = childHandle;
7390   }
7391
7392   void operator()()
7393   {
7394     mSignalReceived = true;
7395   }
7396
7397   bool&  mSignalReceived;
7398   Actor& mChildHandle;
7399 };
7400
7401 int UtcDaliChildRemovedSignalP1(void)
7402 {
7403   TestApplication application;
7404   auto            stage = application.GetScene();
7405
7406   bool  signalReceived = false;
7407   Actor childActor;
7408
7409   ChildRemovedSignalCheck signal(signalReceived, childActor);
7410   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7411   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7412
7413   auto actorA = Actor::New();
7414   stage.Add(actorA);
7415   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7416   DALI_TEST_CHECK(!childActor);
7417
7418   stage.Remove(actorA);
7419   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7420   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7421
7422   signalReceived = false;
7423   auto actorB    = Actor::New();
7424   stage.Add(actorB);
7425   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7426
7427   stage.Remove(actorB);
7428   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7429   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7430
7431   END_TEST;
7432 }
7433
7434 int UtcDaliChildRemovedSignalP2(void)
7435 {
7436   TestApplication application;
7437   auto            stage = application.GetScene();
7438
7439   bool  signalReceived = false;
7440   Actor childActor;
7441
7442   ChildAddedSignalCheck signal(signalReceived, childActor);
7443   tet_infoline("Connect to childRemoved signal by name");
7444
7445   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7446   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7447
7448   auto actorA = Actor::New();
7449   stage.Add(actorA);
7450   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7451
7452   stage.Remove(actorA);
7453   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7454
7455   signalReceived = false;
7456   auto actorB    = Actor::New();
7457   stage.Add(actorB);
7458   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7459
7460   stage.Remove(actorB);
7461   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7462
7463   END_TEST;
7464 }
7465
7466 int UtcDaliChildRemovedSignalN(void)
7467 {
7468   TestApplication application;
7469   auto            stage = application.GetScene();
7470
7471   bool  signalReceived = false;
7472   Actor childActor;
7473
7474   ChildRemovedSignalCheck signal(signalReceived, childActor);
7475   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7476   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7477
7478   auto actorA = Actor::New();
7479   stage.Add(actorA);
7480
7481   auto actorB = Actor::New();
7482   actorA.Add(actorB);
7483
7484   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7485   DALI_TEST_CHECK(!childActor);
7486
7487   actorA.Remove(actorB);
7488   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7489   END_TEST;
7490 }
7491
7492 int UtcDaliChildMovedSignalP(void)
7493 {
7494   TestApplication application;
7495   auto            stage = application.GetScene();
7496
7497   bool  addedASignalReceived   = false;
7498   bool  removedASignalReceived = false;
7499   bool  addedBSignalReceived   = false;
7500   bool  removedBSignalReceived = false;
7501   Actor childActor;
7502
7503   auto actorA = Actor::New();
7504   auto actorB = Actor::New();
7505   stage.Add(actorA);
7506   stage.Add(actorB);
7507
7508   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
7509   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7510   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
7511   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7512
7513   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7514   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7515   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7516   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7517
7518   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7519   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7520   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7521   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7522
7523   // Create a child of A
7524
7525   auto child = Actor::New();
7526   actorA.Add(child);
7527
7528   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7529   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7530   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7531   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7532   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7533
7534   // Move child to B:
7535   addedASignalReceived   = false;
7536   addedBSignalReceived   = false;
7537   removedASignalReceived = false;
7538   removedBSignalReceived = false;
7539
7540   actorB.Add(child); // Expect this child to be re-parented
7541   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7542   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7543   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7544   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7545
7546   // Move child back to A:
7547   addedASignalReceived   = false;
7548   addedBSignalReceived   = false;
7549   removedASignalReceived = false;
7550   removedBSignalReceived = false;
7551
7552   actorA.Add(child); // Expect this child to be re-parented
7553   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7554   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7555   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7556   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7557
7558   END_TEST;
7559 }
7560
7561 int utcDaliActorCulled(void)
7562 {
7563   TestApplication application;
7564   auto            stage = application.GetScene();
7565
7566   tet_infoline("Check that the actor is culled if the actor is out of the screen");
7567
7568   Actor actor = Actor::New();
7569   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7570
7571   Geometry geometry = CreateQuadGeometry();
7572   Shader   shader   = CreateShader();
7573   Renderer renderer = Renderer::New(geometry, shader);
7574   actor.AddRenderer(renderer);
7575
7576   stage.Add(actor);
7577
7578   application.SendNotification();
7579   application.Render(0);
7580
7581   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7582
7583   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7584   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7585
7586   // Connect NotifySignal
7587   bool                              propertyNotificationSignal(false);
7588   PropertyNotification              source;
7589   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7590   notification.NotifySignal().Connect(&application, f);
7591
7592   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7593
7594   application.SendNotification();
7595   application.Render();
7596
7597   application.SendNotification();
7598
7599   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7600
7601   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7602   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7603   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7604
7605   END_TEST;
7606 }
7607
7608 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7609 {
7610   TestApplication application;
7611   auto            stage = application.GetScene();
7612
7613   tet_infoline("Ensure we clear the screen when the last actor is removed");
7614
7615   Actor actor = CreateRenderableActor();
7616   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7617   stage.Add(actor);
7618
7619   application.SendNotification();
7620   application.Render();
7621
7622   auto&      glAbstraction    = application.GetGlAbstraction();
7623   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7624
7625   actor.Unparent();
7626
7627   application.SendNotification();
7628   application.Render();
7629
7630   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7631
7632   END_TEST;
7633 }
7634
7635 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7636 {
7637   TestApplication application;
7638   auto            stage = application.GetScene();
7639
7640   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7641
7642   Actor actor = CreateRenderableActor();
7643   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7644   stage.Add(actor);
7645
7646   application.SendNotification();
7647   application.Render();
7648
7649   auto&      glAbstraction    = application.GetGlAbstraction();
7650   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7651
7652   actor.SetProperty(Actor::Property::VISIBLE, false);
7653
7654   application.SendNotification();
7655   application.Render();
7656
7657   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7658
7659   END_TEST;
7660 }
7661
7662 int utcDaliActorGetSizeAfterAnimation(void)
7663 {
7664   TestApplication application;
7665   tet_infoline("Check the actor size before / after an animation is finished");
7666
7667   Vector3 actorSize(100.0f, 100.0f, 0.0f);
7668
7669   Actor actor = Actor::New();
7670   actor.SetProperty(Actor::Property::SIZE, actorSize);
7671   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7672   application.GetScene().Add(actor);
7673
7674   // Size should be updated without rendering.
7675   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7676   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7677
7678   application.SendNotification();
7679   application.Render();
7680
7681   // Size and current size should be updated.
7682   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7683   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7684   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7685   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7686   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7687
7688   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7689   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7690   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7691   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7692   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7693
7694   // Set size again
7695   actorSize = Vector3(200.0f, 200.0f, 0.0f);
7696   actor.SetProperty(Actor::Property::SIZE, actorSize);
7697
7698   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7699   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7700
7701   Vector3 targetValue(10.0f, 20.0f, 0.0f);
7702
7703   Animation animation = Animation::New(1.0f);
7704   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7705   animation.Play();
7706
7707   // Size should be updated without rendering.
7708   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7709   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7710
7711   application.SendNotification();
7712   application.Render(1100); // After the animation
7713
7714   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7715   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7716   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7717   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7718   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7719
7720   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7721   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7722   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7723   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7724   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7725
7726   targetValue.width = 50.0f;
7727
7728   animation.Clear();
7729   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7730   animation.Play();
7731
7732   application.SendNotification();
7733   application.Render(1100); // After the animation
7734
7735   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7736   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7737   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7738   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7739   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7740
7741   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7742   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7743   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7744   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7745   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7746
7747   targetValue.height = 70.0f;
7748
7749   animation.Clear();
7750   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7751   animation.Play();
7752
7753   application.SendNotification();
7754   application.Render(1100); // After the animation
7755
7756   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7757   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7758   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7759   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7760   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7761
7762   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7763   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7764   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7765   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7766   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7767
7768   Vector3 offset(10.0f, 20.0f, 0.0f);
7769
7770   animation.Clear();
7771   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7772   animation.Play();
7773
7774   application.SendNotification();
7775   application.Render(1100); // After the animation
7776
7777   targetValue += offset;
7778
7779   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7780   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7781   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7782   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7783   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7784
7785   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7786   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7787   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7788   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7789   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7790
7791   offset.width = 20.0f;
7792
7793   animation.Clear();
7794   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7795   animation.Play();
7796
7797   application.SendNotification();
7798   application.Render(1100); // After the animation
7799
7800   targetValue.width += offset.width;
7801
7802   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7803   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7804   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7805   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7806   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7807
7808   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7809   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7810   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7811   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7812   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7813
7814   offset.height = 10.0f;
7815
7816   animation.Clear();
7817   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7818   animation.Play();
7819
7820   application.SendNotification();
7821   application.Render(1100); // After the animation
7822
7823   targetValue.height += offset.height;
7824
7825   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7826   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7827   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7828   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7829   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7830
7831   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7832   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7833   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7834   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7835   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7836
7837   // Set size again
7838   actorSize = Vector3(300.0f, 300.0f, 0.0f);
7839
7840   actor.SetProperty(Actor::Property::SIZE, actorSize);
7841
7842   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7843   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7844
7845   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7846   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7847
7848   application.SendNotification();
7849   application.Render();
7850
7851   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7852   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7853
7854   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7855   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7856
7857   END_TEST;
7858 }
7859
7860 int utcDaliActorPartialUpdate(void)
7861 {
7862   TestApplication application(
7863     TestApplication::DEFAULT_SURFACE_WIDTH,
7864     TestApplication::DEFAULT_SURFACE_HEIGHT,
7865     TestApplication::DEFAULT_HORIZONTAL_DPI,
7866     TestApplication::DEFAULT_VERTICAL_DPI,
7867     true,
7868     true);
7869
7870   tet_infoline("Check the damaged area");
7871
7872   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7873
7874   std::vector<Rect<int>> damagedRects;
7875   Rect<int>              clippingRect;
7876   application.SendNotification();
7877   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7878
7879   // First render pass, nothing to render, adaptor would just do swap buffer.
7880   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7881   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7882
7883   Actor actor = CreateRenderableActor();
7884   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7885   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7886   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7887   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7888   application.GetScene().Add(actor);
7889
7890   application.SendNotification();
7891
7892   // 1. Actor added, damaged rect is added size of actor
7893   damagedRects.clear();
7894   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7895   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7896
7897   // Aligned by 16
7898   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7899   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7900   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7901   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7902   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7903   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7904   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7905
7906   // 2. Set new size
7907   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7908   application.SendNotification();
7909
7910   damagedRects.clear();
7911   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7912   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7913
7914   // Aligned by 16
7915   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7916   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7917   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7918   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7919   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7920   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7921   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7922
7923   // 3. Set new position
7924   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7925   application.SendNotification();
7926
7927   damagedRects.clear();
7928   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7929   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7930
7931   // Aligned by 16
7932   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7933   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7934   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7935   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7936   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7937   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7938   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7939
7940   application.GetScene().Remove(actor);
7941   application.SendNotification();
7942
7943   // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7944   damagedRects.clear();
7945   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7946   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7947
7948   clippingRect = damagedRects[0];
7949   clippingRect.Merge(damagedRects[1]);
7950   clippingRect.Merge(damagedRects[2]);
7951
7952   DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7953   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7954   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7955
7956   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7957   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7958   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7959   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7960   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7961
7962   END_TEST;
7963 }
7964
7965 int utcDaliActorPartialUpdateSetColor(void)
7966 {
7967   TestApplication application(
7968     TestApplication::DEFAULT_SURFACE_WIDTH,
7969     TestApplication::DEFAULT_SURFACE_HEIGHT,
7970     TestApplication::DEFAULT_HORIZONTAL_DPI,
7971     TestApplication::DEFAULT_VERTICAL_DPI,
7972     true,
7973     true);
7974
7975   tet_infoline("Check uniform update");
7976
7977   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7978
7979   std::vector<Rect<int>> damagedRects;
7980   Rect<int>              clippingRect;
7981   application.SendNotification();
7982   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7983
7984   // First render pass, nothing to render, adaptor would just do swap buffer.
7985   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7986   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7987
7988   Actor actor = CreateRenderableActor();
7989   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7990   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7991   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7992   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7993   application.GetScene().Add(actor);
7994
7995   application.SendNotification();
7996
7997   // 1. Actor added, damaged rect is added size of actor
7998   damagedRects.clear();
7999   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8000   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8001
8002   // Aligned by 16
8003   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8004   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8005   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8006   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8007   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8008   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8009   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8010
8011   damagedRects.clear();
8012   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8013
8014   damagedRects.clear();
8015   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8016
8017   // 2. Set new color
8018   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8019   application.SendNotification();
8020
8021   damagedRects.clear();
8022   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8023   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8024
8025   // Aligned by 16
8026   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8027   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8028   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8029   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8030   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8031   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8032   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8033
8034   END_TEST;
8035 }
8036
8037 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8038 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8039 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8040 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8041   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8042   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8043   "\n"
8044   "void main()\n"
8045   "{\n"
8046   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8047   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8048   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8049   "}\n";
8050
8051 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8052   "uniform lowp vec4 uShadowColor;\n"
8053   "void main()\n"
8054   "{\n"
8055   "  lowp float alpha;\n"
8056   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8057   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8058   "}\n";
8059
8060 int utcDaliActorPartialUpdateSetProperty(void)
8061 {
8062   TestApplication application(
8063     TestApplication::DEFAULT_SURFACE_WIDTH,
8064     TestApplication::DEFAULT_SURFACE_HEIGHT,
8065     TestApplication::DEFAULT_HORIZONTAL_DPI,
8066     TestApplication::DEFAULT_VERTICAL_DPI,
8067     true,
8068     true);
8069
8070   tet_infoline("Set/Update property with partial update");
8071
8072   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8073
8074   std::vector<Rect<int>> damagedRects;
8075   Rect<int>              clippingRect;
8076   application.SendNotification();
8077   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8078
8079   // First render pass, nothing to render, adaptor would just do swap buffer.
8080   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8081   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8082
8083   Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8084   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8085   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8086   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8087   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8088   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8089   application.GetScene().Add(actor);
8090
8091   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8092
8093   damagedRects.clear();
8094   application.SendNotification();
8095   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8096   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8097
8098   // Aligned by 16
8099   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8100   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8101   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8102   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8103   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8104   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8105   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8106
8107   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8108   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8109
8110   damagedRects.clear();
8111   application.SendNotification();
8112   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8113   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8114
8115   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8116   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8117   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8118   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8119   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8120   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8121
8122   damagedRects.clear();
8123   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8124   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8125
8126   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8127   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8128   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8129   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8130   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8131   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8132
8133   damagedRects.clear();
8134   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8135   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8136
8137   END_TEST;
8138 }
8139
8140 int utcDaliActorPartialUpdateTwoActors(void)
8141 {
8142   TestApplication application(
8143     TestApplication::DEFAULT_SURFACE_WIDTH,
8144     TestApplication::DEFAULT_SURFACE_HEIGHT,
8145     TestApplication::DEFAULT_HORIZONTAL_DPI,
8146     TestApplication::DEFAULT_VERTICAL_DPI,
8147     true,
8148     true);
8149
8150   tet_infoline("Check the damaged rects with partial update and two actors");
8151
8152   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8153
8154   Actor actor = CreateRenderableActor();
8155   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8156   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8157   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8158   application.GetScene().Add(actor);
8159
8160   Actor actor2 = CreateRenderableActor();
8161   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8162   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8163   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8164   application.GetScene().Add(actor2);
8165
8166   application.SendNotification();
8167   std::vector<Rect<int>> damagedRects;
8168   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8169
8170   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8171   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8172   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8173
8174   // in screen coordinates, adaptor would calculate it using previous frames information
8175   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8176   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8177
8178   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8179   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8180   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8181   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8182
8183   END_TEST;
8184 }
8185
8186 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8187 {
8188   TestApplication application(
8189     TestApplication::DEFAULT_SURFACE_WIDTH,
8190     TestApplication::DEFAULT_SURFACE_HEIGHT,
8191     TestApplication::DEFAULT_HORIZONTAL_DPI,
8192     TestApplication::DEFAULT_VERTICAL_DPI,
8193     true,
8194     true);
8195
8196   tet_infoline("Check the damaged rect with partial update and actor size hint");
8197
8198   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8199
8200   Actor actor = CreateRenderableActor();
8201   actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
8202   actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
8203   actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
8204   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8205   application.GetScene().Add(actor);
8206
8207   application.SendNotification();
8208   std::vector<Rect<int>> damagedRects;
8209   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8210
8211   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8212
8213   Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
8214   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8215
8216   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8217
8218   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8219   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8220   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8221   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8222
8223   END_TEST;
8224 }
8225
8226 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
8227 {
8228   TestApplication application;
8229
8230   Actor actor = Actor::New();
8231   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
8232   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
8233   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
8234   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
8235   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
8236   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8237   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8238   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
8239   END_TEST;
8240 }
8241
8242 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
8243 {
8244   TestApplication application;
8245
8246   Actor actor = Actor::New();
8247
8248   // Make sure setting invalid types does not cause a crash
8249   try
8250   {
8251     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
8252     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
8253     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
8254     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
8255     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
8256     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
8257     tet_result(TET_PASS);
8258   }
8259   catch(...)
8260   {
8261     tet_result(TET_FAIL);
8262   }
8263   END_TEST;
8264 }
8265
8266 int UtcDaliActorTouchAreaPropertyP(void)
8267 {
8268   TestApplication application;
8269
8270   Actor   actor     = Actor::New();
8271   Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8272   DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
8273   actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
8274   touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8275   DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
8276   END_TEST;
8277 }
8278
8279 int UtcDaliActorTouchAreaPropertyN(void)
8280 {
8281   TestApplication application;
8282
8283   Actor actor = Actor::New();
8284
8285   // Make sure setting invalid types does not cause a crash
8286   try
8287   {
8288     actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
8289     actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
8290     actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
8291     actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
8292     actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
8293     actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
8294     tet_result(TET_PASS);
8295   }
8296   catch(...)
8297   {
8298     tet_result(TET_FAIL);
8299   }
8300   END_TEST;
8301 }
8302
8303 int UtcDaliActorLowerBelowNegative(void)
8304 {
8305   TestApplication application;
8306   Dali::Actor     instance;
8307   try
8308   {
8309     Dali::Actor arg1;
8310     instance.LowerBelow(arg1);
8311     DALI_TEST_CHECK(false); // Should not get here
8312   }
8313   catch(...)
8314   {
8315     DALI_TEST_CHECK(true); // We expect an assert
8316   }
8317   END_TEST;
8318 }
8319
8320 int UtcDaliActorRaiseAboveNegative(void)
8321 {
8322   TestApplication application;
8323   Dali::Actor     instance;
8324   try
8325   {
8326     Dali::Actor arg1;
8327     instance.RaiseAbove(arg1);
8328     DALI_TEST_CHECK(false); // Should not get here
8329   }
8330   catch(...)
8331   {
8332     DALI_TEST_CHECK(true); // We expect an assert
8333   }
8334   END_TEST;
8335 }
8336
8337 int UtcDaliActorRaiseToTopNegative(void)
8338 {
8339   TestApplication application;
8340   Dali::Actor     instance;
8341   try
8342   {
8343     instance.RaiseToTop();
8344     DALI_TEST_CHECK(false); // Should not get here
8345   }
8346   catch(...)
8347   {
8348     DALI_TEST_CHECK(true); // We expect an assert
8349   }
8350   END_TEST;
8351 }
8352
8353 int UtcDaliActorAddRendererNegative(void)
8354 {
8355   TestApplication application;
8356   Dali::Actor     instance;
8357   try
8358   {
8359     Dali::Renderer arg1;
8360     instance.AddRenderer(arg1);
8361     DALI_TEST_CHECK(false); // Should not get here
8362   }
8363   catch(...)
8364   {
8365     DALI_TEST_CHECK(true); // We expect an assert
8366   }
8367   END_TEST;
8368 }
8369
8370 int UtcDaliActorTouchedSignalNegative(void)
8371 {
8372   TestApplication application;
8373   Dali::Actor     instance;
8374   try
8375   {
8376     instance.TouchedSignal();
8377     DALI_TEST_CHECK(false); // Should not get here
8378   }
8379   catch(...)
8380   {
8381     DALI_TEST_CHECK(true); // We expect an assert
8382   }
8383   END_TEST;
8384 }
8385
8386 int UtcDaliActorTranslateByNegative(void)
8387 {
8388   TestApplication application;
8389   Dali::Actor     instance;
8390   try
8391   {
8392     Dali::Vector3 arg1;
8393     instance.TranslateBy(arg1);
8394     DALI_TEST_CHECK(false); // Should not get here
8395   }
8396   catch(...)
8397   {
8398     DALI_TEST_CHECK(true); // We expect an assert
8399   }
8400   END_TEST;
8401 }
8402
8403 int UtcDaliActorFindChildByIdNegative(void)
8404 {
8405   TestApplication application;
8406   Dali::Actor     instance;
8407   try
8408   {
8409     unsigned int arg1 = 0u;
8410     instance.FindChildById(arg1);
8411     DALI_TEST_CHECK(false); // Should not get here
8412   }
8413   catch(...)
8414   {
8415     DALI_TEST_CHECK(true); // We expect an assert
8416   }
8417   END_TEST;
8418 }
8419
8420 int UtcDaliActorGetRendererAtNegative(void)
8421 {
8422   TestApplication application;
8423   Dali::Actor     instance;
8424   try
8425   {
8426     unsigned int arg1 = 0u;
8427     instance.GetRendererAt(arg1);
8428     DALI_TEST_CHECK(false); // Should not get here
8429   }
8430   catch(...)
8431   {
8432     DALI_TEST_CHECK(true); // We expect an assert
8433   }
8434   END_TEST;
8435 }
8436
8437 int UtcDaliActorHoveredSignalNegative(void)
8438 {
8439   TestApplication application;
8440   Dali::Actor     instance;
8441   try
8442   {
8443     instance.HoveredSignal();
8444     DALI_TEST_CHECK(false); // Should not get here
8445   }
8446   catch(...)
8447   {
8448     DALI_TEST_CHECK(true); // We expect an assert
8449   }
8450   END_TEST;
8451 }
8452
8453 int UtcDaliActorLowerToBottomNegative(void)
8454 {
8455   TestApplication application;
8456   Dali::Actor     instance;
8457   try
8458   {
8459     instance.LowerToBottom();
8460     DALI_TEST_CHECK(false); // Should not get here
8461   }
8462   catch(...)
8463   {
8464     DALI_TEST_CHECK(true); // We expect an assert
8465   }
8466   END_TEST;
8467 }
8468
8469 int UtcDaliActorOnSceneSignalNegative(void)
8470 {
8471   TestApplication application;
8472   Dali::Actor     instance;
8473   try
8474   {
8475     instance.OnSceneSignal();
8476     DALI_TEST_CHECK(false); // Should not get here
8477   }
8478   catch(...)
8479   {
8480     DALI_TEST_CHECK(true); // We expect an assert
8481   }
8482   END_TEST;
8483 }
8484
8485 int UtcDaliActorOffSceneSignalNegative(void)
8486 {
8487   TestApplication application;
8488   Dali::Actor     instance;
8489   try
8490   {
8491     instance.OffSceneSignal();
8492     DALI_TEST_CHECK(false); // Should not get here
8493   }
8494   catch(...)
8495   {
8496     DALI_TEST_CHECK(true); // We expect an assert
8497   }
8498   END_TEST;
8499 }
8500
8501 int UtcDaliActorRemoveRendererNegative01(void)
8502 {
8503   TestApplication application;
8504   Dali::Actor     instance;
8505   try
8506   {
8507     unsigned int arg1 = 0u;
8508     instance.RemoveRenderer(arg1);
8509     DALI_TEST_CHECK(false); // Should not get here
8510   }
8511   catch(...)
8512   {
8513     DALI_TEST_CHECK(true); // We expect an assert
8514   }
8515   END_TEST;
8516 }
8517
8518 int UtcDaliActorRemoveRendererNegative02(void)
8519 {
8520   TestApplication application;
8521   Dali::Actor     instance;
8522   try
8523   {
8524     Dali::Renderer arg1;
8525     instance.RemoveRenderer(arg1);
8526     DALI_TEST_CHECK(false); // Should not get here
8527   }
8528   catch(...)
8529   {
8530     DALI_TEST_CHECK(true); // We expect an assert
8531   }
8532   END_TEST;
8533 }
8534
8535 int UtcDaliActorFindChildByNameNegative(void)
8536 {
8537   TestApplication application;
8538   Dali::Actor     instance;
8539   try
8540   {
8541     std::string arg1;
8542     instance.FindChildByName(arg1);
8543     DALI_TEST_CHECK(false); // Should not get here
8544   }
8545   catch(...)
8546   {
8547     DALI_TEST_CHECK(true); // We expect an assert
8548   }
8549   END_TEST;
8550 }
8551
8552 int UtcDaliActorSetResizePolicyNegative(void)
8553 {
8554   TestApplication application;
8555   Dali::Actor     instance;
8556   try
8557   {
8558     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8559     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
8560     instance.SetResizePolicy(arg1, arg2);
8561     DALI_TEST_CHECK(false); // Should not get here
8562   }
8563   catch(...)
8564   {
8565     DALI_TEST_CHECK(true); // We expect an assert
8566   }
8567   END_TEST;
8568 }
8569
8570 int UtcDaliActorOnRelayoutSignalNegative(void)
8571 {
8572   TestApplication application;
8573   Dali::Actor     instance;
8574   try
8575   {
8576     instance.OnRelayoutSignal();
8577     DALI_TEST_CHECK(false); // Should not get here
8578   }
8579   catch(...)
8580   {
8581     DALI_TEST_CHECK(true); // We expect an assert
8582   }
8583   END_TEST;
8584 }
8585
8586 int UtcDaliActorWheelEventSignalNegative(void)
8587 {
8588   TestApplication application;
8589   Dali::Actor     instance;
8590   try
8591   {
8592     instance.WheelEventSignal();
8593     DALI_TEST_CHECK(false); // Should not get here
8594   }
8595   catch(...)
8596   {
8597     DALI_TEST_CHECK(true); // We expect an assert
8598   }
8599   END_TEST;
8600 }
8601
8602 int UtcDaliActorGetHeightForWidthNegative(void)
8603 {
8604   TestApplication application;
8605   Dali::Actor     instance;
8606   try
8607   {
8608     float arg1 = 0.0f;
8609     instance.GetHeightForWidth(arg1);
8610     DALI_TEST_CHECK(false); // Should not get here
8611   }
8612   catch(...)
8613   {
8614     DALI_TEST_CHECK(true); // We expect an assert
8615   }
8616   END_TEST;
8617 }
8618
8619 int UtcDaliActorGetWidthForHeightNegative(void)
8620 {
8621   TestApplication application;
8622   Dali::Actor     instance;
8623   try
8624   {
8625     float arg1 = 0.0f;
8626     instance.GetWidthForHeight(arg1);
8627     DALI_TEST_CHECK(false); // Should not get here
8628   }
8629   catch(...)
8630   {
8631     DALI_TEST_CHECK(true); // We expect an assert
8632   }
8633   END_TEST;
8634 }
8635
8636 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8637 {
8638   TestApplication application;
8639   Dali::Actor     instance;
8640   try
8641   {
8642     instance.LayoutDirectionChangedSignal();
8643     DALI_TEST_CHECK(false); // Should not get here
8644   }
8645   catch(...)
8646   {
8647     DALI_TEST_CHECK(true); // We expect an assert
8648   }
8649   END_TEST;
8650 }
8651
8652 int UtcDaliActorAddNegative(void)
8653 {
8654   TestApplication application;
8655   Dali::Actor     instance;
8656   try
8657   {
8658     Dali::Actor arg1;
8659     instance.Add(arg1);
8660     DALI_TEST_CHECK(false); // Should not get here
8661   }
8662   catch(...)
8663   {
8664     DALI_TEST_CHECK(true); // We expect an assert
8665   }
8666   END_TEST;
8667 }
8668
8669 int UtcDaliActorLowerNegative(void)
8670 {
8671   TestApplication application;
8672   Dali::Actor     instance;
8673   try
8674   {
8675     instance.Lower();
8676     DALI_TEST_CHECK(false); // Should not get here
8677   }
8678   catch(...)
8679   {
8680     DALI_TEST_CHECK(true); // We expect an assert
8681   }
8682   END_TEST;
8683 }
8684
8685 int UtcDaliActorRaiseNegative(void)
8686 {
8687   TestApplication application;
8688   Dali::Actor     instance;
8689   try
8690   {
8691     instance.Raise();
8692     DALI_TEST_CHECK(false); // Should not get here
8693   }
8694   catch(...)
8695   {
8696     DALI_TEST_CHECK(true); // We expect an assert
8697   }
8698   END_TEST;
8699 }
8700
8701 int UtcDaliActorRemoveNegative(void)
8702 {
8703   TestApplication application;
8704   Dali::Actor     instance;
8705   try
8706   {
8707     Dali::Actor arg1;
8708     instance.Remove(arg1);
8709     DALI_TEST_CHECK(false); // Should not get here
8710   }
8711   catch(...)
8712   {
8713     DALI_TEST_CHECK(true); // We expect an assert
8714   }
8715   END_TEST;
8716 }
8717
8718 int UtcDaliActorScaleByNegative(void)
8719 {
8720   TestApplication application;
8721   Dali::Actor     instance;
8722   try
8723   {
8724     Dali::Vector3 arg1;
8725     instance.ScaleBy(arg1);
8726     DALI_TEST_CHECK(false); // Should not get here
8727   }
8728   catch(...)
8729   {
8730     DALI_TEST_CHECK(true); // We expect an assert
8731   }
8732   END_TEST;
8733 }
8734
8735 int UtcDaliActorGetLayerNegative(void)
8736 {
8737   TestApplication application;
8738   Dali::Actor     instance;
8739   try
8740   {
8741     instance.GetLayer();
8742     DALI_TEST_CHECK(false); // Should not get here
8743   }
8744   catch(...)
8745   {
8746     DALI_TEST_CHECK(true); // We expect an assert
8747   }
8748   END_TEST;
8749 }
8750
8751 int UtcDaliActorRotateByNegative01(void)
8752 {
8753   TestApplication application;
8754   Dali::Actor     instance;
8755   try
8756   {
8757     Dali::Quaternion arg1;
8758     instance.RotateBy(arg1);
8759     DALI_TEST_CHECK(false); // Should not get here
8760   }
8761   catch(...)
8762   {
8763     DALI_TEST_CHECK(true); // We expect an assert
8764   }
8765   END_TEST;
8766 }
8767
8768 int UtcDaliActorRotateByNegative02(void)
8769 {
8770   TestApplication application;
8771   Dali::Actor     instance;
8772   try
8773   {
8774     Dali::Radian  arg1;
8775     Dali::Vector3 arg2;
8776     instance.RotateBy(arg1, arg2);
8777     DALI_TEST_CHECK(false); // Should not get here
8778   }
8779   catch(...)
8780   {
8781     DALI_TEST_CHECK(true); // We expect an assert
8782   }
8783   END_TEST;
8784 }
8785
8786 int UtcDaliActorUnparentNegative(void)
8787 {
8788   TestApplication application;
8789   Dali::Actor     instance;
8790   try
8791   {
8792     instance.Unparent();
8793     DALI_TEST_CHECK(false); // Should not get here
8794   }
8795   catch(...)
8796   {
8797     DALI_TEST_CHECK(true); // We expect an assert
8798   }
8799   END_TEST;
8800 }
8801
8802 int UtcDaliActorGetChildAtNegative(void)
8803 {
8804   TestApplication application;
8805   Dali::Actor     instance;
8806   try
8807   {
8808     unsigned int arg1 = 0u;
8809     instance.GetChildAt(arg1);
8810     DALI_TEST_CHECK(false); // Should not get here
8811   }
8812   catch(...)
8813   {
8814     DALI_TEST_CHECK(true); // We expect an assert
8815   }
8816   END_TEST;
8817 }
8818
8819 int UtcDaliActorGetChildCountNegative(void)
8820 {
8821   TestApplication application;
8822   Dali::Actor     instance;
8823   try
8824   {
8825     instance.GetChildCount();
8826     DALI_TEST_CHECK(false); // Should not get here
8827   }
8828   catch(...)
8829   {
8830     DALI_TEST_CHECK(true); // We expect an assert
8831   }
8832   END_TEST;
8833 }
8834
8835 int UtcDaliActorGetTargetSizeNegative(void)
8836 {
8837   TestApplication application;
8838   Dali::Actor     instance;
8839   try
8840   {
8841     instance.GetTargetSize();
8842     DALI_TEST_CHECK(false); // Should not get here
8843   }
8844   catch(...)
8845   {
8846     DALI_TEST_CHECK(true); // We expect an assert
8847   }
8848   END_TEST;
8849 }
8850
8851 int UtcDaliActorScreenToLocalNegative(void)
8852 {
8853   TestApplication application;
8854   Dali::Actor     instance;
8855   try
8856   {
8857     float arg1 = 0.0f;
8858     float arg2 = 0.0f;
8859     float arg3 = 0.0f;
8860     float arg4 = 0.0f;
8861     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
8862     DALI_TEST_CHECK(false); // Should not get here
8863   }
8864   catch(...)
8865   {
8866     DALI_TEST_CHECK(true); // We expect an assert
8867   }
8868   END_TEST;
8869 }
8870
8871 int UtcDaliActorGetNaturalSizeNegative(void)
8872 {
8873   TestApplication application;
8874   Dali::Actor     instance;
8875   try
8876   {
8877     instance.GetNaturalSize();
8878     DALI_TEST_CHECK(false); // Should not get here
8879   }
8880   catch(...)
8881   {
8882     DALI_TEST_CHECK(true); // We expect an assert
8883   }
8884   END_TEST;
8885 }
8886
8887 int UtcDaliActorGetRelayoutSizeNegative(void)
8888 {
8889   TestApplication application;
8890   Dali::Actor     instance;
8891   try
8892   {
8893     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
8894     instance.GetRelayoutSize(arg1);
8895     DALI_TEST_CHECK(false); // Should not get here
8896   }
8897   catch(...)
8898   {
8899     DALI_TEST_CHECK(true); // We expect an assert
8900   }
8901   END_TEST;
8902 }
8903
8904 int UtcDaliActorGetResizePolicyNegative(void)
8905 {
8906   TestApplication application;
8907   Dali::Actor     instance;
8908   try
8909   {
8910     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
8911     instance.GetResizePolicy(arg1);
8912     DALI_TEST_CHECK(false); // Should not get here
8913   }
8914   catch(...)
8915   {
8916     DALI_TEST_CHECK(true); // We expect an assert
8917   }
8918   END_TEST;
8919 }
8920
8921 int UtcDaliActorGetRendererCountNegative(void)
8922 {
8923   TestApplication application;
8924   Dali::Actor     instance;
8925   try
8926   {
8927     instance.GetRendererCount();
8928     DALI_TEST_CHECK(false); // Should not get here
8929   }
8930   catch(...)
8931   {
8932     DALI_TEST_CHECK(true); // We expect an assert
8933   }
8934   END_TEST;
8935 }
8936
8937 int UtcDaliActorGetParentNegative(void)
8938 {
8939   TestApplication application;
8940   Dali::Actor     instance;
8941   try
8942   {
8943     instance.GetParent();
8944     DALI_TEST_CHECK(false); // Should not get here
8945   }
8946   catch(...)
8947   {
8948     DALI_TEST_CHECK(true); // We expect an assert
8949   }
8950   END_TEST;
8951 }
8952
8953 int UtcDaliActorPropertyBlendEquation(void)
8954 {
8955   TestApplication application;
8956
8957   tet_infoline("Test SetProperty AdvancedBlendEquation");
8958
8959   Geometry geometry  = CreateQuadGeometry();
8960   Shader   shader    = CreateShader();
8961   Renderer renderer1 = Renderer::New(geometry, shader);
8962
8963   Actor actor = Actor::New();
8964   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
8965
8966   actor.AddRenderer(renderer1);
8967   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
8968   application.GetScene().Add(actor);
8969
8970   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
8971   {
8972     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
8973     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
8974     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
8975   }
8976
8977   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
8978   {
8979     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
8980     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
8981     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
8982   }
8983
8984   Renderer renderer2 = Renderer::New(geometry, shader);
8985   actor.AddRenderer(renderer2);
8986
8987   END_TEST;
8988 }
8989
8990 int UtcDaliActorRegisterProperty(void)
8991 {
8992   tet_infoline("Test property registration and uniform map update\n");
8993
8994   TestApplication application;
8995
8996   Geometry geometry  = CreateQuadGeometry();
8997   Shader   shader    = CreateShader();
8998   Renderer renderer1 = Renderer::New(geometry, shader);
8999   Renderer renderer2 = Renderer::New(geometry, shader);
9000
9001   Actor actor1 = Actor::New();
9002   actor1.AddRenderer(renderer1);
9003   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9004   actor1.RegisterProperty("uCustom", 1);
9005   application.GetScene().Add(actor1);
9006
9007   Actor actor2 = Actor::New();
9008   actor2.AddRenderer(renderer2);
9009   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9010   application.GetScene().Add(actor2);
9011
9012   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
9013   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
9014   glAbstraction.EnableSetUniformCallTrace(true);
9015
9016   application.SendNotification();
9017   application.Render();
9018
9019   std::stringstream out;
9020   out.str("1");
9021   std::string params;
9022
9023   // Test uniform value of the custom property
9024   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9025   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9026
9027   // Make invisible
9028   actor1[Actor::Property::VISIBLE] = false;
9029
9030   application.SendNotification();
9031   application.Render();
9032
9033   // Make visible again
9034   actor1[Actor::Property::VISIBLE] = true;
9035   actor1["uCustom"]                = 2;
9036
9037   glAbstraction.ResetSetUniformCallStack();
9038
9039   application.SendNotification();
9040   application.Render();
9041
9042   out.str("2");
9043
9044   // The uniform value should not be changed
9045   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9046   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9047
9048   END_TEST;
9049 }