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