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