Sync UTC harness
[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.GetScene().Add(actor);
1358
1359   application.SendNotification();
1360   application.Render();
1361
1362   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1363   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1364   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1365   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1366   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1367   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1368
1369   application.GetScene().Remove(actor);
1370   END_TEST;
1371 }
1372
1373 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1374 {
1375   TestApplication    application;
1376   Integration::Scene scene = application.GetScene();
1377
1378   // Make 3D Layer
1379   Layer layer = Layer::New();
1380   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1381   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1382   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1383
1384   scene.Add(layer);
1385
1386   // Build custom camera with top-view
1387   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1388   {
1389     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1390     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1391     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1392
1393     {
1394       std::ostringstream oss;
1395       oss << cameraPos << "\n";
1396       oss << cameraOrient << "\n";
1397       tet_printf("%s\n", oss.str().c_str());
1398     }
1399
1400     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1401     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1402
1403     // Now, upside : -Z, leftside : -X, foward : +Y
1404
1405     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1406     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1407     {
1408       std::ostringstream oss;
1409       oss << cameraPos << "\n";
1410       oss << cameraOrient << "\n";
1411       tet_printf("%s\n", oss.str().c_str());
1412     }
1413   }
1414
1415   Actor actor = Actor::New();
1416   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1417   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1418   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1419   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1420
1421   layer.Add(actor);
1422
1423   application.SendNotification();
1424   application.Render();
1425
1426   Vector2 sceneSize = scene.GetSize();
1427
1428   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1429   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1430   {
1431     std::ostringstream oss;
1432     oss << expectedExtent << "\n";
1433     oss << actualExtent << "\n";
1434     tet_printf("%s\n", oss.str().c_str());
1435   }
1436
1437   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1438   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1439   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1440   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1441
1442   END_TEST;
1443 }
1444
1445 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1446 {
1447   // TODO : Need to make it works well
1448   TestApplication    application;
1449   Integration::Scene scene     = application.GetScene();
1450   Vector2            sceneSize = scene.GetSize();
1451
1452   // Make 3D Layer
1453   Layer layer = Layer::New();
1454   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1455   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1456   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1457   layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1458   layer.SetProperty(Actor::Property::SIZE, sceneSize);
1459
1460   scene.Add(layer);
1461
1462   // Build custom camera with top-view
1463   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1464
1465   offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1466   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1467   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1468
1469   scene.Add(offscreenCameraActor);
1470   {
1471     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1472     Vector3    cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1473     Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1474
1475     {
1476       std::ostringstream oss;
1477       oss << cameraPos << "\n";
1478       oss << cameraOrient << "\n";
1479       tet_printf("%s\n", oss.str().c_str());
1480     }
1481
1482     offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1483     offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1484
1485     // Now, upside : -Z, leftside : -X, foward : +Y
1486
1487     cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1488     cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1489     {
1490       std::ostringstream oss;
1491       oss << cameraPos << "\n";
1492       oss << cameraOrient << "\n";
1493       tet_printf("%s\n", oss.str().c_str());
1494     }
1495   }
1496   Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1497   Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1498
1499   Actor sourceActor = Actor::New();
1500   sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1501   sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1502   sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1503   sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1504
1505   layer.Add(sourceActor);
1506
1507   // Create framebuffer
1508   unsigned int width(64);
1509   unsigned int height(64);
1510   Texture      texture     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1511   FrameBuffer  frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1512   frameBuffer.AttachColorTexture(texture);
1513
1514   Actor rootActor = Actor::New();
1515   rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1516   rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1517   rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1518   rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1519   scene.Add(rootActor);
1520
1521   RenderTaskList taskList = scene.GetRenderTaskList();
1522   RenderTask     newTask  = taskList.CreateTask();
1523   newTask.SetCameraActor(offscreenCameraActor);
1524   newTask.SetSourceActor(layer);
1525   newTask.SetInputEnabled(false);
1526   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1527   newTask.SetClearEnabled(true);
1528   newTask.SetExclusive(true);
1529   newTask.SetFrameBuffer(frameBuffer);
1530   newTask.SetScreenToFrameBufferMappingActor(rootActor);
1531
1532   application.SendNotification();
1533   application.Render(16u);
1534
1535   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1536                                sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1537                                sourceSize.x,
1538                                sourceSize.z};
1539   auto actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1540   {
1541     std::ostringstream oss;
1542     oss << expectedExtent << "\n";
1543     oss << actualExtent << "\n";
1544     tet_printf("%s\n", oss.str().c_str());
1545   }
1546
1547   auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1548   auto actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1549   {
1550     std::ostringstream oss;
1551     oss << expectedScreen << "\n";
1552     oss << actualScreen << "\n";
1553     tet_printf("%s\n", oss.str().c_str());
1554   }
1555
1556   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1557   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1558   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1559   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1560
1561   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1562   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1563
1564   // Change rootActor's size and position
1565
1566   Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1567   Vector3 rootSize{200.0f, 100.0f, 0.0f};
1568
1569   rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1570   rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1571
1572   application.SendNotification();
1573   application.Render(16u);
1574
1575   expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1576                           sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1577                           sourceSize.x * rootSize.x / sceneSize.x,
1578                           sourceSize.z * rootSize.y / sceneSize.y};
1579   actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1580   {
1581     std::ostringstream oss;
1582     oss << expectedExtent << "\n";
1583     oss << actualExtent << "\n";
1584     tet_printf("%s\n", oss.str().c_str());
1585   }
1586
1587   expectedScreen = Vector2{sceneSize.x * 0.5f + rootPosition.x + sourcePosition.x * rootSize.x / sceneSize.x, sceneSize.y * 0.5f + rootPosition.y + sourcePosition.z * rootSize.y / sceneSize.y};
1588   actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1589   {
1590     std::ostringstream oss;
1591     oss << expectedScreen << "\n";
1592     oss << actualScreen << "\n";
1593     tet_printf("%s\n", oss.str().c_str());
1594   }
1595
1596   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1597   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1598   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1599   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1600
1601   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1602   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1603
1604   END_TEST;
1605 }
1606
1607 // SetPosition(float x, float y)
1608 int UtcDaliActorSetPosition01(void)
1609 {
1610   TestApplication application;
1611
1612   Actor actor = Actor::New();
1613
1614   // Set to random to start off with
1615   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1616
1617   Vector3 vector(100.0f, 100.0f, 0.0f);
1618
1619   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1620
1621   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1622   // flush the queue and render once
1623   application.SendNotification();
1624   application.Render();
1625   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1626
1627   application.GetScene().Add(actor);
1628   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1629   // flush the queue and render once
1630   application.SendNotification();
1631   application.Render();
1632   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1633
1634   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1635   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1636   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1637   // flush the queue and render once
1638   application.SendNotification();
1639   application.Render();
1640   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1641
1642   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1643   // flush the queue and render once
1644   application.SendNotification();
1645   application.Render();
1646   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1647
1648   application.GetScene().Remove(actor);
1649   END_TEST;
1650 }
1651
1652 // SetPosition(float x, float y, float z)
1653 int UtcDaliActorSetPosition02(void)
1654 {
1655   TestApplication application;
1656
1657   Actor actor = Actor::New();
1658
1659   // Set to random to start off with
1660   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1661
1662   Vector3 vector(100.0f, 100.0f, 100.0f);
1663
1664   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1665
1666   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1667
1668   // flush the queue and render once
1669   application.SendNotification();
1670   application.Render();
1671
1672   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1673   END_TEST;
1674 }
1675
1676 // SetPosition(Vector3 position)
1677 int UtcDaliActorSetPosition03(void)
1678 {
1679   TestApplication application;
1680
1681   Actor actor = Actor::New();
1682
1683   // Set to random to start off with
1684   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1685
1686   Vector3 vector(100.0f, 100.0f, 100.0f);
1687
1688   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1689
1690   actor.SetProperty(Actor::Property::POSITION, vector);
1691
1692   // flush the queue and render once
1693   application.SendNotification();
1694   application.Render();
1695
1696   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1697   END_TEST;
1698 }
1699
1700 int UtcDaliActorSetX(void)
1701 {
1702   TestApplication application;
1703
1704   Actor actor = Actor::New();
1705
1706   Vector3 vector(100.0f, 0.0f, 0.0f);
1707
1708   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1709
1710   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1711
1712   // flush the queue and render once
1713   application.SendNotification();
1714   application.Render();
1715
1716   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1717   END_TEST;
1718 }
1719
1720 int UtcDaliActorSetY(void)
1721 {
1722   TestApplication application;
1723
1724   Actor actor = Actor::New();
1725
1726   Vector3 vector(0.0f, 100.0f, 0.0f);
1727
1728   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1729
1730   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1731
1732   // flush the queue and render once
1733   application.SendNotification();
1734   application.Render();
1735
1736   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1737   END_TEST;
1738 }
1739
1740 int UtcDaliActorSetZ(void)
1741 {
1742   TestApplication application;
1743
1744   Actor actor = Actor::New();
1745
1746   Vector3 vector(0.0f, 0.0f, 100.0f);
1747
1748   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1749
1750   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1751
1752   // flush the queue and render once
1753   application.SendNotification();
1754   application.Render();
1755
1756   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1757   END_TEST;
1758 }
1759
1760 int UtcDaliActorSetPositionProperties(void)
1761 {
1762   TestApplication application;
1763
1764   Actor actor = Actor::New();
1765
1766   Vector3 vector(0.7f, 0.8f, 0.9f);
1767   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1768
1769   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1770   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1771   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1772
1773   // flush the queue and render once
1774   application.SendNotification();
1775   application.Render();
1776
1777   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1778   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1779   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1780   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1781   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1782
1783   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1784   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1785   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1786
1787   // flush the queue and render once
1788   application.SendNotification();
1789   application.Render();
1790
1791   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1792   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1793   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1794   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1795   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1796
1797   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1798   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1799   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1800
1801   // flush the queue and render once
1802   application.SendNotification();
1803   application.Render();
1804
1805   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1806   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1807   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1808   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1809   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1810
1811   END_TEST;
1812 }
1813
1814 int UtcDaliActorTranslateBy(void)
1815 {
1816   TestApplication application;
1817
1818   Actor   actor = Actor::New();
1819   Vector3 vector(100.0f, 100.0f, 100.0f);
1820
1821   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1822
1823   actor.SetProperty(Actor::Property::POSITION, vector);
1824
1825   // flush the queue and render once
1826   application.SendNotification();
1827   application.Render();
1828
1829   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1830
1831   actor.TranslateBy(vector);
1832
1833   // flush the queue and render once
1834   application.SendNotification();
1835   application.Render();
1836
1837   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1838   END_TEST;
1839 }
1840
1841 int UtcDaliActorGetCurrentPosition(void)
1842 {
1843   TestApplication application;
1844
1845   Actor   actor = Actor::New();
1846   Vector3 setVector(100.0f, 100.0f, 0.0f);
1847   actor.SetProperty(Actor::Property::POSITION, setVector);
1848
1849   // flush the queue and render once
1850   application.SendNotification();
1851   application.Render();
1852
1853   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1854   END_TEST;
1855 }
1856
1857 int UtcDaliActorGetCurrentWorldPosition(void)
1858 {
1859   TestApplication application;
1860
1861   Actor   parent = Actor::New();
1862   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1863   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1864   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1865   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1866   application.GetScene().Add(parent);
1867
1868   Actor child = Actor::New();
1869   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1870   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1871   Vector3 childPosition(6.0f, 6.0f, 6.0f);
1872   child.SetProperty(Actor::Property::POSITION, childPosition);
1873   parent.Add(child);
1874
1875   // The actors should not have a world position yet
1876   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1877   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1878
1879   application.SendNotification();
1880   application.Render(0);
1881
1882   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1883   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1884
1885   // The actors should have a world position now
1886   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1887   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1888   END_TEST;
1889 }
1890
1891 int UtcDaliActorSetInheritPosition(void)
1892 {
1893   tet_infoline("Testing Actor::SetInheritPosition");
1894   TestApplication application;
1895
1896   Actor   parent = Actor::New();
1897   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1898   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1899   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1900   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1901   application.GetScene().Add(parent);
1902
1903   Actor child = Actor::New();
1904   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1905   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1906   Vector3 childPosition(10.0f, 11.0f, 12.0f);
1907   child.SetProperty(Actor::Property::POSITION, childPosition);
1908   parent.Add(child);
1909
1910   // The actors should not have a world position yet
1911   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1912   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1913
1914   // first test default, which is to inherit position
1915   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1916   application.SendNotification();
1917   application.Render(0); // should only really call Update as Render is not required to update scene
1918   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1919   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1920   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1921   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1922
1923   //Change child position
1924   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1925   child.SetProperty(Actor::Property::POSITION, childOffset);
1926
1927   // Use local position as world postion
1928   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1929   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1930   application.SendNotification();
1931   application.Render(0); // should only really call Update as Render is not required to update scene
1932   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1933   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1934   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1935   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1936
1937   //Change back to inherit position from parent
1938   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1939   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1940   application.SendNotification();
1941   application.Render(0); // should only really call Update as Render is not required to update scene
1942   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1943   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1944   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1945   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1946   END_TEST;
1947 }
1948
1949 int UtcDaliActorInheritOpacity(void)
1950 {
1951   tet_infoline("Testing Actor::Inherit Opacity");
1952   TestApplication application;
1953
1954   Actor parent = Actor::New();
1955   Actor child  = Actor::New();
1956   parent.Add(child);
1957   application.GetScene().Add(parent);
1958
1959   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1960   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1961
1962   // flush the queue and render once
1963   application.SendNotification();
1964   application.Render();
1965
1966   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1967
1968   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1969   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1970
1971   application.SendNotification();
1972   application.Render();
1973
1974   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1975   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1976   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1977   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1978   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1979   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1980
1981   END_TEST;
1982 }
1983
1984 // SetOrientation(float angleRadians, Vector3 axis)
1985 int UtcDaliActorSetOrientation01(void)
1986 {
1987   TestApplication application;
1988
1989   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1990   Actor      actor = Actor::New();
1991
1992   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1993
1994   // flush the queue and render once
1995   application.SendNotification();
1996   application.Render();
1997
1998   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1999   END_TEST;
2000 }
2001
2002 int UtcDaliActorSetOrientation02(void)
2003 {
2004   TestApplication application;
2005
2006   Actor actor = Actor::New();
2007
2008   Radian  angle(0.785f);
2009   Vector3 axis(1.0f, 1.0f, 0.0f);
2010
2011   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2012   Quaternion rotation(angle, axis);
2013   // flush the queue and render once
2014   application.SendNotification();
2015   application.Render();
2016   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2017
2018   application.GetScene().Add(actor);
2019   actor.RotateBy(Degree(360), axis);
2020   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2021
2022   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2023   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2024   // flush the queue and render once
2025   application.SendNotification();
2026   application.Render();
2027   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2028
2029   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2030   // flush the queue and render once
2031   application.SendNotification();
2032   application.Render();
2033   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2034
2035   application.GetScene().Remove(actor);
2036   END_TEST;
2037 }
2038
2039 // SetOrientation(float angleRadians, Vector3 axis)
2040 int UtcDaliActorSetOrientationProperty(void)
2041 {
2042   TestApplication application;
2043
2044   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2045   Actor      actor = Actor::New();
2046
2047   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2048   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2049
2050   // flush the queue and render once
2051   application.SendNotification();
2052   application.Render();
2053
2054   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2055   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2056   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2057   END_TEST;
2058 }
2059
2060 // RotateBy(float angleRadians, Vector3 axis)
2061 int UtcDaliActorRotateBy01(void)
2062 {
2063   TestApplication application;
2064
2065   Actor actor = Actor::New();
2066
2067   Radian angle(M_PI * 0.25f);
2068   actor.RotateBy((angle), Vector3::ZAXIS);
2069   // flush the queue and render once
2070   application.SendNotification();
2071   application.Render();
2072   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2073
2074   application.GetScene().Add(actor);
2075
2076   actor.RotateBy(angle, Vector3::ZAXIS);
2077   // flush the queue and render once
2078   application.SendNotification();
2079   application.Render();
2080   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2081
2082   application.GetScene().Remove(actor);
2083   END_TEST;
2084 }
2085
2086 // RotateBy(Quaternion relativeRotation)
2087 int UtcDaliActorRotateBy02(void)
2088 {
2089   TestApplication application;
2090
2091   Actor actor = Actor::New();
2092
2093   Radian     angle(M_PI * 0.25f);
2094   Quaternion rotation(angle, Vector3::ZAXIS);
2095   actor.RotateBy(rotation);
2096   // flush the queue and render once
2097   application.SendNotification();
2098   application.Render();
2099   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2100
2101   actor.RotateBy(rotation);
2102   // flush the queue and render once
2103   application.SendNotification();
2104   application.Render();
2105   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2106   END_TEST;
2107 }
2108
2109 int UtcDaliActorGetCurrentOrientation(void)
2110 {
2111   TestApplication application;
2112   Actor           actor = Actor::New();
2113
2114   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2115   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2116   // flush the queue and render once
2117   application.SendNotification();
2118   application.Render();
2119   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2120   END_TEST;
2121 }
2122
2123 int UtcDaliActorGetCurrentWorldOrientation(void)
2124 {
2125   tet_infoline("Testing Actor::GetCurrentWorldRotation");
2126   TestApplication application;
2127
2128   Actor      parent = Actor::New();
2129   Radian     rotationAngle(Degree(90.0f));
2130   Quaternion rotation(rotationAngle, Vector3::YAXIS);
2131   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2132   application.GetScene().Add(parent);
2133
2134   Actor child = Actor::New();
2135   child.SetProperty(Actor::Property::ORIENTATION, rotation);
2136   parent.Add(child);
2137
2138   // The actors should not have a world rotation yet
2139   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2140   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2141
2142   application.SendNotification();
2143   application.Render(0);
2144
2145   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2146   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2147
2148   // The actors should have a world rotation now
2149   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2150   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2151
2152   // turn off child rotation inheritance
2153   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2154   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2155   application.SendNotification();
2156   application.Render(0);
2157
2158   // The actors should have a world rotation now
2159   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2160   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2161   END_TEST;
2162 }
2163
2164 // SetScale(float scale)
2165 int UtcDaliActorSetScale01(void)
2166 {
2167   TestApplication application;
2168
2169   Actor actor = Actor::New();
2170
2171   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2172   actor.SetProperty(Actor::Property::SCALE, 0.25f);
2173
2174   Vector3 scale(10.0f, 10.0f, 10.0f);
2175   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2176
2177   actor.SetProperty(Actor::Property::SCALE, scale.x);
2178
2179   // flush the queue and render once
2180   application.SendNotification();
2181   application.Render();
2182
2183   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2184   END_TEST;
2185 }
2186
2187 // SetScale(float scaleX, float scaleY, float scaleZ)
2188 int UtcDaliActorSetScale02(void)
2189 {
2190   TestApplication application;
2191   Vector3         scale(10.0f, 10.0f, 10.0f);
2192
2193   Actor actor = Actor::New();
2194
2195   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2196   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2197
2198   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2199
2200   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2201   // flush the queue and render once
2202   application.SendNotification();
2203   application.Render();
2204   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2205
2206   // add to stage and test
2207   application.GetScene().Add(actor);
2208   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2209   // flush the queue and render once
2210   application.SendNotification();
2211   application.Render();
2212   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2213
2214   application.GetScene().Remove(actor);
2215
2216   END_TEST;
2217 }
2218
2219 // SetScale(Vector3 scale)
2220 int UtcDaliActorSetScale03(void)
2221 {
2222   TestApplication application;
2223   Vector3         scale(10.0f, 10.0f, 10.0f);
2224
2225   Actor actor = Actor::New();
2226
2227   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2228   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2229
2230   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2231
2232   actor.SetProperty(Actor::Property::SCALE, scale);
2233
2234   // flush the queue and render once
2235   application.SendNotification();
2236   application.Render();
2237
2238   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2239   END_TEST;
2240 }
2241
2242 int UtcDaliActorSetScaleIndividual(void)
2243 {
2244   TestApplication application;
2245
2246   Actor actor = Actor::New();
2247
2248   Vector3 vector(0.7f, 0.8f, 0.9f);
2249   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2250
2251   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2252   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2253
2254   // flush the queue and render once
2255   application.SendNotification();
2256   application.Render();
2257
2258   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2259   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2260   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2261
2262   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2263   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2264
2265   // flush the queue and render once
2266   application.SendNotification();
2267   application.Render();
2268
2269   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2270   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2271   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2272
2273   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2274   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2275
2276   // flush the queue and render once
2277   application.SendNotification();
2278   application.Render();
2279
2280   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2281   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2282   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2283
2284   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2285   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2286
2287   END_TEST;
2288 }
2289
2290 int UtcDaliActorScaleBy(void)
2291 {
2292   TestApplication application;
2293   Actor           actor = Actor::New();
2294   Vector3         vector(100.0f, 100.0f, 100.0f);
2295
2296   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2297
2298   actor.SetProperty(Actor::Property::SCALE, vector);
2299
2300   // flush the queue and render once
2301   application.SendNotification();
2302   application.Render();
2303
2304   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2305
2306   actor.ScaleBy(vector);
2307
2308   // flush the queue and render once
2309   application.SendNotification();
2310   application.Render();
2311
2312   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2313   END_TEST;
2314 }
2315
2316 int UtcDaliActorGetCurrentScale(void)
2317 {
2318   TestApplication application;
2319   Vector3         scale(12.0f, 1.0f, 2.0f);
2320
2321   Actor actor = Actor::New();
2322
2323   actor.SetProperty(Actor::Property::SCALE, scale);
2324
2325   // flush the queue and render once
2326   application.SendNotification();
2327   application.Render();
2328
2329   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2330   END_TEST;
2331 }
2332
2333 int UtcDaliActorGetCurrentWorldScale(void)
2334 {
2335   TestApplication application;
2336
2337   Actor   parent = Actor::New();
2338   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2339   parent.SetProperty(Actor::Property::SCALE, parentScale);
2340   application.GetScene().Add(parent);
2341
2342   Actor   child = Actor::New();
2343   Vector3 childScale(2.0f, 2.0f, 2.0f);
2344   child.SetProperty(Actor::Property::SCALE, childScale);
2345   parent.Add(child);
2346
2347   // The actors should not have a scale yet
2348   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2349   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2350
2351   // The actors should not have a world scale yet
2352   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2353   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2354
2355   application.SendNotification();
2356   application.Render(0);
2357
2358   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2359   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2360
2361   // The actors should have a world scale now
2362   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2363   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2364   END_TEST;
2365 }
2366
2367 int UtcDaliActorInheritScale(void)
2368 {
2369   tet_infoline("Testing Actor::SetInheritScale");
2370   TestApplication application;
2371
2372   Actor   parent = Actor::New();
2373   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2374   parent.SetProperty(Actor::Property::SCALE, parentScale);
2375   application.GetScene().Add(parent);
2376
2377   Actor   child = Actor::New();
2378   Vector3 childScale(2.0f, 2.0f, 2.0f);
2379   child.SetProperty(Actor::Property::SCALE, childScale);
2380   parent.Add(child);
2381
2382   application.SendNotification();
2383   application.Render(0);
2384
2385   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2386   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2387
2388   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2389   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2390
2391   application.SendNotification();
2392   application.Render(0);
2393
2394   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2395   END_TEST;
2396 }
2397
2398 int UtcDaliActorSetVisible(void)
2399 {
2400   TestApplication application;
2401
2402   Actor actor = Actor::New();
2403   actor.SetProperty(Actor::Property::VISIBLE, false);
2404   // flush the queue and render once
2405   application.SendNotification();
2406   application.Render();
2407   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2408
2409   actor.SetProperty(Actor::Property::VISIBLE, true);
2410   // flush the queue and render once
2411   application.SendNotification();
2412   application.Render();
2413   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2414
2415   // put actor on stage
2416   application.GetScene().Add(actor);
2417   actor.SetProperty(Actor::Property::VISIBLE, false);
2418   // flush the queue and render once
2419   application.SendNotification();
2420   application.Render();
2421   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2422   END_TEST;
2423 }
2424
2425 int UtcDaliActorIsVisible(void)
2426 {
2427   TestApplication application;
2428
2429   Actor actor = Actor::New();
2430
2431   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2432   END_TEST;
2433 }
2434
2435 int UtcDaliActorSetOpacity(void)
2436 {
2437   TestApplication application;
2438
2439   Actor actor = Actor::New();
2440   // initial opacity is 1
2441   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2442
2443   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2444   // flush the queue and render once
2445   application.SendNotification();
2446   application.Render();
2447   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2448
2449   // change opacity, actor is on stage to change is not immediate
2450   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2451   // flush the queue and render once
2452   application.SendNotification();
2453   application.Render();
2454   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2455
2456   // put actor on stage
2457   application.GetScene().Add(actor);
2458
2459   // change opacity, actor is on stage to change is not immediate
2460   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2461   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2462   // flush the queue and render once
2463   application.SendNotification();
2464   application.Render();
2465   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2466
2467   // change opacity, actor is on stage to change is not immediate
2468   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2469   // flush the queue and render once
2470   application.SendNotification();
2471   application.Render();
2472   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2473   END_TEST;
2474 }
2475
2476 int UtcDaliActorGetCurrentOpacity(void)
2477 {
2478   TestApplication application;
2479
2480   Actor actor = Actor::New();
2481   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2482
2483   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2484   // flush the queue and render once
2485   application.SendNotification();
2486   application.Render();
2487   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2488   END_TEST;
2489 }
2490
2491 int UtcDaliActorSetSensitive(void)
2492 {
2493   TestApplication application;
2494   Actor           actor = Actor::New();
2495
2496   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2497
2498   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2499
2500   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2501   END_TEST;
2502 }
2503
2504 int UtcDaliActorIsSensitive(void)
2505 {
2506   TestApplication application;
2507   Actor           actor = Actor::New();
2508   actor.SetProperty(Actor::Property::SENSITIVE, false);
2509
2510   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2511   END_TEST;
2512 }
2513
2514 int UtcDaliActorSetColor(void)
2515 {
2516   TestApplication application;
2517   Actor           actor = Actor::New();
2518   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2519
2520   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2521
2522   actor.SetProperty(Actor::Property::COLOR, color);
2523   // flush the queue and render once
2524   application.SendNotification();
2525   application.Render();
2526   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2527
2528   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2529   // flush the queue and render once
2530   application.SendNotification();
2531   application.Render();
2532   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2533
2534   application.GetScene().Add(actor);
2535   actor.SetProperty(Actor::Property::COLOR, color);
2536   // flush the queue and render once
2537   application.SendNotification();
2538   application.Render();
2539   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2540
2541   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2542   // flush the queue and render once
2543   application.SendNotification();
2544   application.Render();
2545   // Actor color is not clamped
2546   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2547   // world color is clamped
2548   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2549
2550   actor.SetProperty(Actor::Property::COLOR, color);
2551   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2552
2553   Vector3 newColor(1.0f, 0.0f, 0.0f);
2554   actor.SetProperty(Actor::Property::COLOR, newColor);
2555   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2556
2557   application.GetScene().Remove(actor);
2558   END_TEST;
2559 }
2560
2561 int UtcDaliActorSetColorIndividual(void)
2562 {
2563   TestApplication application;
2564
2565   Actor actor = Actor::New();
2566
2567   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2568   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2569
2570   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2571   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2572
2573   // flush the queue and render once
2574   application.SendNotification();
2575   application.Render();
2576
2577   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2578   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2579   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2580
2581   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2582   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2583
2584   // flush the queue and render once
2585   application.SendNotification();
2586   application.Render();
2587
2588   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2589   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2590   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2591
2592   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2593   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2594
2595   // flush the queue and render once
2596   application.SendNotification();
2597   application.Render();
2598
2599   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2600   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2601   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2602
2603   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2604   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2605
2606   // flush the queue and render once
2607   application.SendNotification();
2608   application.Render();
2609
2610   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2611   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2612   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2613
2614   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2615   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2616
2617   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2618
2619   // flush the queue and render once
2620   application.SendNotification();
2621   application.Render();
2622
2623   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2624
2625   END_TEST;
2626 }
2627
2628 int UtcDaliActorGetCurrentColor(void)
2629 {
2630   TestApplication application;
2631   Actor           actor = Actor::New();
2632   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2633
2634   actor.SetProperty(Actor::Property::COLOR, color);
2635   // flush the queue and render once
2636   application.SendNotification();
2637   application.Render();
2638   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2639   END_TEST;
2640 }
2641
2642 int UtcDaliActorGetCurrentWorldColor(void)
2643 {
2644   tet_infoline("Actor::GetCurrentWorldColor");
2645   TestApplication application;
2646
2647   Actor   parent = Actor::New();
2648   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2649   parent.SetProperty(Actor::Property::COLOR, parentColor);
2650   application.GetScene().Add(parent);
2651
2652   Actor   child = Actor::New();
2653   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2654   child.SetProperty(Actor::Property::COLOR, childColor);
2655   parent.Add(child);
2656
2657   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2658   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2659
2660   // verify the default color mode
2661   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2662
2663   // The actors should not have a world color yet
2664   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2665   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2666
2667   application.SendNotification();
2668   application.Render(0);
2669
2670   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2671   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2672
2673   // The actors should have a world color now
2674   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2675   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2676
2677   // use own color
2678   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2679   application.SendNotification();
2680   application.Render(0);
2681   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2682
2683   // use parent color
2684   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2685   application.SendNotification();
2686   application.Render(0);
2687   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2688   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2689
2690   // use parent alpha
2691   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2692   application.SendNotification();
2693   application.Render(0);
2694   Vector4 expectedColor(childColor);
2695   expectedColor.a *= parentColor.a;
2696   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2697   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2698   END_TEST;
2699 }
2700
2701 int UtcDaliActorSetColorMode(void)
2702 {
2703   tet_infoline("Actor::SetColorMode");
2704   TestApplication application;
2705   Actor           actor = Actor::New();
2706   Actor           child = Actor::New();
2707   actor.Add(child);
2708
2709   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2710   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2711
2712   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2713   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2714
2715   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2716   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2717
2718   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2719   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2720   END_TEST;
2721 }
2722
2723 int UtcDaliActorScreenToLocal(void)
2724 {
2725   TestApplication application;
2726   Actor           actor = Actor::New();
2727   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2728   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2729   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2730   application.GetScene().Add(actor);
2731
2732   // flush the queue and render once
2733   application.SendNotification();
2734   application.Render();
2735
2736   float localX;
2737   float localY;
2738
2739   application.SendNotification();
2740   application.Render();
2741
2742   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2743
2744   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2745   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2746   END_TEST;
2747 }
2748
2749 int UtcDaliActorSetLeaveRequired(void)
2750 {
2751   TestApplication application;
2752
2753   Actor actor = Actor::New();
2754
2755   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2756   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2757
2758   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2759   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2760   END_TEST;
2761 }
2762
2763 int UtcDaliActorGetLeaveRequired(void)
2764 {
2765   TestApplication application;
2766
2767   Actor actor = Actor::New();
2768
2769   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2770   END_TEST;
2771 }
2772
2773 int UtcDaliActorSetKeyboardFocusable(void)
2774 {
2775   TestApplication application;
2776
2777   Actor actor = Actor::New();
2778
2779   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2780   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2781
2782   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2783   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2784   END_TEST;
2785 }
2786
2787 int UtcDaliActorIsKeyboardFocusable(void)
2788 {
2789   TestApplication application;
2790
2791   Actor actor = Actor::New();
2792
2793   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2794   END_TEST;
2795 }
2796
2797 int UtcDaliActorSetKeyboardFocusableChildren(void)
2798 {
2799   TestApplication application;
2800
2801   Actor actor = Actor::New();
2802
2803   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2804   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2805
2806   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2807   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2808   END_TEST;
2809 }
2810
2811 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2812 {
2813   TestApplication application;
2814
2815   Actor actor = Actor::New();
2816
2817   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2818   END_TEST;
2819 }
2820
2821 int UtcDaliActorSetTouchFocusable(void)
2822 {
2823   TestApplication application;
2824
2825   Actor actor = Actor::New();
2826
2827   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2828   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2829
2830   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2831   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2832   END_TEST;
2833 }
2834
2835 int UtcDaliActorIsTouchFocusable(void)
2836 {
2837   TestApplication application;
2838
2839   Actor actor = Actor::New();
2840
2841   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2842   END_TEST;
2843 }
2844
2845 int UtcDaliActorSetUserInteractionEnabled(void)
2846 {
2847   TestApplication application;
2848   Actor           actor = Actor::New();
2849
2850   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2851
2852   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2853
2854   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2855   END_TEST;
2856 }
2857
2858 int UtcDaliActorIsUserInteractionEnabled(void)
2859 {
2860   TestApplication application;
2861   Actor           actor = Actor::New();
2862   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2863
2864   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2865   END_TEST;
2866 }
2867
2868 int UtcDaliActorRemoveConstraints(void)
2869 {
2870   tet_infoline(" UtcDaliActorRemoveConstraints");
2871   TestApplication application;
2872
2873   gTestConstraintCalled = false;
2874
2875   Actor actor = Actor::New();
2876
2877   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2878   constraint.Apply();
2879   actor.RemoveConstraints();
2880
2881   DALI_TEST_CHECK(gTestConstraintCalled == false);
2882
2883   application.GetScene().Add(actor);
2884   constraint.Apply();
2885
2886   // flush the queue and render once
2887   application.SendNotification();
2888   application.Render();
2889
2890   actor.RemoveConstraints();
2891
2892   DALI_TEST_CHECK(gTestConstraintCalled == true);
2893   END_TEST;
2894 }
2895
2896 int UtcDaliActorRemoveConstraintTag(void)
2897 {
2898   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2899   TestApplication application;
2900
2901   Actor actor = Actor::New();
2902
2903   // 1. Apply Constraint1 and Constraint2, and test...
2904   unsigned int result1 = 0u;
2905   unsigned int result2 = 0u;
2906
2907   unsigned   constraint1Tag = 1u;
2908   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2909   constraint1.SetTag(constraint1Tag);
2910   constraint1.Apply();
2911
2912   unsigned   constraint2Tag = 2u;
2913   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2914   constraint2.SetTag(constraint2Tag);
2915   constraint2.Apply();
2916
2917   application.GetScene().Add(actor);
2918   // flush the queue and render once
2919   application.SendNotification();
2920   application.Render();
2921
2922   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2923   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2924
2925   // 2. Remove Constraint1 and test...
2926   result1 = 0;
2927   result2 = 0;
2928   actor.RemoveConstraints(constraint1Tag);
2929   // make color property dirty, which will trigger constraints to be reapplied.
2930   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2931   // flush the queue and render once
2932   application.SendNotification();
2933   application.Render();
2934
2935   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2936   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2937
2938   // 3. Re-Apply Constraint1 and test...
2939   result1 = 0;
2940   result2 = 0;
2941   constraint1.Apply();
2942   // make color property dirty, which will trigger constraints to be reapplied.
2943   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2944   // flush the queue and render once
2945   application.SendNotification();
2946   application.Render();
2947
2948   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2949   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2950
2951   // 2. Remove Constraint2 and test...
2952   result1 = 0;
2953   result2 = 0;
2954   actor.RemoveConstraints(constraint2Tag);
2955   // make color property dirty, which will trigger constraints to be reapplied.
2956   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2957   // flush the queue and render once
2958   application.SendNotification();
2959   application.Render();
2960
2961   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2962   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2963
2964   // 2. Remove Constraint1 as well and test...
2965   result1 = 0;
2966   result2 = 0;
2967   actor.RemoveConstraints(constraint1Tag);
2968   // make color property dirty, which will trigger constraints to be reapplied.
2969   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2970   // flush the queue and render once
2971   application.SendNotification();
2972   application.Render();
2973
2974   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2975   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2976   END_TEST;
2977 }
2978
2979 int UtcDaliActorTouchedSignal(void)
2980 {
2981   TestApplication application;
2982
2983   ResetTouchCallbacks();
2984
2985   // get the root layer
2986   Actor actor = application.GetScene().GetRootLayer();
2987   DALI_TEST_CHECK(gTouchCallBackCalled == false);
2988
2989   application.SendNotification();
2990   application.Render();
2991
2992   // connect to its touch signal
2993   actor.TouchedSignal().Connect(TestTouchCallback);
2994
2995   // simulate a touch event in the middle of the screen
2996   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2997   Dali::Integration::Point point;
2998   point.SetDeviceId(1);
2999   point.SetState(PointState::DOWN);
3000   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3001   Dali::Integration::TouchEvent touchEvent;
3002   touchEvent.AddPoint(point);
3003   application.ProcessEvent(touchEvent);
3004
3005   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3006   END_TEST;
3007 }
3008
3009 int UtcDaliActorHoveredSignal(void)
3010 {
3011   TestApplication application;
3012
3013   gHoverCallBackCalled = false;
3014
3015   // get the root layer
3016   Actor actor = application.GetScene().GetRootLayer();
3017   DALI_TEST_CHECK(gHoverCallBackCalled == false);
3018
3019   application.SendNotification();
3020   application.Render();
3021
3022   // connect to its hover signal
3023   actor.HoveredSignal().Connect(TestCallback3);
3024
3025   // simulate a hover event in the middle of the screen
3026   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3027   Dali::Integration::Point point;
3028   point.SetDeviceId(1);
3029   point.SetState(PointState::MOTION);
3030   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3031   Dali::Integration::HoverEvent hoverEvent;
3032   hoverEvent.AddPoint(point);
3033   application.ProcessEvent(hoverEvent);
3034
3035   DALI_TEST_CHECK(gHoverCallBackCalled == true);
3036   END_TEST;
3037 }
3038
3039 int UtcDaliActorOnOffSceneSignal(void)
3040 {
3041   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3042
3043   TestApplication application;
3044
3045   // clean test data
3046   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3047   gActorNamesOnOffScene.clear();
3048
3049   Actor parent = Actor::New();
3050   parent.SetProperty(Actor::Property::NAME, "parent");
3051   parent.OnSceneSignal().Connect(OnSceneCallback);
3052   parent.OffSceneSignal().Connect(OffSceneCallback);
3053   // sanity check
3054   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3055   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3056
3057   // add parent to the scene
3058   application.GetScene().Add(parent);
3059   // onstage emitted, offstage not
3060   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3061   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3062   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3063
3064   // test adding a child, should get onstage emitted
3065   // clean test data
3066   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3067   gActorNamesOnOffScene.clear();
3068
3069   Actor child = Actor::New();
3070   child.SetProperty(Actor::Property::NAME, "child");
3071   child.OnSceneSignal().Connect(OnSceneCallback);
3072   child.OffSceneSignal().Connect(OffSceneCallback);
3073   parent.Add(child); // add child
3074   // onscene emitted, offscene not
3075   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3076   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3077   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3078
3079   // test removing parent from the scene
3080   // clean test data
3081   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3082   gActorNamesOnOffScene.clear();
3083
3084   application.GetScene().Remove(parent);
3085   // onscene not emitted, offscene is
3086   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3087   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3088   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3089   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3090
3091   // test adding parent back to the scene
3092   // clean test data
3093   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3094   gActorNamesOnOffScene.clear();
3095
3096   application.GetScene().Add(parent);
3097   // onscene emitted, offscene not
3098   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3099   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3100   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3101   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3102
3103   // test removing child
3104   // clean test data
3105   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3106   gActorNamesOnOffScene.clear();
3107
3108   parent.Remove(child);
3109   // onscene not emitted, offscene is
3110   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3111   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3112   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3113
3114   // test removing parent
3115   // clean test data
3116   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3117   gActorNamesOnOffScene.clear();
3118
3119   application.GetScene().Remove(parent);
3120   // onscene not emitted, offscene is
3121   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3122   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3123   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3124   END_TEST;
3125 }
3126
3127 int UtcDaliActorFindChildByName(void)
3128 {
3129   tet_infoline("Testing Dali::Actor::FindChildByName()");
3130   TestApplication application;
3131
3132   Actor parent = Actor::New();
3133   parent.SetProperty(Actor::Property::NAME, "parent");
3134   Actor first = Actor::New();
3135   first.SetProperty(Actor::Property::NAME, "first");
3136   Actor second = Actor::New();
3137   second.SetProperty(Actor::Property::NAME, "second");
3138
3139   parent.Add(first);
3140   first.Add(second);
3141
3142   Actor found = parent.FindChildByName("foo");
3143   DALI_TEST_CHECK(!found);
3144
3145   found = parent.FindChildByName("parent");
3146   DALI_TEST_CHECK(found == parent);
3147
3148   found = parent.FindChildByName("first");
3149   DALI_TEST_CHECK(found == first);
3150
3151   found = parent.FindChildByName("second");
3152   DALI_TEST_CHECK(found == second);
3153   END_TEST;
3154 }
3155
3156 int UtcDaliActorFindChildById(void)
3157 {
3158   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3159   TestApplication application;
3160
3161   Actor parent = Actor::New();
3162   Actor first  = Actor::New();
3163   Actor second = Actor::New();
3164
3165   parent.Add(first);
3166   first.Add(second);
3167
3168   Actor found = parent.FindChildById(100000);
3169   DALI_TEST_CHECK(!found);
3170
3171   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3172   DALI_TEST_CHECK(found == parent);
3173
3174   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3175   DALI_TEST_CHECK(found == first);
3176
3177   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3178   DALI_TEST_CHECK(found == second);
3179   END_TEST;
3180 }
3181
3182 int UtcDaliActorHitTest(void)
3183 {
3184   struct HitTestData
3185   {
3186   public:
3187     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3188     : mScale(scale),
3189       mTouchPoint(touchPoint),
3190       mResult(result)
3191     {
3192     }
3193
3194     Vector3 mScale;
3195     Vector2 mTouchPoint;
3196     bool    mResult;
3197   };
3198
3199   TestApplication application;
3200   tet_infoline(" UtcDaliActorHitTest");
3201
3202   // Fill a vector with different hit tests.
3203   struct HitTestData* hitTestData[] = {
3204     //                    scale                     touch point           result
3205     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3206     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3207     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.
3208     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3209     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.
3210     NULL,
3211   };
3212
3213   // get the root layer
3214   Actor actor = Actor::New();
3215   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3216   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3217
3218   application.GetScene().Add(actor);
3219
3220   ResetTouchCallbacks();
3221
3222   unsigned int index = 0;
3223   while(NULL != hitTestData[index])
3224   {
3225     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3226     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3227
3228     // flush the queue and render once
3229     application.SendNotification();
3230     application.Render();
3231
3232     DALI_TEST_CHECK(!gTouchCallBackCalled);
3233
3234     // connect to its touch signal
3235     actor.TouchedSignal().Connect(TestTouchCallback);
3236
3237     Dali::Integration::Point point;
3238     point.SetState(PointState::DOWN);
3239     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3240     Dali::Integration::TouchEvent event;
3241     event.AddPoint(point);
3242
3243     // flush the queue and render once
3244     application.SendNotification();
3245     application.Render();
3246     application.ProcessEvent(event);
3247
3248     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3249
3250     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3251       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3252                  hitTestData[index]->mScale.x,
3253                  hitTestData[index]->mScale.y,
3254                  hitTestData[index]->mScale.z,
3255                  hitTestData[index]->mTouchPoint.x,
3256                  hitTestData[index]->mTouchPoint.y,
3257                  hitTestData[index]->mResult);
3258
3259     ResetTouchCallbacks();
3260     ++index;
3261   }
3262   END_TEST;
3263 }
3264
3265 int UtcDaliActorSetDrawMode(void)
3266 {
3267   TestApplication application;
3268   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3269
3270   Actor a = Actor::New();
3271
3272   application.GetScene().Add(a);
3273   application.SendNotification();
3274   application.Render(0);
3275   application.SendNotification();
3276   application.Render(1);
3277
3278   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3279
3280   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3281   application.SendNotification();
3282   application.Render(1);
3283
3284   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3285
3286   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3287   application.SendNotification();
3288   application.Render(1);
3289
3290   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3291   END_TEST;
3292 }
3293
3294 int UtcDaliActorSetDrawModeOverlayRender(void)
3295 {
3296   TestApplication application;
3297   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3298
3299   application.SendNotification();
3300   application.Render(1);
3301
3302   std::vector<GLuint> ids;
3303   ids.push_back(8);  // first rendered actor
3304   ids.push_back(9);  // second rendered actor
3305   ids.push_back(10); // third rendered actor
3306   application.GetGlAbstraction().SetNextTextureIds(ids);
3307
3308   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3309   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3310   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3311   Actor   a      = CreateRenderableActor(imageA);
3312   Actor   b      = CreateRenderableActor(imageB);
3313   Actor   c      = CreateRenderableActor(imageC);
3314
3315   application.SendNotification();
3316   application.Render(1);
3317
3318   //Textures are bound when first created. Clear bound textures vector
3319   application.GetGlAbstraction().ClearBoundTextures();
3320
3321   // Render a,b,c as regular non-overlays. so order will be:
3322   // a (8)
3323   // b (9)
3324   // c (10)
3325   application.GetScene().Add(a);
3326   application.GetScene().Add(b);
3327   application.GetScene().Add(c);
3328
3329   application.SendNotification();
3330   application.Render(1);
3331
3332   // Should be 3 textures changes.
3333   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3334   typedef std::vector<GLuint>::size_type TextureSize;
3335   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3336   if(boundTextures.size() == 3)
3337   {
3338     DALI_TEST_CHECK(boundTextures[0] == 8u);
3339     DALI_TEST_CHECK(boundTextures[1] == 9u);
3340     DALI_TEST_CHECK(boundTextures[2] == 10u);
3341   }
3342
3343   // Now texture ids have been set, we can monitor their render order.
3344   // render a as an overlay (last), so order will be:
3345   // b (9)
3346   // c (10)
3347   // a (8)
3348   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3349   application.GetGlAbstraction().ClearBoundTextures();
3350
3351   application.SendNotification();
3352   application.Render(1);
3353
3354   // Should be 3 texture changes.
3355   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3356   if(boundTextures.size() == 3)
3357   {
3358     DALI_TEST_CHECK(boundTextures[0] == 9u);
3359     DALI_TEST_CHECK(boundTextures[1] == 10u);
3360     DALI_TEST_CHECK(boundTextures[2] == 8u);
3361   }
3362   END_TEST;
3363 }
3364
3365 int UtcDaliActorGetCurrentWorldMatrix(void)
3366 {
3367   TestApplication application;
3368   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3369
3370   Actor parent = Actor::New();
3371   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3372   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3373   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3374   Radian     rotationAngle(Degree(85.0f));
3375   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3376   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3377   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3378   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3379   parent.SetProperty(Actor::Property::SCALE, parentScale);
3380   application.GetScene().Add(parent);
3381
3382   Actor child = Actor::New();
3383   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3384   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3385   Radian     childRotationAngle(Degree(23.0f));
3386   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3387   Vector3    childScale(2.0f, 2.0f, 2.0f);
3388   child.SetProperty(Actor::Property::POSITION, childPosition);
3389   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3390   child.SetProperty(Actor::Property::SCALE, childScale);
3391   parent.Add(child);
3392
3393   application.SendNotification();
3394   application.Render(0);
3395   application.Render();
3396   application.SendNotification();
3397
3398   Matrix parentMatrix(false);
3399   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3400
3401   Matrix childMatrix(false);
3402   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3403
3404   //Child matrix should be the composition of child and parent
3405   Matrix childWorldMatrix(false);
3406   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3407
3408   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3409   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3410   END_TEST;
3411 }
3412
3413 int UtcDaliActorConstrainedToWorldMatrix(void)
3414 {
3415   TestApplication application;
3416   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3417
3418   Actor parent = Actor::New();
3419   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3420   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3421   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3422   Radian     rotationAngle(Degree(85.0f));
3423   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3424   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3425   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3426   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3427   parent.SetProperty(Actor::Property::SCALE, parentScale);
3428   application.GetScene().Add(parent);
3429
3430   Actor child = Actor::New();
3431   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3432   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3433   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3434   posConstraint.Apply();
3435
3436   application.GetScene().Add(child);
3437
3438   application.SendNotification();
3439   application.Render(0);
3440   application.Render();
3441   application.SendNotification();
3442
3443   Matrix parentMatrix(false);
3444   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3445
3446   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3447   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3448   END_TEST;
3449 }
3450
3451 int UtcDaliActorConstrainedToOrientation(void)
3452 {
3453   TestApplication application;
3454   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3455
3456   Actor parent = Actor::New();
3457   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3458   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3459   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3460   Radian     rotationAngle(Degree(85.0f));
3461   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3462   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3463   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3464   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3465   parent.SetProperty(Actor::Property::SCALE, parentScale);
3466   application.GetScene().Add(parent);
3467
3468   Actor child = Actor::New();
3469   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3470   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3471   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3472   posConstraint.Apply();
3473
3474   application.GetScene().Add(child);
3475
3476   application.SendNotification();
3477   application.Render(0);
3478   application.Render();
3479   application.SendNotification();
3480
3481   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3482   END_TEST;
3483 }
3484
3485 int UtcDaliActorConstrainedToOpacity(void)
3486 {
3487   TestApplication application;
3488   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3489
3490   Actor parent = Actor::New();
3491   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3492   application.GetScene().Add(parent);
3493
3494   Actor      child             = Actor::New();
3495   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3496   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3497   opacityConstraint.Apply();
3498
3499   application.GetScene().Add(child);
3500
3501   application.SendNotification();
3502   application.Render(0);
3503   application.Render();
3504   application.SendNotification();
3505
3506   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3507
3508   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3509
3510   application.SendNotification();
3511   application.Render(0);
3512   application.Render();
3513   application.SendNotification();
3514
3515   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3516
3517   END_TEST;
3518 }
3519
3520 int UtcDaliActorUnparent(void)
3521 {
3522   TestApplication application;
3523   tet_infoline(" UtcDaliActorUnparent");
3524
3525   Actor parent = Actor::New();
3526   application.GetScene().Add(parent);
3527
3528   Actor child = Actor::New();
3529
3530   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3531   DALI_TEST_CHECK(!child.GetParent());
3532
3533   // Test that calling Unparent with no parent is a NOOP
3534   child.Unparent();
3535
3536   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3537   DALI_TEST_CHECK(!child.GetParent());
3538
3539   // Test that Unparent works
3540   parent.Add(child);
3541
3542   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3543   DALI_TEST_CHECK(parent == child.GetParent());
3544
3545   child.Unparent();
3546
3547   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3548   DALI_TEST_CHECK(!child.GetParent());
3549
3550   // Test that UnparentAndReset works
3551   parent.Add(child);
3552
3553   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3554   DALI_TEST_CHECK(parent == child.GetParent());
3555
3556   UnparentAndReset(child);
3557
3558   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3559   DALI_TEST_CHECK(!child);
3560
3561   // Test that UnparentAndReset is a NOOP with empty handle
3562   UnparentAndReset(child);
3563
3564   DALI_TEST_CHECK(!child);
3565   END_TEST;
3566 }
3567
3568 int UtcDaliActorGetChildAt(void)
3569 {
3570   TestApplication application;
3571   tet_infoline(" UtcDaliActorGetChildAt");
3572
3573   Actor parent = Actor::New();
3574   application.GetScene().Add(parent);
3575
3576   Actor child0 = Actor::New();
3577   parent.Add(child0);
3578
3579   Actor child1 = Actor::New();
3580   parent.Add(child1);
3581
3582   Actor child2 = Actor::New();
3583   parent.Add(child2);
3584
3585   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3586   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3587   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3588   END_TEST;
3589 }
3590
3591 int UtcDaliActorSetGetOverlay(void)
3592 {
3593   TestApplication application;
3594   tet_infoline(" UtcDaliActorSetGetOverlay");
3595
3596   Actor parent = Actor::New();
3597   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3598   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3599   END_TEST;
3600 }
3601
3602 int UtcDaliActorCreateDestroy(void)
3603 {
3604   Actor* actor = new Actor;
3605   DALI_TEST_CHECK(actor);
3606   delete actor;
3607   END_TEST;
3608 }
3609
3610 namespace
3611 {
3612 struct PropertyStringIndex
3613 {
3614   const char* const     name;
3615   const Property::Index index;
3616   const Property::Type  type;
3617 };
3618
3619 const PropertyStringIndex PROPERTY_TABLE[] =
3620   {
3621     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3622     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3623     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3624     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3625     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3626     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3627     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3628     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3629     {"size", Actor::Property::SIZE, Property::VECTOR3},
3630     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3631     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3632     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3633     {"position", Actor::Property::POSITION, Property::VECTOR3},
3634     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3635     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3636     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3637     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3638     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3639     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3640     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3641     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3642     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3643     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3644     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3645     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3646     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3647     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3648     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3649     {"color", Actor::Property::COLOR, Property::VECTOR4},
3650     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3651     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3652     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3653     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3654     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3655     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3656     {"name", Actor::Property::NAME, Property::STRING},
3657     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3658     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3659     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3660     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3661     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3662     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3663     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3664     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3665     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3666     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3667     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3668     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3669     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3670     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3671     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3672     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3673     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3674     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3675 };
3676 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3677 } // unnamed namespace
3678
3679 int UtcDaliActorProperties(void)
3680 {
3681   TestApplication application;
3682
3683   Actor actor = Actor::New();
3684
3685   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3686   {
3687     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3688     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3689     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3690     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3691   }
3692   END_TEST;
3693 }
3694
3695 int UtcDaliRelayoutProperties_ResizePolicies(void)
3696 {
3697   TestApplication application;
3698
3699   Actor actor = Actor::New();
3700
3701   // Defaults
3702   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3703   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3704
3705   // Set resize policy for all dimensions
3706   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3707   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3708   {
3709     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3710   }
3711
3712   // Set individual dimensions
3713   const char* const widthPolicy  = "FILL_TO_PARENT";
3714   const char* const heightPolicy = "FIXED";
3715
3716   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3717   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3718
3719   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3720   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3721
3722   // Set individual dimensions using enums
3723   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3724   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3725
3726   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3727   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3728
3729   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3730   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3731
3732   END_TEST;
3733 }
3734
3735 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3736 {
3737   TestApplication application;
3738
3739   Actor actor = Actor::New();
3740
3741   // Defaults
3742   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3743
3744   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3745   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3746   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3747
3748   // Set
3749   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3750   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3751
3752   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3753   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3754
3755   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3756   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3757
3758   END_TEST;
3759 }
3760
3761 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3762 {
3763   TestApplication application;
3764
3765   Actor actor = Actor::New();
3766
3767   // Defaults
3768   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3769   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3770
3771   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3772   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3773   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3774
3775   // Set
3776   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3777
3778   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3779   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3780
3781   END_TEST;
3782 }
3783
3784 int UtcDaliRelayoutProperties_DimensionDependency(void)
3785 {
3786   TestApplication application;
3787
3788   Actor actor = Actor::New();
3789
3790   // Defaults
3791   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3792   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3793
3794   // Set
3795   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3796   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3797
3798   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3799   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3800
3801   // Test setting another resize policy
3802   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3803   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3804
3805   END_TEST;
3806 }
3807
3808 int UtcDaliRelayoutProperties_Padding(void)
3809 {
3810   TestApplication application;
3811
3812   Actor actor = Actor::New();
3813
3814   // Data
3815   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3816
3817   // PADDING
3818   actor.SetProperty(Actor::Property::PADDING, padding);
3819   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3820
3821   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3822
3823   END_TEST;
3824 }
3825
3826 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3827 {
3828   TestApplication application;
3829
3830   Actor actor = Actor::New();
3831
3832   // Data
3833   Vector2 minSize(1.0f, 2.0f);
3834
3835   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3836   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3837
3838   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3839
3840   Vector2 maxSize(3.0f, 4.0f);
3841
3842   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3843   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3844
3845   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3846
3847   END_TEST;
3848 }
3849
3850 int UtcDaliActorGetHeightForWidth(void)
3851 {
3852   TestApplication application;
3853
3854   Actor actor = Actor::New();
3855
3856   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3857
3858   END_TEST;
3859 }
3860
3861 int UtcDaliActorGetWidthForHeight(void)
3862 {
3863   TestApplication application;
3864
3865   Actor actor = Actor::New();
3866
3867   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3868
3869   END_TEST;
3870 }
3871
3872 int UtcDaliActorGetRelayoutSize(void)
3873 {
3874   TestApplication application;
3875
3876   Actor actor = Actor::New();
3877
3878   // Add actor to stage
3879   application.GetScene().Add(actor);
3880
3881   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3882
3883   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3884   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3885
3886   // Flush the queue and render once
3887   application.SendNotification();
3888   application.Render();
3889
3890   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3891
3892   END_TEST;
3893 }
3894
3895 int UtcDaliActorSetPadding(void)
3896 {
3897   TestApplication application;
3898
3899   Actor actor = Actor::New();
3900
3901   Padding padding;
3902   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3903
3904   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3905   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3906   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3907   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3908
3909   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3910   actor.SetProperty(Actor::Property::PADDING, padding2);
3911
3912   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3913
3914   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3915   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3916   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3917   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3918
3919   END_TEST;
3920 }
3921
3922 int UtcDaliActorSetMinimumSize(void)
3923 {
3924   TestApplication application;
3925
3926   Actor actor = Actor::New();
3927
3928   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3929
3930   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3931   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3932
3933   Vector2 size2(1.0f, 2.0f);
3934   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3935
3936   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3937
3938   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3939   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3940
3941   END_TEST;
3942 }
3943
3944 int UtcDaliActorSetMaximumSize(void)
3945 {
3946   TestApplication application;
3947
3948   Actor actor = Actor::New();
3949
3950   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3951
3952   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3953   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3954
3955   Vector2 size2(1.0f, 2.0f);
3956   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3957
3958   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3959
3960   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3961   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3962
3963   END_TEST;
3964 }
3965
3966 int UtcDaliActorOnRelayoutSignal(void)
3967 {
3968   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3969
3970   TestApplication application;
3971
3972   // Clean test data
3973   gOnRelayoutCallBackCalled = false;
3974   gActorNamesRelayout.clear();
3975
3976   Actor actor = Actor::New();
3977   actor.SetProperty(Actor::Property::NAME, "actor");
3978   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3979
3980   // Sanity check
3981   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3982
3983   // Add actor to stage
3984   application.GetScene().Add(actor);
3985
3986   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3987   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3988
3989   // Flush the queue and render once
3990   application.SendNotification();
3991   application.Render();
3992
3993   // OnRelayout emitted
3994   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3995   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3996
3997   END_TEST;
3998 }
3999
4000 int UtcDaliActorGetHierachyDepth(void)
4001 {
4002   TestApplication application;
4003   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4004
4005   /* Build tree of actors:
4006    *
4007    *                      Depth
4008    *
4009    *       A (parent)       1
4010    *      / \
4011    *     B   C              2`
4012    *    / \   \
4013    *   D   E   F            3
4014    *
4015    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4016    */
4017   Integration::Scene stage(application.GetScene());
4018
4019   Actor actorA = Actor::New();
4020   Actor actorB = Actor::New();
4021   Actor actorC = Actor::New();
4022   Actor actorD = Actor::New();
4023   Actor actorE = Actor::New();
4024   Actor actorF = Actor::New();
4025
4026   //Test that root actor has depth equal 0
4027   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4028
4029   //Test actors return depth -1 when not connected to the tree
4030   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4031   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4032   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4033   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4034   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4035   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4036
4037   //Create the hierarchy
4038   stage.Add(actorA);
4039   actorA.Add(actorB);
4040   actorA.Add(actorC);
4041   actorB.Add(actorD);
4042   actorB.Add(actorE);
4043   actorC.Add(actorF);
4044
4045   //Test actors return correct depth
4046   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4047   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4048   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4049   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4050   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4051   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4052
4053   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4054   actorA.Remove(actorB);
4055
4056   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4057   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4058   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4059
4060   //Removing actorA from the stage. All actors should have depth equal -1
4061   stage.Remove(actorA);
4062
4063   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4064   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4065   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4066   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4067   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4068   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4069
4070   END_TEST;
4071 }
4072
4073 int UtcDaliActorAnchorPointPropertyAsString(void)
4074 {
4075   TestApplication application;
4076
4077   Actor actor = Actor::New();
4078
4079   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4080   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4081
4082   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4083   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4084
4085   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4086   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4087
4088   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4089   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4090
4091   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4092   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4093
4094   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4095   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4096
4097   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4098   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4099
4100   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4101   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4102
4103   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4104   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4105
4106   // Invalid should not change anything
4107   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4108   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4109
4110   END_TEST;
4111 }
4112
4113 int UtcDaliActorParentOriginPropertyAsString(void)
4114 {
4115   TestApplication application;
4116
4117   Actor actor = Actor::New();
4118
4119   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4120   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4121
4122   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4123   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4124
4125   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4126   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4127
4128   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4129   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4130
4131   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4132   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4133
4134   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4135   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4136
4137   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4138   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4139
4140   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4141   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4142
4143   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4144   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4145
4146   // Invalid should not change anything
4147   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4148   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4149
4150   END_TEST;
4151 }
4152
4153 int UtcDaliActorColorModePropertyAsString(void)
4154 {
4155   TestApplication application;
4156
4157   Actor actor = Actor::New();
4158
4159   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4160   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4161
4162   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4163   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4164
4165   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4166   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4167
4168   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4169   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4170
4171   // Invalid should not change anything
4172   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4173   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4174
4175   END_TEST;
4176 }
4177
4178 int UtcDaliActorDrawModePropertyAsString(void)
4179 {
4180   TestApplication application;
4181
4182   Actor actor = Actor::New();
4183
4184   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4185   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4186
4187   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4188   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4189
4190   // Invalid should not change anything
4191   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4192   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4193
4194   END_TEST;
4195 }
4196
4197 int UtcDaliActorColorModePropertyAsEnum(void)
4198 {
4199   TestApplication application;
4200
4201   Actor actor = Actor::New();
4202
4203   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4204   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4205
4206   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4207   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4208
4209   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4210   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4211
4212   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4213   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4214
4215   END_TEST;
4216 }
4217
4218 int UtcDaliActorDrawModePropertyAsEnum(void)
4219 {
4220   TestApplication application;
4221
4222   Actor actor = Actor::New();
4223
4224   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4225   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4226
4227   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4228   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4229
4230   END_TEST;
4231 }
4232
4233 int UtcDaliActorAddRendererP(void)
4234 {
4235   tet_infoline("Testing Actor::AddRenderer");
4236   TestApplication application;
4237
4238   Actor actor = Actor::New();
4239
4240   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4241
4242   Geometry geometry = CreateQuadGeometry();
4243   Shader   shader   = CreateShader();
4244   Renderer renderer = Renderer::New(geometry, shader);
4245
4246   actor.AddRenderer(renderer);
4247   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4248   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4249
4250   END_TEST;
4251 }
4252
4253 int UtcDaliActorAddRendererN01(void)
4254 {
4255   tet_infoline("Testing Actor::AddRenderer");
4256   TestApplication application;
4257
4258   Actor    actor = Actor::New();
4259   Renderer renderer;
4260
4261   // try illegal Add
4262   try
4263   {
4264     actor.AddRenderer(renderer);
4265     tet_printf("Assertion test failed - no Exception\n");
4266     tet_result(TET_FAIL);
4267   }
4268   catch(Dali::DaliException& e)
4269   {
4270     DALI_TEST_PRINT_ASSERT(e);
4271     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4272     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4273   }
4274   catch(...)
4275   {
4276     tet_printf("Assertion test failed - wrong Exception\n");
4277     tet_result(TET_FAIL);
4278   }
4279
4280   END_TEST;
4281 }
4282
4283 int UtcDaliActorAddRendererN02(void)
4284 {
4285   tet_infoline("UtcDaliActorAddRendererN02");
4286
4287   Actor    actor;
4288   Renderer renderer;
4289
4290   {
4291     TestApplication application;
4292
4293     Geometry geometry = CreateQuadGeometry();
4294     Shader   shader   = CreateShader();
4295     renderer          = Renderer::New(geometry, shader);
4296
4297     actor = Actor::New();
4298   }
4299
4300   // try illegal AddRenderer
4301   try
4302   {
4303     actor.AddRenderer(renderer);
4304     tet_printf("Assertion test failed - no Exception\n");
4305     tet_result(TET_FAIL);
4306   }
4307   catch(Dali::DaliException& e)
4308   {
4309     DALI_TEST_PRINT_ASSERT(e);
4310     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4311   }
4312   catch(...)
4313   {
4314     tet_printf("Assertion test failed - wrong Exception\n");
4315     tet_result(TET_FAIL);
4316   }
4317
4318   END_TEST;
4319 }
4320
4321 int UtcDaliActorAddRendererOnScene(void)
4322 {
4323   tet_infoline("Testing Actor::AddRenderer");
4324   TestApplication application;
4325
4326   Actor actor = Actor::New();
4327   application.GetScene().Add(actor);
4328
4329   application.SendNotification();
4330   application.Render(0);
4331
4332   Geometry geometry = CreateQuadGeometry();
4333   Shader   shader   = CreateShader();
4334   Renderer renderer = Renderer::New(geometry, shader);
4335
4336   application.SendNotification();
4337   application.Render(0);
4338
4339   try
4340   {
4341     actor.AddRenderer(renderer);
4342     tet_result(TET_PASS);
4343   }
4344   catch(...)
4345   {
4346     tet_result(TET_FAIL);
4347   }
4348
4349   END_TEST;
4350 }
4351
4352 int UtcDaliActorRemoveRendererP1(void)
4353 {
4354   tet_infoline("Testing Actor::RemoveRenderer");
4355   TestApplication application;
4356
4357   Actor actor = Actor::New();
4358
4359   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4360
4361   {
4362     Geometry geometry = CreateQuadGeometry();
4363     Shader   shader   = CreateShader();
4364     Renderer renderer = Renderer::New(geometry, shader);
4365
4366     actor.AddRenderer(renderer);
4367     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4368     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4369
4370     application.SendNotification();
4371     application.Render();
4372   }
4373
4374   {
4375     Renderer renderer = actor.GetRendererAt(0);
4376     actor.RemoveRenderer(renderer);
4377     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4378
4379     application.SendNotification();
4380     application.Render();
4381   }
4382
4383   // Call one final time to ensure that the renderer is actually removed after
4384   // the handle goes out of scope, and excercises the deletion code path in
4385   // scene graph and render.
4386   application.SendNotification();
4387   application.Render();
4388
4389   END_TEST;
4390 }
4391
4392 int UtcDaliActorRemoveRendererP2(void)
4393 {
4394   tet_infoline("Testing Actor::RemoveRenderer");
4395   TestApplication application;
4396
4397   Actor actor = Actor::New();
4398
4399   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4400
4401   Geometry geometry = CreateQuadGeometry();
4402   Shader   shader   = CreateShader();
4403   Renderer renderer = Renderer::New(geometry, shader);
4404
4405   actor.AddRenderer(renderer);
4406   application.SendNotification();
4407   application.Render();
4408
4409   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4410   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4411
4412   actor.RemoveRenderer(0);
4413   application.SendNotification();
4414   application.Render();
4415
4416   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4417
4418   // Shut down whilst holding onto the renderer handle.
4419   END_TEST;
4420 }
4421
4422 int UtcDaliActorRemoveRendererN(void)
4423 {
4424   tet_infoline("Testing Actor::RemoveRenderer");
4425   TestApplication application;
4426
4427   Actor actor = Actor::New();
4428
4429   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4430
4431   Geometry geometry = CreateQuadGeometry();
4432   Shader   shader   = CreateShader();
4433   Renderer renderer = Renderer::New(geometry, shader);
4434
4435   actor.AddRenderer(renderer);
4436   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4437   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4438
4439   actor.RemoveRenderer(10);
4440   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4441   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4442
4443   END_TEST;
4444 }
4445
4446 // Clipping test helper functions:
4447 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4448 {
4449   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4450   Actor   actor = CreateRenderableActor(image);
4451
4452   // Setup dimensions and position so actor is not skipped by culling.
4453   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4454   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4455   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4456   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4457
4458   return actor;
4459 }
4460
4461 Actor CreateActorWithContent16x16()
4462 {
4463   return CreateActorWithContent(16, 16);
4464 }
4465
4466 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4467 {
4468   enabledDisableTrace.Reset();
4469   stencilTrace.Reset();
4470   enabledDisableTrace.Enable(true);
4471   stencilTrace.Enable(true);
4472
4473   application.SendNotification();
4474   application.Render();
4475
4476   enabledDisableTrace.Enable(false);
4477   stencilTrace.Enable(false);
4478 }
4479
4480 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4481 {
4482   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4483
4484   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4485   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4486   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4487
4488   // @todo only test alpha if the framebuffer has an alpha channel
4489   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4490 }
4491
4492 int UtcDaliActorPropertyClippingP(void)
4493 {
4494   // This test checks the clippingMode property.
4495   tet_infoline("Testing Actor::Property::ClippingMode: P");
4496   TestApplication application;
4497
4498   Actor actor = Actor::New();
4499
4500   // Check default clippingEnabled value.
4501   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4502
4503   int  value          = 0;
4504   bool getValueResult = getValue.Get(value);
4505   DALI_TEST_CHECK(getValueResult);
4506
4507   if(getValueResult)
4508   {
4509     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4510   }
4511
4512   // Check setting the property to the stencil mode.
4513   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4514
4515   // Check the new value was set.
4516   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4517   getValueResult = getValue.Get(value);
4518   DALI_TEST_CHECK(getValueResult);
4519
4520   if(getValueResult)
4521   {
4522     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4523   }
4524
4525   // Check setting the property to the scissor mode.
4526   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4527
4528   // Check the new value was set.
4529   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4530   getValueResult = getValue.Get(value);
4531   DALI_TEST_CHECK(getValueResult);
4532
4533   if(getValueResult)
4534   {
4535     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4536   }
4537   END_TEST;
4538 }
4539
4540 int UtcDaliActorPropertyClippingN(void)
4541 {
4542   // Negative test case for Clipping.
4543   tet_infoline("Testing Actor::Property::ClippingMode: N");
4544   TestApplication application;
4545
4546   Actor actor = Actor::New();
4547
4548   // Check default clippingEnabled value.
4549   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4550
4551   int  value          = 0;
4552   bool getValueResult = getValue.Get(value);
4553   DALI_TEST_CHECK(getValueResult);
4554
4555   if(getValueResult)
4556   {
4557     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4558   }
4559
4560   // Check setting an invalid property value won't change the current property value.
4561   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4562
4563   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4564   getValueResult = getValue.Get(value);
4565   DALI_TEST_CHECK(getValueResult);
4566
4567   if(getValueResult)
4568   {
4569     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4570   }
4571
4572   END_TEST;
4573 }
4574
4575 int UtcDaliActorPropertyClippingActor(void)
4576 {
4577   // This test checks that an actor is correctly setup for clipping.
4578   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4579   TestApplication application;
4580
4581   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4582   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4583   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4584   size_t             startIndex          = 0u;
4585
4586   // Create a clipping actor.
4587   Actor actorDepth1Clip = CreateActorWithContent16x16();
4588   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4589   application.GetScene().Add(actorDepth1Clip);
4590
4591   // Gather the call trace.
4592   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4593
4594   // Check we are writing to the color buffer.
4595   CheckColorMask(glAbstraction, true);
4596
4597   // Check the stencil buffer was enabled.
4598   std::ostringstream oss;
4599   oss << std::hex << GL_STENCIL_TEST;
4600   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4601
4602   // Check the stencil buffer was cleared.
4603   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4604
4605   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4606   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4607   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4608   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4609
4610   END_TEST;
4611 }
4612
4613 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4614 {
4615   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4616   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4617   TestApplication application;
4618
4619   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4620   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4621   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4622   size_t             startIndex          = 0u;
4623
4624   // Create a clipping actor.
4625   Actor actorDepth1Clip = CreateActorWithContent16x16();
4626   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4627   application.GetScene().Add(actorDepth1Clip);
4628
4629   // Gather the call trace.
4630   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4631
4632   // Check we are writing to the color buffer.
4633   CheckColorMask(glAbstraction, true);
4634
4635   // Check the stencil buffer was enabled.
4636   std::ostringstream oss;
4637   oss << std::hex << GL_STENCIL_TEST;
4638   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4639
4640   // Check the stencil buffer was cleared.
4641   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4642
4643   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4644   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4645   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4646   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4647
4648   // Now disable the clipping
4649   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4650
4651   // Gather the call trace.
4652   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4653
4654   // Check the stencil buffer was disabled.
4655   std::ostringstream stencil;
4656   stencil << std::hex << GL_STENCIL_TEST;
4657   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4658
4659   // Ensure all values in stencil-mask are set to 1.
4660   startIndex = 0u;
4661   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4662
4663   END_TEST;
4664 }
4665
4666 int UtcDaliActorPropertyClippingNestedChildren(void)
4667 {
4668   // This test checks that a hierarchy of actors are clipped correctly by
4669   // writing to and reading from the correct bit-planes of the stencil buffer.
4670   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4671   TestApplication    application;
4672   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4673   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4674   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4675
4676   // Create a clipping actor.
4677   Actor actorDepth1Clip = CreateActorWithContent16x16();
4678   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4679   application.GetScene().Add(actorDepth1Clip);
4680
4681   // Create a child actor.
4682   Actor childDepth2 = CreateActorWithContent16x16();
4683   actorDepth1Clip.Add(childDepth2);
4684
4685   // Create another clipping actor.
4686   Actor childDepth2Clip = CreateActorWithContent16x16();
4687   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4688   childDepth2.Add(childDepth2Clip);
4689
4690   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4691   // This tests the sort algorithm.
4692   Actor childDepth3 = CreateActorWithContent16x16();
4693   childDepth2Clip.Add(childDepth3);
4694   Actor childDepth4 = CreateActorWithContent16x16();
4695   childDepth3.Add(childDepth4);
4696
4697   // Gather the call trace.
4698   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4699
4700   // Check we are writing to the color buffer.
4701   CheckColorMask(glAbstraction, true);
4702
4703   // Check the stencil buffer was enabled.
4704   std::ostringstream oss;
4705   oss << std::hex << GL_STENCIL_TEST;
4706   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4707
4708   // Perform the test twice, once for 2D layer, and once for 3D.
4709   for(unsigned int i = 0u; i < 2u; ++i)
4710   {
4711     size_t startIndex = 0u;
4712
4713     // Check the stencil buffer was cleared.
4714     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4715
4716     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4717     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4718     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4719     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4720
4721     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4722     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4723     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4724
4725     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4726     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4727     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4728     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4729
4730     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4731     // (Both must be set to pass the check).
4732     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4733     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4734
4735     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4736     if(i == 0u)
4737     {
4738       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4739       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4740     }
4741   }
4742
4743   END_TEST;
4744 }
4745
4746 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4747 {
4748   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4749   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4750   TestApplication    application;
4751   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4752   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4753
4754   /* We create a small tree of actors as follows:
4755
4756                            A
4757                           / \
4758      Clipping enabled -> B   D
4759                          |   |
4760                          C   E
4761
4762      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4763   */
4764   Actor actors[5];
4765   for(int i = 0; i < 5; ++i)
4766   {
4767     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4768     Actor   actor = CreateRenderableActor(image);
4769
4770     // Setup dimensions and position so actor is not skipped by culling.
4771     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4772     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4773
4774     if(i == 0)
4775     {
4776       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4777     }
4778     else
4779     {
4780       float b = i > 2 ? 1.0f : -1.0f;
4781       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4782     }
4783
4784     actors[i] = actor;
4785   }
4786
4787   // Enable clipping on the actor at the top of the left branch.
4788   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4789
4790   // Build the scene graph.
4791   application.GetScene().Add(actors[0]);
4792
4793   // Left branch:
4794   actors[0].Add(actors[1]);
4795   actors[1].Add(actors[2]);
4796
4797   // Right branch:
4798   actors[0].Add(actors[3]);
4799   actors[3].Add(actors[4]);
4800
4801   // Gather the call trace.
4802   enabledDisableTrace.Reset();
4803   enabledDisableTrace.Enable(true);
4804   application.SendNotification();
4805   application.Render();
4806   enabledDisableTrace.Enable(false);
4807
4808   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4809
4810      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
4811            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4812   */
4813   size_t             startIndex = 0u;
4814   std::ostringstream blend;
4815   blend << std::hex << GL_BLEND;
4816   std::ostringstream stencil;
4817   stencil << std::hex << GL_STENCIL_TEST;
4818
4819   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4820   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4821   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4822
4823   // Swap the clipping actor from top of left branch to top of right branch.
4824   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4825   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4826
4827   // Gather the call trace.
4828   enabledDisableTrace.Reset();
4829   enabledDisableTrace.Enable(true);
4830   application.SendNotification();
4831   application.Render();
4832   enabledDisableTrace.Enable(false);
4833
4834   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4835   // This proves the draw order has remained the same.
4836   startIndex = 0u;
4837   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4838   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4839
4840   END_TEST;
4841 }
4842
4843 int UtcDaliActorPropertyScissorClippingActor01(void)
4844 {
4845   // This test checks that an actor is correctly setup for clipping.
4846   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4847   TestApplication application;
4848
4849   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4850   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4851   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4852
4853   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4854   const Vector2 imageSize(16.0f, 16.0f);
4855
4856   // Create a clipping actor.
4857   Actor clippingActorA = CreateActorWithContent16x16();
4858   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4859   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4860   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4861   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4862   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4863   application.GetScene().Add(clippingActorA);
4864
4865   // Gather the call trace.
4866   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4867
4868   // Check we are writing to the color buffer.
4869   CheckColorMask(glAbstraction, true);
4870
4871   // Check scissor test was enabled.
4872
4873   std::ostringstream scissor;
4874   scissor << std::hex << GL_SCISSOR_TEST;
4875   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4876
4877   // Check the scissor was set, and the coordinates are correct.
4878   std::stringstream compareParametersString;
4879   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4880   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4881
4882   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4883   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4884
4885   // Gather the call trace.
4886   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4887
4888   // Check the scissor was set, and the coordinates are correct.
4889   compareParametersString.str(std::string());
4890   compareParametersString.clear();
4891   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4892   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4893
4894   END_TEST;
4895 }
4896
4897 int UtcDaliActorPropertyScissorClippingActor02(void)
4898 {
4899   // This test checks that an actor is correctly setup for clipping.
4900   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4901   TestApplication application;
4902
4903   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4904   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4905   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4906
4907   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4908   const Vector2 actorSize(16.0f, 16.0f);
4909
4910   // Create a clipping actor.
4911   Actor clippingActorA                  = CreateRenderableActor();
4912   clippingActorA[Actor::Property::SIZE] = actorSize;
4913
4914   Renderer renderer = clippingActorA.GetRendererAt(0);
4915   DALI_TEST_CHECK(renderer);
4916
4917   // Make Renderer opacity 0.
4918   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4919
4920   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4921   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4922   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4923   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4924   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4925   application.GetScene().Add(clippingActorA);
4926
4927   // Gather the call trace.
4928   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4929
4930   // Check we are writing to the color buffer.
4931   CheckColorMask(glAbstraction, true);
4932
4933   // Check scissor test was enabled.
4934
4935   std::ostringstream scissor;
4936   scissor << std::hex << GL_SCISSOR_TEST;
4937   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4938
4939   // Check the scissor was set, and the coordinates are correct.
4940   std::stringstream compareParametersString;
4941   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4942   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4943
4944   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4945   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4946
4947   // Gather the call trace.
4948   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4949
4950   // Check the scissor was set, and the coordinates are correct.
4951   compareParametersString.str(std::string());
4952   compareParametersString.clear();
4953   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4954   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4955
4956   END_TEST;
4957 }
4958
4959 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4960 {
4961   // This test checks that an actor is correctly setup for clipping.
4962   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4963   TestApplication application;
4964
4965   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4966   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4967   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4968
4969   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4970   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4971   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4972
4973   // Create a clipping actors.
4974   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4975   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4976
4977   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4978   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4979   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4980
4981   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4982   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4983   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4984
4985   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4986   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4987
4988   application.GetScene().Add(clippingActorA);
4989   application.GetScene().Add(clippingActorB);
4990
4991   // Gather the call trace.
4992   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4993
4994   // Check we are writing to the color buffer.
4995   CheckColorMask(glAbstraction, true);
4996
4997   // Check scissor test was enabled.
4998   std::ostringstream scissor;
4999   scissor << std::hex << GL_SCISSOR_TEST;
5000   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5001
5002   // Check the scissor was set, and the coordinates are correct.
5003   std::stringstream compareParametersString;
5004
5005   std::string clipA("0, 500, 480, 200");
5006   std::string clipB("0, 380, 480, 40");
5007
5008   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5009   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5010
5011   END_TEST;
5012 }
5013
5014 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5015 {
5016   // This test checks that an actor is correctly setup for clipping.
5017   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5018   TestApplication application;
5019
5020   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5021   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5022   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5023
5024   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5025   const Vector2 imageSize(16.0f, 16.0f);
5026
5027   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5028
5029      A is drawn first - with scissor clipping on
5030      B is drawn second - also with scissor clipping on
5031      C is the generated clipping region, the intersection ( A ∩ B )
5032
5033            ┏━━━━━━━┓                   ┌───────┐
5034            ┃     B ┃                   │     B │
5035        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5036        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5037        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5038        │ A     │                   ┊ A     ┊
5039        └───────┘                   └┄┄┄┄┄┄┄┘
5040
5041      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5042   */
5043
5044   // Create a clipping actor.
5045   Actor clippingActorA = CreateActorWithContent16x16();
5046   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5047   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5048   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5049   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5050   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5051   application.GetScene().Add(clippingActorA);
5052
5053   // Create a child clipping actor.
5054   Actor clippingActorB = CreateActorWithContent16x16();
5055   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5056   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5057   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5058   clippingActorA.Add(clippingActorB);
5059
5060   // positionModifiers is an array of positions to position B around.
5061   // expect is an array of expected scissor clip coordinate results.
5062   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5063   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5064
5065   // Loop through each overlap combination.
5066   for(unsigned int test = 0u; test < 4u; ++test)
5067   {
5068     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5069     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5070     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5071
5072     // Gather the call trace.
5073     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5074
5075     // Check we are writing to the color buffer.
5076     CheckColorMask(glAbstraction, true);
5077
5078     // Check scissor test was enabled.
5079     std::ostringstream scissor;
5080     scissor << std::hex << GL_SCISSOR_TEST;
5081     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5082
5083     // Check the scissor was set, and the coordinates are correct.
5084     const Vector4&    expectResults(expect[test]);
5085     std::stringstream compareParametersString;
5086     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5087     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5088   }
5089
5090   END_TEST;
5091 }
5092
5093 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5094 {
5095   // This test checks that an actor is correctly setup for clipping.
5096   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5097   TestApplication application;
5098
5099   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5100   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5101   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5102
5103   /* Create a nest of 2 scissors and siblings of the parent.
5104
5105             stage
5106               |
5107         ┌─────┐─────┐
5108         A     C     D
5109         |           |
5110         B           E
5111   */
5112
5113   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5114   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5115   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5116   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5117   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5118   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5119
5120   // Create a clipping actors.
5121   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5122   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5123   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5124   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5125   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5126
5127   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5128   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5129   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5130
5131   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5132   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5133   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5134
5135   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5136   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5137   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5138
5139   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5140   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5141   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5142
5143   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5144   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5145
5146   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5147   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5148   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5149   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5150   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5151
5152   application.GetScene().Add(clippingActorA);
5153   clippingActorA.Add(clippingActorB);
5154   application.GetScene().Add(clippingActorC);
5155   application.GetScene().Add(clippingActorD);
5156   clippingActorD.Add(clippingActorE);
5157
5158   // Gather the call trace.
5159   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5160
5161   // Check we are writing to the color buffer.
5162   CheckColorMask(glAbstraction, true);
5163
5164   // Check scissor test was enabled.
5165   std::ostringstream scissor;
5166   scissor << std::hex << GL_SCISSOR_TEST;
5167   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5168
5169   // Check the scissor was set, and the coordinates are correct.
5170   std::string clipA("0, 500, 480, 200");
5171   std::string clipB("0, 580, 480, 40");
5172   std::string clipC("0, 200, 480, 200");
5173   std::string clipD("0, 300, 480, 200");
5174
5175   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5176   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5177   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5178   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5179   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5180
5181   END_TEST;
5182 }
5183
5184 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5185 {
5186   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5187   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5188   TestApplication application;
5189
5190   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5191   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5192   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5193
5194   // Create a clipping actor.
5195   Actor actorDepth1Clip = CreateActorWithContent16x16();
5196   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5197   application.GetScene().Add(actorDepth1Clip);
5198
5199   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5200   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5201
5202   // Gather the call trace.
5203   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5204
5205   // Check we are writing to the color buffer.
5206   CheckColorMask(glAbstraction, true);
5207
5208   // Check the stencil buffer was not enabled.
5209   std::ostringstream stencil;
5210   stencil << std::hex << GL_STENCIL_TEST;
5211   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5212
5213   // Check stencil functions are not called.
5214   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5215   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5216
5217   // Check that scissor clipping is overriden by the renderer properties.
5218   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5219
5220   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5221
5222   // Gather the call trace.
5223   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5224
5225   // Check the stencil buffer was not enabled.
5226   std::ostringstream scissor;
5227   scissor << std::hex << GL_SCISSOR_TEST;
5228   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5229
5230   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5231
5232   END_TEST;
5233 }
5234
5235 int UtcDaliActorPropertyClippingActorCulled(void)
5236 {
5237   // This test checks that child actors are clipped by an culled parent actor.
5238   tet_infoline("Testing child actors are clipped by an culled parent actor");
5239   TestApplication application;
5240
5241   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5242   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5243   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5244
5245   const Vector2 actorSize(160.0f, 160.0f);
5246
5247   // Create a clipping actor.
5248   Actor clippingActorA                  = CreateRenderableActor();
5249   clippingActorA[Actor::Property::SIZE] = actorSize;
5250
5251   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5252   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5253   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5254   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5255   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5256   application.GetScene().Add(clippingActorA);
5257
5258   // Create a child actor
5259   Actor childActor                              = CreateRenderableActor();
5260   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5261   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5262   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5263   childActor[Actor::Property::INHERIT_POSITION] = false;
5264
5265   // Gather the call trace.
5266   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5267
5268   // Check scissor test was enabled.
5269   std::ostringstream scissor;
5270   scissor << std::hex << GL_SCISSOR_TEST;
5271   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5272
5273   // Check the scissor was set, and the coordinates are correct.
5274   std::stringstream compareParametersString;
5275   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5276   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5277
5278   // Move the clipping actor out of screen
5279   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5280
5281   // Gather the call trace.
5282   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5283
5284   // Check the scissor was set, and the coordinates are correct.
5285   compareParametersString.str(std::string());
5286   compareParametersString.clear();
5287   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5288   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5289
5290   END_TEST;
5291 }
5292
5293 int UtcDaliGetPropertyN(void)
5294 {
5295   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5296   TestApplication application;
5297
5298   Actor actor = Actor::New();
5299
5300   unsigned int propertyCount = actor.GetPropertyCount();
5301   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5302   END_TEST;
5303 }
5304
5305 int UtcDaliActorRaiseLower(void)
5306 {
5307   tet_infoline("UtcDaliActor Raise and Lower test\n");
5308
5309   TestApplication application;
5310
5311   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5312
5313   Integration::Scene stage(application.GetScene());
5314
5315   Actor actorA = Actor::New();
5316   Actor actorB = Actor::New();
5317   Actor actorC = Actor::New();
5318
5319   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5320   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5321
5322   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5323   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5324
5325   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5326   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5327
5328   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5329   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5330
5331   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5332   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5333
5334   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5335   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5336
5337   stage.Add(actorA);
5338   stage.Add(actorB);
5339   stage.Add(actorC);
5340
5341   ResetTouchCallbacks();
5342
5343   application.SendNotification();
5344   application.Render();
5345
5346   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5347   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5348   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5349
5350   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5351   // Only top actor will get touched.
5352   actorA.TouchedSignal().Connect(TestTouchCallback);
5353   actorB.TouchedSignal().Connect(TestTouchCallback2);
5354   actorC.TouchedSignal().Connect(TestTouchCallback3);
5355
5356   // Connect ChildOrderChangedSignal
5357   bool                     orderChangedSignal(false);
5358   Actor                    orderChangedActor;
5359   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5360   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5361
5362   Dali::Integration::Point point;
5363   point.SetDeviceId(1);
5364   point.SetState(PointState::DOWN);
5365   point.SetScreenPosition(Vector2(10.f, 10.f));
5366   Dali::Integration::TouchEvent touchEvent;
5367   touchEvent.AddPoint(point);
5368
5369   application.ProcessEvent(touchEvent);
5370
5371   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5372   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5373   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5374
5375   ResetTouchCallbacks();
5376
5377   tet_printf("Testing Raising of Actor\n");
5378
5379   int preActorOrder(0);
5380   int postActorOrder(0);
5381
5382   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5383   value.Get(preActorOrder);
5384
5385   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5386   actorB.Raise();
5387   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5388   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5389
5390   // Ensure sort order is calculated before next touch event
5391   application.SendNotification();
5392
5393   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5394   value.Get(postActorOrder);
5395
5396   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5397
5398   application.ProcessEvent(touchEvent);
5399
5400   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5401   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5402   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5403
5404   ResetTouchCallbacks();
5405
5406   tet_printf("Testing Lowering of Actor\n");
5407
5408   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5409   value.Get(preActorOrder);
5410
5411   orderChangedSignal = false;
5412
5413   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5414   actorB.Lower();
5415   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5416   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5417
5418   application.SendNotification(); // ensure sort order calculated before next touch event
5419
5420   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5421   value.Get(postActorOrder);
5422
5423   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5424
5425   application.ProcessEvent(touchEvent);
5426
5427   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5428   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5429   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5430
5431   ResetTouchCallbacks();
5432
5433   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5434
5435   END_TEST;
5436 }
5437
5438 int UtcDaliActorRaiseToTopLowerToBottom(void)
5439 {
5440   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5441
5442   TestApplication application;
5443
5444   Integration::Scene stage(application.GetScene());
5445
5446   Actor actorA = Actor::New();
5447   Actor actorB = Actor::New();
5448   Actor actorC = Actor::New();
5449
5450   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5451   // enables checking of which actor the uniform is assigned too
5452   Shader shaderA = CreateShader();
5453   shaderA.RegisterProperty("uRendererColor", 1.f);
5454
5455   Shader shaderB = CreateShader();
5456   shaderB.RegisterProperty("uRendererColor", 2.f);
5457
5458   Shader shaderC = CreateShader();
5459   shaderC.RegisterProperty("uRendererColor", 3.f);
5460
5461   Geometry geometry = CreateQuadGeometry();
5462
5463   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5464   Renderer rendererA = Renderer::New(geometry, shaderA);
5465   actorA.AddRenderer(rendererA);
5466
5467   Renderer rendererB = Renderer::New(geometry, shaderB);
5468   actorB.AddRenderer(rendererB);
5469
5470   Renderer rendererC = Renderer::New(geometry, shaderC);
5471   actorC.AddRenderer(rendererC);
5472
5473   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5474   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5475
5476   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5477   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5478
5479   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5480   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5481
5482   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5483   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5484
5485   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5486   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5487
5488   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5489   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5490
5491   stage.Add(actorA);
5492   stage.Add(actorB);
5493   stage.Add(actorC);
5494
5495   ResetTouchCallbacks();
5496
5497   // Connect ChildOrderChangedSignal
5498   bool                     orderChangedSignal(false);
5499   Actor                    orderChangedActor;
5500   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5501   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5502
5503   // Set up gl abstraction trace so can query the set uniform order
5504   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5505   glAbstraction.EnableSetUniformCallTrace(true);
5506   glAbstraction.ResetSetUniformCallStack();
5507
5508   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5509
5510   application.SendNotification();
5511   application.Render();
5512
5513   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5514
5515   // Test order of uniforms in stack
5516   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5517   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5518   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5519
5520   bool CBA = (indexC > indexB) && (indexB > indexA);
5521
5522   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5523
5524   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5525   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5526   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5527
5528   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5529   // Only top actor will get touched.
5530   actorA.TouchedSignal().Connect(TestTouchCallback);
5531   actorB.TouchedSignal().Connect(TestTouchCallback2);
5532   actorC.TouchedSignal().Connect(TestTouchCallback3);
5533
5534   Dali::Integration::Point point;
5535   point.SetDeviceId(1);
5536   point.SetState(PointState::DOWN);
5537   point.SetScreenPosition(Vector2(10.f, 10.f));
5538   Dali::Integration::TouchEvent touchEvent;
5539   touchEvent.AddPoint(point);
5540
5541   application.ProcessEvent(touchEvent);
5542
5543   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5544   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5545   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5546
5547   ResetTouchCallbacks();
5548
5549   tet_printf("RaiseToTop ActorA\n");
5550
5551   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5552   actorA.RaiseToTop();
5553   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5554   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5555
5556   application.SendNotification(); // ensure sorting order is calculated before next touch event
5557
5558   application.ProcessEvent(touchEvent);
5559
5560   glSetUniformStack.Reset();
5561
5562   application.SendNotification();
5563   application.Render();
5564
5565   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5566
5567   // Test order of uniforms in stack
5568   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5569   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5570   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5571
5572   tet_infoline("Testing A above C and B at bottom\n");
5573   bool ACB = (indexA > indexC) && (indexC > indexB);
5574
5575   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5576
5577   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5578   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5579   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5580
5581   ResetTouchCallbacks();
5582
5583   tet_printf("RaiseToTop ActorB\n");
5584
5585   orderChangedSignal = false;
5586
5587   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5588   actorB.RaiseToTop();
5589   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5590   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5591
5592   application.SendNotification(); // Ensure sort order is calculated before next touch event
5593
5594   application.ProcessEvent(touchEvent);
5595
5596   glSetUniformStack.Reset();
5597
5598   application.SendNotification();
5599   application.Render();
5600
5601   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5602
5603   // Test order of uniforms in stack
5604   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5605   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5606   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5607
5608   tet_infoline("Testing B above A and C at bottom\n");
5609   bool BAC = (indexB > indexA) && (indexA > indexC);
5610
5611   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5612
5613   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5614   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5615   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5616
5617   ResetTouchCallbacks();
5618
5619   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5620
5621   orderChangedSignal = false;
5622
5623   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5624   actorA.LowerToBottom();
5625   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5626   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5627
5628   application.SendNotification();
5629   application.Render();
5630
5631   orderChangedSignal = false;
5632
5633   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5634   actorB.LowerToBottom();
5635   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5636   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5637
5638   application.SendNotification();
5639   application.Render();
5640
5641   application.ProcessEvent(touchEvent);
5642
5643   glSetUniformStack.Reset();
5644
5645   application.SendNotification();
5646   application.Render();
5647
5648   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5649
5650   // Test order of uniforms in stack
5651   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5652   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5653   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5654
5655   tet_infoline("Testing C above A and B at bottom\n");
5656   bool CAB = (indexC > indexA) && (indexA > indexB);
5657
5658   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5659
5660   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5661   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5662   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5663
5664   ResetTouchCallbacks();
5665
5666   END_TEST;
5667 }
5668
5669 int UtcDaliActorRaiseAbove(void)
5670 {
5671   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5672
5673   TestApplication application;
5674
5675   Integration::Scene stage(application.GetScene());
5676
5677   Actor actorA = Actor::New();
5678   Actor actorB = Actor::New();
5679   Actor actorC = Actor::New();
5680
5681   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5682   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5683
5684   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5685   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5686
5687   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5688   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5689
5690   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5691   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5692
5693   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5694   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5695
5696   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5697   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5698
5699   stage.Add(actorA);
5700   stage.Add(actorB);
5701   stage.Add(actorC);
5702
5703   ResetTouchCallbacks();
5704
5705   application.SendNotification();
5706   application.Render();
5707
5708   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5709   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5710   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5711
5712   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5713   // Only top actor will get touched.
5714   actorA.TouchedSignal().Connect(TestTouchCallback);
5715   actorB.TouchedSignal().Connect(TestTouchCallback2);
5716   actorC.TouchedSignal().Connect(TestTouchCallback3);
5717
5718   bool                     orderChangedSignal(false);
5719   Actor                    orderChangedActor;
5720   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5721   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5722
5723   Dali::Integration::Point point;
5724   point.SetDeviceId(1);
5725   point.SetState(PointState::DOWN);
5726   point.SetScreenPosition(Vector2(10.f, 10.f));
5727   Dali::Integration::TouchEvent touchEvent;
5728   touchEvent.AddPoint(point);
5729
5730   application.ProcessEvent(touchEvent);
5731
5732   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5733   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5734   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5735
5736   ResetTouchCallbacks();
5737
5738   tet_printf("Raise actor B Above Actor C\n");
5739
5740   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5741   actorB.RaiseAbove(actorC);
5742   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5743   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5744
5745   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5746   application.SendNotification();
5747   application.ProcessEvent(touchEvent);
5748
5749   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5750   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5751   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5752
5753   ResetTouchCallbacks();
5754
5755   tet_printf("Raise actor A Above Actor B\n");
5756
5757   orderChangedSignal = false;
5758
5759   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5760   actorA.RaiseAbove(actorB);
5761   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5762   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5763
5764   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5765   application.SendNotification();
5766
5767   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5768
5769   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5770   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5771   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5772
5773   ResetTouchCallbacks();
5774
5775   END_TEST;
5776 }
5777
5778 int UtcDaliActorRaiseAbove2(void)
5779 {
5780   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5781
5782   TestApplication application;
5783
5784   Integration::Scene stage(application.GetScene());
5785
5786   Actor actorA = Actor::New();
5787   Actor actorB = Actor::New();
5788   Actor actorC = Actor::New();
5789
5790   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5791   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5792
5793   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5794   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5795
5796   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5797   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5798
5799   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5800   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5801
5802   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5803   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5804
5805   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5806   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5807
5808   stage.Add(actorA);
5809   stage.Add(actorB);
5810   stage.Add(actorC);
5811
5812   ResetTouchCallbacks();
5813
5814   application.SendNotification();
5815   application.Render();
5816
5817   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5818   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5819   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5820
5821   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5822   // Only top actor will get touched.
5823   actorA.TouchedSignal().Connect(TestTouchCallback);
5824   actorB.TouchedSignal().Connect(TestTouchCallback2);
5825   actorC.TouchedSignal().Connect(TestTouchCallback3);
5826
5827   bool                     orderChangedSignal(false);
5828   Actor                    orderChangedActor;
5829   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5830   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5831
5832   Dali::Integration::Point point;
5833   point.SetDeviceId(1);
5834   point.SetState(PointState::DOWN);
5835   point.SetScreenPosition(Vector2(10.f, 10.f));
5836   Dali::Integration::TouchEvent touchEvent;
5837   touchEvent.AddPoint(point);
5838
5839   application.ProcessEvent(touchEvent);
5840
5841   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5842   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5843   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5844
5845   ResetTouchCallbacks();
5846
5847   tet_printf("Raise actor B Above Actor C\n");
5848
5849   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5850   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5851   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5852   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5853   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5854
5855   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5856   application.SendNotification();
5857   application.ProcessEvent(touchEvent);
5858
5859   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5860   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5861   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5862
5863   ResetTouchCallbacks();
5864
5865   tet_printf("Raise actor A Above Actor B\n");
5866
5867   orderChangedSignal = false;
5868
5869   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5870   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5871   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5872   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5873   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5874
5875   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5876   application.SendNotification();
5877
5878   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5879
5880   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5881   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5882   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5883
5884   ResetTouchCallbacks();
5885
5886   END_TEST;
5887 }
5888
5889 int UtcDaliActorLowerBelow(void)
5890 {
5891   tet_infoline("UtcDaliActor LowerBelow test \n");
5892
5893   TestApplication application;
5894
5895   Integration::Scene stage(application.GetScene());
5896
5897   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5898   // enables checking of which actor the uniform is assigned too
5899   Shader shaderA = CreateShader();
5900   shaderA.RegisterProperty("uRendererColor", 1.f);
5901
5902   Shader shaderB = CreateShader();
5903   shaderB.RegisterProperty("uRendererColor", 2.f);
5904
5905   Shader shaderC = CreateShader();
5906   shaderC.RegisterProperty("uRendererColor", 3.f);
5907
5908   Actor actorA = Actor::New();
5909   Actor actorB = Actor::New();
5910   Actor actorC = Actor::New();
5911
5912   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5913   Geometry geometry = CreateQuadGeometry();
5914
5915   Renderer rendererA = Renderer::New(geometry, shaderA);
5916   actorA.AddRenderer(rendererA);
5917
5918   Renderer rendererB = Renderer::New(geometry, shaderB);
5919   actorB.AddRenderer(rendererB);
5920
5921   Renderer rendererC = Renderer::New(geometry, shaderC);
5922   actorC.AddRenderer(rendererC);
5923
5924   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5925   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5926
5927   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5928   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5929
5930   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5931   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5932
5933   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5934   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5935
5936   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5937   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5938
5939   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5940   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5941
5942   Actor container = Actor::New();
5943   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5944   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5945   stage.Add(container);
5946
5947   container.Add(actorA);
5948   container.Add(actorB);
5949   container.Add(actorC);
5950
5951   ResetTouchCallbacks();
5952
5953   // Connect ChildOrderChangedSignal
5954   bool                     orderChangedSignal(false);
5955   Actor                    orderChangedActor;
5956   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5957   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5958
5959   // Set up gl abstraction trace so can query the set uniform order
5960   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5961   glAbstraction.EnableSetUniformCallTrace(true);
5962   glAbstraction.ResetSetUniformCallStack();
5963   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5964
5965   glAbstraction.ResetSetUniformCallStack();
5966
5967   application.SendNotification();
5968   application.Render();
5969
5970   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5971
5972   // Test order of uniforms in stack
5973   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5974   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5975   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5976
5977   tet_infoline("Testing C above B and A at bottom\n");
5978   bool CBA = (indexC > indexB) && (indexB > indexA);
5979
5980   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5981
5982   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5983   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5984   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5985
5986   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5987   // Only top actor will get touched.
5988   actorA.TouchedSignal().Connect(TestTouchCallback);
5989   actorB.TouchedSignal().Connect(TestTouchCallback2);
5990   actorC.TouchedSignal().Connect(TestTouchCallback3);
5991
5992   Dali::Integration::Point point;
5993   point.SetDeviceId(1);
5994   point.SetState(PointState::DOWN);
5995   point.SetScreenPosition(Vector2(10.f, 10.f));
5996   Dali::Integration::TouchEvent touchEvent;
5997   touchEvent.AddPoint(point);
5998
5999   tet_infoline("UtcDaliActor Test Set up completed \n");
6000
6001   application.ProcessEvent(touchEvent);
6002
6003   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6004   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6005   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6006
6007   ResetTouchCallbacks();
6008
6009   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");
6010
6011   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6012   actorC.LowerBelow(actorB);
6013   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6014   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6015
6016   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6017   application.SendNotification();
6018   application.Render();
6019
6020   application.ProcessEvent(touchEvent); // touch event
6021
6022   glSetUniformStack.Reset();
6023
6024   application.SendNotification();
6025   application.Render();
6026
6027   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6028
6029   // Test order of uniforms in stack
6030   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6031   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6032   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6033
6034   tet_infoline("Testing render order is A, C, B");
6035   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6036   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6037
6038   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6039   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6040   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6041
6042   ResetTouchCallbacks();
6043
6044   tet_printf("Lower actor C below Actor A leaving B on top\n");
6045
6046   orderChangedSignal = false;
6047
6048   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6049   actorC.LowerBelow(actorA);
6050   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6051   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6052
6053   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6054   application.SendNotification();
6055   application.Render();
6056
6057   application.ProcessEvent(touchEvent);
6058
6059   glSetUniformStack.Reset();
6060
6061   application.Render();
6062   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6063
6064   // Test order of uniforms in stack
6065   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6066   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6067   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6068
6069   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6070   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6071
6072   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6073   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6074   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6075
6076   ResetTouchCallbacks();
6077
6078   tet_printf("Lower actor B below Actor C leaving A on top\n");
6079
6080   orderChangedSignal = false;
6081
6082   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6083   actorB.LowerBelow(actorC);
6084   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6085   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6086
6087   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6088   application.SendNotification();
6089   application.Render();
6090
6091   application.ProcessEvent(touchEvent);
6092
6093   glSetUniformStack.Reset();
6094
6095   application.Render();
6096   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6097
6098   // Test order of uniforms in stack
6099   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6100   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6101   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6102
6103   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6104   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6105
6106   END_TEST;
6107 }
6108
6109 int UtcDaliActorLowerBelow2(void)
6110 {
6111   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6112
6113   TestApplication application;
6114
6115   Integration::Scene stage(application.GetScene());
6116
6117   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6118   // enables checking of which actor the uniform is assigned too
6119   Shader shaderA = CreateShader();
6120   shaderA.RegisterProperty("uRendererColor", 1.f);
6121
6122   Shader shaderB = CreateShader();
6123   shaderB.RegisterProperty("uRendererColor", 2.f);
6124
6125   Shader shaderC = CreateShader();
6126   shaderC.RegisterProperty("uRendererColor", 3.f);
6127
6128   Actor actorA = Actor::New();
6129   Actor actorB = Actor::New();
6130   Actor actorC = Actor::New();
6131
6132   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6133   Geometry geometry = CreateQuadGeometry();
6134
6135   Renderer rendererA = Renderer::New(geometry, shaderA);
6136   actorA.AddRenderer(rendererA);
6137
6138   Renderer rendererB = Renderer::New(geometry, shaderB);
6139   actorB.AddRenderer(rendererB);
6140
6141   Renderer rendererC = Renderer::New(geometry, shaderC);
6142   actorC.AddRenderer(rendererC);
6143
6144   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6145   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6146
6147   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6148   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6149
6150   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6151   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6152
6153   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6154   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6155
6156   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6157   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6158
6159   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6160   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6161
6162   Actor container = Actor::New();
6163   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6164   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6165   stage.Add(container);
6166
6167   container.Add(actorA);
6168   container.Add(actorB);
6169   container.Add(actorC);
6170
6171   ResetTouchCallbacks();
6172
6173   // Connect ChildOrderChangedSignal
6174   bool                     orderChangedSignal(false);
6175   Actor                    orderChangedActor;
6176   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6177   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6178
6179   // Set up gl abstraction trace so can query the set uniform order
6180   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6181   glAbstraction.EnableSetUniformCallTrace(true);
6182   glAbstraction.ResetSetUniformCallStack();
6183   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6184
6185   glAbstraction.ResetSetUniformCallStack();
6186
6187   application.SendNotification();
6188   application.Render();
6189
6190   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6191
6192   // Test order of uniforms in stack
6193   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6194   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6195   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6196
6197   tet_infoline("Testing C above B and A at bottom\n");
6198   bool CBA = (indexC > indexB) && (indexB > indexA);
6199
6200   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6201
6202   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6203   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6204   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6205
6206   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6207   // Only top actor will get touched.
6208   actorA.TouchedSignal().Connect(TestTouchCallback);
6209   actorB.TouchedSignal().Connect(TestTouchCallback2);
6210   actorC.TouchedSignal().Connect(TestTouchCallback3);
6211
6212   Dali::Integration::Point point;
6213   point.SetDeviceId(1);
6214   point.SetState(PointState::DOWN);
6215   point.SetScreenPosition(Vector2(10.f, 10.f));
6216   Dali::Integration::TouchEvent touchEvent;
6217   touchEvent.AddPoint(point);
6218
6219   tet_infoline("UtcDaliActor Test Set up completed \n");
6220
6221   application.ProcessEvent(touchEvent);
6222
6223   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6224   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6225   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6226
6227   ResetTouchCallbacks();
6228
6229   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");
6230
6231   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6232   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6233   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6234   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6235
6236   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6237   application.SendNotification();
6238   application.Render();
6239
6240   application.ProcessEvent(touchEvent); // touch event
6241
6242   glSetUniformStack.Reset();
6243
6244   application.SendNotification();
6245   application.Render();
6246
6247   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6248
6249   // Test order of uniforms in stack
6250   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6251   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6252   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6253
6254   tet_infoline("Testing render order is A, C, B");
6255   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6256   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6257
6258   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6259   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6260   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6261
6262   ResetTouchCallbacks();
6263
6264   tet_printf("Lower actor C below Actor A leaving B on top\n");
6265
6266   orderChangedSignal = false;
6267
6268   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6269   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6270   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6271   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6272
6273   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6274   application.SendNotification();
6275   application.Render();
6276
6277   application.ProcessEvent(touchEvent);
6278
6279   glSetUniformStack.Reset();
6280
6281   application.Render();
6282   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6283
6284   // Test order of uniforms in stack
6285   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6286   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6287   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6288
6289   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6290   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6291
6292   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6293   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6294   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6295
6296   ResetTouchCallbacks();
6297
6298   tet_printf("Lower actor B below Actor C leaving A on top\n");
6299
6300   orderChangedSignal = false;
6301
6302   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6303   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6304   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6305   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6306
6307   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6308   application.SendNotification();
6309   application.Render();
6310
6311   application.ProcessEvent(touchEvent);
6312
6313   glSetUniformStack.Reset();
6314
6315   application.Render();
6316   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6317
6318   // Test order of uniforms in stack
6319   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6320   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6321   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6322
6323   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6324   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6325
6326   END_TEST;
6327 }
6328
6329 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6330 {
6331   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6332
6333   TestApplication application;
6334
6335   Integration::Scene stage(application.GetScene());
6336
6337   Actor parentA = Actor::New();
6338   Actor parentB = Actor::New();
6339   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6340   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6341   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6342   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6343
6344   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6345   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6346
6347   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6348   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6349
6350   stage.Add(parentA);
6351   stage.Add(parentB);
6352
6353   Actor actorA = Actor::New();
6354   Actor actorB = Actor::New();
6355   Actor actorC = Actor::New();
6356
6357   parentA.Add(actorA);
6358   parentA.Add(actorB);
6359
6360   tet_printf("Actor C added to different parent from A and B \n");
6361   parentB.Add(actorC);
6362
6363   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6364   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6365
6366   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6367   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6368
6369   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6370   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6371
6372   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6373   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6374
6375   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6376   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6377
6378   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6379   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6380
6381   ResetTouchCallbacks();
6382
6383   // Connect ChildOrderChangedSignal
6384   bool                     orderChangedSignal(false);
6385   Actor                    orderChangedActor;
6386   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6387   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6388
6389   application.SendNotification();
6390   application.Render();
6391
6392   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6393   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6394   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6395
6396   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6397   // Only top actor will get touched.
6398   actorA.TouchedSignal().Connect(TestTouchCallback);
6399   actorB.TouchedSignal().Connect(TestTouchCallback2);
6400   actorC.TouchedSignal().Connect(TestTouchCallback3);
6401
6402   Dali::Integration::Point point;
6403   point.SetDeviceId(1);
6404   point.SetState(PointState::DOWN);
6405   point.SetScreenPosition(Vector2(10.f, 10.f));
6406   Dali::Integration::TouchEvent touchEvent;
6407   touchEvent.AddPoint(point);
6408
6409   application.ProcessEvent(touchEvent);
6410
6411   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6412   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6413   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6414
6415   ResetTouchCallbacks();
6416
6417   tet_printf("Raise actor A Above Actor C which have different parents\n");
6418
6419   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6420   actorA.RaiseAbove(actorC);
6421   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6422
6423   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6424   application.SendNotification();
6425
6426   application.ProcessEvent(touchEvent); // touch event
6427
6428   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6429   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6430   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6431
6432   ResetTouchCallbacks();
6433
6434   END_TEST;
6435 }
6436
6437 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6438 {
6439   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6440
6441   TestApplication application;
6442
6443   Integration::Scene stage(application.GetScene());
6444
6445   Actor actorA = Actor::New();
6446   Actor actorB = Actor::New();
6447   Actor actorC = Actor::New();
6448
6449   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6450   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6451
6452   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6453   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6454
6455   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6456   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6457
6458   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6459   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6460
6461   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6462   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6463
6464   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6465   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6466
6467   ResetTouchCallbacks();
6468
6469   // Connect ChildOrderChangedSignal
6470   bool                     orderChangedSignal(false);
6471   Actor                    orderChangedActor;
6472   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6473   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6474
6475   application.SendNotification();
6476   application.Render();
6477
6478   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6479   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6480   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6481
6482   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6483   // Only top actor will get touched.
6484   actorA.TouchedSignal().Connect(TestTouchCallback);
6485   actorB.TouchedSignal().Connect(TestTouchCallback2);
6486   actorC.TouchedSignal().Connect(TestTouchCallback3);
6487
6488   Dali::Integration::Point point;
6489   point.SetDeviceId(1);
6490   point.SetState(PointState::DOWN);
6491   point.SetScreenPosition(Vector2(10.f, 10.f));
6492   Dali::Integration::TouchEvent touchEvent;
6493   touchEvent.AddPoint(point);
6494
6495   tet_printf("Raise actor A Above Actor C which have no parents\n");
6496
6497   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6498   actorA.RaiseAbove(actorC);
6499   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6500
6501   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6502   application.SendNotification();
6503
6504   application.ProcessEvent(touchEvent);
6505
6506   tet_printf("Not parented so RaiseAbove should show no effect\n");
6507
6508   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6509   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6510   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6511
6512   ResetTouchCallbacks();
6513
6514   orderChangedSignal = false;
6515
6516   stage.Add(actorB);
6517   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6518
6519   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6520   actorA.LowerBelow(actorC);
6521   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6522
6523   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6524   application.SendNotification();
6525   application.Render();
6526
6527   application.ProcessEvent(touchEvent);
6528
6529   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6530   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6531   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6532   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6533
6534   ResetTouchCallbacks();
6535
6536   orderChangedSignal = false;
6537
6538   tet_printf("Adding Actor A to stage, will be on top\n");
6539
6540   stage.Add(actorA);
6541   application.SendNotification();
6542   application.Render();
6543
6544   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6545
6546   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6547   actorB.RaiseAbove(actorC);
6548   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6549
6550   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6551   application.SendNotification();
6552
6553   application.ProcessEvent(touchEvent);
6554
6555   tet_printf("C not parented so RaiseAbove should show no effect\n");
6556   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6557   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6558   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6559
6560   ResetTouchCallbacks();
6561
6562   orderChangedSignal = false;
6563
6564   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6565
6566   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6567   actorA.LowerBelow(actorC);
6568   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6569
6570   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6571   application.SendNotification();
6572
6573   application.ProcessEvent(touchEvent);
6574
6575   tet_printf("C not parented so LowerBelow should show no effect\n");
6576   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6577   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6578   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6579
6580   ResetTouchCallbacks();
6581
6582   orderChangedSignal = false;
6583
6584   stage.Add(actorC);
6585
6586   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6587   actorA.RaiseAbove(actorC);
6588   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6589   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6590
6591   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6592   application.SendNotification();
6593   application.Render();
6594
6595   application.ProcessEvent(touchEvent);
6596
6597   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6598   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6599   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6600   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6601
6602   END_TEST;
6603 }
6604
6605 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6606 {
6607   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6608
6609   TestApplication application;
6610
6611   Integration::Scene stage(application.GetScene());
6612
6613   Actor actorA = Actor::New();
6614   Actor actorB = Actor::New();
6615   Actor actorC = Actor::New();
6616
6617   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6618   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6619
6620   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6621   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6622
6623   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6624   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6625
6626   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6627   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6628
6629   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6630   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6631
6632   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6633   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6634
6635   ResetTouchCallbacks();
6636
6637   // Connect ChildOrderChangedSignal
6638   bool                     orderChangedSignal(false);
6639   Actor                    orderChangedActor;
6640   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6641   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6642
6643   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6644   // Only top actor will get touched.
6645   actorA.TouchedSignal().Connect(TestTouchCallback);
6646   actorB.TouchedSignal().Connect(TestTouchCallback2);
6647   actorC.TouchedSignal().Connect(TestTouchCallback3);
6648
6649   Dali::Integration::Point point;
6650   point.SetDeviceId(1);
6651   point.SetState(PointState::DOWN);
6652   point.SetScreenPosition(Vector2(10.f, 10.f));
6653   Dali::Integration::TouchEvent touchEvent;
6654   touchEvent.AddPoint(point);
6655
6656   stage.Add(actorA);
6657   tet_printf("Raise actor B Above Actor C but B not parented\n");
6658
6659   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6660   actorB.Raise();
6661   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6662
6663   application.SendNotification();
6664   application.Render();
6665
6666   application.ProcessEvent(touchEvent);
6667
6668   tet_printf("Not parented so RaiseAbove should show no effect\n");
6669
6670   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6671   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6672   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6673
6674   tet_printf("Raise actor B Above Actor C but B not parented\n");
6675   ResetTouchCallbacks();
6676
6677   orderChangedSignal = false;
6678
6679   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6680   actorC.Lower();
6681   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6682
6683   // Sort actor tree before next touch event
6684   application.SendNotification();
6685   application.Render();
6686
6687   application.ProcessEvent(touchEvent);
6688
6689   tet_printf("Not parented so RaiseAbove should show no effect\n");
6690
6691   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6692   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6693   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6694   ResetTouchCallbacks();
6695
6696   orderChangedSignal = false;
6697
6698   tet_printf("Lower actor C below B but C not parented\n");
6699
6700   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6701   actorB.Lower();
6702   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6703
6704   // Sort actor tree before next touch event
6705   application.SendNotification();
6706   application.Render();
6707
6708   application.ProcessEvent(touchEvent);
6709
6710   tet_printf("Not parented so Lower should show no effect\n");
6711
6712   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6713   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6714   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6715   ResetTouchCallbacks();
6716
6717   orderChangedSignal = false;
6718
6719   tet_printf("Raise actor B to top\n");
6720
6721   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6722   actorB.RaiseToTop();
6723   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6724
6725   // Sort actor tree before next touch event
6726   application.SendNotification();
6727   application.Render();
6728
6729   application.ProcessEvent(touchEvent);
6730
6731   tet_printf("Not parented so RaiseToTop should show no effect\n");
6732
6733   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6734   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6735   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6736   ResetTouchCallbacks();
6737
6738   orderChangedSignal = false;
6739
6740   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6741
6742   stage.Add(actorB);
6743
6744   tet_printf("Lower actor C to Bottom, B stays at top\n");
6745
6746   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6747   actorC.LowerToBottom();
6748   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6749
6750   application.SendNotification();
6751   application.Render();
6752
6753   application.ProcessEvent(touchEvent);
6754
6755   tet_printf("Not parented so LowerToBottom should show no effect\n");
6756
6757   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6758   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6759   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6760   ResetTouchCallbacks();
6761
6762   END_TEST;
6763 }
6764
6765 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6766 {
6767   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6768
6769   TestApplication application;
6770
6771   Integration::Scene stage(application.GetScene());
6772
6773   Actor actorA = Actor::New();
6774   Actor actorB = Actor::New();
6775   Actor actorC = Actor::New();
6776
6777   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6778   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6779
6780   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6781   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6782
6783   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6784   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6785
6786   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6787   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6788
6789   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6790   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6791
6792   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6793   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6794
6795   stage.Add(actorA);
6796   stage.Add(actorB);
6797   stage.Add(actorC);
6798
6799   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6800   // Only top actor will get touched.
6801   actorA.TouchedSignal().Connect(TestTouchCallback);
6802   actorB.TouchedSignal().Connect(TestTouchCallback2);
6803   actorC.TouchedSignal().Connect(TestTouchCallback3);
6804
6805   ResetTouchCallbacks();
6806
6807   // Connect ChildOrderChangedSignal
6808   bool                     orderChangedSignal(false);
6809   Actor                    orderChangedActor;
6810   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6811   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6812
6813   application.SendNotification();
6814   application.Render();
6815
6816   Dali::Integration::Point point;
6817   point.SetDeviceId(1);
6818   point.SetState(PointState::DOWN);
6819   point.SetScreenPosition(Vector2(10.f, 10.f));
6820   Dali::Integration::TouchEvent touchEvent;
6821   touchEvent.AddPoint(point);
6822
6823   application.ProcessEvent(touchEvent);
6824
6825   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6826   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6827   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6828
6829   ResetTouchCallbacks();
6830
6831   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6832
6833   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6834   actorA.RaiseAbove(actorA);
6835   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6836   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6837
6838   application.SendNotification();
6839   application.Render();
6840
6841   application.ProcessEvent(touchEvent);
6842
6843   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6844
6845   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6846   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6847   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6848
6849   ResetTouchCallbacks();
6850
6851   orderChangedSignal = false;
6852
6853   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6854   actorA.RaiseAbove(actorC);
6855   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6856   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6857
6858   application.SendNotification();
6859   application.Render();
6860
6861   application.ProcessEvent(touchEvent);
6862
6863   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6864   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6865   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6866   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6867
6868   END_TEST;
6869 }
6870
6871 int UtcDaliActorGetScreenPosition(void)
6872 {
6873   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6874
6875   TestApplication application;
6876
6877   Integration::Scene stage(application.GetScene());
6878
6879   Actor actorA = Actor::New();
6880   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6881
6882   Vector2 size2(10.0f, 20.0f);
6883   actorA.SetProperty(Actor::Property::SIZE, size2);
6884
6885   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6886
6887   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6888
6889   stage.Add(actorA);
6890
6891   application.SendNotification();
6892   application.Render();
6893
6894   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6895   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6896
6897   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6898   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6899
6900   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6901   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6902
6903   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6904
6905   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6906
6907   application.SendNotification();
6908   application.Render();
6909
6910   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6911   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6912
6913   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6914   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6915
6916   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6917   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6918
6919   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6920
6921   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6922
6923   application.SendNotification();
6924   application.Render();
6925
6926   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6927   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6928
6929   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
6930   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
6931
6932   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6933   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6934
6935   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6936
6937   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6938
6939   application.SendNotification();
6940   application.Render();
6941
6942   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6943   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6944
6945   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6946   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
6947
6948   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6949   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6950
6951   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6952
6953   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6954
6955   application.SendNotification();
6956   application.Render();
6957
6958   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6959   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6960
6961   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6962   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6963
6964   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6965   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6966
6967   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6968
6969   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6970   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6971
6972   Actor actorB = Actor::New();
6973   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6974   actorB.SetProperty(Actor::Property::SIZE, size2);
6975   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6976   actorA.Add(actorB);
6977
6978   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6979
6980   application.SendNotification();
6981   application.Render();
6982
6983   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6984
6985   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6986   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6987
6988   END_TEST;
6989 }
6990
6991 int UtcDaliActorGetScreenPositionAfterScaling(void)
6992 {
6993   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6994
6995   TestApplication application;
6996
6997   Integration::Scene stage(application.GetScene());
6998
6999   Actor actorA = Actor::New();
7000   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7001
7002   Vector2 size2(10.0f, 20.0f);
7003   actorA.SetProperty(Actor::Property::SIZE, size2);
7004   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7005   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7006
7007   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7008
7009   stage.Add(actorA);
7010
7011   application.SendNotification();
7012   application.Render();
7013
7014   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7015   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7016
7017   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7018   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7019
7020   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7021   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7022
7023   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7024
7025   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7026
7027   application.SendNotification();
7028   application.Render();
7029
7030   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7031   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7032
7033   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7034   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7035
7036   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7037   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7038
7039   END_TEST;
7040 }
7041
7042 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7043 {
7044   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7045
7046   TestApplication application;
7047
7048   Integration::Scene stage(application.GetScene());
7049
7050   Actor actorA = Actor::New();
7051   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7052   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7053   Vector2 size2(10.0f, 20.0f);
7054   actorA.SetProperty(Actor::Property::SIZE, size2);
7055   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7056
7057   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7058
7059   stage.Add(actorA);
7060
7061   application.SendNotification();
7062   application.Render();
7063
7064   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7065   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7066
7067   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7068   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7069
7070   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7071   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7072
7073   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7074
7075   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7076   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7077
7078   application.SendNotification();
7079   application.Render();
7080
7081   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7082   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7083
7084   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7085   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7086
7087   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7088   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7089
7090   END_TEST;
7091   END_TEST;
7092 }
7093
7094 int UtcDaliActorGetScreenPositionWithChildActors(void)
7095 {
7096   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7097
7098   TestApplication application;
7099
7100   Integration::Scene stage(application.GetScene());
7101
7102   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7103
7104   Actor actorA = Actor::New();
7105   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7106   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7107   Vector2 size1(10.0f, 20.0f);
7108   actorA.SetProperty(Actor::Property::SIZE, size1);
7109   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7110
7111   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7112
7113   Actor parentActorA = Actor::New();
7114   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7115   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7116   Vector2 size2(30.0f, 60.0f);
7117   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7118   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7119
7120   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7121
7122   stage.Add(parentActorA);
7123   parentActorA.Add(actorA);
7124
7125   application.SendNotification();
7126   application.Render();
7127
7128   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7129   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7130
7131   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7132   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7133
7134   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7135   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7136
7137   tet_infoline("Test 2\n");
7138
7139   tet_infoline("change parent anchor point and parent origin then check screen position \n");
7140
7141   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7142   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7143
7144   application.SendNotification();
7145   application.Render();
7146
7147   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7148   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7149
7150   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7151   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7152
7153   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7154   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7155
7156   END_TEST;
7157 }
7158
7159 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7160 {
7161   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7162
7163   TestApplication application;
7164
7165   Integration::Scene stage(application.GetScene());
7166
7167   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7168
7169   Actor actorA = Actor::New();
7170   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7171   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7172   Vector2 size1(10.0f, 20.0f);
7173   actorA.SetProperty(Actor::Property::SIZE, size1);
7174   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7175
7176   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7177
7178   Actor parentActorA = Actor::New();
7179   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7180   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7181   Vector2 size2(30.0f, 60.0f);
7182   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7183   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7184
7185   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7186
7187   Actor grandParentActorA = Actor::New();
7188   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7189   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7190   Vector2 size3(60.0f, 120.0f);
7191   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7192   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7193
7194   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7195
7196   stage.Add(grandParentActorA);
7197   grandParentActorA.Add(parentActorA);
7198
7199   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7200
7201   parentActorA.Add(actorA);
7202
7203   application.SendNotification();
7204   application.Render();
7205
7206   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7207   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7208
7209   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7210   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7211
7212   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7213   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7214
7215   END_TEST;
7216 }
7217
7218 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7219 {
7220   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7221
7222   TestApplication application;
7223
7224   Integration::Scene stage(application.GetScene());
7225
7226   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7227
7228   Actor actorA = Actor::New();
7229   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7230   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7231   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7232   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7233   stage.Add(actorA);
7234
7235   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7236
7237   Actor actorB = Actor::New();
7238   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7239   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7240   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7241   Vector2 actorBSize(30.0f, 60.0f);
7242   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7243   stage.Add(actorB);
7244
7245   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7246
7247   Actor actorC = Actor::New();
7248   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7249   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7250   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7251   Vector2 actorCSize(60.0f, 120.0f);
7252   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7253   stage.Add(actorC);
7254
7255   application.SendNotification();
7256   application.Render();
7257
7258   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7259
7260   Vector2 center(stage.GetSize() * 0.5f);
7261
7262   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7263   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7264   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7265
7266   tet_infoline("Add scale to all actors");
7267
7268   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7269   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7270   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7271
7272   application.SendNotification();
7273   application.Render();
7274
7275   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7276   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7277   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7278
7279   END_TEST;
7280 }
7281
7282 int UtcDaliActorGetScreenPositionResizeScene(void)
7283 {
7284   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7285
7286   TestApplication    application;
7287   Integration::Scene scene = application.GetScene();
7288
7289   Actor actorA = Actor::New();
7290   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7291   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7292   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7293
7294   scene.Add(actorA);
7295
7296   application.SendNotification();
7297   application.Render();
7298
7299   Vector2 sceneSize           = scene.GetSize();
7300   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7301
7302   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7303
7304   // Resize the scene
7305   Vector2 newSize(1000.0f, 2000.0f);
7306   DALI_TEST_CHECK(scene.GetSize() != newSize);
7307
7308   scene.SurfaceResized(newSize.width, newSize.height);
7309
7310   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7311
7312   // The screen position should not be updated yet
7313   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7314
7315   application.SendNotification();
7316   application.Render();
7317
7318   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7319
7320   // The screen position should be updated
7321   sceneSize = scene.GetSize();
7322   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7323
7324   END_TEST;
7325 }
7326
7327 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7328 {
7329   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7330
7331   TestApplication    application;
7332   Integration::Scene scene = application.GetScene();
7333
7334   // Make 3D Layer
7335   Layer layer = scene.GetRootLayer();
7336   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7337
7338   // Build custom camera with top-view
7339   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7340   {
7341     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7342     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7343     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7344
7345     {
7346       std::ostringstream oss;
7347       oss << cameraPos << "\n";
7348       oss << cameraOrient << "\n";
7349       tet_printf("%s\n", oss.str().c_str());
7350     }
7351
7352     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7353     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7354
7355     // Now, upside : -Z, leftside : -X, foward : +Y
7356
7357     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7358     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7359     {
7360       std::ostringstream oss;
7361       oss << cameraPos << "\n";
7362       oss << cameraOrient << "\n";
7363       tet_printf("%s\n", oss.str().c_str());
7364     }
7365   }
7366
7367   Actor actorA = Actor::New();
7368   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7369   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7370   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7371   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7372
7373   Actor actorB = Actor::New();
7374   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7375   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7376   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7377   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7378
7379   scene.Add(actorA);
7380   scene.Add(actorB);
7381
7382   application.SendNotification();
7383   application.Render();
7384
7385   Vector2 sceneSize           = scene.GetSize();
7386   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7387
7388   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7389
7390   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7391
7392   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7393
7394   END_TEST;
7395 }
7396
7397 int utcDaliActorPositionUsesAnchorPoint(void)
7398 {
7399   TestApplication application;
7400   tet_infoline("Check default behaviour\n");
7401
7402   Actor actor = Actor::New();
7403   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7404   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7405   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7406   application.GetScene().Add(actor);
7407
7408   application.SendNotification();
7409   application.Render();
7410
7411   tet_infoline("Check that the world position is in the center\n");
7412   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7413
7414   tet_infoline("Set the position uses anchor point property to false\n");
7415   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7416
7417   application.SendNotification();
7418   application.Render();
7419
7420   tet_infoline("Check that the world position has changed appropriately\n");
7421   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7422
7423   END_TEST;
7424 }
7425
7426 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7427 {
7428   TestApplication application;
7429   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7430
7431   Actor actor = Actor::New();
7432   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7433   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7434   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7435   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7436   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7437   application.GetScene().Add(actor);
7438
7439   application.SendNotification();
7440   application.Render();
7441
7442   tet_infoline("Check the world position is the same as it would be without a scale\n");
7443   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7444
7445   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7446   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7447   application.SendNotification();
7448   application.Render();
7449   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7450
7451   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7452   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7453   application.SendNotification();
7454   application.Render();
7455   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7456
7457   END_TEST;
7458 }
7459
7460 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7461 {
7462   TestApplication application;
7463   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7464
7465   Actor actor = Actor::New();
7466   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7467   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7468   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7469   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7470   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7471   application.GetScene().Add(actor);
7472
7473   application.SendNotification();
7474   application.Render();
7475
7476   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7477   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7478
7479   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7480   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7481   application.SendNotification();
7482   application.Render();
7483   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7484
7485   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7486   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7487   application.SendNotification();
7488   application.Render();
7489   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7490
7491   END_TEST;
7492 }
7493
7494 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7495 {
7496   TestApplication application;
7497   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7498
7499   Actor actor = Actor::New();
7500   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7501   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7502   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7503   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7504   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7505   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7506   application.GetScene().Add(actor);
7507
7508   application.SendNotification();
7509   application.Render();
7510
7511   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7512   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7513
7514   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7515   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7516   application.SendNotification();
7517   application.Render();
7518   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7519
7520   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7521   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7522   application.SendNotification();
7523   application.Render();
7524   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7525
7526   END_TEST;
7527 }
7528
7529 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7530 {
7531   TestApplication application;
7532   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7533
7534   Actor parent = Actor::New();
7535
7536   application.GetScene().Add(parent);
7537   Vector2 stageSize(application.GetScene().GetSize());
7538
7539   Actor actor = Actor::New();
7540   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7541   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7542   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7543   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7544   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7545   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7546   parent.Add(actor);
7547
7548   application.SendNotification();
7549   application.Render();
7550
7551   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7552
7553   tet_infoline("Check the world position is in the right place\n");
7554   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7555
7556   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7557   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7558   application.SendNotification();
7559   application.Render();
7560   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7561
7562   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7563   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7564   application.SendNotification();
7565   application.Render();
7566   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7567
7568   END_TEST;
7569 }
7570
7571 int utcDaliActorVisibilityChangeSignalSelf(void)
7572 {
7573   TestApplication application;
7574   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7575
7576   Actor actor = Actor::New();
7577
7578   VisibilityChangedFunctorData data;
7579   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7580
7581   actor.SetProperty(Actor::Property::VISIBLE, false);
7582
7583   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7584
7585   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7586   data.Reset();
7587
7588   actor.SetProperty(Actor::Property::VISIBLE, false);
7589   data.Check(false /* not called */, TEST_LOCATION);
7590
7591   tet_infoline("Change the visibility using properties, ensure called");
7592   data.Reset();
7593
7594   actor.SetProperty(Actor::Property::VISIBLE, true);
7595   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7596
7597   tet_infoline("Set the visibility to current using properties, ensure not called");
7598   data.Reset();
7599
7600   actor.SetProperty(Actor::Property::VISIBLE, true);
7601   data.Check(false /* not called */, TEST_LOCATION);
7602
7603   END_TEST;
7604 }
7605
7606 int utcDaliActorVisibilityChangeSignalChildren(void)
7607 {
7608   TestApplication application;
7609   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7610
7611   Actor parent = Actor::New();
7612   Actor child  = Actor::New();
7613   parent.Add(child);
7614
7615   Actor grandChild = Actor::New();
7616   child.Add(grandChild);
7617
7618   VisibilityChangedFunctorData parentData;
7619   VisibilityChangedFunctorData childData;
7620   VisibilityChangedFunctorData grandChildData;
7621
7622   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7623   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7624   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7625
7626   parent.SetProperty(Actor::Property::VISIBLE, false);
7627   parentData.Check(false /* not called */, TEST_LOCATION);
7628   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7629   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7630
7631   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7632   parentData.Reset();
7633   childData.Reset();
7634   grandChildData.Reset();
7635
7636   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7637
7638   parent.SetProperty(Actor::Property::VISIBLE, true);
7639   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7640   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7641   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7642
7643   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7644   parentData.Reset();
7645   childData.Reset();
7646   grandChildData.Reset();
7647
7648   parent.SetProperty(Actor::Property::VISIBLE, true);
7649   parentData.Check(false /* not called */, TEST_LOCATION);
7650   childData.Check(false /* not called */, TEST_LOCATION);
7651   grandChildData.Check(false /* not called */, TEST_LOCATION);
7652
7653   END_TEST;
7654 }
7655
7656 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7657 {
7658   TestApplication application;
7659   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7660
7661   Actor actor = Actor::New();
7662   application.GetScene().Add(actor);
7663
7664   application.SendNotification();
7665   application.Render();
7666
7667   VisibilityChangedFunctorData data;
7668   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7669
7670   Animation animation = Animation::New(1.0f);
7671   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7672
7673   data.Check(false, TEST_LOCATION);
7674   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7675   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7676
7677   tet_infoline("Play the animation and check the property value");
7678   animation.Play();
7679
7680   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7681   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7682
7683   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7684   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7685
7686   application.SendNotification();
7687   application.Render(1100); // After the animation
7688
7689   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7690
7691   END_TEST;
7692 }
7693
7694 int utcDaliActorVisibilityChangeSignalByName(void)
7695 {
7696   TestApplication application;
7697   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7698
7699   Actor actor = Actor::New();
7700
7701   bool signalCalled = false;
7702   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7703   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7704   actor.SetProperty(Actor::Property::VISIBLE, false);
7705   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7706
7707   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7708   signalCalled = false;
7709   actor.SetProperty(Actor::Property::VISIBLE, false);
7710   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7711
7712   tet_infoline("Change the visibility using properties, ensure called");
7713   actor.SetProperty(Actor::Property::VISIBLE, true);
7714   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7715
7716   tet_infoline("Set the visibility to current using properties, ensure not called");
7717   signalCalled = false;
7718
7719   actor.SetProperty(Actor::Property::VISIBLE, true);
7720   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7721
7722   END_TEST;
7723 }
7724
7725 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7726 {
7727   gLayoutDirectionType = type;
7728 }
7729
7730 int UtcDaliActorLayoutDirectionProperty(void)
7731 {
7732   TestApplication application;
7733   tet_infoline("Check layout direction property");
7734
7735   Actor actor0 = Actor::New();
7736   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7737   application.GetScene().Add(actor0);
7738
7739   application.SendNotification();
7740   application.Render();
7741
7742   Actor actor1 = Actor::New();
7743   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7744   Actor actor2 = Actor::New();
7745   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7746   Actor actor3 = Actor::New();
7747   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7748   Actor actor4 = Actor::New();
7749   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7750   Actor actor5 = Actor::New();
7751   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7752   Actor actor6 = Actor::New();
7753   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7754   Actor actor7 = Actor::New();
7755   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7756   Actor actor8 = Actor::New();
7757   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7758   Actor actor9 = Actor::New();
7759   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7760
7761   actor1.Add(actor2);
7762   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7763   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7764
7765   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7766   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7767   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7768
7769   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7770   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7771   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7772
7773   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7774   actor0.Add(actor1);
7775   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7776   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7777
7778   application.GetScene().Add(actor3);
7779   actor3.Add(actor4);
7780   actor4.Add(actor5);
7781   actor5.Add(actor6);
7782   actor5.Add(actor7);
7783   actor7.Add(actor8);
7784   actor8.Add(actor9);
7785   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7786   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7787
7788   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7789   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7790   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7791
7792   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7793
7794   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7795   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7796   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7797   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7798   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7799   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7800   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7801
7802   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7803   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7804   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7805
7806   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7807   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7808   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7809   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7810
7811   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7812   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7813   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7814
7815   END_TEST;
7816 }
7817
7818 struct LayoutDirectionFunctor
7819 {
7820   LayoutDirectionFunctor(bool& signalCalled)
7821   : mSignalCalled(signalCalled)
7822   {
7823   }
7824
7825   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7826   : mSignalCalled(rhs.mSignalCalled)
7827   {
7828   }
7829
7830   void operator()()
7831   {
7832     mSignalCalled = true;
7833   }
7834
7835   bool& mSignalCalled;
7836 };
7837
7838 int UtcDaliActorLayoutDirectionSignal(void)
7839 {
7840   TestApplication application;
7841   tet_infoline("Check changing layout direction property sends a signal");
7842
7843   Actor actor = Actor::New();
7844   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7845   application.GetScene().Add(actor);
7846   bool                   signalCalled = false;
7847   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7848
7849   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7850   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7851
7852   // Test that writing the same value doesn't send a signal
7853   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7854   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7855
7856   // Test that writing a different value sends the signal
7857   signalCalled = false;
7858   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7859   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7860
7861   signalCalled = false;
7862   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7863   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7864
7865   END_TEST;
7866 }
7867
7868 struct ChildAddedSignalCheck
7869 {
7870   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7871   : mSignalReceived(signalReceived),
7872     mChildHandle(childHandle)
7873   {
7874   }
7875
7876   void operator()(Actor childHandle)
7877   {
7878     mSignalReceived = true;
7879     mChildHandle    = childHandle;
7880   }
7881   void operator()()
7882   {
7883     mSignalReceived = true;
7884     mChildHandle    = Actor();
7885   }
7886
7887   bool&  mSignalReceived;
7888   Actor& mChildHandle;
7889 };
7890
7891 int UtcDaliChildAddedSignalP1(void)
7892 {
7893   TestApplication application;
7894   auto            stage = application.GetScene();
7895
7896   bool  signalReceived = false;
7897   Actor childActor;
7898
7899   ChildAddedSignalCheck signal(signalReceived, childActor);
7900   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7901   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7902
7903   auto actorA = Actor::New();
7904   stage.Add(actorA);
7905   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7906   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7907   signalReceived = false;
7908
7909   auto actorB = Actor::New();
7910   stage.Add(actorB);
7911   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7912   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7913
7914   END_TEST;
7915 }
7916
7917 int UtcDaliChildAddedSignalP2(void)
7918 {
7919   TestApplication application;
7920   auto            stage = application.GetScene();
7921
7922   bool  signalReceived = false;
7923   Actor childActor;
7924
7925   ChildAddedSignalCheck signal(signalReceived, childActor);
7926   tet_infoline("Connect to childAdded signal by name");
7927
7928   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7929   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7930
7931   auto actorA = Actor::New();
7932   stage.Add(actorA);
7933   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7934
7935   // Can't test which actor was added; signal signature is void() when connecting via name.
7936   signalReceived = false;
7937
7938   auto actorB = Actor::New();
7939   stage.Add(actorB);
7940   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7941
7942   END_TEST;
7943 }
7944
7945 int UtcDaliChildAddedSignalN(void)
7946 {
7947   TestApplication application;
7948   auto            stage = application.GetScene();
7949
7950   bool  signalReceived = false;
7951   Actor childActor;
7952
7953   ChildAddedSignalCheck signal(signalReceived, childActor);
7954   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7955   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7956
7957   auto actorA = Actor::New();
7958   stage.Add(actorA);
7959   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7960   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7961   signalReceived = false;
7962
7963   auto actorB = Actor::New();
7964   actorA.Add(actorB);
7965   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7966   END_TEST;
7967 }
7968
7969 struct ChildRemovedSignalCheck
7970 {
7971   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7972   : mSignalReceived(signalReceived),
7973     mChildHandle(childHandle)
7974   {
7975   }
7976
7977   void operator()(Actor childHandle)
7978   {
7979     mSignalReceived = true;
7980     mChildHandle    = childHandle;
7981   }
7982
7983   void operator()()
7984   {
7985     mSignalReceived = true;
7986   }
7987
7988   bool&  mSignalReceived;
7989   Actor& mChildHandle;
7990 };
7991
7992 int UtcDaliChildRemovedSignalP1(void)
7993 {
7994   TestApplication application;
7995   auto            stage = application.GetScene();
7996
7997   bool  signalReceived = false;
7998   Actor childActor;
7999
8000   ChildRemovedSignalCheck signal(signalReceived, childActor);
8001   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8002   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8003
8004   auto actorA = Actor::New();
8005   stage.Add(actorA);
8006   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8007   DALI_TEST_CHECK(!childActor);
8008
8009   stage.Remove(actorA);
8010   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8011   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8012
8013   signalReceived = false;
8014   auto actorB    = Actor::New();
8015   stage.Add(actorB);
8016   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8017
8018   stage.Remove(actorB);
8019   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8020   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8021
8022   END_TEST;
8023 }
8024
8025 int UtcDaliChildRemovedSignalP2(void)
8026 {
8027   TestApplication application;
8028   auto            stage = application.GetScene();
8029
8030   bool  signalReceived = false;
8031   Actor childActor;
8032
8033   ChildAddedSignalCheck signal(signalReceived, childActor);
8034   tet_infoline("Connect to childRemoved signal by name");
8035
8036   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8037   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8038
8039   auto actorA = Actor::New();
8040   stage.Add(actorA);
8041   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8042
8043   stage.Remove(actorA);
8044   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8045
8046   signalReceived = false;
8047   auto actorB    = Actor::New();
8048   stage.Add(actorB);
8049   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8050
8051   stage.Remove(actorB);
8052   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8053
8054   END_TEST;
8055 }
8056
8057 int UtcDaliChildRemovedSignalN(void)
8058 {
8059   TestApplication application;
8060   auto            stage = application.GetScene();
8061
8062   bool  signalReceived = false;
8063   Actor childActor;
8064
8065   ChildRemovedSignalCheck signal(signalReceived, childActor);
8066   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8067   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8068
8069   auto actorA = Actor::New();
8070   stage.Add(actorA);
8071
8072   auto actorB = Actor::New();
8073   actorA.Add(actorB);
8074
8075   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8076   DALI_TEST_CHECK(!childActor);
8077
8078   actorA.Remove(actorB);
8079   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8080   END_TEST;
8081 }
8082
8083 int UtcDaliChildMovedSignalP(void)
8084 {
8085   TestApplication application;
8086   auto            stage = application.GetScene();
8087
8088   bool  addedASignalReceived   = false;
8089   bool  removedASignalReceived = false;
8090   bool  addedBSignalReceived   = false;
8091   bool  removedBSignalReceived = false;
8092   Actor childActor;
8093
8094   auto actorA = Actor::New();
8095   auto actorB = Actor::New();
8096   stage.Add(actorA);
8097   stage.Add(actorB);
8098
8099   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
8100   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8101   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
8102   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8103
8104   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8105   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8106   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8107   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8108
8109   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8110   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8111   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8112   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8113
8114   // Create a child of A
8115
8116   auto child = Actor::New();
8117   actorA.Add(child);
8118
8119   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8120   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8121   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8122   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8123   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8124
8125   // Move child to B:
8126   addedASignalReceived   = false;
8127   addedBSignalReceived   = false;
8128   removedASignalReceived = false;
8129   removedBSignalReceived = false;
8130
8131   actorB.Add(child); // Expect this child to be re-parented
8132   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8133   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8134   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8135   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8136
8137   // Move child back to A:
8138   addedASignalReceived   = false;
8139   addedBSignalReceived   = false;
8140   removedASignalReceived = false;
8141   removedBSignalReceived = false;
8142
8143   actorA.Add(child); // Expect this child to be re-parented
8144   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8145   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8146   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8147   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8148
8149   END_TEST;
8150 }
8151
8152 int UtcDaliActorSwitchParentP(void)
8153 {
8154   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8155   TestApplication application;
8156
8157   Actor parent1 = Actor::New();
8158   Actor child   = Actor::New();
8159
8160   application.GetScene().Add(parent1);
8161
8162   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8163
8164   child.OnSceneSignal().Connect(OnSceneCallback);
8165   child.OffSceneSignal().Connect(OffSceneCallback);
8166
8167   // sanity check
8168   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8169   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8170
8171   parent1.Add(child);
8172
8173   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8174
8175   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8176   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8177
8178   Actor parent2 = Actor::New();
8179   application.GetScene().Add(parent2);
8180
8181   bool                  addSignalReceived = false;
8182   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8183   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8184   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8185
8186   bool                    removedSignalReceived = false;
8187   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8188   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8189   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8190
8191   DevelActor::SwitchParent(child, parent2);
8192
8193   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8194   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8195
8196   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8197   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8198
8199   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8200   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8201   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8202   DALI_TEST_CHECK(child.GetParent() == parent2);
8203
8204   END_TEST;
8205 }
8206
8207 int utcDaliActorCulled(void)
8208 {
8209   TestApplication application;
8210   auto            stage = application.GetScene();
8211
8212   tet_infoline("Check that the actor is culled if the actor is out of the screen");
8213
8214   Actor actor = Actor::New();
8215   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8216
8217   Geometry geometry = CreateQuadGeometry();
8218   Shader   shader   = CreateShader();
8219   Renderer renderer = Renderer::New(geometry, shader);
8220   actor.AddRenderer(renderer);
8221
8222   stage.Add(actor);
8223
8224   application.SendNotification();
8225   application.Render(0);
8226
8227   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8228
8229   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8230   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8231
8232   // Connect NotifySignal
8233   bool                              propertyNotificationSignal(false);
8234   PropertyNotification              source;
8235   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8236   notification.NotifySignal().Connect(&application, f);
8237
8238   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8239
8240   application.SendNotification();
8241   application.Render();
8242
8243   application.SendNotification();
8244
8245   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8246
8247   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8248   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8249   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8250
8251   END_TEST;
8252 }
8253
8254 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8255 {
8256   TestApplication application;
8257   auto            stage = application.GetScene();
8258
8259   tet_infoline("Ensure we clear the screen when the last actor is removed");
8260
8261   Actor actor = CreateRenderableActor();
8262   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8263   stage.Add(actor);
8264
8265   application.SendNotification();
8266   application.Render();
8267
8268   auto&      glAbstraction    = application.GetGlAbstraction();
8269   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8270
8271   actor.Unparent();
8272
8273   application.SendNotification();
8274   application.Render();
8275
8276   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8277
8278   END_TEST;
8279 }
8280
8281 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8282 {
8283   TestApplication application;
8284   auto            stage = application.GetScene();
8285
8286   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8287
8288   Actor actor = CreateRenderableActor();
8289   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8290   stage.Add(actor);
8291
8292   application.SendNotification();
8293   application.Render();
8294
8295   auto&      glAbstraction    = application.GetGlAbstraction();
8296   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8297
8298   actor.SetProperty(Actor::Property::VISIBLE, false);
8299
8300   application.SendNotification();
8301   application.Render();
8302
8303   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8304
8305   END_TEST;
8306 }
8307
8308 int utcDaliActorGetSizeAfterAnimation(void)
8309 {
8310   TestApplication application;
8311   tet_infoline("Check the actor size before / after an animation is finished");
8312
8313   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8314
8315   Actor actor = Actor::New();
8316   actor.SetProperty(Actor::Property::SIZE, actorSize);
8317   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8318   application.GetScene().Add(actor);
8319
8320   // Size should be updated without rendering.
8321   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8322   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8323
8324   application.SendNotification();
8325   application.Render();
8326
8327   // Size and current size should be updated.
8328   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8329   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8330   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8331   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8332   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8333
8334   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8335   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8336   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8337   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8338   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8339
8340   // Set size again
8341   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8342   actor.SetProperty(Actor::Property::SIZE, actorSize);
8343
8344   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8345   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8346
8347   Vector3 targetValue(10.0f, 20.0f, 0.0f);
8348
8349   Animation animation = Animation::New(1.0f);
8350   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8351   animation.Play();
8352
8353   // Size should be updated without rendering.
8354   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8355   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8356
8357   application.SendNotification();
8358   application.Render(1100); // After the animation
8359
8360   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8361   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8362   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8363   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8364   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8365
8366   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8367   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8368   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8369   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8370   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8371
8372   targetValue.width = 50.0f;
8373
8374   animation.Clear();
8375   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8376   animation.Play();
8377
8378   application.SendNotification();
8379   application.Render(1100); // After the animation
8380
8381   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8382   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8383   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8384   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8385   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8386
8387   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8388   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8389   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8390   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8391   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8392
8393   targetValue.height = 70.0f;
8394
8395   animation.Clear();
8396   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8397   animation.Play();
8398
8399   application.SendNotification();
8400   application.Render(1100); // After the animation
8401
8402   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8403   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8404   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8405   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8406   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8407
8408   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8409   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8410   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8411   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8412   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8413
8414   Vector3 offset(10.0f, 20.0f, 0.0f);
8415
8416   animation.Clear();
8417   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8418   animation.Play();
8419
8420   application.SendNotification();
8421   application.Render(1100); // After the animation
8422
8423   targetValue += offset;
8424
8425   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8426   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8427   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8428   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8429   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8430
8431   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8432   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8433   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8434   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8435   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8436
8437   offset.width = 20.0f;
8438
8439   animation.Clear();
8440   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8441   animation.Play();
8442
8443   application.SendNotification();
8444   application.Render(1100); // After the animation
8445
8446   targetValue.width += offset.width;
8447
8448   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8449   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8450   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8451   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8452   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8453
8454   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8455   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8456   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8457   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8458   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8459
8460   offset.height = 10.0f;
8461
8462   animation.Clear();
8463   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8464   animation.Play();
8465
8466   application.SendNotification();
8467   application.Render(1100); // After the animation
8468
8469   targetValue.height += offset.height;
8470
8471   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8472   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8473   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8474   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8475   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8476
8477   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8478   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8479   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8480   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8481   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8482
8483   // Set size again
8484   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8485
8486   actor.SetProperty(Actor::Property::SIZE, actorSize);
8487
8488   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8489   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8490
8491   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8492   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8493
8494   application.SendNotification();
8495   application.Render();
8496
8497   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8498   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8499
8500   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8501   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8502
8503   END_TEST;
8504 }
8505
8506 int utcDaliActorRelayoutAndAnimation(void)
8507 {
8508   TestApplication application;
8509   tet_infoline("Check the actor size when relayoutting and playing animation");
8510
8511   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8512   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8513
8514   {
8515     Actor parentA = Actor::New();
8516     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8517     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8518     application.GetScene().Add(parentA);
8519
8520     Actor parentB = Actor::New();
8521     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8522     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8523     application.GetScene().Add(parentB);
8524
8525     Actor actor = Actor::New();
8526     actor.SetProperty(Actor::Property::SIZE, actorSize);
8527     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8528     parentA.Add(actor);
8529
8530     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8531     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8532
8533     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8534
8535     Animation animation = Animation::New(1.0f);
8536     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8537     animation.Play();
8538
8539     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8540     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8541
8542     application.SendNotification();
8543     application.Render(1100); // After the animation
8544
8545     // Size and current size should be updated.
8546     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8547     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8548
8549     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8550     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8551
8552     // Trigger relayout
8553     parentB.Add(actor);
8554
8555     application.SendNotification();
8556     application.Render();
8557
8558     // Size and current size should be same.
8559     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8560     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8561
8562     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8563     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8564
8565     actor.Unparent();
8566     parentA.Unparent();
8567     parentB.Unparent();
8568   }
8569
8570   {
8571     Actor parentA = Actor::New();
8572     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8573     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8574     application.GetScene().Add(parentA);
8575
8576     Actor parentB = Actor::New();
8577     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8578     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8579     application.GetScene().Add(parentB);
8580
8581     Actor actor = Actor::New();
8582     actor.SetProperty(Actor::Property::SIZE, actorSize);
8583     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8584     parentA.Add(actor);
8585
8586     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8587     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8588
8589     application.SendNotification();
8590     application.Render();
8591
8592     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8593     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8594
8595     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8596     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8597
8598     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8599
8600     // Make an animation
8601     Animation animation = Animation::New(1.0f);
8602     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8603     animation.Play();
8604
8605     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8606     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8607
8608     application.SendNotification();
8609     application.Render(1100); // After the animation
8610
8611     // Size and current size should be updated.
8612     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8613     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8614
8615     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8616     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8617
8618     // Trigger relayout
8619     parentB.Add(actor);
8620
8621     application.SendNotification();
8622     application.Render();
8623
8624     // Size and current size should be same.
8625     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8626     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8627
8628     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8629     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8630
8631     actor.Unparent();
8632     parentA.Unparent();
8633     parentB.Unparent();
8634   }
8635
8636   END_TEST;
8637 }
8638
8639 int utcDaliActorPartialUpdate(void)
8640 {
8641   TestApplication application(
8642     TestApplication::DEFAULT_SURFACE_WIDTH,
8643     TestApplication::DEFAULT_SURFACE_HEIGHT,
8644     TestApplication::DEFAULT_HORIZONTAL_DPI,
8645     TestApplication::DEFAULT_VERTICAL_DPI,
8646     true,
8647     true);
8648
8649   tet_infoline("Check the damaged area");
8650
8651   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8652
8653   std::vector<Rect<int>> damagedRects;
8654   Rect<int>              clippingRect;
8655   application.SendNotification();
8656   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8657
8658   // First render pass, nothing to render, adaptor would just do swap buffer.
8659   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8660
8661   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8662   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8663
8664   Actor actor = CreateRenderableActor();
8665   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8666   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8667   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8668   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8669   application.GetScene().Add(actor);
8670
8671   application.SendNotification();
8672
8673   // 1. Actor added, damaged rect is added size of actor
8674   damagedRects.clear();
8675   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8676   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8677
8678   // Aligned by 16
8679   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8680   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8681   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8682   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8683   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8684   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8685   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8686
8687   // 2. Set new size
8688   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8689   application.SendNotification();
8690
8691   damagedRects.clear();
8692   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8693   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8694
8695   // Aligned by 16
8696   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8697   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8698   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8699   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8700   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8701   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8702   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8703
8704   // 3. Set new position
8705   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8706   application.SendNotification();
8707
8708   damagedRects.clear();
8709   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8710   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8711
8712   // Aligned by 16
8713   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8714   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8715   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8716   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8717   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8718   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8719   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8720
8721   application.GetScene().Remove(actor);
8722   application.SendNotification();
8723
8724   // Actor removed, last a dirty rect is reported.
8725   damagedRects.clear();
8726   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8727   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8728
8729   clippingRect = damagedRects[0];
8730
8731   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8732   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8733
8734   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8735   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8736   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8737   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8738   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8739
8740   END_TEST;
8741 }
8742
8743 int utcDaliActorPartialUpdateSetColor(void)
8744 {
8745   TestApplication application(
8746     TestApplication::DEFAULT_SURFACE_WIDTH,
8747     TestApplication::DEFAULT_SURFACE_HEIGHT,
8748     TestApplication::DEFAULT_HORIZONTAL_DPI,
8749     TestApplication::DEFAULT_VERTICAL_DPI,
8750     true,
8751     true);
8752
8753   tet_infoline("Check uniform update");
8754
8755   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8756
8757   std::vector<Rect<int>> damagedRects;
8758   Rect<int>              clippingRect;
8759   application.SendNotification();
8760   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8761
8762   // First render pass, nothing to render, adaptor would just do swap buffer.
8763   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8764
8765   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8766   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8767
8768   Actor actor = CreateRenderableActor();
8769   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8770   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8771   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8772   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8773   application.GetScene().Add(actor);
8774
8775   application.SendNotification();
8776
8777   // 1. Actor added, damaged rect is added size of actor
8778   damagedRects.clear();
8779   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8780   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8781
8782   // Aligned by 16
8783   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8784   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8785   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8786   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8787   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8788   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8789   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8790
8791   damagedRects.clear();
8792   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8793   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8794
8795   damagedRects.clear();
8796   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8797   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8798
8799   // 2. Set new color
8800   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8801   application.SendNotification();
8802
8803   damagedRects.clear();
8804   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8805   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8806
8807   // Aligned by 16
8808   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8809   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8810   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8811   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8812   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8813   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8814   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8815
8816   END_TEST;
8817 }
8818
8819 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8820 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8821 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8822 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8823   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8824   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8825   "\n"
8826   "void main()\n"
8827   "{\n"
8828   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8829   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8830   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8831   "}\n";
8832
8833 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8834   "uniform lowp vec4 uShadowColor;\n"
8835   "void main()\n"
8836   "{\n"
8837   "  lowp float alpha;\n"
8838   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8839   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8840   "}\n";
8841
8842 int utcDaliActorPartialUpdateSetProperty(void)
8843 {
8844   TestApplication application(
8845     TestApplication::DEFAULT_SURFACE_WIDTH,
8846     TestApplication::DEFAULT_SURFACE_HEIGHT,
8847     TestApplication::DEFAULT_HORIZONTAL_DPI,
8848     TestApplication::DEFAULT_VERTICAL_DPI,
8849     true,
8850     true);
8851
8852   tet_infoline("Set/Update property with partial update");
8853
8854   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8855
8856   std::vector<Rect<int>> damagedRects;
8857   Rect<int>              clippingRect;
8858   application.SendNotification();
8859   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8860
8861   // First render pass, nothing to render, adaptor would just do swap buffer.
8862   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8863
8864   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8865   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8866
8867   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8868   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8869   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8870   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8871   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8872   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8873   application.GetScene().Add(actor);
8874
8875   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8876
8877   damagedRects.clear();
8878   application.SendNotification();
8879   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8881
8882   // Aligned by 16
8883   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8884   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8885   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8886   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8887   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8888   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8889   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8890
8891   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8892   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8893
8894   damagedRects.clear();
8895   application.SendNotification();
8896   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8897   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8898
8899   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8900   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8901   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8902   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8903   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8904   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8905
8906   // Should be no damage rects, nothing changed
8907   damagedRects.clear();
8908   application.SendNotification();
8909   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8910   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8911
8912   // Should be 1 damage rect due to change in size
8913   damagedRects.clear();
8914   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8915   application.SendNotification();
8916   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8917   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8918
8919   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8920   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8921   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8922   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8923   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8924   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8925   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8926
8927   damagedRects.clear();
8928   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8929   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8930
8931   END_TEST;
8932 }
8933
8934 int utcDaliActorPartialUpdateTwoActors(void)
8935 {
8936   TestApplication application(
8937     TestApplication::DEFAULT_SURFACE_WIDTH,
8938     TestApplication::DEFAULT_SURFACE_HEIGHT,
8939     TestApplication::DEFAULT_HORIZONTAL_DPI,
8940     TestApplication::DEFAULT_VERTICAL_DPI,
8941     true,
8942     true);
8943
8944   tet_infoline("Check the damaged rects with partial update and two actors");
8945
8946   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8947
8948   Actor actor = CreateRenderableActor();
8949   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8950   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8951   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8952   application.GetScene().Add(actor);
8953
8954   Actor actor2 = CreateRenderableActor();
8955   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8956   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8957   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8958   application.GetScene().Add(actor2);
8959
8960   application.SendNotification();
8961   std::vector<Rect<int>> damagedRects;
8962   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8963
8964   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8965   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8966   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8967
8968   // in screen coordinates, adaptor would calculate it using previous frames information
8969   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8970   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8971
8972   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8973   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8974   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8975   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8976
8977   // Change a Renderer of actor1
8978   Geometry geometry    = CreateQuadGeometry();
8979   Shader   shader      = CreateShader();
8980   Renderer newRenderer = Renderer::New(geometry, shader);
8981   Renderer renderer    = actor.GetRendererAt(0);
8982
8983   actor.RemoveRenderer(renderer);
8984   actor.AddRenderer(newRenderer);
8985
8986   damagedRects.clear();
8987
8988   application.SendNotification();
8989   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8990
8991   DALI_TEST_CHECK(damagedRects.size() > 0);
8992   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8993
8994   // in screen coordinates, adaptor would calculate it using previous frames information
8995   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8996
8997   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8998   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8999   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9000   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9001
9002   END_TEST;
9003 }
9004
9005 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9006 {
9007   TestApplication application(
9008     TestApplication::DEFAULT_SURFACE_WIDTH,
9009     TestApplication::DEFAULT_SURFACE_HEIGHT,
9010     TestApplication::DEFAULT_HORIZONTAL_DPI,
9011     TestApplication::DEFAULT_VERTICAL_DPI,
9012     true,
9013     true);
9014
9015   tet_infoline("Check the damaged rect with partial update and actor size hint");
9016
9017   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9018
9019   Actor actor = CreateRenderableActor();
9020   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9021   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9022   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9023   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9024   application.GetScene().Add(actor);
9025
9026   application.SendNotification();
9027   std::vector<Rect<int>> damagedRects;
9028   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9029
9030   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9031
9032   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9033   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9034
9035   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9036
9037   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9038   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9039   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9040   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9041
9042   // Reset
9043   actor.Unparent();
9044
9045   damagedRects.clear();
9046   application.SendNotification();
9047   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9048
9049   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9050   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9051
9052   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9053
9054   damagedRects.clear();
9055   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9056   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9057
9058   // Ensure the damaged rect is empty
9059   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9060
9061   // Chnage UPDATE_AREA_HINT
9062   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9063   application.GetScene().Add(actor);
9064
9065   application.SendNotification();
9066   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9067
9068   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9069
9070   clippingRect = Rect<int>(64, 704, 48, 48);
9071   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9072
9073   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9074
9075   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9076   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9077   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9078   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9079
9080   // Reset
9081   actor.Unparent();
9082
9083   damagedRects.clear();
9084   application.SendNotification();
9085   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9086
9087   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9088   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9089
9090   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9091
9092   damagedRects.clear();
9093   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9094   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9095
9096   // Ensure the damaged rect is empty
9097   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9098
9099   // Chnage UPDATE_AREA_HINT
9100   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9101   application.GetScene().Add(actor);
9102
9103   application.SendNotification();
9104   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9105
9106   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9107
9108   clippingRect = Rect<int>(0, 720, 80, 80);
9109   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9110
9111   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9112
9113   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9114   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9115   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9116   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9117
9118   END_TEST;
9119 }
9120
9121 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9122 {
9123   TestApplication application(
9124     TestApplication::DEFAULT_SURFACE_WIDTH,
9125     TestApplication::DEFAULT_SURFACE_HEIGHT,
9126     TestApplication::DEFAULT_HORIZONTAL_DPI,
9127     TestApplication::DEFAULT_VERTICAL_DPI,
9128     true,
9129     true);
9130
9131   tet_infoline("Check the damaged rect with partial update and actor size hint");
9132
9133   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9134
9135   Actor actor = CreateRenderableActor();
9136   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9137   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9138   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9139   application.GetScene().Add(actor);
9140
9141   application.SendNotification();
9142   std::vector<Rect<int>> damagedRects;
9143   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9144
9145   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9146
9147   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9148   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9149
9150   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9151
9152   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9153   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9154   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9155   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9156
9157   damagedRects.clear();
9158   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9159   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9160
9161   // Ensure the damaged rect is empty
9162   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9163
9164   // Chnage UPDATE_AREA_HINT
9165   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9166
9167   application.SendNotification();
9168   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9169
9170   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9171
9172   clippingRect = Rect<int>(32, 704, 80, 80);
9173   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9174
9175   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9176
9177   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9178   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9179   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9180   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9181
9182   damagedRects.clear();
9183   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9184   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9185
9186   // Ensure the damaged rect is empty
9187   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9188
9189   // Chnage UPDATE_AREA_HINT
9190   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9191   application.GetScene().Add(actor);
9192
9193   application.SendNotification();
9194   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9195
9196   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9197
9198   clippingRect = Rect<int>(32, 688, 96, 96);
9199   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9200
9201   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9202
9203   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9204   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9205   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9206   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9207
9208   END_TEST;
9209 }
9210
9211 int utcDaliActorPartialUpdateAnimation(void)
9212 {
9213   TestApplication application(
9214     TestApplication::DEFAULT_SURFACE_WIDTH,
9215     TestApplication::DEFAULT_SURFACE_HEIGHT,
9216     TestApplication::DEFAULT_HORIZONTAL_DPI,
9217     TestApplication::DEFAULT_VERTICAL_DPI,
9218     true,
9219     true);
9220
9221   tet_infoline("Check the damaged area with partial update and animation");
9222
9223   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9224   drawTrace.Enable(true);
9225   drawTrace.Reset();
9226
9227   Actor actor1 = CreateRenderableActor();
9228   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9229   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9230   application.GetScene().Add(actor1);
9231
9232   Actor actor2 = CreateRenderableActor();
9233   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9234   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9235   application.GetScene().Add(actor2);
9236
9237   std::vector<Rect<int>> damagedRects;
9238   Rect<int>              clippingRect;
9239   Rect<int>              expectedRect1, expectedRect2;
9240
9241   application.SendNotification();
9242   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9243
9244   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9245
9246   // Aligned by 16
9247   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9248   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
9249   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9250   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
9251
9252   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9253   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9254
9255   // Make an animation
9256   Animation animation = Animation::New(1.0f);
9257   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9258   animation.Play();
9259
9260   application.SendNotification();
9261
9262   damagedRects.clear();
9263   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9264   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9265   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9266
9267   drawTrace.Reset();
9268   damagedRects.clear();
9269
9270   // In animation deley time
9271   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9272   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9273   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9274
9275   // Skip rendering
9276   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9277
9278   drawTrace.Reset();
9279   damagedRects.clear();
9280
9281   // Also in animation deley time
9282   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9283   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9284   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9285
9286   // Skip rendering
9287   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9288
9289   // Unparent 2 actors and make a new actor
9290   actor1.Unparent();
9291   actor2.Unparent();
9292
9293   Actor actor3 = CreateRenderableActor();
9294   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9295   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9296   application.GetScene().Add(actor3);
9297
9298   application.SendNotification();
9299
9300   // Started animation
9301   damagedRects.clear();
9302   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9303   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9304
9305   // The first dirty rect is actor3's.
9306   // We don't know the exact dirty rect of actor2
9307   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
9308   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
9309
9310   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9311   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9312
9313   // Finished animation, but the actor was already unparented
9314   damagedRects.clear();
9315   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9316
9317   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9318
9319   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9320   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9321
9322   END_TEST;
9323 }
9324
9325 int utcDaliActorPartialUpdateChangeVisibility(void)
9326 {
9327   TestApplication application(
9328     TestApplication::DEFAULT_SURFACE_WIDTH,
9329     TestApplication::DEFAULT_SURFACE_HEIGHT,
9330     TestApplication::DEFAULT_HORIZONTAL_DPI,
9331     TestApplication::DEFAULT_VERTICAL_DPI,
9332     true,
9333     true);
9334
9335   tet_infoline("Check the damaged rect with partial update and visibility change");
9336
9337   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9338
9339   Actor actor = CreateRenderableActor();
9340   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9341   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9342   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9343   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9344   application.GetScene().Add(actor);
9345
9346   application.SendNotification();
9347
9348   std::vector<Rect<int>> damagedRects;
9349   Rect<int>              clippingRect;
9350
9351   // 1. Actor added, damaged rect is added size of actor
9352   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9353   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9354
9355   // Aligned by 16
9356   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9357   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9358   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9359   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9360   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9361   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9362   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9363
9364   damagedRects.clear();
9365   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9366   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9367
9368   damagedRects.clear();
9369   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9370   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9371
9372   // Ensure the damaged rect is empty
9373   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9374
9375   // 2. Make the Actor invisible
9376   actor.SetProperty(Actor::Property::VISIBLE, false);
9377   application.SendNotification();
9378
9379   damagedRects.clear();
9380   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9381   DALI_TEST_CHECK(damagedRects.size() > 0);
9382   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9383
9384   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9385   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9386   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9387   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9388   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9389
9390   // 3. Make the Actor visible again
9391   actor.SetProperty(Actor::Property::VISIBLE, true);
9392   application.SendNotification();
9393
9394   damagedRects.clear();
9395   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9396   DALI_TEST_CHECK(damagedRects.size() > 0);
9397   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9398
9399   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9400   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9401   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9402   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9403   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9404
9405   END_TEST;
9406 }
9407
9408 int utcDaliActorPartialUpdateOnOffScene(void)
9409 {
9410   TestApplication application(
9411     TestApplication::DEFAULT_SURFACE_WIDTH,
9412     TestApplication::DEFAULT_SURFACE_HEIGHT,
9413     TestApplication::DEFAULT_HORIZONTAL_DPI,
9414     TestApplication::DEFAULT_VERTICAL_DPI,
9415     true,
9416     true);
9417
9418   tet_infoline("Check the damaged rect with partial update and on/off scene");
9419
9420   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9421
9422   Actor actor = CreateRenderableActor();
9423   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9424   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9425   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9426   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9427   application.GetScene().Add(actor);
9428
9429   application.SendNotification();
9430
9431   std::vector<Rect<int>> damagedRects;
9432   Rect<int>              clippingRect;
9433
9434   // 1. Actor added, damaged rect is added size of actor
9435   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9436   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9437
9438   // Aligned by 16
9439   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9440   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9441   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9442   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9443   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9444   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9445   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9446
9447   damagedRects.clear();
9448   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9449   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9450
9451   damagedRects.clear();
9452   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9453   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9454
9455   // Ensure the damaged rect is empty
9456   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9457
9458   // 2. Remove the Actor from the Scene
9459   actor.Unparent();
9460   application.SendNotification();
9461
9462   damagedRects.clear();
9463   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9464   DALI_TEST_CHECK(damagedRects.size() > 0);
9465   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9466
9467   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9468   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9469   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9470   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9471   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9472
9473   // 3. Add the Actor to the Scene again
9474   application.GetScene().Add(actor);
9475   application.SendNotification();
9476
9477   damagedRects.clear();
9478   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9479   DALI_TEST_CHECK(damagedRects.size() > 0);
9480   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9481
9482   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9483   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9484   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9485   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9486   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9487
9488   END_TEST;
9489 }
9490
9491 int utcDaliActorPartialUpdateSkipRendering(void)
9492 {
9493   TestApplication application(
9494     TestApplication::DEFAULT_SURFACE_WIDTH,
9495     TestApplication::DEFAULT_SURFACE_HEIGHT,
9496     TestApplication::DEFAULT_HORIZONTAL_DPI,
9497     TestApplication::DEFAULT_VERTICAL_DPI,
9498     true,
9499     true);
9500
9501   tet_infoline("Check to skip rendering in case of the empty damaged rect");
9502
9503   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9504   drawTrace.Enable(true);
9505   drawTrace.Reset();
9506
9507   Actor actor1 = CreateRenderableActor();
9508   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9509   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9510   application.GetScene().Add(actor1);
9511
9512   std::vector<Rect<int>> damagedRects;
9513   Rect<int>              clippingRect;
9514   Rect<int>              expectedRect1;
9515
9516   application.SendNotification();
9517   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9518
9519   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9520
9521   // Aligned by 16
9522   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9523   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9524
9525   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9526   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9527
9528   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9529
9530   damagedRects.clear();
9531   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9532   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9533   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9534
9535   // Remove the actor
9536   actor1.Unparent();
9537
9538   application.SendNotification();
9539
9540   damagedRects.clear();
9541   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9542
9543   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9544
9545   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9546   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9547
9548   // Render again without any change
9549   damagedRects.clear();
9550   drawTrace.Reset();
9551   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9552
9553   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9554
9555   clippingRect = Rect<int>();
9556   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9557
9558   // Skip rendering
9559   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9560
9561   // Add the actor again
9562   application.GetScene().Add(actor1);
9563
9564   application.SendNotification();
9565
9566   damagedRects.clear();
9567   drawTrace.Reset();
9568   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9569
9570   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9571
9572   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9573   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9574
9575   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9576
9577   END_TEST;
9578 }
9579
9580 int utcDaliActorPartialUpdate3DNode(void)
9581 {
9582   TestApplication application(
9583     TestApplication::DEFAULT_SURFACE_WIDTH,
9584     TestApplication::DEFAULT_SURFACE_HEIGHT,
9585     TestApplication::DEFAULT_HORIZONTAL_DPI,
9586     TestApplication::DEFAULT_VERTICAL_DPI,
9587     true,
9588     true);
9589
9590   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9591
9592   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9593   drawTrace.Enable(true);
9594   drawTrace.Reset();
9595
9596   Actor actor1 = CreateRenderableActor();
9597   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9598   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9599   application.GetScene().Add(actor1);
9600
9601   std::vector<Rect<int>> damagedRects;
9602   Rect<int>              clippingRect;
9603
9604   application.SendNotification();
9605   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9606
9607   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9608
9609   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9610   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9611
9612   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9613
9614   // Change the layer to 3D
9615   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9616
9617   application.SendNotification();
9618
9619   damagedRects.clear();
9620   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9621
9622   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9623   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9624
9625   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9626   drawTrace.Reset();
9627   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9628
9629   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9630
9631   // Change the layer to 2D
9632   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9633
9634   application.SendNotification();
9635
9636   damagedRects.clear();
9637   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9638
9639   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9640
9641   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9642   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9643
9644   // Make 3D transform
9645   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9646
9647   application.SendNotification();
9648
9649   damagedRects.clear();
9650   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9651
9652   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9653   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9654
9655   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9656   drawTrace.Reset();
9657   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9658
9659   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9660
9661   END_TEST;
9662 }
9663
9664 int utcDaliActorPartialUpdateNotRenderableActor(void)
9665 {
9666   TestApplication application(
9667     TestApplication::DEFAULT_SURFACE_WIDTH,
9668     TestApplication::DEFAULT_SURFACE_HEIGHT,
9669     TestApplication::DEFAULT_HORIZONTAL_DPI,
9670     TestApplication::DEFAULT_VERTICAL_DPI,
9671     true,
9672     true);
9673
9674   tet_infoline("Check the damaged rect with not renderable parent actor");
9675
9676   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9677
9678   Actor parent                          = Actor::New();
9679   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9680   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9681   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9682   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9683   application.GetScene().Add(parent);
9684
9685   Actor child                          = CreateRenderableActor();
9686   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9687   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9688   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9689   parent.Add(child);
9690
9691   application.SendNotification();
9692
9693   std::vector<Rect<int>> damagedRects;
9694
9695   // 1. Actor added, damaged rect is added size of actor
9696   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9697   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9698
9699   // Aligned by 16
9700   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9701   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9702
9703   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9704   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9705   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9706   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9707   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9708
9709   damagedRects.clear();
9710   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9711   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9712
9713   damagedRects.clear();
9714   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9715   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9716
9717   // Ensure the damaged rect is empty
9718   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9719
9720   END_TEST;
9721 }
9722
9723 int utcDaliActorPartialUpdateChangeTransparency(void)
9724 {
9725   TestApplication application(
9726     TestApplication::DEFAULT_SURFACE_WIDTH,
9727     TestApplication::DEFAULT_SURFACE_HEIGHT,
9728     TestApplication::DEFAULT_HORIZONTAL_DPI,
9729     TestApplication::DEFAULT_VERTICAL_DPI,
9730     true,
9731     true);
9732
9733   tet_infoline("Check the damaged rect with changing transparency");
9734
9735   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9736
9737   Actor actor                          = CreateRenderableActor();
9738   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9739   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9740   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9741   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9742   application.GetScene().Add(actor);
9743
9744   application.SendNotification();
9745
9746   std::vector<Rect<int>> damagedRects;
9747
9748   // Actor added, damaged rect is added size of actor
9749   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9750   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9751
9752   // Aligned by 16
9753   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9754   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9755
9756   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9757   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9758   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9759   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9760   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9761
9762   damagedRects.clear();
9763   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9764   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9765
9766   // Ensure the damaged rect is empty
9767   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9768
9769   // Make the actor transparent by changing opacity of the Renderer
9770   // It changes a uniform value
9771   Renderer renderer                          = actor.GetRendererAt(0);
9772   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9773
9774   application.SendNotification();
9775
9776   // The damaged rect should be same
9777   damagedRects.clear();
9778   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9779   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9780   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9781   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9782
9783   damagedRects.clear();
9784   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9785   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9786
9787   // Ensure the damaged rect is empty
9788   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9789
9790   // Make the actor opaque again
9791   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9792
9793   application.SendNotification();
9794
9795   // The damaged rect should not be empty
9796   damagedRects.clear();
9797   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9798   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9799   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9800   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9801
9802   damagedRects.clear();
9803   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9804   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9805
9806   // Ensure the damaged rect is empty
9807   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9808
9809   // Make the actor translucent
9810   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9811
9812   application.SendNotification();
9813
9814   // The damaged rect should not be empty
9815   damagedRects.clear();
9816   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9817   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9818   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9819   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9820
9821   damagedRects.clear();
9822   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9823   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9824
9825   // Ensure the damaged rect is empty
9826   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9827
9828   // Change Renderer opacity - also translucent
9829   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9830
9831   application.SendNotification();
9832
9833   // The damaged rect should not be empty
9834   damagedRects.clear();
9835   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9836   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9837   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9838   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9839
9840   damagedRects.clear();
9841   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9842   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9843
9844   // Ensure the damaged rect is empty
9845   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9846
9847   // Make the actor culled
9848   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9849
9850   application.SendNotification();
9851
9852   // The damaged rect should be same
9853   damagedRects.clear();
9854   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9855   DALI_TEST_CHECK(damagedRects.size() > 0);
9856   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9857   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9858
9859   damagedRects.clear();
9860   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9861   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9862
9863   // Ensure the damaged rect is empty
9864   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9865
9866   // Make the actor not culled again
9867   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9868
9869   application.SendNotification();
9870
9871   // The damaged rect should not be empty
9872   damagedRects.clear();
9873   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9874   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9875   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9876   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9877
9878   END_TEST;
9879 }
9880
9881 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9882 {
9883   TestApplication application(
9884     TestApplication::DEFAULT_SURFACE_WIDTH,
9885     TestApplication::DEFAULT_SURFACE_HEIGHT,
9886     TestApplication::DEFAULT_HORIZONTAL_DPI,
9887     TestApplication::DEFAULT_VERTICAL_DPI,
9888     true,
9889     true);
9890
9891   tet_infoline("Check the damaged rect with changing parent's opacity");
9892
9893   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9894
9895   Actor parent                          = Actor::New();
9896   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9897   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9898   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9899   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9900   application.GetScene().Add(parent);
9901
9902   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9903   Actor   child                        = CreateRenderableActor(texture);
9904   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9905   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9906   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9907   parent.Add(child);
9908
9909   application.SendNotification();
9910
9911   std::vector<Rect<int>> damagedRects;
9912
9913   // Actor added, damaged rect is added size of actor
9914   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9915   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9916
9917   // Aligned by 16
9918   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9919   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9920
9921   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9922   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9923   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9924   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9925   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9926
9927   damagedRects.clear();
9928   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9929   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9930
9931   damagedRects.clear();
9932   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9933   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9934
9935   // Ensure the damaged rect is empty
9936   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9937
9938   // Change the parent's opacity
9939   parent[Actor::Property::OPACITY] = 0.5f;
9940
9941   application.SendNotification();
9942
9943   // The damaged rect should be same
9944   damagedRects.clear();
9945   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9946   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9947   DALI_TEST_CHECK(damagedRects.size() > 0);
9948   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9949
9950   END_TEST;
9951 }
9952
9953 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
9954 {
9955   TestApplication application(
9956     TestApplication::DEFAULT_SURFACE_WIDTH,
9957     TestApplication::DEFAULT_SURFACE_HEIGHT,
9958     TestApplication::DEFAULT_HORIZONTAL_DPI,
9959     TestApplication::DEFAULT_VERTICAL_DPI,
9960     true,
9961     true);
9962
9963   tet_infoline("Check the damaged rect with adding / removing renderer");
9964
9965   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9966
9967   Actor actor                          = CreateRenderableActor();
9968   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9969   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9970   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9971   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9972   application.GetScene().Add(actor);
9973
9974   application.SendNotification();
9975
9976   std::vector<Rect<int>> damagedRects;
9977
9978   // Actor added, damaged rect is added size of actor
9979   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9980   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9981
9982   // Aligned by 16
9983   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9984   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9985
9986   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9987   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9988   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9989   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9990   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9991
9992   damagedRects.clear();
9993   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9994   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9995
9996   damagedRects.clear();
9997   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9998   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9999
10000   // Remove the Renderer
10001   Renderer renderer = actor.GetRendererAt(0);
10002   actor.RemoveRenderer(renderer);
10003
10004   application.SendNotification();
10005
10006   // The damaged rect should be the actor area
10007   damagedRects.clear();
10008   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10009   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10010   DALI_TEST_CHECK(damagedRects.size() > 0);
10011   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10012
10013   damagedRects.clear();
10014   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10015   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10016
10017   // Ensure the damaged rect is empty
10018   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10019
10020   // Add the Renderer again
10021   actor.AddRenderer(renderer);
10022
10023   application.SendNotification();
10024
10025   // The damaged rect should be the actor area
10026   damagedRects.clear();
10027   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10028   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10029   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10030   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10031
10032   END_TEST;
10033 }
10034
10035 int utcDaliActorPartialUpdate3DTransform(void)
10036 {
10037   TestApplication application(
10038     TestApplication::DEFAULT_SURFACE_WIDTH,
10039     TestApplication::DEFAULT_SURFACE_HEIGHT,
10040     TestApplication::DEFAULT_HORIZONTAL_DPI,
10041     TestApplication::DEFAULT_VERTICAL_DPI,
10042     true,
10043     true);
10044
10045   tet_infoline("Check the damaged rect with 3D transformed actors");
10046
10047   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10048
10049   Actor actor1                          = CreateRenderableActor();
10050   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10051   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10052   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10053   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10054   application.GetScene().Add(actor1);
10055
10056   // Add a new actor
10057   Actor actor2                          = CreateRenderableActor();
10058   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10059   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
10060   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10061   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10062   application.GetScene().Add(actor2);
10063
10064   application.SendNotification();
10065
10066   std::vector<Rect<int>> damagedRects;
10067
10068   // Actor added, damaged rect is added size of actor
10069   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10070   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10071
10072   // Aligned by 16
10073   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10074   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10075   DALI_TEST_EQUALS<Rect<int>>(clippingRect1, damagedRects[0], TEST_LOCATION);
10076   DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[1], TEST_LOCATION);
10077
10078   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10079   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10080
10081   damagedRects.clear();
10082   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10083   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10084   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10085
10086   damagedRects.clear();
10087   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10088   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10089   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10090
10091   // Rotate actor1 on y axis
10092   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10093
10094   // Remove actor2
10095   actor2.Unparent();
10096
10097   application.SendNotification();
10098
10099   damagedRects.clear();
10100   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10101
10102   // Should update full area
10103   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10104   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10105   DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10106   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10107
10108   // Add actor2 again
10109   application.GetScene().Add(actor2);
10110
10111   application.SendNotification();
10112
10113   damagedRects.clear();
10114   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10115
10116   // Should update full area
10117   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10118   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10119   DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10120   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10121
10122   // Reset the orientation of actor1
10123   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10124
10125   application.SendNotification();
10126
10127   damagedRects.clear();
10128   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10129
10130   // Should update full area
10131   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10132   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10133   DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10134   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10135
10136   // Make actor2 dirty
10137   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10138
10139   application.SendNotification();
10140
10141   damagedRects.clear();
10142   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10143
10144   clippingRect2 = Rect<int>(160, 608, 48, 48);
10145   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10146   DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[0], TEST_LOCATION);
10147
10148   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10149   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10150   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10151   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10152   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10153
10154   // Remove actor1
10155   actor1.Unparent();
10156
10157   application.SendNotification();
10158
10159   damagedRects.clear();
10160   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10161   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10162   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10163
10164   // Rotate actor1 on y axis
10165   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10166
10167   // Add actor1 again
10168   application.GetScene().Add(actor1);
10169
10170   application.SendNotification();
10171
10172   damagedRects.clear();
10173   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10174
10175   // Should update full area
10176   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10177   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10178   DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10179   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10180
10181   END_TEST;
10182 }
10183
10184 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10185 {
10186   TestApplication application(
10187     TestApplication::DEFAULT_SURFACE_WIDTH,
10188     TestApplication::DEFAULT_SURFACE_HEIGHT,
10189     TestApplication::DEFAULT_HORIZONTAL_DPI,
10190     TestApplication::DEFAULT_VERTICAL_DPI,
10191     true,
10192     true);
10193
10194   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10195
10196   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10197
10198   Actor actor = CreateRenderableActor();
10199
10200   // Create another renderer
10201   Geometry geometry  = CreateQuadGeometry();
10202   Shader   shader    = CreateShader();
10203   Renderer renderer2 = Renderer::New(geometry, shader);
10204   actor.AddRenderer(renderer2);
10205
10206   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10207   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10208   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10209   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10210   application.GetScene().Add(actor);
10211
10212   application.SendNotification();
10213
10214   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10215
10216   std::vector<Rect<int>> damagedRects;
10217
10218   // Actor added, damaged rect is added size of actor
10219   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10220   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10221
10222   // Aligned by 16
10223   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10224   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10225   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10226
10227   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10228   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10229   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10230   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10231   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10232
10233   damagedRects.clear();
10234   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10235   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10236
10237   // Ensure the damaged rect is empty
10238   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10239
10240   // Make renderer2 dirty
10241   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10242
10243   application.SendNotification();
10244
10245   // The damaged rect should be the actor area
10246   damagedRects.clear();
10247   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10248
10249   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10250   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10251   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10252
10253   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10254
10255   damagedRects.clear();
10256   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10257   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10258
10259   // Ensure the damaged rect is empty
10260   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10261
10262   // Make renderer2 dirty
10263   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10264
10265   application.SendNotification();
10266
10267   // The damaged rect should be the actor area
10268   damagedRects.clear();
10269   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10270
10271   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10272   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10273   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10274
10275   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10276
10277   damagedRects.clear();
10278   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10279   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10280
10281   // Ensure the damaged rect is empty
10282   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10283
10284   END_TEST;
10285 }
10286
10287 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10288 {
10289   TestApplication application(
10290     TestApplication::DEFAULT_SURFACE_WIDTH,
10291     TestApplication::DEFAULT_SURFACE_HEIGHT,
10292     TestApplication::DEFAULT_HORIZONTAL_DPI,
10293     TestApplication::DEFAULT_VERTICAL_DPI,
10294     true,
10295     true);
10296
10297   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10298
10299   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10300
10301   Actor actor                          = CreateRenderableActor();
10302   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10303   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10304   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10305   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10306   application.GetScene().Add(actor);
10307
10308   // Create another actor which has the same renderer with actor1
10309   Actor    actor2   = Actor::New();
10310   Renderer renderer = actor.GetRendererAt(0);
10311   actor2.AddRenderer(renderer);
10312   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10313   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10314   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10315   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10316   application.GetScene().Add(actor2);
10317
10318   application.SendNotification();
10319
10320   std::vector<Rect<int>> damagedRects;
10321
10322   // Actor added, damaged rect is added size of actor
10323   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10324   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10325
10326   // Aligned by 16
10327   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10328   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10329   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10330
10331   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10332   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10333   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10334   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10335   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10336
10337   damagedRects.clear();
10338   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10339   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10340
10341   // Ensure the damaged rect is empty
10342   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10343
10344   // Make renderer dirty
10345   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10346
10347   application.SendNotification();
10348
10349   // The damaged rect should be the actor area
10350   damagedRects.clear();
10351   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10352
10353   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10354   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10355   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10356   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10357
10358   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10359
10360   damagedRects.clear();
10361   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10362   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10363
10364   // Ensure the damaged rect is empty
10365   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10366
10367   END_TEST;
10368 }
10369
10370 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10371 {
10372   TestApplication application;
10373
10374   Actor actor = Actor::New();
10375   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10376   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10377   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10378   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10379   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10380   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10381   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10382   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10383   END_TEST;
10384 }
10385
10386 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10387 {
10388   TestApplication application;
10389
10390   Actor actor = Actor::New();
10391
10392   // Make sure setting invalid types does not cause a crash
10393   try
10394   {
10395     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10396     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10397     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10398     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10399     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10400     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10401     tet_result(TET_PASS);
10402   }
10403   catch(...)
10404   {
10405     tet_result(TET_FAIL);
10406   }
10407   END_TEST;
10408 }
10409
10410 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10411 {
10412   TestApplication application;
10413
10414   Actor     actor           = Actor::New();
10415   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10416   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10417   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10418   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10419   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10420   END_TEST;
10421 }
10422
10423 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10424 {
10425   TestApplication application;
10426
10427   Actor actor = Actor::New();
10428
10429   // Make sure setting invalid types does not cause a crash
10430   try
10431   {
10432     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10433     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10434     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10435     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10436     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10437     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10438     tet_result(TET_PASS);
10439   }
10440   catch(...)
10441   {
10442     tet_result(TET_FAIL);
10443   }
10444   END_TEST;
10445 }
10446
10447 int UtcDaliActorLowerBelowNegative(void)
10448 {
10449   TestApplication application;
10450   Dali::Actor     instance;
10451   try
10452   {
10453     Dali::Actor arg1;
10454     instance.LowerBelow(arg1);
10455     DALI_TEST_CHECK(false); // Should not get here
10456   }
10457   catch(...)
10458   {
10459     DALI_TEST_CHECK(true); // We expect an assert
10460   }
10461   END_TEST;
10462 }
10463
10464 int UtcDaliActorRaiseAboveNegative(void)
10465 {
10466   TestApplication application;
10467   Dali::Actor     instance;
10468   try
10469   {
10470     Dali::Actor arg1;
10471     instance.RaiseAbove(arg1);
10472     DALI_TEST_CHECK(false); // Should not get here
10473   }
10474   catch(...)
10475   {
10476     DALI_TEST_CHECK(true); // We expect an assert
10477   }
10478   END_TEST;
10479 }
10480
10481 int UtcDaliActorRaiseToTopNegative(void)
10482 {
10483   TestApplication application;
10484   Dali::Actor     instance;
10485   try
10486   {
10487     instance.RaiseToTop();
10488     DALI_TEST_CHECK(false); // Should not get here
10489   }
10490   catch(...)
10491   {
10492     DALI_TEST_CHECK(true); // We expect an assert
10493   }
10494   END_TEST;
10495 }
10496
10497 int UtcDaliActorAddRendererNegative(void)
10498 {
10499   TestApplication application;
10500   Dali::Actor     instance;
10501   try
10502   {
10503     Dali::Renderer arg1;
10504     instance.AddRenderer(arg1);
10505     DALI_TEST_CHECK(false); // Should not get here
10506   }
10507   catch(...)
10508   {
10509     DALI_TEST_CHECK(true); // We expect an assert
10510   }
10511   END_TEST;
10512 }
10513
10514 int UtcDaliActorTouchedSignalNegative(void)
10515 {
10516   TestApplication application;
10517   Dali::Actor     instance;
10518   try
10519   {
10520     instance.TouchedSignal();
10521     DALI_TEST_CHECK(false); // Should not get here
10522   }
10523   catch(...)
10524   {
10525     DALI_TEST_CHECK(true); // We expect an assert
10526   }
10527   END_TEST;
10528 }
10529
10530 int UtcDaliActorTranslateByNegative(void)
10531 {
10532   TestApplication application;
10533   Dali::Actor     instance;
10534   try
10535   {
10536     Dali::Vector3 arg1;
10537     instance.TranslateBy(arg1);
10538     DALI_TEST_CHECK(false); // Should not get here
10539   }
10540   catch(...)
10541   {
10542     DALI_TEST_CHECK(true); // We expect an assert
10543   }
10544   END_TEST;
10545 }
10546
10547 int UtcDaliActorFindChildByIdNegative(void)
10548 {
10549   TestApplication application;
10550   Dali::Actor     instance;
10551   try
10552   {
10553     unsigned int arg1 = 0u;
10554     instance.FindChildById(arg1);
10555     DALI_TEST_CHECK(false); // Should not get here
10556   }
10557   catch(...)
10558   {
10559     DALI_TEST_CHECK(true); // We expect an assert
10560   }
10561   END_TEST;
10562 }
10563
10564 int UtcDaliActorGetRendererAtNegative(void)
10565 {
10566   TestApplication application;
10567   Dali::Actor     instance;
10568   try
10569   {
10570     unsigned int arg1 = 0u;
10571     instance.GetRendererAt(arg1);
10572     DALI_TEST_CHECK(false); // Should not get here
10573   }
10574   catch(...)
10575   {
10576     DALI_TEST_CHECK(true); // We expect an assert
10577   }
10578   END_TEST;
10579 }
10580
10581 int UtcDaliActorHoveredSignalNegative(void)
10582 {
10583   TestApplication application;
10584   Dali::Actor     instance;
10585   try
10586   {
10587     instance.HoveredSignal();
10588     DALI_TEST_CHECK(false); // Should not get here
10589   }
10590   catch(...)
10591   {
10592     DALI_TEST_CHECK(true); // We expect an assert
10593   }
10594   END_TEST;
10595 }
10596
10597 int UtcDaliActorLowerToBottomNegative(void)
10598 {
10599   TestApplication application;
10600   Dali::Actor     instance;
10601   try
10602   {
10603     instance.LowerToBottom();
10604     DALI_TEST_CHECK(false); // Should not get here
10605   }
10606   catch(...)
10607   {
10608     DALI_TEST_CHECK(true); // We expect an assert
10609   }
10610   END_TEST;
10611 }
10612
10613 int UtcDaliActorOnSceneSignalNegative(void)
10614 {
10615   TestApplication application;
10616   Dali::Actor     instance;
10617   try
10618   {
10619     instance.OnSceneSignal();
10620     DALI_TEST_CHECK(false); // Should not get here
10621   }
10622   catch(...)
10623   {
10624     DALI_TEST_CHECK(true); // We expect an assert
10625   }
10626   END_TEST;
10627 }
10628
10629 int UtcDaliActorOffSceneSignalNegative(void)
10630 {
10631   TestApplication application;
10632   Dali::Actor     instance;
10633   try
10634   {
10635     instance.OffSceneSignal();
10636     DALI_TEST_CHECK(false); // Should not get here
10637   }
10638   catch(...)
10639   {
10640     DALI_TEST_CHECK(true); // We expect an assert
10641   }
10642   END_TEST;
10643 }
10644
10645 int UtcDaliActorRemoveRendererNegative01(void)
10646 {
10647   TestApplication application;
10648   Dali::Actor     instance;
10649   try
10650   {
10651     unsigned int arg1 = 0u;
10652     instance.RemoveRenderer(arg1);
10653     DALI_TEST_CHECK(false); // Should not get here
10654   }
10655   catch(...)
10656   {
10657     DALI_TEST_CHECK(true); // We expect an assert
10658   }
10659   END_TEST;
10660 }
10661
10662 int UtcDaliActorRemoveRendererNegative02(void)
10663 {
10664   TestApplication application;
10665   Dali::Actor     instance;
10666   try
10667   {
10668     Dali::Renderer arg1;
10669     instance.RemoveRenderer(arg1);
10670     DALI_TEST_CHECK(false); // Should not get here
10671   }
10672   catch(...)
10673   {
10674     DALI_TEST_CHECK(true); // We expect an assert
10675   }
10676   END_TEST;
10677 }
10678
10679 int UtcDaliActorFindChildByNameNegative(void)
10680 {
10681   TestApplication application;
10682   Dali::Actor     instance;
10683   try
10684   {
10685     std::string arg1;
10686     instance.FindChildByName(arg1);
10687     DALI_TEST_CHECK(false); // Should not get here
10688   }
10689   catch(...)
10690   {
10691     DALI_TEST_CHECK(true); // We expect an assert
10692   }
10693   END_TEST;
10694 }
10695
10696 int UtcDaliActorSetResizePolicyNegative(void)
10697 {
10698   TestApplication application;
10699   Dali::Actor     instance;
10700   try
10701   {
10702     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10703     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
10704     instance.SetResizePolicy(arg1, arg2);
10705     DALI_TEST_CHECK(false); // Should not get here
10706   }
10707   catch(...)
10708   {
10709     DALI_TEST_CHECK(true); // We expect an assert
10710   }
10711   END_TEST;
10712 }
10713
10714 int UtcDaliActorOnRelayoutSignalNegative(void)
10715 {
10716   TestApplication application;
10717   Dali::Actor     instance;
10718   try
10719   {
10720     instance.OnRelayoutSignal();
10721     DALI_TEST_CHECK(false); // Should not get here
10722   }
10723   catch(...)
10724   {
10725     DALI_TEST_CHECK(true); // We expect an assert
10726   }
10727   END_TEST;
10728 }
10729
10730 int UtcDaliActorWheelEventSignalNegative(void)
10731 {
10732   TestApplication application;
10733   Dali::Actor     instance;
10734   try
10735   {
10736     instance.WheelEventSignal();
10737     DALI_TEST_CHECK(false); // Should not get here
10738   }
10739   catch(...)
10740   {
10741     DALI_TEST_CHECK(true); // We expect an assert
10742   }
10743   END_TEST;
10744 }
10745
10746 int UtcDaliActorGetHeightForWidthNegative(void)
10747 {
10748   TestApplication application;
10749   Dali::Actor     instance;
10750   try
10751   {
10752     float arg1 = 0.0f;
10753     instance.GetHeightForWidth(arg1);
10754     DALI_TEST_CHECK(false); // Should not get here
10755   }
10756   catch(...)
10757   {
10758     DALI_TEST_CHECK(true); // We expect an assert
10759   }
10760   END_TEST;
10761 }
10762
10763 int UtcDaliActorGetWidthForHeightNegative(void)
10764 {
10765   TestApplication application;
10766   Dali::Actor     instance;
10767   try
10768   {
10769     float arg1 = 0.0f;
10770     instance.GetWidthForHeight(arg1);
10771     DALI_TEST_CHECK(false); // Should not get here
10772   }
10773   catch(...)
10774   {
10775     DALI_TEST_CHECK(true); // We expect an assert
10776   }
10777   END_TEST;
10778 }
10779
10780 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10781 {
10782   TestApplication application;
10783   Dali::Actor     instance;
10784   try
10785   {
10786     instance.LayoutDirectionChangedSignal();
10787     DALI_TEST_CHECK(false); // Should not get here
10788   }
10789   catch(...)
10790   {
10791     DALI_TEST_CHECK(true); // We expect an assert
10792   }
10793   END_TEST;
10794 }
10795
10796 int UtcDaliActorAddNegative(void)
10797 {
10798   TestApplication application;
10799   Dali::Actor     instance;
10800   try
10801   {
10802     Dali::Actor arg1;
10803     instance.Add(arg1);
10804     DALI_TEST_CHECK(false); // Should not get here
10805   }
10806   catch(...)
10807   {
10808     DALI_TEST_CHECK(true); // We expect an assert
10809   }
10810   END_TEST;
10811 }
10812
10813 int UtcDaliActorLowerNegative(void)
10814 {
10815   TestApplication application;
10816   Dali::Actor     instance;
10817   try
10818   {
10819     instance.Lower();
10820     DALI_TEST_CHECK(false); // Should not get here
10821   }
10822   catch(...)
10823   {
10824     DALI_TEST_CHECK(true); // We expect an assert
10825   }
10826   END_TEST;
10827 }
10828
10829 int UtcDaliActorRaiseNegative(void)
10830 {
10831   TestApplication application;
10832   Dali::Actor     instance;
10833   try
10834   {
10835     instance.Raise();
10836     DALI_TEST_CHECK(false); // Should not get here
10837   }
10838   catch(...)
10839   {
10840     DALI_TEST_CHECK(true); // We expect an assert
10841   }
10842   END_TEST;
10843 }
10844
10845 int UtcDaliActorRemoveNegative(void)
10846 {
10847   TestApplication application;
10848   Dali::Actor     instance;
10849   try
10850   {
10851     Dali::Actor arg1;
10852     instance.Remove(arg1);
10853     DALI_TEST_CHECK(false); // Should not get here
10854   }
10855   catch(...)
10856   {
10857     DALI_TEST_CHECK(true); // We expect an assert
10858   }
10859   END_TEST;
10860 }
10861
10862 int UtcDaliActorScaleByNegative(void)
10863 {
10864   TestApplication application;
10865   Dali::Actor     instance;
10866   try
10867   {
10868     Dali::Vector3 arg1;
10869     instance.ScaleBy(arg1);
10870     DALI_TEST_CHECK(false); // Should not get here
10871   }
10872   catch(...)
10873   {
10874     DALI_TEST_CHECK(true); // We expect an assert
10875   }
10876   END_TEST;
10877 }
10878
10879 int UtcDaliActorGetLayerNegative(void)
10880 {
10881   TestApplication application;
10882   Dali::Actor     instance;
10883   try
10884   {
10885     instance.GetLayer();
10886     DALI_TEST_CHECK(false); // Should not get here
10887   }
10888   catch(...)
10889   {
10890     DALI_TEST_CHECK(true); // We expect an assert
10891   }
10892   END_TEST;
10893 }
10894
10895 int UtcDaliActorRotateByNegative01(void)
10896 {
10897   TestApplication application;
10898   Dali::Actor     instance;
10899   try
10900   {
10901     Dali::Quaternion arg1;
10902     instance.RotateBy(arg1);
10903     DALI_TEST_CHECK(false); // Should not get here
10904   }
10905   catch(...)
10906   {
10907     DALI_TEST_CHECK(true); // We expect an assert
10908   }
10909   END_TEST;
10910 }
10911
10912 int UtcDaliActorRotateByNegative02(void)
10913 {
10914   TestApplication application;
10915   Dali::Actor     instance;
10916   try
10917   {
10918     Dali::Radian  arg1;
10919     Dali::Vector3 arg2;
10920     instance.RotateBy(arg1, arg2);
10921     DALI_TEST_CHECK(false); // Should not get here
10922   }
10923   catch(...)
10924   {
10925     DALI_TEST_CHECK(true); // We expect an assert
10926   }
10927   END_TEST;
10928 }
10929
10930 int UtcDaliActorUnparentNegative(void)
10931 {
10932   TestApplication application;
10933   Dali::Actor     instance;
10934   try
10935   {
10936     instance.Unparent();
10937     DALI_TEST_CHECK(false); // Should not get here
10938   }
10939   catch(...)
10940   {
10941     DALI_TEST_CHECK(true); // We expect an assert
10942   }
10943   END_TEST;
10944 }
10945
10946 int UtcDaliActorGetChildAtNegative(void)
10947 {
10948   TestApplication application;
10949   Dali::Actor     instance;
10950   try
10951   {
10952     unsigned int arg1 = 0u;
10953     instance.GetChildAt(arg1);
10954     DALI_TEST_CHECK(false); // Should not get here
10955   }
10956   catch(...)
10957   {
10958     DALI_TEST_CHECK(true); // We expect an assert
10959   }
10960   END_TEST;
10961 }
10962
10963 int UtcDaliActorGetChildCountNegative(void)
10964 {
10965   TestApplication application;
10966   Dali::Actor     instance;
10967   try
10968   {
10969     instance.GetChildCount();
10970     DALI_TEST_CHECK(false); // Should not get here
10971   }
10972   catch(...)
10973   {
10974     DALI_TEST_CHECK(true); // We expect an assert
10975   }
10976   END_TEST;
10977 }
10978
10979 int UtcDaliActorGetTargetSizeNegative(void)
10980 {
10981   TestApplication application;
10982   Dali::Actor     instance;
10983   try
10984   {
10985     instance.GetTargetSize();
10986     DALI_TEST_CHECK(false); // Should not get here
10987   }
10988   catch(...)
10989   {
10990     DALI_TEST_CHECK(true); // We expect an assert
10991   }
10992   END_TEST;
10993 }
10994
10995 int UtcDaliActorScreenToLocalNegative(void)
10996 {
10997   TestApplication application;
10998   Dali::Actor     instance;
10999   try
11000   {
11001     float arg1 = 0.0f;
11002     float arg2 = 0.0f;
11003     float arg3 = 0.0f;
11004     float arg4 = 0.0f;
11005     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11006     DALI_TEST_CHECK(false); // Should not get here
11007   }
11008   catch(...)
11009   {
11010     DALI_TEST_CHECK(true); // We expect an assert
11011   }
11012   END_TEST;
11013 }
11014
11015 int UtcDaliActorGetNaturalSizeNegative(void)
11016 {
11017   TestApplication application;
11018   Dali::Actor     instance;
11019   try
11020   {
11021     instance.GetNaturalSize();
11022     DALI_TEST_CHECK(false); // Should not get here
11023   }
11024   catch(...)
11025   {
11026     DALI_TEST_CHECK(true); // We expect an assert
11027   }
11028   END_TEST;
11029 }
11030
11031 int UtcDaliActorGetRelayoutSizeNegative(void)
11032 {
11033   TestApplication application;
11034   Dali::Actor     instance;
11035   try
11036   {
11037     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11038     instance.GetRelayoutSize(arg1);
11039     DALI_TEST_CHECK(false); // Should not get here
11040   }
11041   catch(...)
11042   {
11043     DALI_TEST_CHECK(true); // We expect an assert
11044   }
11045   END_TEST;
11046 }
11047
11048 int UtcDaliActorGetResizePolicyNegative(void)
11049 {
11050   TestApplication application;
11051   Dali::Actor     instance;
11052   try
11053   {
11054     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11055     instance.GetResizePolicy(arg1);
11056     DALI_TEST_CHECK(false); // Should not get here
11057   }
11058   catch(...)
11059   {
11060     DALI_TEST_CHECK(true); // We expect an assert
11061   }
11062   END_TEST;
11063 }
11064
11065 int UtcDaliActorGetRendererCountNegative(void)
11066 {
11067   TestApplication application;
11068   Dali::Actor     instance;
11069   try
11070   {
11071     instance.GetRendererCount();
11072     DALI_TEST_CHECK(false); // Should not get here
11073   }
11074   catch(...)
11075   {
11076     DALI_TEST_CHECK(true); // We expect an assert
11077   }
11078   END_TEST;
11079 }
11080
11081 int UtcDaliActorGetParentNegative(void)
11082 {
11083   TestApplication application;
11084   Dali::Actor     instance;
11085   try
11086   {
11087     instance.GetParent();
11088     DALI_TEST_CHECK(false); // Should not get here
11089   }
11090   catch(...)
11091   {
11092     DALI_TEST_CHECK(true); // We expect an assert
11093   }
11094   END_TEST;
11095 }
11096
11097 int UtcDaliActorPropertyBlendEquation(void)
11098 {
11099   TestApplication application;
11100
11101   tet_infoline("Test SetProperty AdvancedBlendEquation");
11102
11103   Geometry geometry  = CreateQuadGeometry();
11104   Shader   shader    = CreateShader();
11105   Renderer renderer1 = Renderer::New(geometry, shader);
11106
11107   Actor actor = Actor::New();
11108   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11109
11110   actor.AddRenderer(renderer1);
11111   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11112   application.GetScene().Add(actor);
11113
11114   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11115   {
11116     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11117     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11118     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11119   }
11120
11121   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11122   {
11123     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11124     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11125     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11126   }
11127
11128   Renderer renderer2 = Renderer::New(geometry, shader);
11129   actor.AddRenderer(renderer2);
11130
11131   END_TEST;
11132 }
11133
11134 int UtcDaliActorRegisterProperty(void)
11135 {
11136   tet_infoline("Test property registration and uniform map update\n");
11137
11138   TestApplication application;
11139
11140   Geometry geometry  = CreateQuadGeometry();
11141   Shader   shader    = CreateShader();
11142   Renderer renderer1 = Renderer::New(geometry, shader);
11143   Renderer renderer2 = Renderer::New(geometry, shader);
11144
11145   Actor actor1 = Actor::New();
11146   actor1.AddRenderer(renderer1);
11147   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11148   actor1.RegisterProperty("uCustom", 1);
11149   application.GetScene().Add(actor1);
11150
11151   Actor actor2 = Actor::New();
11152   actor2.AddRenderer(renderer2);
11153   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11154   application.GetScene().Add(actor2);
11155
11156   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11157   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
11158   glAbstraction.EnableSetUniformCallTrace(true);
11159
11160   application.SendNotification();
11161   application.Render();
11162
11163   std::stringstream out;
11164   out.str("1");
11165   std::string params;
11166
11167   // Test uniform value of the custom property
11168   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11169   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11170
11171   // Make invisible
11172   actor1[Actor::Property::VISIBLE] = false;
11173
11174   application.SendNotification();
11175   application.Render();
11176
11177   // Make visible again
11178   actor1[Actor::Property::VISIBLE] = true;
11179   actor1["uCustom"]                = 2;
11180
11181   glAbstraction.ResetSetUniformCallStack();
11182
11183   application.SendNotification();
11184   application.Render();
11185
11186   out.str("2");
11187
11188   // The uniform value should not be changed
11189   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11190   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11191
11192   END_TEST;
11193 }
11194
11195 int UtcDaliActorDoesWantedHitTest(void)
11196 {
11197   struct HitTestData
11198   {
11199   public:
11200     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11201     : mScale(scale),
11202       mTouchPoint(touchPoint),
11203       mResult(result)
11204     {
11205     }
11206
11207     Vector3 mScale;
11208     Vector2 mTouchPoint;
11209     bool    mResult;
11210   };
11211
11212   TestApplication application;
11213   tet_infoline(" UtcDaliActorDoesWantedHitTest");
11214
11215   // Fill a vector with different hit tests.
11216   struct HitTestData* hitTestData[] = {
11217     //                    scale                     touch point           result
11218     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
11219     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11220     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.
11221     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11222     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.
11223     NULL,
11224   };
11225
11226   // get the root layer
11227   Actor actor = Actor::New();
11228   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11229   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11230
11231   Actor lowerActor = Actor::New();
11232   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11233   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11234
11235   // actor and lowerActor have no relationship.
11236   application.GetScene().Add(lowerActor);
11237   application.GetScene().Add(actor);
11238
11239   ResetTouchCallbacks();
11240   gHitTestTouchCallBackCalled = false;
11241
11242   unsigned int index = 0;
11243   while(NULL != hitTestData[index])
11244   {
11245     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11246     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11247
11248     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11249     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11250
11251     // flush the queue and render once
11252     application.SendNotification();
11253     application.Render();
11254
11255     DALI_TEST_CHECK(!gTouchCallBackCalled);
11256     DALI_TEST_CHECK(!gTouchCallBackCalled2);
11257     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11258
11259     // connect to its touch signal
11260     actor.TouchedSignal().Connect(TestTouchCallback);
11261     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11262
11263     // connect to its hit-test signal
11264     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11265
11266     Dali::Integration::Point point;
11267     point.SetState(PointState::DOWN);
11268     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11269     Dali::Integration::TouchEvent event;
11270     event.AddPoint(point);
11271
11272     // flush the queue and render once
11273     application.SendNotification();
11274     application.Render();
11275     application.ProcessEvent(event);
11276
11277     // check hit-test events
11278     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11279     // Passed all hit-tests of actor.
11280     DALI_TEST_CHECK(gTouchCallBackCalled == false);
11281     // The lowerActor was hit-tested.
11282     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11283
11284     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11285       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11286                  hitTestData[index]->mScale.x,
11287                  hitTestData[index]->mScale.y,
11288                  hitTestData[index]->mScale.z,
11289                  hitTestData[index]->mTouchPoint.x,
11290                  hitTestData[index]->mTouchPoint.y,
11291                  hitTestData[index]->mResult);
11292
11293     ResetTouchCallbacks();
11294     gHitTestTouchCallBackCalled = false;
11295     ++index;
11296   }
11297   END_TEST;
11298 }
11299
11300 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11301 {
11302   TestApplication application;
11303
11304   Actor actor = Actor::New();
11305   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11306   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11307   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11308   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11309   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11310   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11311   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11312   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11313   END_TEST;
11314 }
11315
11316 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11317 {
11318   TestApplication application;
11319
11320   Actor actor = Actor::New();
11321
11322   // Make sure setting invalid types does not cause a crash
11323   try
11324   {
11325     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11326     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11327     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11328     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11329     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11330     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11331     tet_result(TET_PASS);
11332   }
11333   catch(...)
11334   {
11335     tet_result(TET_FAIL);
11336   }
11337   END_TEST;
11338 }
11339
11340 int UtcDaliActorCalculateWorldTransform01(void)
11341 {
11342   TestApplication application;
11343
11344   tet_infoline("Test that actor position inheritance produces right transform matrix");
11345
11346   Actor rootActor   = Actor::New();
11347   Actor branchActor = Actor::New();
11348   Actor leafActor   = Actor::New();
11349
11350   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11351   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11352   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11353
11354   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11355   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11356   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11357
11358   // Set anchor point to the same value as parent origin
11359   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11360   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11361   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11362
11363   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11364   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11365   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11366
11367   application.GetScene().Add(rootActor);
11368   rootActor.Add(branchActor);
11369   branchActor.Add(leafActor);
11370
11371   application.SendNotification();
11372   application.Render(0);
11373   application.SendNotification();
11374   application.Render(0);
11375
11376   Matrix m = DevelActor::GetWorldTransform(leafActor);
11377
11378   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11379   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11380
11381   Vector3    worldPos;
11382   Vector3    worldScale;
11383   Quaternion worldRotation;
11384   m.GetTransformComponents(worldPos, worldRotation, worldScale);
11385   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11386
11387   END_TEST;
11388 }
11389
11390 int UtcDaliActorCalculateWorldTransform02(void)
11391 {
11392   TestApplication application;
11393
11394   tet_infoline("Test that actor position produces right transform matrix");
11395
11396   Actor rootActor   = Actor::New();
11397   Actor branchActor = Actor::New();
11398   Actor leafActor   = Actor::New();
11399
11400   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11401   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11402   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11403
11404   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11405   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11406   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11407
11408   // Set anchor point to the same value as parent origin
11409   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11410   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11411   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11412
11413   application.GetScene().Add(rootActor);
11414   rootActor.Add(branchActor);
11415   branchActor.Add(leafActor);
11416
11417   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11418   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11419   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11420
11421   application.SendNotification();
11422   application.Render(0);
11423   application.SendNotification();
11424   application.Render(0);
11425
11426   Matrix m = DevelActor::GetWorldTransform(leafActor);
11427
11428   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11429   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11430
11431   END_TEST;
11432 }
11433
11434 int UtcDaliActorCalculateWorldTransform03(void)
11435 {
11436   TestApplication application;
11437
11438   tet_infoline("Test that actor position produces right transform matrix");
11439
11440   Actor rootActor   = Actor::New();
11441   Actor branchActor = Actor::New();
11442   Actor leafActor   = Actor::New();
11443
11444   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11445   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11446   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11447
11448   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11449   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11450   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11451
11452   // Set anchor point to the same value as parent origin
11453   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11454   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11455   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11456
11457   application.GetScene().Add(rootActor);
11458   rootActor.Add(branchActor);
11459   branchActor.Add(leafActor);
11460
11461   leafActor[Actor::Property::INHERIT_POSITION]    = true;
11462   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11463   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11464
11465   application.SendNotification();
11466   application.Render(0);
11467   application.SendNotification();
11468   application.Render(0);
11469
11470   Matrix m = DevelActor::GetWorldTransform(leafActor);
11471
11472   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11473   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11474
11475   END_TEST;
11476 }
11477
11478 int UtcDaliActorCalculateWorldTransform04(void)
11479 {
11480   TestApplication application;
11481
11482   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11483
11484   Actor rootActor   = Actor::New();
11485   Actor branchActor = Actor::New();
11486   Actor leafActor   = Actor::New();
11487
11488   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11489   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11490   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11491
11492   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11493   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11494   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11495
11496   // Set anchor point to the same value as parent origin
11497   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11498   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11499   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11500   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11501
11502   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11503   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11504
11505   application.GetScene().Add(rootActor);
11506   rootActor.Add(branchActor);
11507   branchActor.Add(leafActor);
11508
11509   application.SendNotification();
11510   application.Render(0);
11511   application.SendNotification();
11512   application.Render(0);
11513
11514   Matrix m = DevelActor::GetWorldTransform(leafActor);
11515
11516   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11517   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11518
11519   END_TEST;
11520 }
11521
11522 int UtcDaliActorCalculateWorldTransform05(void)
11523 {
11524   TestApplication application;
11525
11526   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11527
11528   Actor rootActor   = Actor::New();
11529   Actor branchActor = Actor::New();
11530   Actor leafActor   = Actor::New();
11531
11532   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11533   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11534   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11535
11536   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11537   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11538   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11539
11540   // Set anchor point to the same value as parent origin
11541   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11542   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11543   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11544   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11545
11546   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11547   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11548
11549   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11550   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11551
11552   application.GetScene().Add(rootActor);
11553   rootActor.Add(branchActor);
11554   branchActor.Add(leafActor);
11555
11556   application.SendNotification();
11557   application.Render(0);
11558   application.SendNotification();
11559   application.Render(0);
11560
11561   Matrix m = DevelActor::GetWorldTransform(leafActor);
11562
11563   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11564   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11565
11566   END_TEST;
11567 }
11568
11569 int UtcDaliActorCalculateWorldTransform06(void)
11570 {
11571   TestApplication application;
11572
11573   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11574
11575   Actor rootActor   = Actor::New();
11576   Actor branchActor = Actor::New();
11577   Actor leafActor   = Actor::New();
11578
11579   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11580   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11581   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11582
11583   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11584   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11585   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11586
11587   // Set anchor point to the same value as parent origin
11588   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11589   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11590   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11591   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11592
11593   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11594   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11595   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11596
11597   leafActor[Actor::Property::INHERIT_POSITION] = false;
11598   leafActor[Actor::Property::INHERIT_SCALE]    = false;
11599
11600   application.GetScene().Add(rootActor);
11601   rootActor.Add(branchActor);
11602   branchActor.Add(leafActor);
11603
11604   application.SendNotification();
11605   application.Render(0);
11606   application.SendNotification();
11607   application.Render(0);
11608
11609   Matrix m = DevelActor::GetWorldTransform(leafActor);
11610
11611   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11612   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11613
11614   END_TEST;
11615 }
11616
11617 int UtcDaliActorCalculateWorldTransform07(void)
11618 {
11619   TestApplication application;
11620
11621   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11622
11623   Actor rootActor   = Actor::New();
11624   Actor branchActor = Actor::New();
11625   Actor leafActor   = Actor::New();
11626
11627   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11628   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11629   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11630
11631   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11632   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11633   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11634
11635   // Set anchor point to the same value as parent origin
11636   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11637   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11638   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11639
11640   // This should be ignored.
11641   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11642   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11643
11644   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11645   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11646   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11647
11648   leafActor[Actor::Property::INHERIT_POSITION]           = false;
11649   leafActor[Actor::Property::INHERIT_SCALE]              = false;
11650   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11651
11652   application.GetScene().Add(rootActor);
11653   rootActor.Add(branchActor);
11654   branchActor.Add(leafActor);
11655
11656   application.SendNotification();
11657   application.Render(0);
11658   application.SendNotification();
11659   application.Render(0);
11660
11661   Matrix m = DevelActor::GetWorldTransform(leafActor);
11662
11663   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11664   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11665
11666   END_TEST;
11667 }
11668
11669 int UtcDaliActorCalculateWorldColor01(void)
11670 {
11671   TestApplication application;
11672
11673   tet_infoline("Test that actor inheritance of color produces right final color");
11674
11675   Actor rootActor   = Actor::New();
11676   Actor branchActor = Actor::New();
11677   Actor leafActor   = Actor::New();
11678
11679   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11680   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11681   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11682
11683   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11684   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11685   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11686
11687   rootActor[Actor::Property::COLOR]   = Color::WHITE;
11688   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11689   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11690
11691   // Default is to inherit:
11692   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11693
11694   application.GetScene().Add(rootActor);
11695   rootActor.Add(branchActor);
11696   branchActor.Add(leafActor);
11697
11698   application.SendNotification();
11699   application.Render(0);
11700
11701   Vector4 color = DevelActor::GetWorldColor(leafActor);
11702
11703   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11704   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11705
11706   END_TEST;
11707 }
11708
11709 int UtcDaliActorCalculateWorldColor02(void)
11710 {
11711   TestApplication application;
11712
11713   tet_infoline("Test that actor uses own color");
11714
11715   Actor rootActor   = Actor::New();
11716   Actor branchActor = Actor::New();
11717   Actor leafActor   = Actor::New();
11718
11719   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11720   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11721   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11722
11723   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11724   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11725   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11726
11727   rootActor[Actor::Property::COLOR]   = Color::WHITE;
11728   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11729   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11730
11731   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
11732
11733   application.GetScene().Add(rootActor);
11734   rootActor.Add(branchActor);
11735   branchActor.Add(leafActor);
11736
11737   application.SendNotification();
11738   application.Render(0);
11739
11740   Vector4 color = DevelActor::GetWorldColor(leafActor);
11741
11742   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11743   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11744   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
11745   END_TEST;
11746 }
11747
11748 int UtcDaliActorCalculateWorldColor03(void)
11749 {
11750   TestApplication application;
11751
11752   tet_infoline("Test that actor uses parent color");
11753
11754   Actor rootActor   = Actor::New();
11755   Actor branchActor = Actor::New();
11756   Actor leafActor   = Actor::New();
11757
11758   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11759   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11760   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11761
11762   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11763   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11764   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11765
11766   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
11767   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11768   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11769
11770   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
11771
11772   application.GetScene().Add(rootActor);
11773   rootActor.Add(branchActor);
11774   branchActor.Add(leafActor);
11775
11776   application.SendNotification();
11777   application.Render(0);
11778
11779   Vector4 color = DevelActor::GetWorldColor(leafActor);
11780
11781   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11782   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11783   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
11784   END_TEST;
11785 }
11786
11787 int UtcDaliActorCalculateWorldColor04(void)
11788 {
11789   TestApplication application;
11790
11791   tet_infoline("Test that actor blends with parent color");
11792
11793   Actor rootActor   = Actor::New();
11794   Actor branchActor = Actor::New();
11795   Actor leafActor   = Actor::New();
11796
11797   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11798   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11799   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11800
11801   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11802   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11803   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11804
11805   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
11806   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11807   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11808
11809   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
11810
11811   application.GetScene().Add(rootActor);
11812   rootActor.Add(branchActor);
11813   branchActor.Add(leafActor);
11814
11815   application.SendNotification();
11816   application.Render(0);
11817
11818   Vector4 color = DevelActor::GetWorldColor(leafActor);
11819
11820   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11821   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11822
11823   END_TEST;
11824 }