Add TOUCH_FOCUSABLE property
[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 UtcDaliActorSetTouchFocusable(void)
2528 {
2529   TestApplication application;
2530
2531   Actor actor = Actor::New();
2532
2533   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2534   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2535
2536   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2537   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2538   END_TEST;
2539 }
2540
2541 int UtcDaliActorIsTouchFocusable(void)
2542 {
2543   TestApplication application;
2544
2545   Actor actor = Actor::New();
2546
2547   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2548   END_TEST;
2549 }
2550
2551 int UtcDaliActorRemoveConstraints(void)
2552 {
2553   tet_infoline(" UtcDaliActorRemoveConstraints");
2554   TestApplication application;
2555
2556   gTestConstraintCalled = false;
2557
2558   Actor actor = Actor::New();
2559
2560   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2561   constraint.Apply();
2562   actor.RemoveConstraints();
2563
2564   DALI_TEST_CHECK(gTestConstraintCalled == false);
2565
2566   application.GetScene().Add(actor);
2567   constraint.Apply();
2568
2569   // flush the queue and render once
2570   application.SendNotification();
2571   application.Render();
2572
2573   actor.RemoveConstraints();
2574
2575   DALI_TEST_CHECK(gTestConstraintCalled == true);
2576   END_TEST;
2577 }
2578
2579 int UtcDaliActorRemoveConstraintTag(void)
2580 {
2581   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2582   TestApplication application;
2583
2584   Actor actor = Actor::New();
2585
2586   // 1. Apply Constraint1 and Constraint2, and test...
2587   unsigned int result1 = 0u;
2588   unsigned int result2 = 0u;
2589
2590   unsigned   constraint1Tag = 1u;
2591   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2592   constraint1.SetTag(constraint1Tag);
2593   constraint1.Apply();
2594
2595   unsigned   constraint2Tag = 2u;
2596   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2597   constraint2.SetTag(constraint2Tag);
2598   constraint2.Apply();
2599
2600   application.GetScene().Add(actor);
2601   // flush the queue and render once
2602   application.SendNotification();
2603   application.Render();
2604
2605   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2606   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2607
2608   // 2. Remove Constraint1 and test...
2609   result1 = 0;
2610   result2 = 0;
2611   actor.RemoveConstraints(constraint1Tag);
2612   // make color property dirty, which will trigger constraints to be reapplied.
2613   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2614   // flush the queue and render once
2615   application.SendNotification();
2616   application.Render();
2617
2618   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2619   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2620
2621   // 3. Re-Apply Constraint1 and test...
2622   result1 = 0;
2623   result2 = 0;
2624   constraint1.Apply();
2625   // make color property dirty, which will trigger constraints to be reapplied.
2626   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2627   // flush the queue and render once
2628   application.SendNotification();
2629   application.Render();
2630
2631   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2632   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2633
2634   // 2. Remove Constraint2 and test...
2635   result1 = 0;
2636   result2 = 0;
2637   actor.RemoveConstraints(constraint2Tag);
2638   // make color property dirty, which will trigger constraints to be reapplied.
2639   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2640   // flush the queue and render once
2641   application.SendNotification();
2642   application.Render();
2643
2644   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2645   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2646
2647   // 2. Remove Constraint1 as well and test...
2648   result1 = 0;
2649   result2 = 0;
2650   actor.RemoveConstraints(constraint1Tag);
2651   // make color property dirty, which will trigger constraints to be reapplied.
2652   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2653   // flush the queue and render once
2654   application.SendNotification();
2655   application.Render();
2656
2657   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2658   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2659   END_TEST;
2660 }
2661
2662 int UtcDaliActorTouchedSignal(void)
2663 {
2664   TestApplication application;
2665
2666   ResetTouchCallbacks();
2667
2668   // get the root layer
2669   Actor actor = application.GetScene().GetRootLayer();
2670   DALI_TEST_CHECK(gTouchCallBackCalled == false);
2671
2672   application.SendNotification();
2673   application.Render();
2674
2675   // connect to its touch signal
2676   actor.TouchedSignal().Connect(TestTouchCallback);
2677
2678   // simulate a touch event in the middle of the screen
2679   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2680   Dali::Integration::Point point;
2681   point.SetDeviceId(1);
2682   point.SetState(PointState::DOWN);
2683   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2684   Dali::Integration::TouchEvent touchEvent;
2685   touchEvent.AddPoint(point);
2686   application.ProcessEvent(touchEvent);
2687
2688   DALI_TEST_CHECK(gTouchCallBackCalled == true);
2689   END_TEST;
2690 }
2691
2692 int UtcDaliActorHoveredSignal(void)
2693 {
2694   TestApplication application;
2695
2696   gHoverCallBackCalled = false;
2697
2698   // get the root layer
2699   Actor actor = application.GetScene().GetRootLayer();
2700   DALI_TEST_CHECK(gHoverCallBackCalled == false);
2701
2702   application.SendNotification();
2703   application.Render();
2704
2705   // connect to its hover signal
2706   actor.HoveredSignal().Connect(TestCallback3);
2707
2708   // simulate a hover event in the middle of the screen
2709   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2710   Dali::Integration::Point point;
2711   point.SetDeviceId(1);
2712   point.SetState(PointState::MOTION);
2713   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2714   Dali::Integration::HoverEvent hoverEvent;
2715   hoverEvent.AddPoint(point);
2716   application.ProcessEvent(hoverEvent);
2717
2718   DALI_TEST_CHECK(gHoverCallBackCalled == true);
2719   END_TEST;
2720 }
2721
2722 int UtcDaliActorOnOffSceneSignal(void)
2723 {
2724   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2725
2726   TestApplication application;
2727
2728   // clean test data
2729   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2730   gActorNamesOnOffScene.clear();
2731
2732   Actor parent = Actor::New();
2733   parent.SetProperty(Actor::Property::NAME, "parent");
2734   parent.OnSceneSignal().Connect(OnSceneCallback);
2735   parent.OffSceneSignal().Connect(OffSceneCallback);
2736   // sanity check
2737   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2738   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2739
2740   // add parent to the scene
2741   application.GetScene().Add(parent);
2742   // onstage emitted, offstage not
2743   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2744   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2745   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2746
2747   // test adding a child, should get onstage emitted
2748   // clean test data
2749   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2750   gActorNamesOnOffScene.clear();
2751
2752   Actor child = Actor::New();
2753   child.SetProperty(Actor::Property::NAME, "child");
2754   child.OnSceneSignal().Connect(OnSceneCallback);
2755   child.OffSceneSignal().Connect(OffSceneCallback);
2756   parent.Add(child); // add child
2757   // onscene emitted, offscene not
2758   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2759   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2760   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2761
2762   // test removing parent from the scene
2763   // clean test data
2764   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2765   gActorNamesOnOffScene.clear();
2766
2767   application.GetScene().Remove(parent);
2768   // onscene not emitted, offscene is
2769   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2770   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2771   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2772   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2773
2774   // test adding parent back to the scene
2775   // clean test data
2776   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2777   gActorNamesOnOffScene.clear();
2778
2779   application.GetScene().Add(parent);
2780   // onscene emitted, offscene not
2781   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2782   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2783   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2784   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2785
2786   // test removing child
2787   // clean test data
2788   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2789   gActorNamesOnOffScene.clear();
2790
2791   parent.Remove(child);
2792   // onscene not emitted, offscene is
2793   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2794   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2795   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2796
2797   // test removing parent
2798   // clean test data
2799   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2800   gActorNamesOnOffScene.clear();
2801
2802   application.GetScene().Remove(parent);
2803   // onscene not emitted, offscene is
2804   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2805   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2806   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2807   END_TEST;
2808 }
2809
2810 int UtcDaliActorFindChildByName(void)
2811 {
2812   tet_infoline("Testing Dali::Actor::FindChildByName()");
2813   TestApplication application;
2814
2815   Actor parent = Actor::New();
2816   parent.SetProperty(Actor::Property::NAME, "parent");
2817   Actor first = Actor::New();
2818   first.SetProperty(Actor::Property::NAME, "first");
2819   Actor second = Actor::New();
2820   second.SetProperty(Actor::Property::NAME, "second");
2821
2822   parent.Add(first);
2823   first.Add(second);
2824
2825   Actor found = parent.FindChildByName("foo");
2826   DALI_TEST_CHECK(!found);
2827
2828   found = parent.FindChildByName("parent");
2829   DALI_TEST_CHECK(found == parent);
2830
2831   found = parent.FindChildByName("first");
2832   DALI_TEST_CHECK(found == first);
2833
2834   found = parent.FindChildByName("second");
2835   DALI_TEST_CHECK(found == second);
2836   END_TEST;
2837 }
2838
2839 int UtcDaliActorFindChildById(void)
2840 {
2841   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2842   TestApplication application;
2843
2844   Actor parent = Actor::New();
2845   Actor first  = Actor::New();
2846   Actor second = Actor::New();
2847
2848   parent.Add(first);
2849   first.Add(second);
2850
2851   Actor found = parent.FindChildById(100000);
2852   DALI_TEST_CHECK(!found);
2853
2854   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2855   DALI_TEST_CHECK(found == parent);
2856
2857   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2858   DALI_TEST_CHECK(found == first);
2859
2860   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2861   DALI_TEST_CHECK(found == second);
2862   END_TEST;
2863 }
2864
2865 int UtcDaliActorHitTest(void)
2866 {
2867   struct HitTestData
2868   {
2869   public:
2870     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2871     : mScale(scale),
2872       mTouchPoint(touchPoint),
2873       mResult(result)
2874     {
2875     }
2876
2877     Vector3 mScale;
2878     Vector2 mTouchPoint;
2879     bool    mResult;
2880   };
2881
2882   TestApplication application;
2883   tet_infoline(" UtcDaliActorHitTest");
2884
2885   // Fill a vector with different hit tests.
2886   struct HitTestData* hitTestData[] = {
2887     //                    scale                     touch point           result
2888     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
2889     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2890     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.
2891     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2892     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.
2893     NULL,
2894   };
2895
2896   // get the root layer
2897   Actor actor = Actor::New();
2898   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2899   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2900
2901   application.GetScene().Add(actor);
2902
2903   ResetTouchCallbacks();
2904
2905   unsigned int index = 0;
2906   while(NULL != hitTestData[index])
2907   {
2908     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2909     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2910
2911     // flush the queue and render once
2912     application.SendNotification();
2913     application.Render();
2914
2915     DALI_TEST_CHECK(!gTouchCallBackCalled);
2916
2917     // connect to its touch signal
2918     actor.TouchedSignal().Connect(TestTouchCallback);
2919
2920     Dali::Integration::Point point;
2921     point.SetState(PointState::DOWN);
2922     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2923     Dali::Integration::TouchEvent event;
2924     event.AddPoint(point);
2925
2926     // flush the queue and render once
2927     application.SendNotification();
2928     application.Render();
2929     application.ProcessEvent(event);
2930
2931     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2932
2933     if(gTouchCallBackCalled != hitTestData[index]->mResult)
2934       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2935                  hitTestData[index]->mScale.x,
2936                  hitTestData[index]->mScale.y,
2937                  hitTestData[index]->mScale.z,
2938                  hitTestData[index]->mTouchPoint.x,
2939                  hitTestData[index]->mTouchPoint.y,
2940                  hitTestData[index]->mResult);
2941
2942     ResetTouchCallbacks();
2943     ++index;
2944   }
2945   END_TEST;
2946 }
2947
2948 int UtcDaliActorSetDrawMode(void)
2949 {
2950   TestApplication application;
2951   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2952
2953   Actor a = Actor::New();
2954
2955   application.GetScene().Add(a);
2956   application.SendNotification();
2957   application.Render(0);
2958   application.SendNotification();
2959   application.Render(1);
2960
2961   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2962
2963   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2964   application.SendNotification();
2965   application.Render(1);
2966
2967   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2968
2969   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2970   application.SendNotification();
2971   application.Render(1);
2972
2973   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2974   END_TEST;
2975 }
2976
2977 int UtcDaliActorSetDrawModeOverlayRender(void)
2978 {
2979   TestApplication application;
2980   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2981
2982   application.SendNotification();
2983   application.Render(1);
2984
2985   std::vector<GLuint> ids;
2986   ids.push_back(8);  // first rendered actor
2987   ids.push_back(9);  // second rendered actor
2988   ids.push_back(10); // third rendered actor
2989   application.GetGlAbstraction().SetNextTextureIds(ids);
2990
2991   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2992   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2993   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2994   Actor   a      = CreateRenderableActor(imageA);
2995   Actor   b      = CreateRenderableActor(imageB);
2996   Actor   c      = CreateRenderableActor(imageC);
2997
2998   application.SendNotification();
2999   application.Render(1);
3000
3001   //Textures are bound when first created. Clear bound textures vector
3002   application.GetGlAbstraction().ClearBoundTextures();
3003
3004   // Render a,b,c as regular non-overlays. so order will be:
3005   // a (8)
3006   // b (9)
3007   // c (10)
3008   application.GetScene().Add(a);
3009   application.GetScene().Add(b);
3010   application.GetScene().Add(c);
3011
3012   application.SendNotification();
3013   application.Render(1);
3014
3015   // Should be 3 textures changes.
3016   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3017   typedef std::vector<GLuint>::size_type TextureSize;
3018   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3019   if(boundTextures.size() == 3)
3020   {
3021     DALI_TEST_CHECK(boundTextures[0] == 8u);
3022     DALI_TEST_CHECK(boundTextures[1] == 9u);
3023     DALI_TEST_CHECK(boundTextures[2] == 10u);
3024   }
3025
3026   // Now texture ids have been set, we can monitor their render order.
3027   // render a as an overlay (last), so order will be:
3028   // b (9)
3029   // c (10)
3030   // a (8)
3031   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3032   application.GetGlAbstraction().ClearBoundTextures();
3033
3034   application.SendNotification();
3035   application.Render(1);
3036
3037   // Should be 3 texture changes.
3038   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3039   if(boundTextures.size() == 3)
3040   {
3041     DALI_TEST_CHECK(boundTextures[0] == 9u);
3042     DALI_TEST_CHECK(boundTextures[1] == 10u);
3043     DALI_TEST_CHECK(boundTextures[2] == 8u);
3044   }
3045   END_TEST;
3046 }
3047
3048 int UtcDaliActorGetCurrentWorldMatrix(void)
3049 {
3050   TestApplication application;
3051   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3052
3053   Actor parent = Actor::New();
3054   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3055   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3056   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3057   Radian     rotationAngle(Degree(85.0f));
3058   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3059   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3060   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3061   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3062   parent.SetProperty(Actor::Property::SCALE, parentScale);
3063   application.GetScene().Add(parent);
3064
3065   Actor child = Actor::New();
3066   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3067   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3068   Radian     childRotationAngle(Degree(23.0f));
3069   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3070   Vector3    childScale(2.0f, 2.0f, 2.0f);
3071   child.SetProperty(Actor::Property::POSITION, childPosition);
3072   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3073   child.SetProperty(Actor::Property::SCALE, childScale);
3074   parent.Add(child);
3075
3076   application.SendNotification();
3077   application.Render(0);
3078   application.Render();
3079   application.SendNotification();
3080
3081   Matrix parentMatrix(false);
3082   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3083
3084   Matrix childMatrix(false);
3085   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3086
3087   //Child matrix should be the composition of child and parent
3088   Matrix childWorldMatrix(false);
3089   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3090
3091   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3092   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3093   END_TEST;
3094 }
3095
3096 int UtcDaliActorConstrainedToWorldMatrix(void)
3097 {
3098   TestApplication application;
3099   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3100
3101   Actor parent = Actor::New();
3102   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3103   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3104   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3105   Radian     rotationAngle(Degree(85.0f));
3106   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3107   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3108   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3109   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3110   parent.SetProperty(Actor::Property::SCALE, parentScale);
3111   application.GetScene().Add(parent);
3112
3113   Actor child = Actor::New();
3114   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3115   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3116   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3117   posConstraint.Apply();
3118
3119   application.GetScene().Add(child);
3120
3121   application.SendNotification();
3122   application.Render(0);
3123   application.Render();
3124   application.SendNotification();
3125
3126   Matrix parentMatrix(false);
3127   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3128
3129   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3130   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3131   END_TEST;
3132 }
3133
3134 int UtcDaliActorConstrainedToOrientation(void)
3135 {
3136   TestApplication application;
3137   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3138
3139   Actor parent = Actor::New();
3140   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3141   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3142   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3143   Radian     rotationAngle(Degree(85.0f));
3144   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3145   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3146   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3147   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3148   parent.SetProperty(Actor::Property::SCALE, parentScale);
3149   application.GetScene().Add(parent);
3150
3151   Actor child = Actor::New();
3152   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3153   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3154   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3155   posConstraint.Apply();
3156
3157   application.GetScene().Add(child);
3158
3159   application.SendNotification();
3160   application.Render(0);
3161   application.Render();
3162   application.SendNotification();
3163
3164   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3165   END_TEST;
3166 }
3167
3168 int UtcDaliActorConstrainedToOpacity(void)
3169 {
3170   TestApplication application;
3171   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3172
3173   Actor parent = Actor::New();
3174   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3175   application.GetScene().Add(parent);
3176
3177   Actor      child             = Actor::New();
3178   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3179   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3180   opacityConstraint.Apply();
3181
3182   application.GetScene().Add(child);
3183
3184   application.SendNotification();
3185   application.Render(0);
3186   application.Render();
3187   application.SendNotification();
3188
3189   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3190
3191   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3192
3193   application.SendNotification();
3194   application.Render(0);
3195   application.Render();
3196   application.SendNotification();
3197
3198   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3199
3200   END_TEST;
3201 }
3202
3203 int UtcDaliActorUnparent(void)
3204 {
3205   TestApplication application;
3206   tet_infoline(" UtcDaliActorUnparent");
3207
3208   Actor parent = Actor::New();
3209   application.GetScene().Add(parent);
3210
3211   Actor child = Actor::New();
3212
3213   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3214   DALI_TEST_CHECK(!child.GetParent());
3215
3216   // Test that calling Unparent with no parent is a NOOP
3217   child.Unparent();
3218
3219   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3220   DALI_TEST_CHECK(!child.GetParent());
3221
3222   // Test that Unparent works
3223   parent.Add(child);
3224
3225   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3226   DALI_TEST_CHECK(parent == child.GetParent());
3227
3228   child.Unparent();
3229
3230   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3231   DALI_TEST_CHECK(!child.GetParent());
3232
3233   // Test that UnparentAndReset works
3234   parent.Add(child);
3235
3236   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3237   DALI_TEST_CHECK(parent == child.GetParent());
3238
3239   UnparentAndReset(child);
3240
3241   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3242   DALI_TEST_CHECK(!child);
3243
3244   // Test that UnparentAndReset is a NOOP with empty handle
3245   UnparentAndReset(child);
3246
3247   DALI_TEST_CHECK(!child);
3248   END_TEST;
3249 }
3250
3251 int UtcDaliActorGetChildAt(void)
3252 {
3253   TestApplication application;
3254   tet_infoline(" UtcDaliActorGetChildAt");
3255
3256   Actor parent = Actor::New();
3257   application.GetScene().Add(parent);
3258
3259   Actor child0 = Actor::New();
3260   parent.Add(child0);
3261
3262   Actor child1 = Actor::New();
3263   parent.Add(child1);
3264
3265   Actor child2 = Actor::New();
3266   parent.Add(child2);
3267
3268   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3269   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3270   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3271   END_TEST;
3272 }
3273
3274 int UtcDaliActorSetGetOverlay(void)
3275 {
3276   TestApplication application;
3277   tet_infoline(" UtcDaliActorSetGetOverlay");
3278
3279   Actor parent = Actor::New();
3280   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3281   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3282   END_TEST;
3283 }
3284
3285 int UtcDaliActorCreateDestroy(void)
3286 {
3287   Actor* actor = new Actor;
3288   DALI_TEST_CHECK(actor);
3289   delete actor;
3290   END_TEST;
3291 }
3292
3293 namespace
3294 {
3295 struct PropertyStringIndex
3296 {
3297   const char* const     name;
3298   const Property::Index index;
3299   const Property::Type  type;
3300 };
3301
3302 const PropertyStringIndex PROPERTY_TABLE[] =
3303   {
3304     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3305     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3306     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3307     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3308     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3309     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3310     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3311     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3312     {"size", Actor::Property::SIZE, Property::VECTOR3},
3313     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3314     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3315     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3316     {"position", Actor::Property::POSITION, Property::VECTOR3},
3317     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3318     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3319     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3320     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3321     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3322     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3323     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3324     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3325     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3326     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3327     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3328     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3329     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3330     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3331     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3332     {"color", Actor::Property::COLOR, Property::VECTOR4},
3333     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3334     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3335     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3336     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3337     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3338     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3339     {"name", Actor::Property::NAME, Property::STRING},
3340     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3341     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3342     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3343     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3344     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3345     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3346     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3347     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3348     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3349     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3350     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3351     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3352     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3353     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3354     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3355     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3356     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3357     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3358 };
3359 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3360 } // unnamed namespace
3361
3362 int UtcDaliActorProperties(void)
3363 {
3364   TestApplication application;
3365
3366   Actor actor = Actor::New();
3367
3368   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3369   {
3370     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3371     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3372     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3373     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3374   }
3375   END_TEST;
3376 }
3377
3378 int UtcDaliRelayoutProperties_ResizePolicies(void)
3379 {
3380   TestApplication application;
3381
3382   Actor actor = Actor::New();
3383
3384   // Defaults
3385   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3386   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3387
3388   // Set resize policy for all dimensions
3389   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3390   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3391   {
3392     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3393   }
3394
3395   // Set individual dimensions
3396   const char* const widthPolicy  = "FILL_TO_PARENT";
3397   const char* const heightPolicy = "FIXED";
3398
3399   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3400   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3401
3402   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3403   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3404
3405   // Set individual dimensions using enums
3406   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3407   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3408
3409   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3410   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3411
3412   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3413   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3414
3415   END_TEST;
3416 }
3417
3418 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3419 {
3420   TestApplication application;
3421
3422   Actor actor = Actor::New();
3423
3424   // Defaults
3425   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3426
3427   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3428   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3429   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3430
3431   // Set
3432   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3433   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3434
3435   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3436   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3437
3438   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3439   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3440
3441   END_TEST;
3442 }
3443
3444 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3445 {
3446   TestApplication application;
3447
3448   Actor actor = Actor::New();
3449
3450   // Defaults
3451   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3452   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3453
3454   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3455   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3456   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3457
3458   // Set
3459   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3460
3461   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3462   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3463
3464   END_TEST;
3465 }
3466
3467 int UtcDaliRelayoutProperties_DimensionDependency(void)
3468 {
3469   TestApplication application;
3470
3471   Actor actor = Actor::New();
3472
3473   // Defaults
3474   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3475   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3476
3477   // Set
3478   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3479   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3480
3481   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3482   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3483
3484   // Test setting another resize policy
3485   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3486   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3487
3488   END_TEST;
3489 }
3490
3491 int UtcDaliRelayoutProperties_Padding(void)
3492 {
3493   TestApplication application;
3494
3495   Actor actor = Actor::New();
3496
3497   // Data
3498   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3499
3500   // PADDING
3501   actor.SetProperty(Actor::Property::PADDING, padding);
3502   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3503
3504   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3505
3506   END_TEST;
3507 }
3508
3509 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3510 {
3511   TestApplication application;
3512
3513   Actor actor = Actor::New();
3514
3515   // Data
3516   Vector2 minSize(1.0f, 2.0f);
3517
3518   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3519   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3520
3521   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3522
3523   Vector2 maxSize(3.0f, 4.0f);
3524
3525   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3526   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3527
3528   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3529
3530   END_TEST;
3531 }
3532
3533 int UtcDaliActorGetHeightForWidth(void)
3534 {
3535   TestApplication application;
3536
3537   Actor actor = Actor::New();
3538
3539   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3540
3541   END_TEST;
3542 }
3543
3544 int UtcDaliActorGetWidthForHeight(void)
3545 {
3546   TestApplication application;
3547
3548   Actor actor = Actor::New();
3549
3550   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3551
3552   END_TEST;
3553 }
3554
3555 int UtcDaliActorGetRelayoutSize(void)
3556 {
3557   TestApplication application;
3558
3559   Actor actor = Actor::New();
3560
3561   // Add actor to stage
3562   application.GetScene().Add(actor);
3563
3564   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3565
3566   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3567   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3568
3569   // Flush the queue and render once
3570   application.SendNotification();
3571   application.Render();
3572
3573   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3574
3575   END_TEST;
3576 }
3577
3578 int UtcDaliActorSetPadding(void)
3579 {
3580   TestApplication application;
3581
3582   Actor actor = Actor::New();
3583
3584   Padding padding;
3585   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3586
3587   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3588   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3589   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3590   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3591
3592   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3593   actor.SetProperty(Actor::Property::PADDING, padding2);
3594
3595   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3596
3597   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3598   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3599   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3600   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3601
3602   END_TEST;
3603 }
3604
3605 int UtcDaliActorSetMinimumSize(void)
3606 {
3607   TestApplication application;
3608
3609   Actor actor = Actor::New();
3610
3611   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3612
3613   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3614   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3615
3616   Vector2 size2(1.0f, 2.0f);
3617   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3618
3619   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3620
3621   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3622   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3623
3624   END_TEST;
3625 }
3626
3627 int UtcDaliActorSetMaximumSize(void)
3628 {
3629   TestApplication application;
3630
3631   Actor actor = Actor::New();
3632
3633   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3634
3635   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3636   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3637
3638   Vector2 size2(1.0f, 2.0f);
3639   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3640
3641   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3642
3643   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3644   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3645
3646   END_TEST;
3647 }
3648
3649 int UtcDaliActorOnRelayoutSignal(void)
3650 {
3651   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3652
3653   TestApplication application;
3654
3655   // Clean test data
3656   gOnRelayoutCallBackCalled = false;
3657   gActorNamesRelayout.clear();
3658
3659   Actor actor = Actor::New();
3660   actor.SetProperty(Actor::Property::NAME, "actor");
3661   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3662
3663   // Sanity check
3664   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3665
3666   // Add actor to stage
3667   application.GetScene().Add(actor);
3668
3669   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3670   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3671
3672   // Flush the queue and render once
3673   application.SendNotification();
3674   application.Render();
3675
3676   // OnRelayout emitted
3677   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3678   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3679
3680   END_TEST;
3681 }
3682
3683 int UtcDaliActorGetHierachyDepth(void)
3684 {
3685   TestApplication application;
3686   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3687
3688   /* Build tree of actors:
3689    *
3690    *                      Depth
3691    *
3692    *       A (parent)       1
3693    *      / \
3694    *     B   C              2`
3695    *    / \   \
3696    *   D   E   F            3
3697    *
3698    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3699    */
3700   Integration::Scene stage(application.GetScene());
3701
3702   Actor actorA = Actor::New();
3703   Actor actorB = Actor::New();
3704   Actor actorC = Actor::New();
3705   Actor actorD = Actor::New();
3706   Actor actorE = Actor::New();
3707   Actor actorF = Actor::New();
3708
3709   //Test that root actor has depth equal 0
3710   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3711
3712   //Test actors return depth -1 when not connected to the tree
3713   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3714   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3715   DALI_TEST_EQUALS(-1, actorC.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   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3719
3720   //Create the hierarchy
3721   stage.Add(actorA);
3722   actorA.Add(actorB);
3723   actorA.Add(actorC);
3724   actorB.Add(actorD);
3725   actorB.Add(actorE);
3726   actorC.Add(actorF);
3727
3728   //Test actors return correct depth
3729   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3730   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3731   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3732   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3733   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3734   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3735
3736   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3737   actorA.Remove(actorB);
3738
3739   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3740   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3741   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3742
3743   //Removing actorA from the stage. All actors should have depth equal -1
3744   stage.Remove(actorA);
3745
3746   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3747   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3748   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3749   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3750   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3751   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3752
3753   END_TEST;
3754 }
3755
3756 int UtcDaliActorAnchorPointPropertyAsString(void)
3757 {
3758   TestApplication application;
3759
3760   Actor actor = Actor::New();
3761
3762   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3763   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3764
3765   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3766   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3767
3768   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3769   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3770
3771   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3772   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3773
3774   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3775   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3776
3777   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3778   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3779
3780   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3781   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3782
3783   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3784   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3785
3786   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3787   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3788
3789   // Invalid should not change anything
3790   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3791   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3792
3793   END_TEST;
3794 }
3795
3796 int UtcDaliActorParentOriginPropertyAsString(void)
3797 {
3798   TestApplication application;
3799
3800   Actor actor = Actor::New();
3801
3802   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3803   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3804
3805   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3806   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3807
3808   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3809   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3810
3811   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3812   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3813
3814   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3815   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3816
3817   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3818   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3819
3820   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3821   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3822
3823   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3824   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3825
3826   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3827   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3828
3829   // Invalid should not change anything
3830   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3831   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3832
3833   END_TEST;
3834 }
3835
3836 int UtcDaliActorColorModePropertyAsString(void)
3837 {
3838   TestApplication application;
3839
3840   Actor actor = Actor::New();
3841
3842   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3843   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3844
3845   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3846   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3847
3848   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3849   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3850
3851   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3852   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3853
3854   // Invalid should not change anything
3855   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3856   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3857
3858   END_TEST;
3859 }
3860
3861 int UtcDaliActorDrawModePropertyAsString(void)
3862 {
3863   TestApplication application;
3864
3865   Actor actor = Actor::New();
3866
3867   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3868   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3869
3870   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3871   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3872
3873   // Invalid should not change anything
3874   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3875   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3876
3877   END_TEST;
3878 }
3879
3880 int UtcDaliActorColorModePropertyAsEnum(void)
3881 {
3882   TestApplication application;
3883
3884   Actor actor = Actor::New();
3885
3886   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3887   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3888
3889   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3890   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3891
3892   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3893   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3894
3895   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3896   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3897
3898   END_TEST;
3899 }
3900
3901 int UtcDaliActorDrawModePropertyAsEnum(void)
3902 {
3903   TestApplication application;
3904
3905   Actor actor = Actor::New();
3906
3907   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3908   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3909
3910   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3911   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3912
3913   END_TEST;
3914 }
3915
3916 int UtcDaliActorAddRendererP(void)
3917 {
3918   tet_infoline("Testing Actor::AddRenderer");
3919   TestApplication application;
3920
3921   Actor actor = Actor::New();
3922
3923   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3924
3925   Geometry geometry = CreateQuadGeometry();
3926   Shader   shader   = CreateShader();
3927   Renderer renderer = Renderer::New(geometry, shader);
3928
3929   actor.AddRenderer(renderer);
3930   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3931   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3932
3933   END_TEST;
3934 }
3935
3936 int UtcDaliActorAddRendererN01(void)
3937 {
3938   tet_infoline("Testing Actor::AddRenderer");
3939   TestApplication application;
3940
3941   Actor    actor = Actor::New();
3942   Renderer renderer;
3943
3944   // try illegal Add
3945   try
3946   {
3947     actor.AddRenderer(renderer);
3948     tet_printf("Assertion test failed - no Exception\n");
3949     tet_result(TET_FAIL);
3950   }
3951   catch(Dali::DaliException& e)
3952   {
3953     DALI_TEST_PRINT_ASSERT(e);
3954     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3955     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3956   }
3957   catch(...)
3958   {
3959     tet_printf("Assertion test failed - wrong Exception\n");
3960     tet_result(TET_FAIL);
3961   }
3962
3963   END_TEST;
3964 }
3965
3966 int UtcDaliActorAddRendererN02(void)
3967 {
3968   tet_infoline("UtcDaliActorAddRendererN02");
3969
3970   Actor    actor;
3971   Renderer renderer;
3972
3973   {
3974     TestApplication application;
3975
3976     Geometry geometry = CreateQuadGeometry();
3977     Shader   shader   = CreateShader();
3978     renderer          = Renderer::New(geometry, shader);
3979
3980     actor = Actor::New();
3981   }
3982
3983   // try illegal AddRenderer
3984   try
3985   {
3986     actor.AddRenderer(renderer);
3987     tet_printf("Assertion test failed - no Exception\n");
3988     tet_result(TET_FAIL);
3989   }
3990   catch(Dali::DaliException& e)
3991   {
3992     DALI_TEST_PRINT_ASSERT(e);
3993     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3994   }
3995   catch(...)
3996   {
3997     tet_printf("Assertion test failed - wrong Exception\n");
3998     tet_result(TET_FAIL);
3999   }
4000
4001   END_TEST;
4002 }
4003
4004 int UtcDaliActorAddRendererOnScene(void)
4005 {
4006   tet_infoline("Testing Actor::AddRenderer");
4007   TestApplication application;
4008
4009   Actor actor = Actor::New();
4010   application.GetScene().Add(actor);
4011
4012   application.SendNotification();
4013   application.Render(0);
4014
4015   Geometry geometry = CreateQuadGeometry();
4016   Shader   shader   = CreateShader();
4017   Renderer renderer = Renderer::New(geometry, shader);
4018
4019   application.SendNotification();
4020   application.Render(0);
4021
4022   try
4023   {
4024     actor.AddRenderer(renderer);
4025     tet_result(TET_PASS);
4026   }
4027   catch(...)
4028   {
4029     tet_result(TET_FAIL);
4030   }
4031
4032   END_TEST;
4033 }
4034
4035 int UtcDaliActorRemoveRendererP1(void)
4036 {
4037   tet_infoline("Testing Actor::RemoveRenderer");
4038   TestApplication application;
4039
4040   Actor actor = Actor::New();
4041
4042   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4043
4044   {
4045     Geometry geometry = CreateQuadGeometry();
4046     Shader   shader   = CreateShader();
4047     Renderer renderer = Renderer::New(geometry, shader);
4048
4049     actor.AddRenderer(renderer);
4050     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4051     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4052
4053     application.SendNotification();
4054     application.Render();
4055   }
4056
4057   {
4058     Renderer renderer = actor.GetRendererAt(0);
4059     actor.RemoveRenderer(renderer);
4060     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4061
4062     application.SendNotification();
4063     application.Render();
4064   }
4065
4066   // Call one final time to ensure that the renderer is actually removed after
4067   // the handle goes out of scope, and excercises the deletion code path in
4068   // scene graph and render.
4069   application.SendNotification();
4070   application.Render();
4071
4072   END_TEST;
4073 }
4074
4075 int UtcDaliActorRemoveRendererP2(void)
4076 {
4077   tet_infoline("Testing Actor::RemoveRenderer");
4078   TestApplication application;
4079
4080   Actor actor = Actor::New();
4081
4082   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4083
4084   Geometry geometry = CreateQuadGeometry();
4085   Shader   shader   = CreateShader();
4086   Renderer renderer = Renderer::New(geometry, shader);
4087
4088   actor.AddRenderer(renderer);
4089   application.SendNotification();
4090   application.Render();
4091
4092   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4093   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4094
4095   actor.RemoveRenderer(0);
4096   application.SendNotification();
4097   application.Render();
4098
4099   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4100
4101   // Shut down whilst holding onto the renderer handle.
4102   END_TEST;
4103 }
4104
4105 int UtcDaliActorRemoveRendererN(void)
4106 {
4107   tet_infoline("Testing Actor::RemoveRenderer");
4108   TestApplication application;
4109
4110   Actor actor = Actor::New();
4111
4112   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4113
4114   Geometry geometry = CreateQuadGeometry();
4115   Shader   shader   = CreateShader();
4116   Renderer renderer = Renderer::New(geometry, shader);
4117
4118   actor.AddRenderer(renderer);
4119   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4120   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4121
4122   actor.RemoveRenderer(10);
4123   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4124   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4125
4126   END_TEST;
4127 }
4128
4129 // Clipping test helper functions:
4130 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4131 {
4132   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4133   Actor   actor = CreateRenderableActor(image);
4134
4135   // Setup dimensions and position so actor is not skipped by culling.
4136   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4137   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4138   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4139   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4140
4141   return actor;
4142 }
4143
4144 Actor CreateActorWithContent16x16()
4145 {
4146   return CreateActorWithContent(16, 16);
4147 }
4148
4149 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4150 {
4151   enabledDisableTrace.Reset();
4152   stencilTrace.Reset();
4153   enabledDisableTrace.Enable(true);
4154   stencilTrace.Enable(true);
4155
4156   application.SendNotification();
4157   application.Render();
4158
4159   enabledDisableTrace.Enable(false);
4160   stencilTrace.Enable(false);
4161 }
4162
4163 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4164 {
4165   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4166
4167   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4168   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4169   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4170
4171   // @todo only test alpha if the framebuffer has an alpha channel
4172   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4173 }
4174
4175 int UtcDaliActorPropertyClippingP(void)
4176 {
4177   // This test checks the clippingMode property.
4178   tet_infoline("Testing Actor::Property::ClippingMode: P");
4179   TestApplication application;
4180
4181   Actor actor = Actor::New();
4182
4183   // Check default clippingEnabled value.
4184   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4185
4186   int  value          = 0;
4187   bool getValueResult = getValue.Get(value);
4188   DALI_TEST_CHECK(getValueResult);
4189
4190   if(getValueResult)
4191   {
4192     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4193   }
4194
4195   // Check setting the property to the stencil mode.
4196   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4197
4198   // Check the new value was set.
4199   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4200   getValueResult = getValue.Get(value);
4201   DALI_TEST_CHECK(getValueResult);
4202
4203   if(getValueResult)
4204   {
4205     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4206   }
4207
4208   // Check setting the property to the scissor mode.
4209   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4210
4211   // Check the new value was set.
4212   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4213   getValueResult = getValue.Get(value);
4214   DALI_TEST_CHECK(getValueResult);
4215
4216   if(getValueResult)
4217   {
4218     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4219   }
4220   END_TEST;
4221 }
4222
4223 int UtcDaliActorPropertyClippingN(void)
4224 {
4225   // Negative test case for Clipping.
4226   tet_infoline("Testing Actor::Property::ClippingMode: N");
4227   TestApplication application;
4228
4229   Actor actor = Actor::New();
4230
4231   // Check default clippingEnabled value.
4232   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4233
4234   int  value          = 0;
4235   bool getValueResult = getValue.Get(value);
4236   DALI_TEST_CHECK(getValueResult);
4237
4238   if(getValueResult)
4239   {
4240     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4241   }
4242
4243   // Check setting an invalid property value won't change the current property value.
4244   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4245
4246   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4247   getValueResult = getValue.Get(value);
4248   DALI_TEST_CHECK(getValueResult);
4249
4250   if(getValueResult)
4251   {
4252     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4253   }
4254
4255   END_TEST;
4256 }
4257
4258 int UtcDaliActorPropertyClippingActor(void)
4259 {
4260   // This test checks that an actor is correctly setup for clipping.
4261   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4262   TestApplication application;
4263
4264   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4265   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4266   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4267   size_t             startIndex          = 0u;
4268
4269   // Create a clipping actor.
4270   Actor actorDepth1Clip = CreateActorWithContent16x16();
4271   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4272   application.GetScene().Add(actorDepth1Clip);
4273
4274   // Gather the call trace.
4275   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4276
4277   // Check we are writing to the color buffer.
4278   CheckColorMask(glAbstraction, true);
4279
4280   // Check the stencil buffer was enabled.
4281   std::ostringstream oss;
4282   oss << std::hex << GL_STENCIL_TEST;
4283   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4284
4285   // Check the stencil buffer was cleared.
4286   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4287
4288   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4289   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4290   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4291   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4292
4293   END_TEST;
4294 }
4295
4296 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4297 {
4298   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4299   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4300   TestApplication application;
4301
4302   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4303   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4304   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4305   size_t             startIndex          = 0u;
4306
4307   // Create a clipping actor.
4308   Actor actorDepth1Clip = CreateActorWithContent16x16();
4309   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4310   application.GetScene().Add(actorDepth1Clip);
4311
4312   // Gather the call trace.
4313   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4314
4315   // Check we are writing to the color buffer.
4316   CheckColorMask(glAbstraction, true);
4317
4318   // Check the stencil buffer was enabled.
4319   std::ostringstream oss;
4320   oss << std::hex << GL_STENCIL_TEST;
4321   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4322
4323   // Check the stencil buffer was cleared.
4324   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4325
4326   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4327   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4328   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4329   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4330
4331   // Now disable the clipping
4332   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4333
4334   // Gather the call trace.
4335   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4336
4337   // Check the stencil buffer was disabled.
4338   std::ostringstream stencil;
4339   stencil << std::hex << GL_STENCIL_TEST;
4340   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4341
4342   // Ensure all values in stencil-mask are set to 1.
4343   startIndex = 0u;
4344   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4345
4346   END_TEST;
4347 }
4348
4349 int UtcDaliActorPropertyClippingNestedChildren(void)
4350 {
4351   // This test checks that a hierarchy of actors are clipped correctly by
4352   // writing to and reading from the correct bit-planes of the stencil buffer.
4353   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4354   TestApplication    application;
4355   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4356   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4357   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4358
4359   // Create a clipping actor.
4360   Actor actorDepth1Clip = CreateActorWithContent16x16();
4361   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4362   application.GetScene().Add(actorDepth1Clip);
4363
4364   // Create a child actor.
4365   Actor childDepth2 = CreateActorWithContent16x16();
4366   actorDepth1Clip.Add(childDepth2);
4367
4368   // Create another clipping actor.
4369   Actor childDepth2Clip = CreateActorWithContent16x16();
4370   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4371   childDepth2.Add(childDepth2Clip);
4372
4373   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4374   // This tests the sort algorithm.
4375   Actor childDepth3 = CreateActorWithContent16x16();
4376   childDepth2Clip.Add(childDepth3);
4377   Actor childDepth4 = CreateActorWithContent16x16();
4378   childDepth3.Add(childDepth4);
4379
4380   // Gather the call trace.
4381   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4382
4383   // Check we are writing to the color buffer.
4384   CheckColorMask(glAbstraction, true);
4385
4386   // Check the stencil buffer was enabled.
4387   std::ostringstream oss;
4388   oss << std::hex << GL_STENCIL_TEST;
4389   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4390
4391   // Perform the test twice, once for 2D layer, and once for 3D.
4392   for(unsigned int i = 0u; i < 2u; ++i)
4393   {
4394     size_t startIndex = 0u;
4395
4396     // Check the stencil buffer was cleared.
4397     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4398
4399     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4400     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4401     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4402     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4403
4404     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4405     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4406     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4407
4408     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4409     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4410     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4411     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4412
4413     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4414     // (Both must be set to pass the check).
4415     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4416     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4417
4418     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4419     if(i == 0u)
4420     {
4421       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4422       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4423     }
4424   }
4425
4426   END_TEST;
4427 }
4428
4429 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4430 {
4431   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4432   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4433   TestApplication    application;
4434   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4435   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4436
4437   /* We create a small tree of actors as follows:
4438
4439                            A
4440                           / \
4441      Clipping enabled -> B   D
4442                          |   |
4443                          C   E
4444
4445      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4446   */
4447   Actor actors[5];
4448   for(int i = 0; i < 5; ++i)
4449   {
4450     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4451     Actor   actor = CreateRenderableActor(image);
4452
4453     // Setup dimensions and position so actor is not skipped by culling.
4454     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4455     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4456
4457     if(i == 0)
4458     {
4459       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4460     }
4461     else
4462     {
4463       float b = i > 2 ? 1.0f : -1.0f;
4464       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4465     }
4466
4467     actors[i] = actor;
4468   }
4469
4470   // Enable clipping on the actor at the top of the left branch.
4471   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4472
4473   // Build the scene graph.
4474   application.GetScene().Add(actors[0]);
4475
4476   // Left branch:
4477   actors[0].Add(actors[1]);
4478   actors[1].Add(actors[2]);
4479
4480   // Right branch:
4481   actors[0].Add(actors[3]);
4482   actors[3].Add(actors[4]);
4483
4484   // Gather the call trace.
4485   enabledDisableTrace.Reset();
4486   enabledDisableTrace.Enable(true);
4487   application.SendNotification();
4488   application.Render();
4489   enabledDisableTrace.Enable(false);
4490
4491   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4492
4493      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
4494            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4495   */
4496   size_t             startIndex = 0u;
4497   std::ostringstream blend;
4498   blend << std::hex << GL_BLEND;
4499   std::ostringstream stencil;
4500   stencil << std::hex << GL_STENCIL_TEST;
4501
4502   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4503   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4504   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4505
4506   // Swap the clipping actor from top of left branch to top of right branch.
4507   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4508   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4509
4510   // Gather the call trace.
4511   enabledDisableTrace.Reset();
4512   enabledDisableTrace.Enable(true);
4513   application.SendNotification();
4514   application.Render();
4515   enabledDisableTrace.Enable(false);
4516
4517   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4518   // This proves the draw order has remained the same.
4519   startIndex = 0u;
4520   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4521   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4522
4523   END_TEST;
4524 }
4525
4526 int UtcDaliActorPropertyScissorClippingActor01(void)
4527 {
4528   // This test checks that an actor is correctly setup for clipping.
4529   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4530   TestApplication application;
4531
4532   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4533   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4534   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4535
4536   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4537   const Vector2 imageSize(16.0f, 16.0f);
4538
4539   // Create a clipping actor.
4540   Actor clippingActorA = CreateActorWithContent16x16();
4541   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4542   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4543   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4544   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4545   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4546   application.GetScene().Add(clippingActorA);
4547
4548   // Gather the call trace.
4549   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4550
4551   // Check we are writing to the color buffer.
4552   CheckColorMask(glAbstraction, true);
4553
4554   // Check scissor test was enabled.
4555
4556   std::ostringstream scissor;
4557   scissor << std::hex << GL_SCISSOR_TEST;
4558   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4559
4560   // Check the scissor was set, and the coordinates are correct.
4561   std::stringstream compareParametersString;
4562   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4563   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4564
4565   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4566   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4567
4568   // Gather the call trace.
4569   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4570
4571   // Check the scissor was set, and the coordinates are correct.
4572   compareParametersString.str(std::string());
4573   compareParametersString.clear();
4574   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4575   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4576
4577   END_TEST;
4578 }
4579
4580 int UtcDaliActorPropertyScissorClippingActor02(void)
4581 {
4582   // This test checks that an actor is correctly setup for clipping.
4583   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4584   TestApplication application;
4585
4586   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4587   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4588   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4589
4590   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4591   const Vector2 actorSize(16.0f, 16.0f);
4592
4593   // Create a clipping actor.
4594   Actor clippingActorA                  = CreateRenderableActor();
4595   clippingActorA[Actor::Property::SIZE] = actorSize;
4596
4597   Renderer renderer = clippingActorA.GetRendererAt(0);
4598   DALI_TEST_CHECK(renderer);
4599
4600   // Make Renderer opacity 0.
4601   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4602
4603   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4604   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4605   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4606   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4607   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4608   application.GetScene().Add(clippingActorA);
4609
4610   // Gather the call trace.
4611   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4612
4613   // Check we are writing to the color buffer.
4614   CheckColorMask(glAbstraction, true);
4615
4616   // Check scissor test was enabled.
4617
4618   std::ostringstream scissor;
4619   scissor << std::hex << GL_SCISSOR_TEST;
4620   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4621
4622   // Check the scissor was set, and the coordinates are correct.
4623   std::stringstream compareParametersString;
4624   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4625   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4626
4627   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4628   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4629
4630   // Gather the call trace.
4631   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4632
4633   // Check the scissor was set, and the coordinates are correct.
4634   compareParametersString.str(std::string());
4635   compareParametersString.clear();
4636   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4637   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4638
4639   END_TEST;
4640 }
4641
4642 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4643 {
4644   // This test checks that an actor is correctly setup for clipping.
4645   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4646   TestApplication application;
4647
4648   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4649   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4650   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4651
4652   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4653   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4654   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4655
4656   // Create a clipping actors.
4657   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4658   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4659
4660   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4661   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4662   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4663
4664   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4665   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4666   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4667
4668   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4669   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4670
4671   application.GetScene().Add(clippingActorA);
4672   application.GetScene().Add(clippingActorB);
4673
4674   // Gather the call trace.
4675   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4676
4677   // Check we are writing to the color buffer.
4678   CheckColorMask(glAbstraction, true);
4679
4680   // Check scissor test was enabled.
4681   std::ostringstream scissor;
4682   scissor << std::hex << GL_SCISSOR_TEST;
4683   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4684
4685   // Check the scissor was set, and the coordinates are correct.
4686   std::stringstream compareParametersString;
4687
4688   std::string clipA("0, 500, 480, 200");
4689   std::string clipB("0, 380, 480, 40");
4690
4691   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4692   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4693
4694   END_TEST;
4695 }
4696
4697 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4698 {
4699   // This test checks that an actor is correctly setup for clipping.
4700   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4701   TestApplication application;
4702
4703   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4704   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4705   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4706
4707   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4708   const Vector2 imageSize(16.0f, 16.0f);
4709
4710   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4711
4712      A is drawn first - with scissor clipping on
4713      B is drawn second - also with scissor clipping on
4714      C is the generated clipping region, the intersection ( A ∩ B )
4715
4716            ┏━━━━━━━┓                   ┌───────┐
4717            ┃     B ┃                   │     B │
4718        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4719        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4720        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4721        │ A     │                   ┊ A     ┊
4722        └───────┘                   └┄┄┄┄┄┄┄┘
4723
4724      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4725   */
4726
4727   // Create a clipping actor.
4728   Actor clippingActorA = CreateActorWithContent16x16();
4729   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4730   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4731   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4732   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4733   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4734   application.GetScene().Add(clippingActorA);
4735
4736   // Create a child clipping actor.
4737   Actor clippingActorB = CreateActorWithContent16x16();
4738   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4739   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4740   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4741   clippingActorA.Add(clippingActorB);
4742
4743   // positionModifiers is an array of positions to position B around.
4744   // expect is an array of expected scissor clip coordinate results.
4745   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4746   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4747
4748   // Loop through each overlap combination.
4749   for(unsigned int test = 0u; test < 4u; ++test)
4750   {
4751     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4752     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4753     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4754
4755     // Gather the call trace.
4756     GenerateTrace(application, enabledDisableTrace, scissorTrace);
4757
4758     // Check we are writing to the color buffer.
4759     CheckColorMask(glAbstraction, true);
4760
4761     // Check scissor test was enabled.
4762     std::ostringstream scissor;
4763     scissor << std::hex << GL_SCISSOR_TEST;
4764     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4765
4766     // Check the scissor was set, and the coordinates are correct.
4767     const Vector4&    expectResults(expect[test]);
4768     std::stringstream compareParametersString;
4769     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4770     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4771   }
4772
4773   END_TEST;
4774 }
4775
4776 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4777 {
4778   // This test checks that an actor is correctly setup for clipping.
4779   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4780   TestApplication application;
4781
4782   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4783   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4784   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4785
4786   /* Create a nest of 2 scissors and siblings of the parent.
4787
4788             stage
4789               |
4790         ┌─────┐─────┐
4791         A     C     D
4792         |           |
4793         B           E
4794   */
4795
4796   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4797   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4798   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4799   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4800   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4801   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4802
4803   // Create a clipping actors.
4804   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4805   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4806   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4807   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4808   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4809
4810   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4811   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4812   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4813
4814   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4815   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4816   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4817
4818   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4819   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4820   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4821
4822   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4823   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4824   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4825
4826   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4827   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4828
4829   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4830   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4831   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4832   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4833   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4834
4835   application.GetScene().Add(clippingActorA);
4836   clippingActorA.Add(clippingActorB);
4837   application.GetScene().Add(clippingActorC);
4838   application.GetScene().Add(clippingActorD);
4839   clippingActorD.Add(clippingActorE);
4840
4841   // Gather the call trace.
4842   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4843
4844   // Check we are writing to the color buffer.
4845   CheckColorMask(glAbstraction, true);
4846
4847   // Check scissor test was enabled.
4848   std::ostringstream scissor;
4849   scissor << std::hex << GL_SCISSOR_TEST;
4850   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4851
4852   // Check the scissor was set, and the coordinates are correct.
4853   std::string clipA("0, 500, 480, 200");
4854   std::string clipB("0, 580, 480, 40");
4855   std::string clipC("0, 200, 480, 200");
4856   std::string clipD("0, 300, 480, 200");
4857
4858   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4859   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4860   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4861   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4862   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4863
4864   END_TEST;
4865 }
4866
4867 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4868 {
4869   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4870   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4871   TestApplication application;
4872
4873   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4874   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4875   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4876
4877   // Create a clipping actor.
4878   Actor actorDepth1Clip = CreateActorWithContent16x16();
4879   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4880   application.GetScene().Add(actorDepth1Clip);
4881
4882   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4883   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4884
4885   // Gather the call trace.
4886   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4887
4888   // Check we are writing to the color buffer.
4889   CheckColorMask(glAbstraction, true);
4890
4891   // Check the stencil buffer was not enabled.
4892   std::ostringstream stencil;
4893   stencil << std::hex << GL_STENCIL_TEST;
4894   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4895
4896   // Check stencil functions are not called.
4897   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4898   // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
4899   //  DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4900   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4901
4902   // Check that scissor clipping is overriden by the renderer properties.
4903   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4904
4905   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4906
4907   // Gather the call trace.
4908   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4909
4910   // Check the stencil buffer was not enabled.
4911   std::ostringstream scissor;
4912   scissor << std::hex << GL_SCISSOR_TEST;
4913   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4914
4915   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4916
4917   END_TEST;
4918 }
4919
4920 int UtcDaliGetPropertyN(void)
4921 {
4922   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4923   TestApplication application;
4924
4925   Actor actor = Actor::New();
4926
4927   unsigned int propertyCount = actor.GetPropertyCount();
4928   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4929   END_TEST;
4930 }
4931
4932 int UtcDaliActorRaiseLower(void)
4933 {
4934   tet_infoline("UtcDaliActor Raise and Lower test\n");
4935
4936   TestApplication application;
4937
4938   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4939
4940   Integration::Scene stage(application.GetScene());
4941
4942   Actor actorA = Actor::New();
4943   Actor actorB = Actor::New();
4944   Actor actorC = Actor::New();
4945
4946   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4947   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4948
4949   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4950   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4951
4952   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4953   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4954
4955   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4956   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4957
4958   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4959   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4960
4961   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4962   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4963
4964   stage.Add(actorA);
4965   stage.Add(actorB);
4966   stage.Add(actorC);
4967
4968   ResetTouchCallbacks();
4969
4970   application.SendNotification();
4971   application.Render();
4972
4973   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4974   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4975   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4976
4977   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4978   // Only top actor will get touched.
4979   actorA.TouchedSignal().Connect(TestTouchCallback);
4980   actorB.TouchedSignal().Connect(TestTouchCallback2);
4981   actorC.TouchedSignal().Connect(TestTouchCallback3);
4982
4983   // Connect ChildOrderChangedSignal
4984   bool                     orderChangedSignal(false);
4985   Actor                    orderChangedActor;
4986   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4987   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4988
4989   Dali::Integration::Point point;
4990   point.SetDeviceId(1);
4991   point.SetState(PointState::DOWN);
4992   point.SetScreenPosition(Vector2(10.f, 10.f));
4993   Dali::Integration::TouchEvent touchEvent;
4994   touchEvent.AddPoint(point);
4995
4996   application.ProcessEvent(touchEvent);
4997
4998   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4999   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5000   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5001
5002   ResetTouchCallbacks();
5003
5004   tet_printf("Testing Raising of Actor\n");
5005
5006   int preActorOrder(0);
5007   int postActorOrder(0);
5008
5009   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5010   value.Get(preActorOrder);
5011
5012   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5013   actorB.Raise();
5014   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5015   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5016
5017   // Ensure sort order is calculated before next touch event
5018   application.SendNotification();
5019
5020   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5021   value.Get(postActorOrder);
5022
5023   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5024
5025   application.ProcessEvent(touchEvent);
5026
5027   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5028   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5029   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5030
5031   ResetTouchCallbacks();
5032
5033   tet_printf("Testing Lowering of Actor\n");
5034
5035   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5036   value.Get(preActorOrder);
5037
5038   orderChangedSignal = false;
5039
5040   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5041   actorB.Lower();
5042   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5043   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5044
5045   application.SendNotification(); // ensure sort order calculated before next touch event
5046
5047   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5048   value.Get(postActorOrder);
5049
5050   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5051
5052   application.ProcessEvent(touchEvent);
5053
5054   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5055   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5056   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5057
5058   ResetTouchCallbacks();
5059
5060   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5061
5062   END_TEST;
5063 }
5064
5065 int UtcDaliActorRaiseToTopLowerToBottom(void)
5066 {
5067   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5068
5069   TestApplication application;
5070
5071   Integration::Scene stage(application.GetScene());
5072
5073   Actor actorA = Actor::New();
5074   Actor actorB = Actor::New();
5075   Actor actorC = Actor::New();
5076
5077   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5078   // enables checking of which actor the uniform is assigned too
5079   Shader shaderA = CreateShader();
5080   shaderA.RegisterProperty("uRendererColor", 1.f);
5081
5082   Shader shaderB = CreateShader();
5083   shaderB.RegisterProperty("uRendererColor", 2.f);
5084
5085   Shader shaderC = CreateShader();
5086   shaderC.RegisterProperty("uRendererColor", 3.f);
5087
5088   Geometry geometry = CreateQuadGeometry();
5089
5090   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5091   Renderer rendererA = Renderer::New(geometry, shaderA);
5092   actorA.AddRenderer(rendererA);
5093
5094   Renderer rendererB = Renderer::New(geometry, shaderB);
5095   actorB.AddRenderer(rendererB);
5096
5097   Renderer rendererC = Renderer::New(geometry, shaderC);
5098   actorC.AddRenderer(rendererC);
5099
5100   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5101   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5102
5103   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5104   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5105
5106   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5107   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5108
5109   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5110   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5111
5112   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5113   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5114
5115   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5116   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5117
5118   stage.Add(actorA);
5119   stage.Add(actorB);
5120   stage.Add(actorC);
5121
5122   ResetTouchCallbacks();
5123
5124   // Connect ChildOrderChangedSignal
5125   bool                     orderChangedSignal(false);
5126   Actor                    orderChangedActor;
5127   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5128   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5129
5130   // Set up gl abstraction trace so can query the set uniform order
5131   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5132   glAbstraction.EnableSetUniformCallTrace(true);
5133   glAbstraction.ResetSetUniformCallStack();
5134
5135   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5136
5137   application.SendNotification();
5138   application.Render();
5139
5140   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5141
5142   // Test order of uniforms in stack
5143   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5144   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5145   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5146
5147   bool CBA = (indexC > indexB) && (indexB > indexA);
5148
5149   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5150
5151   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5152   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5153   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5154
5155   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5156   // Only top actor will get touched.
5157   actorA.TouchedSignal().Connect(TestTouchCallback);
5158   actorB.TouchedSignal().Connect(TestTouchCallback2);
5159   actorC.TouchedSignal().Connect(TestTouchCallback3);
5160
5161   Dali::Integration::Point point;
5162   point.SetDeviceId(1);
5163   point.SetState(PointState::DOWN);
5164   point.SetScreenPosition(Vector2(10.f, 10.f));
5165   Dali::Integration::TouchEvent touchEvent;
5166   touchEvent.AddPoint(point);
5167
5168   application.ProcessEvent(touchEvent);
5169
5170   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5171   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5172   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5173
5174   ResetTouchCallbacks();
5175
5176   tet_printf("RaiseToTop ActorA\n");
5177
5178   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5179   actorA.RaiseToTop();
5180   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5181   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5182
5183   application.SendNotification(); // ensure sorting order is calculated before next touch event
5184
5185   application.ProcessEvent(touchEvent);
5186
5187   glSetUniformStack.Reset();
5188
5189   application.SendNotification();
5190   application.Render();
5191
5192   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5193
5194   // Test order of uniforms in stack
5195   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5196   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5197   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5198
5199   tet_infoline("Testing A above C and B at bottom\n");
5200   bool ACB = (indexA > indexC) && (indexC > indexB);
5201
5202   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5203
5204   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5205   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5206   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5207
5208   ResetTouchCallbacks();
5209
5210   tet_printf("RaiseToTop ActorB\n");
5211
5212   orderChangedSignal = false;
5213
5214   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5215   actorB.RaiseToTop();
5216   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5217   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5218
5219   application.SendNotification(); // Ensure sort order is calculated before next touch event
5220
5221   application.ProcessEvent(touchEvent);
5222
5223   glSetUniformStack.Reset();
5224
5225   application.SendNotification();
5226   application.Render();
5227
5228   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5229
5230   // Test order of uniforms in stack
5231   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5232   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5233   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5234
5235   tet_infoline("Testing B above A and C at bottom\n");
5236   bool BAC = (indexB > indexA) && (indexA > indexC);
5237
5238   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5239
5240   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5241   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5242   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5243
5244   ResetTouchCallbacks();
5245
5246   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5247
5248   orderChangedSignal = false;
5249
5250   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5251   actorA.LowerToBottom();
5252   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5253   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5254
5255   application.SendNotification();
5256   application.Render();
5257
5258   orderChangedSignal = false;
5259
5260   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5261   actorB.LowerToBottom();
5262   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5263   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5264
5265   application.SendNotification();
5266   application.Render();
5267
5268   application.ProcessEvent(touchEvent);
5269
5270   glSetUniformStack.Reset();
5271
5272   application.SendNotification();
5273   application.Render();
5274
5275   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5276
5277   // Test order of uniforms in stack
5278   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5279   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5280   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5281
5282   tet_infoline("Testing C above A and B at bottom\n");
5283   bool CAB = (indexC > indexA) && (indexA > indexB);
5284
5285   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5286
5287   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5288   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5289   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5290
5291   ResetTouchCallbacks();
5292
5293   END_TEST;
5294 }
5295
5296 int UtcDaliActorRaiseAbove(void)
5297 {
5298   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5299
5300   TestApplication application;
5301
5302   Integration::Scene stage(application.GetScene());
5303
5304   Actor actorA = Actor::New();
5305   Actor actorB = Actor::New();
5306   Actor actorC = Actor::New();
5307
5308   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5309   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5310
5311   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5312   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5313
5314   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5315   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5316
5317   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5318   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5319
5320   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5321   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5322
5323   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5324   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5325
5326   stage.Add(actorA);
5327   stage.Add(actorB);
5328   stage.Add(actorC);
5329
5330   ResetTouchCallbacks();
5331
5332   application.SendNotification();
5333   application.Render();
5334
5335   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5336   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5337   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5338
5339   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5340   // Only top actor will get touched.
5341   actorA.TouchedSignal().Connect(TestTouchCallback);
5342   actorB.TouchedSignal().Connect(TestTouchCallback2);
5343   actorC.TouchedSignal().Connect(TestTouchCallback3);
5344
5345   bool                     orderChangedSignal(false);
5346   Actor                    orderChangedActor;
5347   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5348   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5349
5350   Dali::Integration::Point point;
5351   point.SetDeviceId(1);
5352   point.SetState(PointState::DOWN);
5353   point.SetScreenPosition(Vector2(10.f, 10.f));
5354   Dali::Integration::TouchEvent touchEvent;
5355   touchEvent.AddPoint(point);
5356
5357   application.ProcessEvent(touchEvent);
5358
5359   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5360   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5361   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5362
5363   ResetTouchCallbacks();
5364
5365   tet_printf("Raise actor B Above Actor C\n");
5366
5367   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5368   actorB.RaiseAbove(actorC);
5369   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5370   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5371
5372   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5373   application.SendNotification();
5374   application.ProcessEvent(touchEvent);
5375
5376   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5377   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5378   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5379
5380   ResetTouchCallbacks();
5381
5382   tet_printf("Raise actor A Above Actor B\n");
5383
5384   orderChangedSignal = false;
5385
5386   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5387   actorA.RaiseAbove(actorB);
5388   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5389   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5390
5391   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5392   application.SendNotification();
5393
5394   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5395
5396   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5397   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5398   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5399
5400   ResetTouchCallbacks();
5401
5402   END_TEST;
5403 }
5404
5405 int UtcDaliActorRaiseAbove2(void)
5406 {
5407   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5408
5409   TestApplication application;
5410
5411   Integration::Scene stage(application.GetScene());
5412
5413   Actor actorA = Actor::New();
5414   Actor actorB = Actor::New();
5415   Actor actorC = Actor::New();
5416
5417   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5418   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5419
5420   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5421   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5422
5423   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5424   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5425
5426   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5427   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5428
5429   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5430   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5431
5432   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5433   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5434
5435   stage.Add(actorA);
5436   stage.Add(actorB);
5437   stage.Add(actorC);
5438
5439   ResetTouchCallbacks();
5440
5441   application.SendNotification();
5442   application.Render();
5443
5444   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5445   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5446   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5447
5448   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5449   // Only top actor will get touched.
5450   actorA.TouchedSignal().Connect(TestTouchCallback);
5451   actorB.TouchedSignal().Connect(TestTouchCallback2);
5452   actorC.TouchedSignal().Connect(TestTouchCallback3);
5453
5454   bool                     orderChangedSignal(false);
5455   Actor                    orderChangedActor;
5456   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5457   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5458
5459   Dali::Integration::Point point;
5460   point.SetDeviceId(1);
5461   point.SetState(PointState::DOWN);
5462   point.SetScreenPosition(Vector2(10.f, 10.f));
5463   Dali::Integration::TouchEvent touchEvent;
5464   touchEvent.AddPoint(point);
5465
5466   application.ProcessEvent(touchEvent);
5467
5468   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5469   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5470   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5471
5472   ResetTouchCallbacks();
5473
5474   tet_printf("Raise actor B Above Actor C\n");
5475
5476   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5477   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5478   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5479   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5480   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5481
5482   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5483   application.SendNotification();
5484   application.ProcessEvent(touchEvent);
5485
5486   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5487   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5488   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5489
5490   ResetTouchCallbacks();
5491
5492   tet_printf("Raise actor A Above Actor B\n");
5493
5494   orderChangedSignal = false;
5495
5496   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5497   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5498   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5499   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5500   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5501
5502   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5503   application.SendNotification();
5504
5505   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5506
5507   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5508   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5509   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5510
5511   ResetTouchCallbacks();
5512
5513   END_TEST;
5514 }
5515
5516 int UtcDaliActorLowerBelow(void)
5517 {
5518   tet_infoline("UtcDaliActor LowerBelow test \n");
5519
5520   TestApplication application;
5521
5522   Integration::Scene stage(application.GetScene());
5523
5524   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5525   // enables checking of which actor the uniform is assigned too
5526   Shader shaderA = CreateShader();
5527   shaderA.RegisterProperty("uRendererColor", 1.f);
5528
5529   Shader shaderB = CreateShader();
5530   shaderB.RegisterProperty("uRendererColor", 2.f);
5531
5532   Shader shaderC = CreateShader();
5533   shaderC.RegisterProperty("uRendererColor", 3.f);
5534
5535   Actor actorA = Actor::New();
5536   Actor actorB = Actor::New();
5537   Actor actorC = Actor::New();
5538
5539   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5540   Geometry geometry = CreateQuadGeometry();
5541
5542   Renderer rendererA = Renderer::New(geometry, shaderA);
5543   actorA.AddRenderer(rendererA);
5544
5545   Renderer rendererB = Renderer::New(geometry, shaderB);
5546   actorB.AddRenderer(rendererB);
5547
5548   Renderer rendererC = Renderer::New(geometry, shaderC);
5549   actorC.AddRenderer(rendererC);
5550
5551   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5553
5554   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5556
5557   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5558   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5559
5560   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5562
5563   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5565
5566   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5567   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5568
5569   Actor container = Actor::New();
5570   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5571   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5572   stage.Add(container);
5573
5574   container.Add(actorA);
5575   container.Add(actorB);
5576   container.Add(actorC);
5577
5578   ResetTouchCallbacks();
5579
5580   // Connect ChildOrderChangedSignal
5581   bool                     orderChangedSignal(false);
5582   Actor                    orderChangedActor;
5583   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5584   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5585
5586   // Set up gl abstraction trace so can query the set uniform order
5587   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5588   glAbstraction.EnableSetUniformCallTrace(true);
5589   glAbstraction.ResetSetUniformCallStack();
5590   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5591
5592   glAbstraction.ResetSetUniformCallStack();
5593
5594   application.SendNotification();
5595   application.Render();
5596
5597   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5598
5599   // Test order of uniforms in stack
5600   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5601   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5602   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5603
5604   tet_infoline("Testing C above B and A at bottom\n");
5605   bool CBA = (indexC > indexB) && (indexB > indexA);
5606
5607   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5608
5609   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5610   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5611   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5612
5613   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5614   // Only top actor will get touched.
5615   actorA.TouchedSignal().Connect(TestTouchCallback);
5616   actorB.TouchedSignal().Connect(TestTouchCallback2);
5617   actorC.TouchedSignal().Connect(TestTouchCallback3);
5618
5619   Dali::Integration::Point point;
5620   point.SetDeviceId(1);
5621   point.SetState(PointState::DOWN);
5622   point.SetScreenPosition(Vector2(10.f, 10.f));
5623   Dali::Integration::TouchEvent touchEvent;
5624   touchEvent.AddPoint(point);
5625
5626   tet_infoline("UtcDaliActor Test Set up completed \n");
5627
5628   application.ProcessEvent(touchEvent);
5629
5630   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5631   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5632   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5633
5634   ResetTouchCallbacks();
5635
5636   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");
5637
5638   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5639   actorC.LowerBelow(actorB);
5640   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5641   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5642
5643   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5644   application.SendNotification();
5645   application.Render();
5646
5647   application.ProcessEvent(touchEvent); // touch event
5648
5649   glSetUniformStack.Reset();
5650
5651   application.SendNotification();
5652   application.Render();
5653
5654   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5655
5656   // Test order of uniforms in stack
5657   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5658   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5659   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5660
5661   tet_infoline("Testing render order is A, C, B");
5662   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5663   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5664
5665   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5666   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5667   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5668
5669   ResetTouchCallbacks();
5670
5671   tet_printf("Lower actor C below Actor A leaving B on top\n");
5672
5673   orderChangedSignal = false;
5674
5675   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5676   actorC.LowerBelow(actorA);
5677   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5678   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5679
5680   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5681   application.SendNotification();
5682   application.Render();
5683
5684   application.ProcessEvent(touchEvent);
5685
5686   glSetUniformStack.Reset();
5687
5688   application.Render();
5689   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5690
5691   // Test order of uniforms in stack
5692   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5693   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5694   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5695
5696   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5697   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5698
5699   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5700   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5701   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5702
5703   ResetTouchCallbacks();
5704
5705   tet_printf("Lower actor B below Actor C leaving A on top\n");
5706
5707   orderChangedSignal = false;
5708
5709   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5710   actorB.LowerBelow(actorC);
5711   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5712   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5713
5714   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5715   application.SendNotification();
5716   application.Render();
5717
5718   application.ProcessEvent(touchEvent);
5719
5720   glSetUniformStack.Reset();
5721
5722   application.Render();
5723   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5724
5725   // Test order of uniforms in stack
5726   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5727   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5728   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5729
5730   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5731   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5732
5733   END_TEST;
5734 }
5735
5736 int UtcDaliActorLowerBelow2(void)
5737 {
5738   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5739
5740   TestApplication application;
5741
5742   Integration::Scene stage(application.GetScene());
5743
5744   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5745   // enables checking of which actor the uniform is assigned too
5746   Shader shaderA = CreateShader();
5747   shaderA.RegisterProperty("uRendererColor", 1.f);
5748
5749   Shader shaderB = CreateShader();
5750   shaderB.RegisterProperty("uRendererColor", 2.f);
5751
5752   Shader shaderC = CreateShader();
5753   shaderC.RegisterProperty("uRendererColor", 3.f);
5754
5755   Actor actorA = Actor::New();
5756   Actor actorB = Actor::New();
5757   Actor actorC = Actor::New();
5758
5759   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5760   Geometry geometry = CreateQuadGeometry();
5761
5762   Renderer rendererA = Renderer::New(geometry, shaderA);
5763   actorA.AddRenderer(rendererA);
5764
5765   Renderer rendererB = Renderer::New(geometry, shaderB);
5766   actorB.AddRenderer(rendererB);
5767
5768   Renderer rendererC = Renderer::New(geometry, shaderC);
5769   actorC.AddRenderer(rendererC);
5770
5771   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5772   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5773
5774   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5775   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5776
5777   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5778   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5779
5780   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5781   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5782
5783   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5784   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5785
5786   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5787   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5788
5789   Actor container = Actor::New();
5790   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5791   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5792   stage.Add(container);
5793
5794   container.Add(actorA);
5795   container.Add(actorB);
5796   container.Add(actorC);
5797
5798   ResetTouchCallbacks();
5799
5800   // Connect ChildOrderChangedSignal
5801   bool                     orderChangedSignal(false);
5802   Actor                    orderChangedActor;
5803   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5804   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5805
5806   // Set up gl abstraction trace so can query the set uniform order
5807   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5808   glAbstraction.EnableSetUniformCallTrace(true);
5809   glAbstraction.ResetSetUniformCallStack();
5810   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5811
5812   glAbstraction.ResetSetUniformCallStack();
5813
5814   application.SendNotification();
5815   application.Render();
5816
5817   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5818
5819   // Test order of uniforms in stack
5820   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5821   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5822   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5823
5824   tet_infoline("Testing C above B and A at bottom\n");
5825   bool CBA = (indexC > indexB) && (indexB > indexA);
5826
5827   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5828
5829   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5830   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5831   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5832
5833   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5834   // Only top actor will get touched.
5835   actorA.TouchedSignal().Connect(TestTouchCallback);
5836   actorB.TouchedSignal().Connect(TestTouchCallback2);
5837   actorC.TouchedSignal().Connect(TestTouchCallback3);
5838
5839   Dali::Integration::Point point;
5840   point.SetDeviceId(1);
5841   point.SetState(PointState::DOWN);
5842   point.SetScreenPosition(Vector2(10.f, 10.f));
5843   Dali::Integration::TouchEvent touchEvent;
5844   touchEvent.AddPoint(point);
5845
5846   tet_infoline("UtcDaliActor Test Set up completed \n");
5847
5848   application.ProcessEvent(touchEvent);
5849
5850   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5851   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5852   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5853
5854   ResetTouchCallbacks();
5855
5856   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");
5857
5858   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5859   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5860   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5861   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5862
5863   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5864   application.SendNotification();
5865   application.Render();
5866
5867   application.ProcessEvent(touchEvent); // touch event
5868
5869   glSetUniformStack.Reset();
5870
5871   application.SendNotification();
5872   application.Render();
5873
5874   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5875
5876   // Test order of uniforms in stack
5877   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5878   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5879   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5880
5881   tet_infoline("Testing render order is A, C, B");
5882   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5883   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5884
5885   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5886   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5887   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5888
5889   ResetTouchCallbacks();
5890
5891   tet_printf("Lower actor C below Actor A leaving B on top\n");
5892
5893   orderChangedSignal = false;
5894
5895   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5896   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
5897   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5898   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5899
5900   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5901   application.SendNotification();
5902   application.Render();
5903
5904   application.ProcessEvent(touchEvent);
5905
5906   glSetUniformStack.Reset();
5907
5908   application.Render();
5909   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5910
5911   // Test order of uniforms in stack
5912   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5913   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5914   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5915
5916   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5917   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5918
5919   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5920   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5921   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5922
5923   ResetTouchCallbacks();
5924
5925   tet_printf("Lower actor B below Actor C leaving A on top\n");
5926
5927   orderChangedSignal = false;
5928
5929   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5930   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
5931   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5932   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5933
5934   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5935   application.SendNotification();
5936   application.Render();
5937
5938   application.ProcessEvent(touchEvent);
5939
5940   glSetUniformStack.Reset();
5941
5942   application.Render();
5943   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5944
5945   // Test order of uniforms in stack
5946   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5947   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5948   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5949
5950   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5951   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5952
5953   END_TEST;
5954 }
5955
5956 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5957 {
5958   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5959
5960   TestApplication application;
5961
5962   Integration::Scene stage(application.GetScene());
5963
5964   Actor parentA = Actor::New();
5965   Actor parentB = Actor::New();
5966   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5967   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5968   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5969   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5970
5971   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5972   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5973
5974   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5975   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5976
5977   stage.Add(parentA);
5978   stage.Add(parentB);
5979
5980   Actor actorA = Actor::New();
5981   Actor actorB = Actor::New();
5982   Actor actorC = Actor::New();
5983
5984   parentA.Add(actorA);
5985   parentA.Add(actorB);
5986
5987   tet_printf("Actor C added to different parent from A and B \n");
5988   parentB.Add(actorC);
5989
5990   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5991   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5992
5993   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5994   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5995
5996   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5997   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5998
5999   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6000   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6001
6002   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6003   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6004
6005   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6006   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6007
6008   ResetTouchCallbacks();
6009
6010   // Connect ChildOrderChangedSignal
6011   bool                     orderChangedSignal(false);
6012   Actor                    orderChangedActor;
6013   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6014   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6015
6016   application.SendNotification();
6017   application.Render();
6018
6019   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6020   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6021   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6022
6023   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6024   // Only top actor will get touched.
6025   actorA.TouchedSignal().Connect(TestTouchCallback);
6026   actorB.TouchedSignal().Connect(TestTouchCallback2);
6027   actorC.TouchedSignal().Connect(TestTouchCallback3);
6028
6029   Dali::Integration::Point point;
6030   point.SetDeviceId(1);
6031   point.SetState(PointState::DOWN);
6032   point.SetScreenPosition(Vector2(10.f, 10.f));
6033   Dali::Integration::TouchEvent touchEvent;
6034   touchEvent.AddPoint(point);
6035
6036   application.ProcessEvent(touchEvent);
6037
6038   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6039   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6040   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6041
6042   ResetTouchCallbacks();
6043
6044   tet_printf("Raise actor A Above Actor C which have different parents\n");
6045
6046   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6047   actorA.RaiseAbove(actorC);
6048   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6049
6050   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6051   application.SendNotification();
6052
6053   application.ProcessEvent(touchEvent); // touch event
6054
6055   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6056   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6057   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6058
6059   ResetTouchCallbacks();
6060
6061   END_TEST;
6062 }
6063
6064 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6065 {
6066   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6067
6068   TestApplication application;
6069
6070   Integration::Scene stage(application.GetScene());
6071
6072   Actor actorA = Actor::New();
6073   Actor actorB = Actor::New();
6074   Actor actorC = Actor::New();
6075
6076   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6077   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6078
6079   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6080   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6081
6082   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6083   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6084
6085   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6086   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6087
6088   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6089   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6090
6091   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6092   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6093
6094   ResetTouchCallbacks();
6095
6096   // Connect ChildOrderChangedSignal
6097   bool                     orderChangedSignal(false);
6098   Actor                    orderChangedActor;
6099   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6100   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6101
6102   application.SendNotification();
6103   application.Render();
6104
6105   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6106   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6107   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6108
6109   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6110   // Only top actor will get touched.
6111   actorA.TouchedSignal().Connect(TestTouchCallback);
6112   actorB.TouchedSignal().Connect(TestTouchCallback2);
6113   actorC.TouchedSignal().Connect(TestTouchCallback3);
6114
6115   Dali::Integration::Point point;
6116   point.SetDeviceId(1);
6117   point.SetState(PointState::DOWN);
6118   point.SetScreenPosition(Vector2(10.f, 10.f));
6119   Dali::Integration::TouchEvent touchEvent;
6120   touchEvent.AddPoint(point);
6121
6122   tet_printf("Raise actor A Above Actor C which have no parents\n");
6123
6124   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6125   actorA.RaiseAbove(actorC);
6126   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6127
6128   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6129   application.SendNotification();
6130
6131   application.ProcessEvent(touchEvent);
6132
6133   tet_printf("Not parented so RaiseAbove should show no effect\n");
6134
6135   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6136   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6137   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6138
6139   ResetTouchCallbacks();
6140
6141   orderChangedSignal = false;
6142
6143   stage.Add(actorB);
6144   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6145
6146   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6147   actorA.LowerBelow(actorC);
6148   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6149
6150   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6151   application.SendNotification();
6152   application.Render();
6153
6154   application.ProcessEvent(touchEvent);
6155
6156   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6157   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6158   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6159   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6160
6161   ResetTouchCallbacks();
6162
6163   orderChangedSignal = false;
6164
6165   tet_printf("Adding Actor A to stage, will be on top\n");
6166
6167   stage.Add(actorA);
6168   application.SendNotification();
6169   application.Render();
6170
6171   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6172
6173   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6174   actorB.RaiseAbove(actorC);
6175   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6176
6177   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6178   application.SendNotification();
6179
6180   application.ProcessEvent(touchEvent);
6181
6182   tet_printf("C not parented so RaiseAbove should show no effect\n");
6183   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6184   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6185   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6186
6187   ResetTouchCallbacks();
6188
6189   orderChangedSignal = false;
6190
6191   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6192
6193   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6194   actorA.LowerBelow(actorC);
6195   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6196
6197   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6198   application.SendNotification();
6199
6200   application.ProcessEvent(touchEvent);
6201
6202   tet_printf("C not parented so LowerBelow should show no effect\n");
6203   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6204   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6205   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6206
6207   ResetTouchCallbacks();
6208
6209   orderChangedSignal = false;
6210
6211   stage.Add(actorC);
6212
6213   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6214   actorA.RaiseAbove(actorC);
6215   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6216   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6217
6218   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6219   application.SendNotification();
6220   application.Render();
6221
6222   application.ProcessEvent(touchEvent);
6223
6224   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6225   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6226   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6227   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6228
6229   END_TEST;
6230 }
6231
6232 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6233 {
6234   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6235
6236   TestApplication application;
6237
6238   Integration::Scene stage(application.GetScene());
6239
6240   Actor actorA = Actor::New();
6241   Actor actorB = Actor::New();
6242   Actor actorC = Actor::New();
6243
6244   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6245   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6246
6247   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6248   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6249
6250   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6251   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6252
6253   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6254   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6255
6256   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6257   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6258
6259   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6260   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6261
6262   ResetTouchCallbacks();
6263
6264   // Connect ChildOrderChangedSignal
6265   bool                     orderChangedSignal(false);
6266   Actor                    orderChangedActor;
6267   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6268   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6269
6270   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6271   // Only top actor will get touched.
6272   actorA.TouchedSignal().Connect(TestTouchCallback);
6273   actorB.TouchedSignal().Connect(TestTouchCallback2);
6274   actorC.TouchedSignal().Connect(TestTouchCallback3);
6275
6276   Dali::Integration::Point point;
6277   point.SetDeviceId(1);
6278   point.SetState(PointState::DOWN);
6279   point.SetScreenPosition(Vector2(10.f, 10.f));
6280   Dali::Integration::TouchEvent touchEvent;
6281   touchEvent.AddPoint(point);
6282
6283   stage.Add(actorA);
6284   tet_printf("Raise actor B Above Actor C but B not parented\n");
6285
6286   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6287   actorB.Raise();
6288   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6289
6290   application.SendNotification();
6291   application.Render();
6292
6293   application.ProcessEvent(touchEvent);
6294
6295   tet_printf("Not parented so RaiseAbove should show no effect\n");
6296
6297   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6298   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6299   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6300
6301   tet_printf("Raise actor B Above Actor C but B not parented\n");
6302   ResetTouchCallbacks();
6303
6304   orderChangedSignal = false;
6305
6306   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6307   actorC.Lower();
6308   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6309
6310   // Sort actor tree before next touch event
6311   application.SendNotification();
6312   application.Render();
6313
6314   application.ProcessEvent(touchEvent);
6315
6316   tet_printf("Not parented so RaiseAbove should show no effect\n");
6317
6318   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6319   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6320   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6321   ResetTouchCallbacks();
6322
6323   orderChangedSignal = false;
6324
6325   tet_printf("Lower actor C below B but C not parented\n");
6326
6327   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6328   actorB.Lower();
6329   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6330
6331   // Sort actor tree before next touch event
6332   application.SendNotification();
6333   application.Render();
6334
6335   application.ProcessEvent(touchEvent);
6336
6337   tet_printf("Not parented so Lower should show no effect\n");
6338
6339   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6340   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6341   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6342   ResetTouchCallbacks();
6343
6344   orderChangedSignal = false;
6345
6346   tet_printf("Raise actor B to top\n");
6347
6348   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6349   actorB.RaiseToTop();
6350   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6351
6352   // Sort actor tree before next touch event
6353   application.SendNotification();
6354   application.Render();
6355
6356   application.ProcessEvent(touchEvent);
6357
6358   tet_printf("Not parented so RaiseToTop should show no effect\n");
6359
6360   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6361   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6362   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6363   ResetTouchCallbacks();
6364
6365   orderChangedSignal = false;
6366
6367   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6368
6369   stage.Add(actorB);
6370
6371   tet_printf("Lower actor C to Bottom, B stays at top\n");
6372
6373   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6374   actorC.LowerToBottom();
6375   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6376
6377   application.SendNotification();
6378   application.Render();
6379
6380   application.ProcessEvent(touchEvent);
6381
6382   tet_printf("Not parented so LowerToBottom should show no effect\n");
6383
6384   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6385   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6386   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6387   ResetTouchCallbacks();
6388
6389   END_TEST;
6390 }
6391
6392 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6393 {
6394   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6395
6396   TestApplication application;
6397
6398   Integration::Scene stage(application.GetScene());
6399
6400   Actor actorA = Actor::New();
6401   Actor actorB = Actor::New();
6402   Actor actorC = Actor::New();
6403
6404   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6405   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6406
6407   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6408   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6409
6410   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6411   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6412
6413   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6414   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6415
6416   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6417   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6418
6419   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6420   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6421
6422   stage.Add(actorA);
6423   stage.Add(actorB);
6424   stage.Add(actorC);
6425
6426   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6427   // Only top actor will get touched.
6428   actorA.TouchedSignal().Connect(TestTouchCallback);
6429   actorB.TouchedSignal().Connect(TestTouchCallback2);
6430   actorC.TouchedSignal().Connect(TestTouchCallback3);
6431
6432   ResetTouchCallbacks();
6433
6434   // Connect ChildOrderChangedSignal
6435   bool                     orderChangedSignal(false);
6436   Actor                    orderChangedActor;
6437   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6438   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6439
6440   application.SendNotification();
6441   application.Render();
6442
6443   Dali::Integration::Point point;
6444   point.SetDeviceId(1);
6445   point.SetState(PointState::DOWN);
6446   point.SetScreenPosition(Vector2(10.f, 10.f));
6447   Dali::Integration::TouchEvent touchEvent;
6448   touchEvent.AddPoint(point);
6449
6450   application.ProcessEvent(touchEvent);
6451
6452   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6453   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6454   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6455
6456   ResetTouchCallbacks();
6457
6458   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6459
6460   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6461   actorA.RaiseAbove(actorA);
6462   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6463   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6464
6465   application.SendNotification();
6466   application.Render();
6467
6468   application.ProcessEvent(touchEvent);
6469
6470   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6471
6472   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6473   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6474   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6475
6476   ResetTouchCallbacks();
6477
6478   orderChangedSignal = false;
6479
6480   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6481   actorA.RaiseAbove(actorC);
6482   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6483   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6484
6485   application.SendNotification();
6486   application.Render();
6487
6488   application.ProcessEvent(touchEvent);
6489
6490   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6491   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6492   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6493   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6494
6495   END_TEST;
6496 }
6497
6498 int UtcDaliActorGetScreenPosition(void)
6499 {
6500   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6501
6502   TestApplication application;
6503
6504   Integration::Scene stage(application.GetScene());
6505
6506   Actor actorA = Actor::New();
6507   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6508
6509   Vector2 size2(10.0f, 20.0f);
6510   actorA.SetProperty(Actor::Property::SIZE, size2);
6511
6512   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6513
6514   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6515
6516   stage.Add(actorA);
6517
6518   application.SendNotification();
6519   application.Render();
6520
6521   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6522   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6523
6524   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6525   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6526
6527   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6528   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6529
6530   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6531
6532   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6533
6534   application.SendNotification();
6535   application.Render();
6536
6537   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6538   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6539
6540   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6541   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6542
6543   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6544   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6545
6546   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6547
6548   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6549
6550   application.SendNotification();
6551   application.Render();
6552
6553   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6554   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6555
6556   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
6557   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
6558
6559   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6560   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6561
6562   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6563
6564   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6565
6566   application.SendNotification();
6567   application.Render();
6568
6569   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6570   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6571
6572   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6573   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
6574
6575   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6576   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6577
6578   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6579
6580   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6581
6582   application.SendNotification();
6583   application.Render();
6584
6585   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6586   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6587
6588   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6589   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6590
6591   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6592   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6593
6594   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6595
6596   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6597   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6598
6599   Actor actorB = Actor::New();
6600   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6601   actorB.SetProperty(Actor::Property::SIZE, size2);
6602   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6603   actorA.Add(actorB);
6604
6605   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6606
6607   application.SendNotification();
6608   application.Render();
6609
6610   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6611
6612   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6613   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6614
6615   END_TEST;
6616 }
6617
6618 int UtcDaliActorGetScreenPositionAfterScaling(void)
6619 {
6620   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6621
6622   TestApplication application;
6623
6624   Integration::Scene stage(application.GetScene());
6625
6626   Actor actorA = Actor::New();
6627   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6628
6629   Vector2 size2(10.0f, 20.0f);
6630   actorA.SetProperty(Actor::Property::SIZE, size2);
6631   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6632   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6633
6634   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6635
6636   stage.Add(actorA);
6637
6638   application.SendNotification();
6639   application.Render();
6640
6641   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6642   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6643
6644   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6645   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6646
6647   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6648   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6649
6650   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6651
6652   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6653
6654   application.SendNotification();
6655   application.Render();
6656
6657   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6658   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6659
6660   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6661   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6662
6663   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6664   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6665
6666   END_TEST;
6667 }
6668
6669 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6670 {
6671   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6672
6673   TestApplication application;
6674
6675   Integration::Scene stage(application.GetScene());
6676
6677   Actor actorA = Actor::New();
6678   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6679   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6680   Vector2 size2(10.0f, 20.0f);
6681   actorA.SetProperty(Actor::Property::SIZE, size2);
6682   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6683
6684   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6685
6686   stage.Add(actorA);
6687
6688   application.SendNotification();
6689   application.Render();
6690
6691   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6692   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6693
6694   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6695   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6696
6697   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6698   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6699
6700   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6701
6702   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6703   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6704
6705   application.SendNotification();
6706   application.Render();
6707
6708   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6709   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6710
6711   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6712   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6713
6714   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6715   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6716
6717   END_TEST;
6718   END_TEST;
6719 }
6720
6721 int UtcDaliActorGetScreenPositionWithChildActors(void)
6722 {
6723   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6724
6725   TestApplication application;
6726
6727   Integration::Scene stage(application.GetScene());
6728
6729   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6730
6731   Actor actorA = Actor::New();
6732   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6733   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6734   Vector2 size1(10.0f, 20.0f);
6735   actorA.SetProperty(Actor::Property::SIZE, size1);
6736   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6737
6738   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6739
6740   Actor parentActorA = Actor::New();
6741   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6742   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6743   Vector2 size2(30.0f, 60.0f);
6744   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6745   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6746
6747   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6748
6749   stage.Add(parentActorA);
6750   parentActorA.Add(actorA);
6751
6752   application.SendNotification();
6753   application.Render();
6754
6755   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6756   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6757
6758   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6759   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6760
6761   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6762   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6763
6764   tet_infoline("Test 2\n");
6765
6766   tet_infoline("change parent anchor point and parent origin then check screen position \n");
6767
6768   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6769   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6770
6771   application.SendNotification();
6772   application.Render();
6773
6774   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6775   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6776
6777   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6778   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6779
6780   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6781   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6782
6783   END_TEST;
6784 }
6785
6786 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6787 {
6788   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6789
6790   TestApplication application;
6791
6792   Integration::Scene stage(application.GetScene());
6793
6794   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6795
6796   Actor actorA = Actor::New();
6797   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6798   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6799   Vector2 size1(10.0f, 20.0f);
6800   actorA.SetProperty(Actor::Property::SIZE, size1);
6801   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6802
6803   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6804
6805   Actor parentActorA = Actor::New();
6806   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6807   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6808   Vector2 size2(30.0f, 60.0f);
6809   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6810   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6811
6812   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6813
6814   Actor grandParentActorA = Actor::New();
6815   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6816   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6817   Vector2 size3(60.0f, 120.0f);
6818   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6819   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6820
6821   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6822
6823   stage.Add(grandParentActorA);
6824   grandParentActorA.Add(parentActorA);
6825
6826   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6827
6828   parentActorA.Add(actorA);
6829
6830   application.SendNotification();
6831   application.Render();
6832
6833   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6834   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6835
6836   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6837   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6838
6839   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6840   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6841
6842   END_TEST;
6843 }
6844
6845 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6846 {
6847   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6848
6849   TestApplication application;
6850
6851   Integration::Scene stage(application.GetScene());
6852
6853   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6854
6855   Actor actorA = Actor::New();
6856   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6857   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6858   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6859   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6860   stage.Add(actorA);
6861
6862   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6863
6864   Actor actorB = Actor::New();
6865   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6866   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6867   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6868   Vector2 actorBSize(30.0f, 60.0f);
6869   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6870   stage.Add(actorB);
6871
6872   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6873
6874   Actor actorC = Actor::New();
6875   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6876   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6877   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6878   Vector2 actorCSize(60.0f, 120.0f);
6879   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6880   stage.Add(actorC);
6881
6882   application.SendNotification();
6883   application.Render();
6884
6885   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6886
6887   Vector2 center(stage.GetSize() * 0.5f);
6888
6889   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6890   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6891   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6892
6893   tet_infoline("Add scale to all actors");
6894
6895   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6896   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6897   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6898
6899   application.SendNotification();
6900   application.Render();
6901
6902   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6903   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6904   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6905
6906   END_TEST;
6907 }
6908
6909 int utcDaliActorPositionUsesAnchorPoint(void)
6910 {
6911   TestApplication application;
6912   tet_infoline("Check default behaviour\n");
6913
6914   Actor actor = Actor::New();
6915   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6916   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6917   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6918   application.GetScene().Add(actor);
6919
6920   application.SendNotification();
6921   application.Render();
6922
6923   tet_infoline("Check that the world position is in the center\n");
6924   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6925
6926   tet_infoline("Set the position uses anchor point property to false\n");
6927   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6928
6929   application.SendNotification();
6930   application.Render();
6931
6932   tet_infoline("Check that the world position has changed appropriately\n");
6933   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6934
6935   END_TEST;
6936 }
6937
6938 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6939 {
6940   TestApplication application;
6941   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6942
6943   Actor actor = Actor::New();
6944   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6945   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6946   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6947   actor.SetProperty(Actor::Property::SCALE, 2.0f);
6948   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6949   application.GetScene().Add(actor);
6950
6951   application.SendNotification();
6952   application.Render();
6953
6954   tet_infoline("Check the world position is the same as it would be without a scale\n");
6955   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6956
6957   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6958   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6959   application.SendNotification();
6960   application.Render();
6961   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6962
6963   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6964   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6965   application.SendNotification();
6966   application.Render();
6967   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6968
6969   END_TEST;
6970 }
6971
6972 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6973 {
6974   TestApplication application;
6975   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6976
6977   Actor actor = Actor::New();
6978   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6979   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6980   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6981   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6982   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6983   application.GetScene().Add(actor);
6984
6985   application.SendNotification();
6986   application.Render();
6987
6988   tet_infoline("Check the world position is the same as it would be without a rotation\n");
6989   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6990
6991   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6992   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6993   application.SendNotification();
6994   application.Render();
6995   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6996
6997   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6998   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6999   application.SendNotification();
7000   application.Render();
7001   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7002
7003   END_TEST;
7004 }
7005
7006 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7007 {
7008   TestApplication application;
7009   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7010
7011   Actor actor = Actor::New();
7012   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7013   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7014   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7015   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7016   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7017   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7018   application.GetScene().Add(actor);
7019
7020   application.SendNotification();
7021   application.Render();
7022
7023   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7024   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7025
7026   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7027   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7028   application.SendNotification();
7029   application.Render();
7030   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7031
7032   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7033   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7034   application.SendNotification();
7035   application.Render();
7036   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7037
7038   END_TEST;
7039 }
7040
7041 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7042 {
7043   TestApplication application;
7044   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7045
7046   Actor parent = Actor::New();
7047
7048   application.GetScene().Add(parent);
7049   Vector2 stageSize(application.GetScene().GetSize());
7050
7051   Actor actor = Actor::New();
7052   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7053   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7054   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7055   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7056   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7057   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7058   parent.Add(actor);
7059
7060   application.SendNotification();
7061   application.Render();
7062
7063   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7064
7065   tet_infoline("Check the world position is in the right place\n");
7066   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7067
7068   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7069   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7070   application.SendNotification();
7071   application.Render();
7072   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7073
7074   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7075   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7076   application.SendNotification();
7077   application.Render();
7078   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7079
7080   END_TEST;
7081 }
7082
7083 int utcDaliActorVisibilityChangeSignalSelf(void)
7084 {
7085   TestApplication application;
7086   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7087
7088   Actor actor = Actor::New();
7089
7090   VisibilityChangedFunctorData data;
7091   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7092
7093   actor.SetProperty(Actor::Property::VISIBLE, false);
7094
7095   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7096
7097   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7098   data.Reset();
7099
7100   actor.SetProperty(Actor::Property::VISIBLE, false);
7101   data.Check(false /* not called */, TEST_LOCATION);
7102
7103   tet_infoline("Change the visibility using properties, ensure called");
7104   data.Reset();
7105
7106   actor.SetProperty(Actor::Property::VISIBLE, true);
7107   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7108
7109   tet_infoline("Set the visibility to current using properties, ensure not called");
7110   data.Reset();
7111
7112   actor.SetProperty(Actor::Property::VISIBLE, true);
7113   data.Check(false /* not called */, TEST_LOCATION);
7114
7115   END_TEST;
7116 }
7117
7118 int utcDaliActorVisibilityChangeSignalChildren(void)
7119 {
7120   TestApplication application;
7121   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7122
7123   Actor parent = Actor::New();
7124   Actor child  = Actor::New();
7125   parent.Add(child);
7126
7127   Actor grandChild = Actor::New();
7128   child.Add(grandChild);
7129
7130   VisibilityChangedFunctorData parentData;
7131   VisibilityChangedFunctorData childData;
7132   VisibilityChangedFunctorData grandChildData;
7133
7134   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7135   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7136   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7137
7138   parent.SetProperty(Actor::Property::VISIBLE, false);
7139   parentData.Check(false /* not called */, TEST_LOCATION);
7140   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7141   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7142
7143   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7144   parentData.Reset();
7145   childData.Reset();
7146   grandChildData.Reset();
7147
7148   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7149
7150   parent.SetProperty(Actor::Property::VISIBLE, true);
7151   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7152   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7153   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7154
7155   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7156   parentData.Reset();
7157   childData.Reset();
7158   grandChildData.Reset();
7159
7160   parent.SetProperty(Actor::Property::VISIBLE, true);
7161   parentData.Check(false /* not called */, TEST_LOCATION);
7162   childData.Check(false /* not called */, TEST_LOCATION);
7163   grandChildData.Check(false /* not called */, TEST_LOCATION);
7164
7165   END_TEST;
7166 }
7167
7168 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7169 {
7170   TestApplication application;
7171   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7172
7173   Actor actor = Actor::New();
7174   application.GetScene().Add(actor);
7175
7176   application.SendNotification();
7177   application.Render();
7178
7179   VisibilityChangedFunctorData data;
7180   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7181
7182   Animation animation = Animation::New(1.0f);
7183   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7184
7185   data.Check(false, TEST_LOCATION);
7186   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7187   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7188
7189   tet_infoline("Play the animation and check the property value");
7190   animation.Play();
7191
7192   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7193   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7194
7195   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7196   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7197
7198   application.SendNotification();
7199   application.Render(1100); // After the animation
7200
7201   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7202
7203   END_TEST;
7204 }
7205
7206 int utcDaliActorVisibilityChangeSignalByName(void)
7207 {
7208   TestApplication application;
7209   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7210
7211   Actor actor = Actor::New();
7212
7213   bool signalCalled = false;
7214   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7215   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7216   actor.SetProperty(Actor::Property::VISIBLE, false);
7217   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7218
7219   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7220   signalCalled = false;
7221   actor.SetProperty(Actor::Property::VISIBLE, false);
7222   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7223
7224   tet_infoline("Change the visibility using properties, ensure called");
7225   actor.SetProperty(Actor::Property::VISIBLE, true);
7226   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7227
7228   tet_infoline("Set the visibility to current using properties, ensure not called");
7229   signalCalled = false;
7230
7231   actor.SetProperty(Actor::Property::VISIBLE, true);
7232   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7233
7234   END_TEST;
7235 }
7236
7237 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7238 {
7239   gLayoutDirectionType = type;
7240 }
7241
7242 int UtcDaliActorLayoutDirectionProperty(void)
7243 {
7244   TestApplication application;
7245   tet_infoline("Check layout direction property");
7246
7247   Actor actor0 = Actor::New();
7248   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7249   application.GetScene().Add(actor0);
7250
7251   application.SendNotification();
7252   application.Render();
7253
7254   Actor actor1 = Actor::New();
7255   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7256   Actor actor2 = Actor::New();
7257   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7258   Actor actor3 = Actor::New();
7259   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7260   Actor actor4 = Actor::New();
7261   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7262   Actor actor5 = Actor::New();
7263   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7264   Actor actor6 = Actor::New();
7265   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7266   Actor actor7 = Actor::New();
7267   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7268   Actor actor8 = Actor::New();
7269   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7270   Actor actor9 = Actor::New();
7271   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7272
7273   actor1.Add(actor2);
7274   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7275   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7276
7277   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7278   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7279   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7280
7281   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7282   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7283   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7284
7285   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7286   actor0.Add(actor1);
7287   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7288   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7289
7290   application.GetScene().Add(actor3);
7291   actor3.Add(actor4);
7292   actor4.Add(actor5);
7293   actor5.Add(actor6);
7294   actor5.Add(actor7);
7295   actor7.Add(actor8);
7296   actor8.Add(actor9);
7297   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7298   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7299
7300   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7301   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7302   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7303
7304   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7305
7306   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7307   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7308   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7309   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7310   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7311   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7312   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7313
7314   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7315   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7316   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7317
7318   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7319   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7320   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7321   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7322
7323   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7324   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7325   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7326
7327   END_TEST;
7328 }
7329
7330 struct LayoutDirectionFunctor
7331 {
7332   LayoutDirectionFunctor(bool& signalCalled)
7333   : mSignalCalled(signalCalled)
7334   {
7335   }
7336
7337   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7338   : mSignalCalled(rhs.mSignalCalled)
7339   {
7340   }
7341
7342   void operator()()
7343   {
7344     mSignalCalled = true;
7345   }
7346
7347   bool& mSignalCalled;
7348 };
7349
7350 int UtcDaliActorLayoutDirectionSignal(void)
7351 {
7352   TestApplication application;
7353   tet_infoline("Check changing layout direction property sends a signal");
7354
7355   Actor actor = Actor::New();
7356   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7357   application.GetScene().Add(actor);
7358   bool                   signalCalled = false;
7359   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7360
7361   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7362   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7363
7364   // Test that writing the same value doesn't send a signal
7365   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7366   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7367
7368   // Test that writing a different value sends the signal
7369   signalCalled = false;
7370   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7371   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7372
7373   signalCalled = false;
7374   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7375   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7376
7377   END_TEST;
7378 }
7379
7380 struct ChildAddedSignalCheck
7381 {
7382   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7383   : mSignalReceived(signalReceived),
7384     mChildHandle(childHandle)
7385   {
7386   }
7387
7388   void operator()(Actor childHandle)
7389   {
7390     mSignalReceived = true;
7391     mChildHandle    = childHandle;
7392   }
7393   void operator()()
7394   {
7395     mSignalReceived = true;
7396     mChildHandle    = Actor();
7397   }
7398
7399   bool&  mSignalReceived;
7400   Actor& mChildHandle;
7401 };
7402
7403 int UtcDaliChildAddedSignalP1(void)
7404 {
7405   TestApplication application;
7406   auto            stage = application.GetScene();
7407
7408   bool  signalReceived = false;
7409   Actor childActor;
7410
7411   ChildAddedSignalCheck signal(signalReceived, childActor);
7412   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7413   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7414
7415   auto actorA = Actor::New();
7416   stage.Add(actorA);
7417   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7418   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7419   signalReceived = false;
7420
7421   auto actorB = Actor::New();
7422   stage.Add(actorB);
7423   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7424   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7425
7426   END_TEST;
7427 }
7428
7429 int UtcDaliChildAddedSignalP2(void)
7430 {
7431   TestApplication application;
7432   auto            stage = application.GetScene();
7433
7434   bool  signalReceived = false;
7435   Actor childActor;
7436
7437   ChildAddedSignalCheck signal(signalReceived, childActor);
7438   tet_infoline("Connect to childAdded signal by name");
7439
7440   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7441   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7442
7443   auto actorA = Actor::New();
7444   stage.Add(actorA);
7445   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7446
7447   // Can't test which actor was added; signal signature is void() when connecting via name.
7448   signalReceived = false;
7449
7450   auto actorB = Actor::New();
7451   stage.Add(actorB);
7452   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7453
7454   END_TEST;
7455 }
7456
7457 int UtcDaliChildAddedSignalN(void)
7458 {
7459   TestApplication application;
7460   auto            stage = application.GetScene();
7461
7462   bool  signalReceived = false;
7463   Actor childActor;
7464
7465   ChildAddedSignalCheck signal(signalReceived, childActor);
7466   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7467   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7468
7469   auto actorA = Actor::New();
7470   stage.Add(actorA);
7471   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7472   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7473   signalReceived = false;
7474
7475   auto actorB = Actor::New();
7476   actorA.Add(actorB);
7477   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7478   END_TEST;
7479 }
7480
7481 struct ChildRemovedSignalCheck
7482 {
7483   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7484   : mSignalReceived(signalReceived),
7485     mChildHandle(childHandle)
7486   {
7487   }
7488
7489   void operator()(Actor childHandle)
7490   {
7491     mSignalReceived = true;
7492     mChildHandle    = childHandle;
7493   }
7494
7495   void operator()()
7496   {
7497     mSignalReceived = true;
7498   }
7499
7500   bool&  mSignalReceived;
7501   Actor& mChildHandle;
7502 };
7503
7504 int UtcDaliChildRemovedSignalP1(void)
7505 {
7506   TestApplication application;
7507   auto            stage = application.GetScene();
7508
7509   bool  signalReceived = false;
7510   Actor childActor;
7511
7512   ChildRemovedSignalCheck signal(signalReceived, childActor);
7513   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7514   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7515
7516   auto actorA = Actor::New();
7517   stage.Add(actorA);
7518   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7519   DALI_TEST_CHECK(!childActor);
7520
7521   stage.Remove(actorA);
7522   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7523   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7524
7525   signalReceived = false;
7526   auto actorB    = Actor::New();
7527   stage.Add(actorB);
7528   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7529
7530   stage.Remove(actorB);
7531   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7532   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7533
7534   END_TEST;
7535 }
7536
7537 int UtcDaliChildRemovedSignalP2(void)
7538 {
7539   TestApplication application;
7540   auto            stage = application.GetScene();
7541
7542   bool  signalReceived = false;
7543   Actor childActor;
7544
7545   ChildAddedSignalCheck signal(signalReceived, childActor);
7546   tet_infoline("Connect to childRemoved signal by name");
7547
7548   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7549   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7550
7551   auto actorA = Actor::New();
7552   stage.Add(actorA);
7553   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7554
7555   stage.Remove(actorA);
7556   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7557
7558   signalReceived = false;
7559   auto actorB    = Actor::New();
7560   stage.Add(actorB);
7561   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7562
7563   stage.Remove(actorB);
7564   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7565
7566   END_TEST;
7567 }
7568
7569 int UtcDaliChildRemovedSignalN(void)
7570 {
7571   TestApplication application;
7572   auto            stage = application.GetScene();
7573
7574   bool  signalReceived = false;
7575   Actor childActor;
7576
7577   ChildRemovedSignalCheck signal(signalReceived, childActor);
7578   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7579   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7580
7581   auto actorA = Actor::New();
7582   stage.Add(actorA);
7583
7584   auto actorB = Actor::New();
7585   actorA.Add(actorB);
7586
7587   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7588   DALI_TEST_CHECK(!childActor);
7589
7590   actorA.Remove(actorB);
7591   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7592   END_TEST;
7593 }
7594
7595 int UtcDaliChildMovedSignalP(void)
7596 {
7597   TestApplication application;
7598   auto            stage = application.GetScene();
7599
7600   bool  addedASignalReceived   = false;
7601   bool  removedASignalReceived = false;
7602   bool  addedBSignalReceived   = false;
7603   bool  removedBSignalReceived = false;
7604   Actor childActor;
7605
7606   auto actorA = Actor::New();
7607   auto actorB = Actor::New();
7608   stage.Add(actorA);
7609   stage.Add(actorB);
7610
7611   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
7612   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7613   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
7614   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7615
7616   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7617   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7618   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7619   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7620
7621   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7622   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7623   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7624   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7625
7626   // Create a child of A
7627
7628   auto child = Actor::New();
7629   actorA.Add(child);
7630
7631   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7632   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7633   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7634   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7635   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7636
7637   // Move child to B:
7638   addedASignalReceived   = false;
7639   addedBSignalReceived   = false;
7640   removedASignalReceived = false;
7641   removedBSignalReceived = false;
7642
7643   actorB.Add(child); // Expect this child to be re-parented
7644   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7645   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7646   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7647   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7648
7649   // Move child back to A:
7650   addedASignalReceived   = false;
7651   addedBSignalReceived   = false;
7652   removedASignalReceived = false;
7653   removedBSignalReceived = false;
7654
7655   actorA.Add(child); // Expect this child to be re-parented
7656   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7657   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7658   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7659   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7660
7661   END_TEST;
7662 }
7663
7664 int utcDaliActorCulled(void)
7665 {
7666   TestApplication application;
7667   auto            stage = application.GetScene();
7668
7669   tet_infoline("Check that the actor is culled if the actor is out of the screen");
7670
7671   Actor actor = Actor::New();
7672   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7673
7674   Geometry geometry = CreateQuadGeometry();
7675   Shader   shader   = CreateShader();
7676   Renderer renderer = Renderer::New(geometry, shader);
7677   actor.AddRenderer(renderer);
7678
7679   stage.Add(actor);
7680
7681   application.SendNotification();
7682   application.Render(0);
7683
7684   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7685
7686   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7687   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7688
7689   // Connect NotifySignal
7690   bool                              propertyNotificationSignal(false);
7691   PropertyNotification              source;
7692   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7693   notification.NotifySignal().Connect(&application, f);
7694
7695   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7696
7697   application.SendNotification();
7698   application.Render();
7699
7700   application.SendNotification();
7701
7702   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7703
7704   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7705   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7706   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7707
7708   END_TEST;
7709 }
7710
7711 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7712 {
7713   TestApplication application;
7714   auto            stage = application.GetScene();
7715
7716   tet_infoline("Ensure we clear the screen when the last actor is removed");
7717
7718   Actor actor = CreateRenderableActor();
7719   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7720   stage.Add(actor);
7721
7722   application.SendNotification();
7723   application.Render();
7724
7725   auto&      glAbstraction    = application.GetGlAbstraction();
7726   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7727
7728   actor.Unparent();
7729
7730   application.SendNotification();
7731   application.Render();
7732
7733   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7734
7735   END_TEST;
7736 }
7737
7738 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7739 {
7740   TestApplication application;
7741   auto            stage = application.GetScene();
7742
7743   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7744
7745   Actor actor = CreateRenderableActor();
7746   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7747   stage.Add(actor);
7748
7749   application.SendNotification();
7750   application.Render();
7751
7752   auto&      glAbstraction    = application.GetGlAbstraction();
7753   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7754
7755   actor.SetProperty(Actor::Property::VISIBLE, false);
7756
7757   application.SendNotification();
7758   application.Render();
7759
7760   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7761
7762   END_TEST;
7763 }
7764
7765 int utcDaliActorGetSizeAfterAnimation(void)
7766 {
7767   TestApplication application;
7768   tet_infoline("Check the actor size before / after an animation is finished");
7769
7770   Vector3 actorSize(100.0f, 100.0f, 0.0f);
7771
7772   Actor actor = Actor::New();
7773   actor.SetProperty(Actor::Property::SIZE, actorSize);
7774   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7775   application.GetScene().Add(actor);
7776
7777   // Size should be updated without rendering.
7778   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7779   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7780
7781   application.SendNotification();
7782   application.Render();
7783
7784   // Size and current size should be updated.
7785   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7786   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7787   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7788   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7789   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7790
7791   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7792   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7793   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7794   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7795   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7796
7797   // Set size again
7798   actorSize = Vector3(200.0f, 200.0f, 0.0f);
7799   actor.SetProperty(Actor::Property::SIZE, actorSize);
7800
7801   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7802   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7803
7804   Vector3 targetValue(10.0f, 20.0f, 0.0f);
7805
7806   Animation animation = Animation::New(1.0f);
7807   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7808   animation.Play();
7809
7810   // Size should be updated without rendering.
7811   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7812   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7813
7814   application.SendNotification();
7815   application.Render(1100); // After the animation
7816
7817   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7818   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7819   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7820   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7821   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7822
7823   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7824   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7825   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7826   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7827   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7828
7829   targetValue.width = 50.0f;
7830
7831   animation.Clear();
7832   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7833   animation.Play();
7834
7835   application.SendNotification();
7836   application.Render(1100); // After the animation
7837
7838   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7839   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7840   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7841   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7842   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7843
7844   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7845   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7846   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7847   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7848   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7849
7850   targetValue.height = 70.0f;
7851
7852   animation.Clear();
7853   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7854   animation.Play();
7855
7856   application.SendNotification();
7857   application.Render(1100); // After the animation
7858
7859   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7860   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7861   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7862   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7863   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7864
7865   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7866   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7867   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7868   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7869   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7870
7871   Vector3 offset(10.0f, 20.0f, 0.0f);
7872
7873   animation.Clear();
7874   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7875   animation.Play();
7876
7877   application.SendNotification();
7878   application.Render(1100); // After the animation
7879
7880   targetValue += offset;
7881
7882   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7883   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7884   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7885   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7886   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7887
7888   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7889   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7890   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7891   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7892   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7893
7894   offset.width = 20.0f;
7895
7896   animation.Clear();
7897   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7898   animation.Play();
7899
7900   application.SendNotification();
7901   application.Render(1100); // After the animation
7902
7903   targetValue.width += offset.width;
7904
7905   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7906   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7907   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7908   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7909   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7910
7911   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7912   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7913   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7914   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7915   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7916
7917   offset.height = 10.0f;
7918
7919   animation.Clear();
7920   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7921   animation.Play();
7922
7923   application.SendNotification();
7924   application.Render(1100); // After the animation
7925
7926   targetValue.height += offset.height;
7927
7928   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7929   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7930   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7931   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7932   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7933
7934   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7935   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7936   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7937   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7938   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7939
7940   // Set size again
7941   actorSize = Vector3(300.0f, 300.0f, 0.0f);
7942
7943   actor.SetProperty(Actor::Property::SIZE, actorSize);
7944
7945   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7946   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7947
7948   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7949   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7950
7951   application.SendNotification();
7952   application.Render();
7953
7954   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7955   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7956
7957   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7958   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7959
7960   END_TEST;
7961 }
7962
7963 int utcDaliActorPartialUpdate(void)
7964 {
7965   TestApplication application(
7966     TestApplication::DEFAULT_SURFACE_WIDTH,
7967     TestApplication::DEFAULT_SURFACE_HEIGHT,
7968     TestApplication::DEFAULT_HORIZONTAL_DPI,
7969     TestApplication::DEFAULT_VERTICAL_DPI,
7970     true,
7971     true);
7972
7973   tet_infoline("Check the damaged area");
7974
7975   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7976
7977   std::vector<Rect<int>> damagedRects;
7978   Rect<int>              clippingRect;
7979   application.SendNotification();
7980   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7981
7982   // First render pass, nothing to render, adaptor would just do swap buffer.
7983   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7984   application.RenderWithPartialUpdate(damagedRects, clippingRect);
7985
7986   Actor actor = CreateRenderableActor();
7987   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7988   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7989   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7990   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7991   application.GetScene().Add(actor);
7992
7993   application.SendNotification();
7994
7995   // 1. Actor added, damaged rect is added size of actor
7996   damagedRects.clear();
7997   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7998   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7999
8000   // Aligned by 16
8001   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8002   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8003   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8004   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8005   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8006   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8007   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8008
8009   // 2. Set new size
8010   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8011   application.SendNotification();
8012
8013   damagedRects.clear();
8014   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8015   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8016
8017   // Aligned by 16
8018   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8019   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8020   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8021   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8022   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8023   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8024   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8025
8026   // 3. Set new position
8027   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8028   application.SendNotification();
8029
8030   damagedRects.clear();
8031   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8032   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8033
8034   // Aligned by 16
8035   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8036   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8037   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8038   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8039   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8040   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8041   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8042
8043   application.GetScene().Remove(actor);
8044   application.SendNotification();
8045
8046   // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8047   damagedRects.clear();
8048   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8049   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8050
8051   clippingRect = damagedRects[0];
8052   clippingRect.Merge(damagedRects[1]);
8053   clippingRect.Merge(damagedRects[2]);
8054
8055   DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8056   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8057   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8058
8059   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8060   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8061   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8062   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8063   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8064
8065   END_TEST;
8066 }
8067
8068 int utcDaliActorPartialUpdateSetColor(void)
8069 {
8070   TestApplication application(
8071     TestApplication::DEFAULT_SURFACE_WIDTH,
8072     TestApplication::DEFAULT_SURFACE_HEIGHT,
8073     TestApplication::DEFAULT_HORIZONTAL_DPI,
8074     TestApplication::DEFAULT_VERTICAL_DPI,
8075     true,
8076     true);
8077
8078   tet_infoline("Check uniform update");
8079
8080   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8081
8082   std::vector<Rect<int>> damagedRects;
8083   Rect<int>              clippingRect;
8084   application.SendNotification();
8085   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8086
8087   // First render pass, nothing to render, adaptor would just do swap buffer.
8088   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8089   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8090
8091   Actor actor = CreateRenderableActor();
8092   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8093   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8094   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8095   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8096   application.GetScene().Add(actor);
8097
8098   application.SendNotification();
8099
8100   // 1. Actor added, damaged rect is added size of actor
8101   damagedRects.clear();
8102   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8103   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8104
8105   // Aligned by 16
8106   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8107   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8108   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8109   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8110   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8111   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8112   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8113
8114   damagedRects.clear();
8115   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8116
8117   damagedRects.clear();
8118   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8119
8120   // 2. Set new color
8121   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8122   application.SendNotification();
8123
8124   damagedRects.clear();
8125   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8126   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8127
8128   // Aligned by 16
8129   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8130   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8131   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8132   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8133   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8134   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8135   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8136
8137   END_TEST;
8138 }
8139
8140 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8141 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8142 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8143 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8144   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8145   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8146   "\n"
8147   "void main()\n"
8148   "{\n"
8149   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8150   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8151   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8152   "}\n";
8153
8154 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8155   "uniform lowp vec4 uShadowColor;\n"
8156   "void main()\n"
8157   "{\n"
8158   "  lowp float alpha;\n"
8159   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8160   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8161   "}\n";
8162
8163 int utcDaliActorPartialUpdateSetProperty(void)
8164 {
8165   TestApplication application(
8166     TestApplication::DEFAULT_SURFACE_WIDTH,
8167     TestApplication::DEFAULT_SURFACE_HEIGHT,
8168     TestApplication::DEFAULT_HORIZONTAL_DPI,
8169     TestApplication::DEFAULT_VERTICAL_DPI,
8170     true,
8171     true);
8172
8173   tet_infoline("Set/Update property with partial update");
8174
8175   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8176
8177   std::vector<Rect<int>> damagedRects;
8178   Rect<int>              clippingRect;
8179   application.SendNotification();
8180   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8181
8182   // First render pass, nothing to render, adaptor would just do swap buffer.
8183   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8184   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8185
8186   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8187   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8188   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8189   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8190   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8191   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8192   application.GetScene().Add(actor);
8193
8194   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8195
8196   damagedRects.clear();
8197   application.SendNotification();
8198   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8199   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8200
8201   // Aligned by 16
8202   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8203   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8204   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8205   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8206   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8207   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8208   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8209
8210   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8211   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8212
8213   damagedRects.clear();
8214   application.SendNotification();
8215   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8216   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8217
8218   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8219   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8220   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8221   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8222   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8223   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8224
8225   // Should be no damage rects, nothing changed
8226   damagedRects.clear();
8227   application.SendNotification();
8228   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8229   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8230
8231   // Should be 1 damage rect due to change in size
8232   damagedRects.clear();
8233   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8234   application.SendNotification();
8235   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8236   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8237
8238   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8239   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8240   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8241   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8242   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8243   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8244   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8245
8246   damagedRects.clear();
8247   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8248   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8249
8250   END_TEST;
8251 }
8252
8253 int utcDaliActorPartialUpdateTwoActors(void)
8254 {
8255   TestApplication application(
8256     TestApplication::DEFAULT_SURFACE_WIDTH,
8257     TestApplication::DEFAULT_SURFACE_HEIGHT,
8258     TestApplication::DEFAULT_HORIZONTAL_DPI,
8259     TestApplication::DEFAULT_VERTICAL_DPI,
8260     true,
8261     true);
8262
8263   tet_infoline("Check the damaged rects with partial update and two actors");
8264
8265   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8266
8267   Actor actor = CreateRenderableActor();
8268   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8269   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8270   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8271   application.GetScene().Add(actor);
8272
8273   Actor actor2 = CreateRenderableActor();
8274   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8275   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8276   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8277   application.GetScene().Add(actor2);
8278
8279   application.SendNotification();
8280   std::vector<Rect<int>> damagedRects;
8281   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8282
8283   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8284   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8285   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8286
8287   // in screen coordinates, adaptor would calculate it using previous frames information
8288   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8289   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8290
8291   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8292   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8293   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8294   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8295
8296   END_TEST;
8297 }
8298
8299 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8300 {
8301   TestApplication application(
8302     TestApplication::DEFAULT_SURFACE_WIDTH,
8303     TestApplication::DEFAULT_SURFACE_HEIGHT,
8304     TestApplication::DEFAULT_HORIZONTAL_DPI,
8305     TestApplication::DEFAULT_VERTICAL_DPI,
8306     true,
8307     true);
8308
8309   tet_infoline("Check the damaged rect with partial update and actor size hint");
8310
8311   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8312
8313   Actor actor = CreateRenderableActor();
8314   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8315   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8316   actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8317   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8318   application.GetScene().Add(actor);
8319
8320   application.SendNotification();
8321   std::vector<Rect<int>> damagedRects;
8322   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8323
8324   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8325
8326   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8327   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8328
8329   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8330
8331   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8332   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8333   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8334   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8335
8336   END_TEST;
8337 }
8338
8339 int utcDaliActorPartialUpdateAnimation(void)
8340 {
8341   TestApplication application(
8342     TestApplication::DEFAULT_SURFACE_WIDTH,
8343     TestApplication::DEFAULT_SURFACE_HEIGHT,
8344     TestApplication::DEFAULT_HORIZONTAL_DPI,
8345     TestApplication::DEFAULT_VERTICAL_DPI,
8346     true,
8347     true);
8348
8349   tet_infoline("Check the damaged area with partial update and animation");
8350
8351   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8352   drawTrace.Enable(true);
8353   drawTrace.Reset();
8354
8355   Actor actor1 = CreateRenderableActor();
8356   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8357   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8358   application.GetScene().Add(actor1);
8359
8360   Actor actor2 = CreateRenderableActor();
8361   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8362   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8363   application.GetScene().Add(actor2);
8364
8365   std::vector<Rect<int>> damagedRects;
8366   Rect<int>              clippingRect;
8367   Rect<int>              expectedRect1, expectedRect2;
8368
8369   application.SendNotification();
8370   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8371
8372   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8373
8374   // Aligned by 16
8375   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8376   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8377   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8378   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8379
8380   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8381
8382   damagedRects.clear();
8383   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8384   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8385
8386   // Make an animation
8387   Animation animation = Animation::New(1.0f);
8388   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8389   animation.Play();
8390
8391   application.SendNotification();
8392
8393   damagedRects.clear();
8394   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8395   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8396
8397   drawTrace.Reset();
8398   damagedRects.clear();
8399
8400   // In animation deley time
8401   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8402   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8403
8404   // Skip rendering
8405   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8406
8407   drawTrace.Reset();
8408   damagedRects.clear();
8409
8410   // Also in animation deley time
8411   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8412   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8413
8414   // Skip rendering
8415   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8416
8417   // Unparent 2 actors and make a new actor
8418   actor1.Unparent();
8419   actor2.Unparent();
8420
8421   Actor actor3 = CreateRenderableActor();
8422   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8423   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8424   application.GetScene().Add(actor3);
8425
8426   application.SendNotification();
8427
8428   // Started animation
8429   damagedRects.clear();
8430   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8431   DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8432
8433   // The first dirty rect is actor3's.
8434   // We don't know the exact dirty rect of actor2
8435   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8436   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8437
8438   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8439
8440   // Finished animation, but the actior was already unparented
8441   damagedRects.clear();
8442   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8443
8444   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8445   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8446
8447   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8448
8449   END_TEST;
8450 }
8451
8452 int utcDaliActorPartialUpdateChangeVisibility(void)
8453 {
8454   TestApplication application(
8455     TestApplication::DEFAULT_SURFACE_WIDTH,
8456     TestApplication::DEFAULT_SURFACE_HEIGHT,
8457     TestApplication::DEFAULT_HORIZONTAL_DPI,
8458     TestApplication::DEFAULT_VERTICAL_DPI,
8459     true,
8460     true);
8461
8462   tet_infoline("Check the damaged rect with partial update and visibility change");
8463
8464   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8465
8466   Actor actor = CreateRenderableActor();
8467   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8468   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8469   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8470   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8471   application.GetScene().Add(actor);
8472
8473   application.SendNotification();
8474
8475   std::vector<Rect<int>> damagedRects;
8476   Rect<int>              clippingRect;
8477
8478   // 1. Actor added, damaged rect is added size of actor
8479   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8480   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8481
8482   // Aligned by 16
8483   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8484   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8485   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8486   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8487   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8488   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8489   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8490
8491   damagedRects.clear();
8492   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8493   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8494
8495   damagedRects.clear();
8496   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8497   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8498
8499   // Ensure the damaged rect is empty
8500   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8501
8502   // 2. Make the Actor invisible
8503   actor.SetProperty(Actor::Property::VISIBLE, false);
8504   application.SendNotification();
8505
8506   damagedRects.clear();
8507   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8508   DALI_TEST_CHECK(damagedRects.size() > 0);
8509   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8510
8511   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8512   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8513   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8514   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8515   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8516
8517   // 3. Make the Actor visible again
8518   actor.SetProperty(Actor::Property::VISIBLE, true);
8519   application.SendNotification();
8520
8521   damagedRects.clear();
8522   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8523   DALI_TEST_CHECK(damagedRects.size() > 0);
8524   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8525
8526   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8527   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8528   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8529   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8530   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8531
8532   END_TEST;
8533 }
8534
8535 int utcDaliActorPartialUpdateOnOffScene(void)
8536 {
8537   TestApplication application(
8538     TestApplication::DEFAULT_SURFACE_WIDTH,
8539     TestApplication::DEFAULT_SURFACE_HEIGHT,
8540     TestApplication::DEFAULT_HORIZONTAL_DPI,
8541     TestApplication::DEFAULT_VERTICAL_DPI,
8542     true,
8543     true);
8544
8545   tet_infoline("Check the damaged rect with partial update and on/off scene");
8546
8547   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8548
8549   Actor actor = CreateRenderableActor();
8550   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8551   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8552   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8553   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8554   application.GetScene().Add(actor);
8555
8556   application.SendNotification();
8557
8558   std::vector<Rect<int>> damagedRects;
8559   Rect<int>              clippingRect;
8560
8561   // 1. Actor added, damaged rect is added size of actor
8562   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8563   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8564
8565   // Aligned by 16
8566   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8567   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8568   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8569   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8570   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8571   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8572   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8573
8574   damagedRects.clear();
8575   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8576   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8577
8578   damagedRects.clear();
8579   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8580   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8581
8582   // Ensure the damaged rect is empty
8583   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8584
8585   // 2. Remove the Actor from the Scene
8586   actor.Unparent();
8587   application.SendNotification();
8588
8589   damagedRects.clear();
8590   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8591   DALI_TEST_CHECK(damagedRects.size() > 0);
8592   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8593
8594   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8595   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8596   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8597   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8598   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8599
8600   // 3. Add the Actor to the Scene again
8601   application.GetScene().Add(actor);
8602   application.SendNotification();
8603
8604   damagedRects.clear();
8605   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8606   DALI_TEST_CHECK(damagedRects.size() > 0);
8607   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8608
8609   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8610   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8611   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8612   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8613   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8614
8615   END_TEST;
8616 }
8617
8618 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
8619 {
8620   TestApplication application;
8621
8622   Actor actor = Actor::New();
8623   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
8624   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
8625   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
8626   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
8627   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
8628   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8629   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8630   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
8631   END_TEST;
8632 }
8633
8634 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
8635 {
8636   TestApplication application;
8637
8638   Actor actor = Actor::New();
8639
8640   // Make sure setting invalid types does not cause a crash
8641   try
8642   {
8643     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
8644     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
8645     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
8646     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
8647     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
8648     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
8649     tet_result(TET_PASS);
8650   }
8651   catch(...)
8652   {
8653     tet_result(TET_FAIL);
8654   }
8655   END_TEST;
8656 }
8657
8658 int UtcDaliActorTouchAreaOffsetPropertyP(void)
8659 {
8660   TestApplication application;
8661
8662   Actor     actor           = Actor::New();
8663   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
8664   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
8665   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
8666   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
8667   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
8668   END_TEST;
8669 }
8670
8671 int UtcDaliActorTouchAreaOffsetPropertyN(void)
8672 {
8673   TestApplication application;
8674
8675   Actor actor = Actor::New();
8676
8677   // Make sure setting invalid types does not cause a crash
8678   try
8679   {
8680     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
8681     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
8682     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
8683     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
8684     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
8685     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
8686     tet_result(TET_PASS);
8687   }
8688   catch(...)
8689   {
8690     tet_result(TET_FAIL);
8691   }
8692   END_TEST;
8693 }
8694
8695 int UtcDaliActorLowerBelowNegative(void)
8696 {
8697   TestApplication application;
8698   Dali::Actor     instance;
8699   try
8700   {
8701     Dali::Actor arg1;
8702     instance.LowerBelow(arg1);
8703     DALI_TEST_CHECK(false); // Should not get here
8704   }
8705   catch(...)
8706   {
8707     DALI_TEST_CHECK(true); // We expect an assert
8708   }
8709   END_TEST;
8710 }
8711
8712 int UtcDaliActorRaiseAboveNegative(void)
8713 {
8714   TestApplication application;
8715   Dali::Actor     instance;
8716   try
8717   {
8718     Dali::Actor arg1;
8719     instance.RaiseAbove(arg1);
8720     DALI_TEST_CHECK(false); // Should not get here
8721   }
8722   catch(...)
8723   {
8724     DALI_TEST_CHECK(true); // We expect an assert
8725   }
8726   END_TEST;
8727 }
8728
8729 int UtcDaliActorRaiseToTopNegative(void)
8730 {
8731   TestApplication application;
8732   Dali::Actor     instance;
8733   try
8734   {
8735     instance.RaiseToTop();
8736     DALI_TEST_CHECK(false); // Should not get here
8737   }
8738   catch(...)
8739   {
8740     DALI_TEST_CHECK(true); // We expect an assert
8741   }
8742   END_TEST;
8743 }
8744
8745 int UtcDaliActorAddRendererNegative(void)
8746 {
8747   TestApplication application;
8748   Dali::Actor     instance;
8749   try
8750   {
8751     Dali::Renderer arg1;
8752     instance.AddRenderer(arg1);
8753     DALI_TEST_CHECK(false); // Should not get here
8754   }
8755   catch(...)
8756   {
8757     DALI_TEST_CHECK(true); // We expect an assert
8758   }
8759   END_TEST;
8760 }
8761
8762 int UtcDaliActorTouchedSignalNegative(void)
8763 {
8764   TestApplication application;
8765   Dali::Actor     instance;
8766   try
8767   {
8768     instance.TouchedSignal();
8769     DALI_TEST_CHECK(false); // Should not get here
8770   }
8771   catch(...)
8772   {
8773     DALI_TEST_CHECK(true); // We expect an assert
8774   }
8775   END_TEST;
8776 }
8777
8778 int UtcDaliActorTranslateByNegative(void)
8779 {
8780   TestApplication application;
8781   Dali::Actor     instance;
8782   try
8783   {
8784     Dali::Vector3 arg1;
8785     instance.TranslateBy(arg1);
8786     DALI_TEST_CHECK(false); // Should not get here
8787   }
8788   catch(...)
8789   {
8790     DALI_TEST_CHECK(true); // We expect an assert
8791   }
8792   END_TEST;
8793 }
8794
8795 int UtcDaliActorFindChildByIdNegative(void)
8796 {
8797   TestApplication application;
8798   Dali::Actor     instance;
8799   try
8800   {
8801     unsigned int arg1 = 0u;
8802     instance.FindChildById(arg1);
8803     DALI_TEST_CHECK(false); // Should not get here
8804   }
8805   catch(...)
8806   {
8807     DALI_TEST_CHECK(true); // We expect an assert
8808   }
8809   END_TEST;
8810 }
8811
8812 int UtcDaliActorGetRendererAtNegative(void)
8813 {
8814   TestApplication application;
8815   Dali::Actor     instance;
8816   try
8817   {
8818     unsigned int arg1 = 0u;
8819     instance.GetRendererAt(arg1);
8820     DALI_TEST_CHECK(false); // Should not get here
8821   }
8822   catch(...)
8823   {
8824     DALI_TEST_CHECK(true); // We expect an assert
8825   }
8826   END_TEST;
8827 }
8828
8829 int UtcDaliActorHoveredSignalNegative(void)
8830 {
8831   TestApplication application;
8832   Dali::Actor     instance;
8833   try
8834   {
8835     instance.HoveredSignal();
8836     DALI_TEST_CHECK(false); // Should not get here
8837   }
8838   catch(...)
8839   {
8840     DALI_TEST_CHECK(true); // We expect an assert
8841   }
8842   END_TEST;
8843 }
8844
8845 int UtcDaliActorLowerToBottomNegative(void)
8846 {
8847   TestApplication application;
8848   Dali::Actor     instance;
8849   try
8850   {
8851     instance.LowerToBottom();
8852     DALI_TEST_CHECK(false); // Should not get here
8853   }
8854   catch(...)
8855   {
8856     DALI_TEST_CHECK(true); // We expect an assert
8857   }
8858   END_TEST;
8859 }
8860
8861 int UtcDaliActorOnSceneSignalNegative(void)
8862 {
8863   TestApplication application;
8864   Dali::Actor     instance;
8865   try
8866   {
8867     instance.OnSceneSignal();
8868     DALI_TEST_CHECK(false); // Should not get here
8869   }
8870   catch(...)
8871   {
8872     DALI_TEST_CHECK(true); // We expect an assert
8873   }
8874   END_TEST;
8875 }
8876
8877 int UtcDaliActorOffSceneSignalNegative(void)
8878 {
8879   TestApplication application;
8880   Dali::Actor     instance;
8881   try
8882   {
8883     instance.OffSceneSignal();
8884     DALI_TEST_CHECK(false); // Should not get here
8885   }
8886   catch(...)
8887   {
8888     DALI_TEST_CHECK(true); // We expect an assert
8889   }
8890   END_TEST;
8891 }
8892
8893 int UtcDaliActorRemoveRendererNegative01(void)
8894 {
8895   TestApplication application;
8896   Dali::Actor     instance;
8897   try
8898   {
8899     unsigned int arg1 = 0u;
8900     instance.RemoveRenderer(arg1);
8901     DALI_TEST_CHECK(false); // Should not get here
8902   }
8903   catch(...)
8904   {
8905     DALI_TEST_CHECK(true); // We expect an assert
8906   }
8907   END_TEST;
8908 }
8909
8910 int UtcDaliActorRemoveRendererNegative02(void)
8911 {
8912   TestApplication application;
8913   Dali::Actor     instance;
8914   try
8915   {
8916     Dali::Renderer arg1;
8917     instance.RemoveRenderer(arg1);
8918     DALI_TEST_CHECK(false); // Should not get here
8919   }
8920   catch(...)
8921   {
8922     DALI_TEST_CHECK(true); // We expect an assert
8923   }
8924   END_TEST;
8925 }
8926
8927 int UtcDaliActorFindChildByNameNegative(void)
8928 {
8929   TestApplication application;
8930   Dali::Actor     instance;
8931   try
8932   {
8933     std::string arg1;
8934     instance.FindChildByName(arg1);
8935     DALI_TEST_CHECK(false); // Should not get here
8936   }
8937   catch(...)
8938   {
8939     DALI_TEST_CHECK(true); // We expect an assert
8940   }
8941   END_TEST;
8942 }
8943
8944 int UtcDaliActorSetResizePolicyNegative(void)
8945 {
8946   TestApplication application;
8947   Dali::Actor     instance;
8948   try
8949   {
8950     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8951     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
8952     instance.SetResizePolicy(arg1, arg2);
8953     DALI_TEST_CHECK(false); // Should not get here
8954   }
8955   catch(...)
8956   {
8957     DALI_TEST_CHECK(true); // We expect an assert
8958   }
8959   END_TEST;
8960 }
8961
8962 int UtcDaliActorOnRelayoutSignalNegative(void)
8963 {
8964   TestApplication application;
8965   Dali::Actor     instance;
8966   try
8967   {
8968     instance.OnRelayoutSignal();
8969     DALI_TEST_CHECK(false); // Should not get here
8970   }
8971   catch(...)
8972   {
8973     DALI_TEST_CHECK(true); // We expect an assert
8974   }
8975   END_TEST;
8976 }
8977
8978 int UtcDaliActorWheelEventSignalNegative(void)
8979 {
8980   TestApplication application;
8981   Dali::Actor     instance;
8982   try
8983   {
8984     instance.WheelEventSignal();
8985     DALI_TEST_CHECK(false); // Should not get here
8986   }
8987   catch(...)
8988   {
8989     DALI_TEST_CHECK(true); // We expect an assert
8990   }
8991   END_TEST;
8992 }
8993
8994 int UtcDaliActorGetHeightForWidthNegative(void)
8995 {
8996   TestApplication application;
8997   Dali::Actor     instance;
8998   try
8999   {
9000     float arg1 = 0.0f;
9001     instance.GetHeightForWidth(arg1);
9002     DALI_TEST_CHECK(false); // Should not get here
9003   }
9004   catch(...)
9005   {
9006     DALI_TEST_CHECK(true); // We expect an assert
9007   }
9008   END_TEST;
9009 }
9010
9011 int UtcDaliActorGetWidthForHeightNegative(void)
9012 {
9013   TestApplication application;
9014   Dali::Actor     instance;
9015   try
9016   {
9017     float arg1 = 0.0f;
9018     instance.GetWidthForHeight(arg1);
9019     DALI_TEST_CHECK(false); // Should not get here
9020   }
9021   catch(...)
9022   {
9023     DALI_TEST_CHECK(true); // We expect an assert
9024   }
9025   END_TEST;
9026 }
9027
9028 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9029 {
9030   TestApplication application;
9031   Dali::Actor     instance;
9032   try
9033   {
9034     instance.LayoutDirectionChangedSignal();
9035     DALI_TEST_CHECK(false); // Should not get here
9036   }
9037   catch(...)
9038   {
9039     DALI_TEST_CHECK(true); // We expect an assert
9040   }
9041   END_TEST;
9042 }
9043
9044 int UtcDaliActorAddNegative(void)
9045 {
9046   TestApplication application;
9047   Dali::Actor     instance;
9048   try
9049   {
9050     Dali::Actor arg1;
9051     instance.Add(arg1);
9052     DALI_TEST_CHECK(false); // Should not get here
9053   }
9054   catch(...)
9055   {
9056     DALI_TEST_CHECK(true); // We expect an assert
9057   }
9058   END_TEST;
9059 }
9060
9061 int UtcDaliActorLowerNegative(void)
9062 {
9063   TestApplication application;
9064   Dali::Actor     instance;
9065   try
9066   {
9067     instance.Lower();
9068     DALI_TEST_CHECK(false); // Should not get here
9069   }
9070   catch(...)
9071   {
9072     DALI_TEST_CHECK(true); // We expect an assert
9073   }
9074   END_TEST;
9075 }
9076
9077 int UtcDaliActorRaiseNegative(void)
9078 {
9079   TestApplication application;
9080   Dali::Actor     instance;
9081   try
9082   {
9083     instance.Raise();
9084     DALI_TEST_CHECK(false); // Should not get here
9085   }
9086   catch(...)
9087   {
9088     DALI_TEST_CHECK(true); // We expect an assert
9089   }
9090   END_TEST;
9091 }
9092
9093 int UtcDaliActorRemoveNegative(void)
9094 {
9095   TestApplication application;
9096   Dali::Actor     instance;
9097   try
9098   {
9099     Dali::Actor arg1;
9100     instance.Remove(arg1);
9101     DALI_TEST_CHECK(false); // Should not get here
9102   }
9103   catch(...)
9104   {
9105     DALI_TEST_CHECK(true); // We expect an assert
9106   }
9107   END_TEST;
9108 }
9109
9110 int UtcDaliActorScaleByNegative(void)
9111 {
9112   TestApplication application;
9113   Dali::Actor     instance;
9114   try
9115   {
9116     Dali::Vector3 arg1;
9117     instance.ScaleBy(arg1);
9118     DALI_TEST_CHECK(false); // Should not get here
9119   }
9120   catch(...)
9121   {
9122     DALI_TEST_CHECK(true); // We expect an assert
9123   }
9124   END_TEST;
9125 }
9126
9127 int UtcDaliActorGetLayerNegative(void)
9128 {
9129   TestApplication application;
9130   Dali::Actor     instance;
9131   try
9132   {
9133     instance.GetLayer();
9134     DALI_TEST_CHECK(false); // Should not get here
9135   }
9136   catch(...)
9137   {
9138     DALI_TEST_CHECK(true); // We expect an assert
9139   }
9140   END_TEST;
9141 }
9142
9143 int UtcDaliActorRotateByNegative01(void)
9144 {
9145   TestApplication application;
9146   Dali::Actor     instance;
9147   try
9148   {
9149     Dali::Quaternion arg1;
9150     instance.RotateBy(arg1);
9151     DALI_TEST_CHECK(false); // Should not get here
9152   }
9153   catch(...)
9154   {
9155     DALI_TEST_CHECK(true); // We expect an assert
9156   }
9157   END_TEST;
9158 }
9159
9160 int UtcDaliActorRotateByNegative02(void)
9161 {
9162   TestApplication application;
9163   Dali::Actor     instance;
9164   try
9165   {
9166     Dali::Radian  arg1;
9167     Dali::Vector3 arg2;
9168     instance.RotateBy(arg1, arg2);
9169     DALI_TEST_CHECK(false); // Should not get here
9170   }
9171   catch(...)
9172   {
9173     DALI_TEST_CHECK(true); // We expect an assert
9174   }
9175   END_TEST;
9176 }
9177
9178 int UtcDaliActorUnparentNegative(void)
9179 {
9180   TestApplication application;
9181   Dali::Actor     instance;
9182   try
9183   {
9184     instance.Unparent();
9185     DALI_TEST_CHECK(false); // Should not get here
9186   }
9187   catch(...)
9188   {
9189     DALI_TEST_CHECK(true); // We expect an assert
9190   }
9191   END_TEST;
9192 }
9193
9194 int UtcDaliActorGetChildAtNegative(void)
9195 {
9196   TestApplication application;
9197   Dali::Actor     instance;
9198   try
9199   {
9200     unsigned int arg1 = 0u;
9201     instance.GetChildAt(arg1);
9202     DALI_TEST_CHECK(false); // Should not get here
9203   }
9204   catch(...)
9205   {
9206     DALI_TEST_CHECK(true); // We expect an assert
9207   }
9208   END_TEST;
9209 }
9210
9211 int UtcDaliActorGetChildCountNegative(void)
9212 {
9213   TestApplication application;
9214   Dali::Actor     instance;
9215   try
9216   {
9217     instance.GetChildCount();
9218     DALI_TEST_CHECK(false); // Should not get here
9219   }
9220   catch(...)
9221   {
9222     DALI_TEST_CHECK(true); // We expect an assert
9223   }
9224   END_TEST;
9225 }
9226
9227 int UtcDaliActorGetTargetSizeNegative(void)
9228 {
9229   TestApplication application;
9230   Dali::Actor     instance;
9231   try
9232   {
9233     instance.GetTargetSize();
9234     DALI_TEST_CHECK(false); // Should not get here
9235   }
9236   catch(...)
9237   {
9238     DALI_TEST_CHECK(true); // We expect an assert
9239   }
9240   END_TEST;
9241 }
9242
9243 int UtcDaliActorScreenToLocalNegative(void)
9244 {
9245   TestApplication application;
9246   Dali::Actor     instance;
9247   try
9248   {
9249     float arg1 = 0.0f;
9250     float arg2 = 0.0f;
9251     float arg3 = 0.0f;
9252     float arg4 = 0.0f;
9253     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
9254     DALI_TEST_CHECK(false); // Should not get here
9255   }
9256   catch(...)
9257   {
9258     DALI_TEST_CHECK(true); // We expect an assert
9259   }
9260   END_TEST;
9261 }
9262
9263 int UtcDaliActorGetNaturalSizeNegative(void)
9264 {
9265   TestApplication application;
9266   Dali::Actor     instance;
9267   try
9268   {
9269     instance.GetNaturalSize();
9270     DALI_TEST_CHECK(false); // Should not get here
9271   }
9272   catch(...)
9273   {
9274     DALI_TEST_CHECK(true); // We expect an assert
9275   }
9276   END_TEST;
9277 }
9278
9279 int UtcDaliActorGetRelayoutSizeNegative(void)
9280 {
9281   TestApplication application;
9282   Dali::Actor     instance;
9283   try
9284   {
9285     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
9286     instance.GetRelayoutSize(arg1);
9287     DALI_TEST_CHECK(false); // Should not get here
9288   }
9289   catch(...)
9290   {
9291     DALI_TEST_CHECK(true); // We expect an assert
9292   }
9293   END_TEST;
9294 }
9295
9296 int UtcDaliActorGetResizePolicyNegative(void)
9297 {
9298   TestApplication application;
9299   Dali::Actor     instance;
9300   try
9301   {
9302     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
9303     instance.GetResizePolicy(arg1);
9304     DALI_TEST_CHECK(false); // Should not get here
9305   }
9306   catch(...)
9307   {
9308     DALI_TEST_CHECK(true); // We expect an assert
9309   }
9310   END_TEST;
9311 }
9312
9313 int UtcDaliActorGetRendererCountNegative(void)
9314 {
9315   TestApplication application;
9316   Dali::Actor     instance;
9317   try
9318   {
9319     instance.GetRendererCount();
9320     DALI_TEST_CHECK(false); // Should not get here
9321   }
9322   catch(...)
9323   {
9324     DALI_TEST_CHECK(true); // We expect an assert
9325   }
9326   END_TEST;
9327 }
9328
9329 int UtcDaliActorGetParentNegative(void)
9330 {
9331   TestApplication application;
9332   Dali::Actor     instance;
9333   try
9334   {
9335     instance.GetParent();
9336     DALI_TEST_CHECK(false); // Should not get here
9337   }
9338   catch(...)
9339   {
9340     DALI_TEST_CHECK(true); // We expect an assert
9341   }
9342   END_TEST;
9343 }
9344
9345 int UtcDaliActorPropertyBlendEquation(void)
9346 {
9347   TestApplication application;
9348
9349   tet_infoline("Test SetProperty AdvancedBlendEquation");
9350
9351   Geometry geometry  = CreateQuadGeometry();
9352   Shader   shader    = CreateShader();
9353   Renderer renderer1 = Renderer::New(geometry, shader);
9354
9355   Actor actor = Actor::New();
9356   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
9357
9358   actor.AddRenderer(renderer1);
9359   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
9360   application.GetScene().Add(actor);
9361
9362   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9363   {
9364     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9365     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9366     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
9367   }
9368
9369   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9370   {
9371     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9372     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9373     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
9374   }
9375
9376   Renderer renderer2 = Renderer::New(geometry, shader);
9377   actor.AddRenderer(renderer2);
9378
9379   END_TEST;
9380 }
9381
9382 int UtcDaliActorRegisterProperty(void)
9383 {
9384   tet_infoline("Test property registration and uniform map update\n");
9385
9386   TestApplication application;
9387
9388   Geometry geometry  = CreateQuadGeometry();
9389   Shader   shader    = CreateShader();
9390   Renderer renderer1 = Renderer::New(geometry, shader);
9391   Renderer renderer2 = Renderer::New(geometry, shader);
9392
9393   Actor actor1 = Actor::New();
9394   actor1.AddRenderer(renderer1);
9395   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9396   actor1.RegisterProperty("uCustom", 1);
9397   application.GetScene().Add(actor1);
9398
9399   Actor actor2 = Actor::New();
9400   actor2.AddRenderer(renderer2);
9401   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9402   application.GetScene().Add(actor2);
9403
9404   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
9405   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
9406   glAbstraction.EnableSetUniformCallTrace(true);
9407
9408   application.SendNotification();
9409   application.Render();
9410
9411   std::stringstream out;
9412   out.str("1");
9413   std::string params;
9414
9415   // Test uniform value of the custom property
9416   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9417   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9418
9419   // Make invisible
9420   actor1[Actor::Property::VISIBLE] = false;
9421
9422   application.SendNotification();
9423   application.Render();
9424
9425   // Make visible again
9426   actor1[Actor::Property::VISIBLE] = true;
9427   actor1["uCustom"]                = 2;
9428
9429   glAbstraction.ResetSetUniformCallStack();
9430
9431   application.SendNotification();
9432   application.Render();
9433
9434   out.str("2");
9435
9436   // The uniform value should not be changed
9437   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9438   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9439
9440   END_TEST;
9441 }