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