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