[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2024 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 #include <test-native-image.h>
31
32 #include <cfloat> // For FLT_MAX
33 #include <string>
34
35 #include "assert.h"
36
37 //& set: DaliActor
38
39 using std::string;
40 using namespace Dali;
41
42 void utc_dali_actor_startup(void)
43 {
44   test_return_value = TET_UNDEF;
45 }
46
47 void utc_dali_actor_cleanup(void)
48 {
49   test_return_value = TET_PASS;
50 }
51
52 namespace
53 {
54 bool gTouchCallBackCalled        = false;
55 bool gTouchCallBackCalled2       = false;
56 bool gTouchCallBackCalled3       = false;
57 bool gHitTestTouchCallBackCalled = false;
58
59 bool gHoverCallBackCalled = false;
60
61 static bool gTestConstraintCalled;
62
63 LayoutDirection::Type gLayoutDirectionType;
64
65 struct TestConstraint
66 {
67   void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
68   {
69     gTestConstraintCalled = true;
70   }
71 };
72
73 /**
74  * TestConstraint reference.
75  * When constraint is called, the resultRef is updated
76  * with the value supplied.
77  */
78 template<typename T>
79 struct TestConstraintRef
80 {
81   TestConstraintRef(unsigned int& resultRef, unsigned int value)
82   : mResultRef(resultRef),
83     mValue(value)
84   {
85   }
86
87   void operator()(T& current, const PropertyInputContainer& /* inputs */)
88   {
89     mResultRef = mValue;
90   }
91
92   unsigned int& mResultRef;
93   unsigned int  mValue;
94 };
95
96 static bool TestTouchCallback(Actor, const TouchEvent&)
97 {
98   gTouchCallBackCalled = true;
99   return true;
100   END_TEST;
101 }
102
103 static bool TestTouchCallback2(Actor, const TouchEvent&)
104 {
105   gTouchCallBackCalled2 = true;
106   return true;
107   END_TEST;
108 }
109
110 static bool TestTouchCallback3(Actor, const TouchEvent&)
111 {
112   gTouchCallBackCalled3 = true;
113   return true;
114   END_TEST;
115 }
116
117 static bool TestHitTestTouchCallback(Actor, const TouchEvent&)
118 {
119   gHitTestTouchCallBackCalled = true;
120   return false;
121   END_TEST;
122 }
123
124 static void ResetTouchCallbacks()
125 {
126   gTouchCallBackCalled  = false;
127   gTouchCallBackCalled2 = false;
128   gTouchCallBackCalled3 = false;
129 }
130
131 static void ResetTouchCallbacks(TestApplication& application)
132 {
133   // reset touch
134   Dali::Integration::Point point;
135   point.SetDeviceId(1);
136   point.SetState(PointState::UP);
137   point.SetScreenPosition(Vector2(10.f, 10.f));
138   Dali::Integration::TouchEvent touchEvent;
139   touchEvent.AddPoint(point);
140   application.ProcessEvent(touchEvent);
141
142   ResetTouchCallbacks();
143 }
144
145 static bool TestCallback3(Actor actor, const HoverEvent& event)
146 {
147   gHoverCallBackCalled = true;
148   return false;
149   END_TEST;
150 }
151
152 // validation stuff for onstage & offstage signals
153 static std::vector<std::string> gActorNamesOnOffScene;
154 static int                      gOnSceneCallBackCalled;
155 void                            OnSceneCallback(Actor actor)
156 {
157   ++gOnSceneCallBackCalled;
158   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
159   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
160 }
161 static int gOffSceneCallBackCalled;
162 void       OffSceneCallback(Actor actor)
163 {
164   ++gOffSceneCallBackCalled;
165   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
166   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
167 }
168
169 struct PositionComponentConstraint
170 {
171   PositionComponentConstraint()
172   {
173   }
174
175   void operator()(Vector3& pos, const PropertyInputContainer& inputs)
176   {
177     const Matrix& m = inputs[0]->GetMatrix();
178     Vector3       scale;
179     Quaternion    rot;
180     m.GetTransformComponents(pos, rot, scale);
181   }
182 };
183
184 struct OrientationComponentConstraint
185 {
186   OrientationComponentConstraint()
187   {
188   }
189
190   void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
191   {
192     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
193     Vector3           pos, scale;
194     Quaternion        rot;
195     orientation = parentOrientation;
196   }
197 };
198 // OnRelayout
199
200 static bool                     gOnRelayoutCallBackCalled = false;
201 static std::vector<std::string> gActorNamesRelayout;
202
203 void OnRelayoutCallback(Actor actor)
204 {
205   gOnRelayoutCallBackCalled = true;
206   gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
207 }
208
209 struct VisibilityChangedFunctorData
210 {
211   VisibilityChangedFunctorData()
212   : actor(),
213     visible(false),
214     type(DevelActor::VisibilityChange::SELF),
215     called(false)
216   {
217   }
218
219   void Reset()
220   {
221     actor.Reset();
222     visible = false;
223     type    = DevelActor::VisibilityChange::SELF;
224     called  = false;
225   }
226
227   void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
228   {
229     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
230     DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
231     DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
232     DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
233   }
234
235   void Check(bool compareCalled, const std::string& location)
236   {
237     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
238   }
239
240   Actor                              actor;
241   bool                               visible;
242   DevelActor::VisibilityChange::Type type;
243   bool                               called;
244 };
245
246 struct VisibilityChangedFunctor
247 {
248   VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
249   : data(dataVar)
250   {
251   }
252
253   void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
254   {
255     data.actor   = actor;
256     data.visible = visible;
257     data.type    = type;
258     data.called  = true;
259   }
260
261   VisibilityChangedFunctorData& data;
262 };
263
264 struct VisibilityChangedVoidFunctor
265 {
266   VisibilityChangedVoidFunctor(bool& signalCalled)
267   : mSignalCalled(signalCalled)
268   {
269   }
270
271   void operator()()
272   {
273     mSignalCalled = true;
274   }
275
276   bool& mSignalCalled;
277 };
278
279 struct InheritedVisibilityChangedFunctorData
280 {
281   InheritedVisibilityChangedFunctorData()
282   : actor(),
283     visible(false),
284     called(false)
285   {
286   }
287
288   void Reset()
289   {
290     actor.Reset();
291     visible = false;
292     called  = false;
293   }
294
295   void Check(bool compareCalled, Actor compareActor, bool compareVisible, const char* location)
296   {
297     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
298     DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
299     DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
300   }
301
302   void Check(bool compareCalled, const std::string& location)
303   {
304     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
305   }
306
307   Actor actor;
308   bool  visible;
309   bool  called;
310 };
311
312 struct InheritedVisibilityChangedFunctor
313 {
314   InheritedVisibilityChangedFunctor(InheritedVisibilityChangedFunctorData& dataVar)
315   : data(dataVar)
316   {
317   }
318
319   void operator()(Actor actor, bool visible)
320   {
321     data.actor   = actor;
322     data.visible = visible;
323     data.called  = true;
324   }
325
326   InheritedVisibilityChangedFunctorData& data;
327 };
328
329 struct ChildOrderChangedFunctor
330 {
331   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
332   : mSignalCalled(signalCalled),
333     mActor(actor)
334   {
335   }
336
337   void operator()(Actor actor)
338   {
339     mSignalCalled = true;
340     mActor        = actor;
341   }
342
343   bool&  mSignalCalled;
344   Actor& mActor;
345 };
346
347 struct CulledPropertyNotificationFunctor
348 {
349   CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
350   : mSignalCalled(signalCalled),
351     mPropertyNotification(propertyNotification)
352   {
353   }
354
355   void operator()(PropertyNotification& source)
356   {
357     mSignalCalled         = true;
358     mPropertyNotification = source;
359   }
360
361   bool&                 mSignalCalled;
362   PropertyNotification& mPropertyNotification;
363 };
364
365 // Clipping test helper functions:
366 Actor CreateActorWithContent(uint32_t width, uint32_t height)
367 {
368   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
369   Actor   actor = CreateRenderableActor(image);
370
371   // Setup dimensions and position so actor is not skipped by culling.
372   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
373   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
374   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
375   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
376
377   return actor;
378 }
379
380 Actor CreateActorWithContent16x16()
381 {
382   return CreateActorWithContent(16, 16);
383 }
384
385 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& callTrace)
386 {
387   enabledDisableTrace.Reset();
388   callTrace.Reset();
389   enabledDisableTrace.Enable(true);
390   callTrace.Enable(true);
391
392   application.SendNotification();
393   application.Render();
394
395   enabledDisableTrace.Enable(false);
396   callTrace.Enable(false);
397 }
398
399 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
400 {
401   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
402
403   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
404   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
405   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
406
407   // @todo only test alpha if the framebuffer has an alpha channel
408   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
409 }
410
411 } // anonymous namespace
412
413 //& purpose: Testing New API
414 int UtcDaliActorNew(void)
415 {
416   TestApplication application;
417
418   Actor actor = Actor::New();
419
420   DALI_TEST_CHECK(actor);
421   END_TEST;
422 }
423
424 //& purpose: Testing Dali::Actor::DownCast()
425 int UtcDaliActorDownCastP(void)
426 {
427   TestApplication application;
428   tet_infoline("Testing Dali::Actor::DownCast()");
429
430   Actor      actor = Actor::New();
431   BaseHandle object(actor);
432   Actor      actor2 = Actor::DownCast(object);
433   DALI_TEST_CHECK(actor2);
434   END_TEST;
435 }
436
437 //& purpose: Testing Dali::Actor::DownCast()
438 int UtcDaliActorDownCastN(void)
439 {
440   TestApplication application;
441   tet_infoline("Testing Dali::Actor::DownCast()");
442
443   BaseHandle unInitializedObject;
444   Actor      actor = Actor::DownCast(unInitializedObject);
445   DALI_TEST_CHECK(!actor);
446   END_TEST;
447 }
448
449 int UtcDaliActorMoveConstructor(void)
450 {
451   TestApplication application;
452
453   Actor actor = Actor::New();
454   DALI_TEST_CHECK(actor);
455
456   int id = actor.GetProperty<int>(Actor::Property::ID);
457
458   Actor moved = std::move(actor);
459   DALI_TEST_CHECK(moved);
460   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
461   DALI_TEST_CHECK(!actor);
462
463   END_TEST;
464 }
465
466 int UtcDaliActorMoveAssignment(void)
467 {
468   TestApplication application;
469
470   Actor actor = Actor::New();
471   DALI_TEST_CHECK(actor);
472
473   int id = actor.GetProperty<int>(Actor::Property::ID);
474
475   Actor moved;
476   moved = std::move(actor);
477   DALI_TEST_CHECK(moved);
478   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
479   DALI_TEST_CHECK(!actor);
480
481   END_TEST;
482 }
483
484 //& purpose: Testing Dali::Actor::GetName()
485 int UtcDaliActorGetName(void)
486 {
487   TestApplication application;
488
489   Actor actor = Actor::New();
490
491   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
492   END_TEST;
493 }
494
495 //& purpose: Testing Dali::Actor::SetName()
496 int UtcDaliActorSetName(void)
497 {
498   TestApplication application;
499
500   string str("ActorName");
501   Actor  actor = Actor::New();
502
503   actor.SetProperty(Actor::Property::NAME, str);
504   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
505   END_TEST;
506 }
507
508 int UtcDaliActorGetId(void)
509 {
510   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
511   TestApplication application;
512
513   Actor first  = Actor::New();
514   Actor second = Actor::New();
515   Actor third  = Actor::New();
516
517   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
518   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
519   END_TEST;
520 }
521
522 int UtcDaliActorIsRoot(void)
523 {
524   TestApplication application;
525
526   Actor actor = Actor::New();
527   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
528
529   // get the root layer
530   actor = application.GetScene().GetLayer(0);
531   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
532   END_TEST;
533 }
534
535 int UtcDaliActorOnScene(void)
536 {
537   TestApplication application;
538
539   Actor actor = Actor::New();
540   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
541
542   // get the root layer
543   actor = application.GetScene().GetLayer(0);
544   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
545   END_TEST;
546 }
547
548 int UtcDaliActorIsLayer(void)
549 {
550   TestApplication application;
551
552   Actor actor = Actor::New();
553   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
554
555   // get the root layer
556   actor = application.GetScene().GetLayer(0);
557   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
558   END_TEST;
559 }
560
561 int UtcDaliActorGetLayer(void)
562 {
563   TestApplication application;
564
565   Actor actor = Actor::New();
566   application.GetScene().Add(actor);
567   Layer layer = actor.GetLayer();
568
569   DALI_TEST_CHECK(layer);
570
571   // get the root layers layer
572   actor = application.GetScene().GetLayer(0);
573   DALI_TEST_CHECK(actor.GetLayer());
574   END_TEST;
575 }
576
577 int UtcDaliActorAddP(void)
578 {
579   tet_infoline("Testing Actor::Add");
580   TestApplication application;
581
582   Actor parent = Actor::New();
583   Actor child  = Actor::New();
584
585   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
586
587   parent.Add(child);
588
589   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
590
591   Actor parent2 = Actor::New();
592   parent2.Add(child);
593
594   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
595   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
596
597   // try Adding to same parent again, works
598   parent2.Add(child);
599   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
600
601   // try reparenting an orphaned child
602   {
603     Actor temporaryParent = Actor::New();
604     temporaryParent.Add(child);
605     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
606   }
607   // temporaryParent has now died, reparent the orphaned child
608   parent2.Add(child);
609   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
610
611   END_TEST;
612 }
613
614 int UtcDaliActorAddN(void)
615 {
616   tet_infoline("Testing Actor::Add");
617   TestApplication application;
618
619   Actor child = Actor::New();
620
621   Actor parent2 = Actor::New();
622   parent2.Add(child);
623
624   // try illegal Add
625   try
626   {
627     parent2.Add(parent2);
628     tet_printf("Assertion test failed - no Exception\n");
629     tet_result(TET_FAIL);
630   }
631   catch(Dali::DaliException& e)
632   {
633     DALI_TEST_PRINT_ASSERT(e);
634     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
635     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
636   }
637   catch(...)
638   {
639     tet_printf("Assertion test failed - wrong Exception\n");
640     tet_result(TET_FAIL);
641   }
642
643   // try reparenting root
644   try
645   {
646     parent2.Add(application.GetScene().GetLayer(0));
647     tet_printf("Assertion test failed - no Exception\n");
648     tet_result(TET_FAIL);
649   }
650   catch(Dali::DaliException& e)
651   {
652     DALI_TEST_PRINT_ASSERT(e);
653     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
654     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
655   }
656   catch(...)
657   {
658     tet_printf("Assertion test failed - wrong Exception\n");
659     tet_result(TET_FAIL);
660   }
661
662   // try Add empty
663   try
664   {
665     Actor empty;
666     parent2.Add(empty);
667     tet_printf("Assertion test failed - no Exception\n");
668     tet_result(TET_FAIL);
669   }
670   catch(Dali::DaliException& e)
671   {
672     DALI_TEST_PRINT_ASSERT(e);
673     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
674     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
675   }
676   catch(...)
677   {
678     tet_printf("Assertion test failed - wrong Exception\n");
679     tet_result(TET_FAIL);
680   }
681
682   END_TEST;
683 }
684
685 int UtcDaliActorRemoveN(void)
686 {
687   tet_infoline("Testing Actor::Remove");
688   TestApplication application;
689
690   Actor parent = Actor::New();
691   Actor child  = Actor::New();
692   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
693
694   parent.Add(child);
695   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
696
697   parent.Remove(child);
698   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
699
700   // remove again, no problem
701   parent.Remove(child);
702   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
703
704   // add child back
705   parent.Add(child);
706   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
707   // try Remove self, its a no-op
708   parent.Remove(parent);
709   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
710
711   // try Remove empty
712   try
713   {
714     Actor empty;
715     parent.Remove(empty);
716     tet_printf("Assertion test failed - no Exception\n");
717     tet_result(TET_FAIL);
718   }
719   catch(Dali::DaliException& e)
720   {
721     DALI_TEST_PRINT_ASSERT(e);
722     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
723     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
724   }
725   catch(...)
726   {
727     tet_printf("Assertion test failed - wrong Exception\n");
728     tet_result(TET_FAIL);
729   }
730   END_TEST;
731 }
732
733 int UtcDaliActorRemoveP(void)
734 {
735   TestApplication application;
736
737   Actor parent = Actor::New();
738   Actor child  = Actor::New();
739   Actor random = Actor::New();
740
741   application.GetScene().Add(parent);
742
743   DALI_TEST_CHECK(parent.GetChildCount() == 0);
744
745   parent.Add(child);
746
747   DALI_TEST_CHECK(parent.GetChildCount() == 1);
748
749   parent.Remove(random);
750
751   DALI_TEST_CHECK(parent.GetChildCount() == 1);
752
753   application.GetScene().Remove(parent);
754
755   DALI_TEST_CHECK(parent.GetChildCount() == 1);
756   END_TEST;
757 }
758
759 int UtcDaliActorSwitchParentN(void)
760 {
761   tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
762   TestApplication application;
763
764   Actor parent1 = Actor::New();
765   Actor child   = Actor::New();
766
767   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
768
769   parent1.Add(child);
770
771   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
772
773   Actor parent2 = Actor::New();
774
775   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
776
777   // Try switch parent with that both of parent1 and parent2 are off scene.
778   DevelActor::SwitchParent(child, parent2);
779
780   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
781   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
782   END_TEST;
783 }
784
785 int UtcDaliActorGetChildCount(void)
786 {
787   TestApplication application;
788
789   Actor parent = Actor::New();
790   Actor child  = Actor::New();
791
792   DALI_TEST_CHECK(parent.GetChildCount() == 0);
793
794   parent.Add(child);
795
796   DALI_TEST_CHECK(parent.GetChildCount() == 1);
797   END_TEST;
798 }
799
800 int UtcDaliActorGetChildren01(void)
801 {
802   TestApplication application;
803
804   Actor parent = Actor::New();
805   Actor first  = Actor::New();
806   Actor second = Actor::New();
807   Actor third  = Actor::New();
808
809   parent.Add(first);
810   parent.Add(second);
811   parent.Add(third);
812
813   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
814   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
815   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
816   END_TEST;
817 }
818
819 int UtcDaliActorGetChildren02(void)
820 {
821   TestApplication application;
822
823   Actor parent = Actor::New();
824   Actor first  = Actor::New();
825   Actor second = Actor::New();
826   Actor third  = Actor::New();
827
828   parent.Add(first);
829   parent.Add(second);
830   parent.Add(third);
831
832   const Actor& constParent = parent;
833
834   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
835   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
836   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
837   END_TEST;
838 }
839
840 int UtcDaliActorGetParent01(void)
841 {
842   TestApplication application;
843
844   Actor parent = Actor::New();
845   Actor child  = Actor::New();
846
847   parent.Add(child);
848
849   DALI_TEST_CHECK(child.GetParent() == parent);
850   END_TEST;
851 }
852
853 int UtcDaliActorGetParent02(void)
854 {
855   TestApplication application;
856
857   Actor actor = Actor::New();
858
859   DALI_TEST_CHECK(!actor.GetParent());
860   END_TEST;
861 }
862
863 int UtcDaliActorCustomProperty(void)
864 {
865   TestApplication application;
866
867   Actor actor = Actor::New();
868   application.GetScene().Add(actor);
869
870   float           startValue(1.0f);
871   Property::Index index = actor.RegisterProperty("testProperty", startValue);
872   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
873
874   application.SendNotification();
875   application.Render(0);
876   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
877
878   actor.SetProperty(index, 5.0f);
879
880   application.SendNotification();
881   application.Render(0);
882   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
883   END_TEST;
884 }
885
886 int UtcDaliActorCustomPropertyIntToFloat(void)
887 {
888   TestApplication application;
889
890   Actor actor = Actor::New();
891   application.GetScene().Add(actor);
892
893   float           startValue(5.0f);
894   Property::Index index = actor.RegisterProperty("testProperty", startValue);
895   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
896
897   application.SendNotification();
898   application.Render(0);
899   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
900
901   actor.SetProperty(index, int(1));
902
903   application.SendNotification();
904   application.Render(0);
905   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
906   END_TEST;
907 }
908
909 int UtcDaliActorCustomPropertyFloatToInt(void)
910 {
911   TestApplication application;
912
913   Actor actor = Actor::New();
914   application.GetScene().Add(actor);
915
916   int             startValue(5);
917   Property::Index index = actor.RegisterProperty("testProperty", startValue);
918   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
919
920   application.SendNotification();
921   application.Render(0);
922   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
923
924   actor.SetProperty(index, float(1.5));
925
926   application.SendNotification();
927   application.Render(0);
928   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
929   END_TEST;
930 }
931
932 int UtcDaliActorSetParentOrigin(void)
933 {
934   TestApplication application;
935
936   Actor actor = Actor::New();
937
938   Vector3 vector(0.7f, 0.8f, 0.9f);
939   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
940
941   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
942
943   // flush the queue and render once
944   application.SendNotification();
945   application.Render();
946
947   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
948
949   application.GetScene().Add(actor);
950
951   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
952
953   // flush the queue and render once
954   application.SendNotification();
955   application.Render();
956
957   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
958
959   application.GetScene().Remove(actor);
960   END_TEST;
961 }
962
963 int UtcDaliActorSetParentOriginIndividual(void)
964 {
965   TestApplication application;
966
967   Actor actor = Actor::New();
968
969   Vector3 vector(0.7f, 0.8f, 0.9f);
970   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
971
972   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
973
974   // flush the queue and render once
975   application.SendNotification();
976   application.Render();
977
978   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
979
980   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
981
982   // flush the queue and render once
983   application.SendNotification();
984   application.Render();
985
986   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
987
988   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
989
990   // flush the queue and render once
991   application.SendNotification();
992   application.Render();
993
994   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
995
996   END_TEST;
997 }
998
999 int UtcDaliActorGetCurrentParentOrigin(void)
1000 {
1001   TestApplication application;
1002
1003   Actor actor = Actor::New();
1004
1005   Vector3 vector(0.7f, 0.8f, 0.9f);
1006   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
1007
1008   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
1009
1010   // flush the queue and render once
1011   application.SendNotification();
1012   application.Render();
1013
1014   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
1015   END_TEST;
1016 }
1017
1018 int UtcDaliActorSetAnchorPoint(void)
1019 {
1020   TestApplication application;
1021
1022   Actor actor = Actor::New();
1023
1024   Vector3 vector(0.7f, 0.8f, 0.9f);
1025   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1026
1027   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1028
1029   // flush the queue and render once
1030   application.SendNotification();
1031   application.Render();
1032
1033   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1034
1035   application.GetScene().Add(actor);
1036
1037   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
1038   // flush the queue and render once
1039   application.SendNotification();
1040   application.Render();
1041
1042   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
1043
1044   application.GetScene().Remove(actor);
1045   END_TEST;
1046 }
1047
1048 int UtcDaliActorSetAnchorPointIndividual(void)
1049 {
1050   TestApplication application;
1051
1052   Actor actor = Actor::New();
1053
1054   Vector3 vector(0.7f, 0.8f, 0.9f);
1055   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1056
1057   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
1058
1059   // flush the queue and render once
1060   application.SendNotification();
1061   application.Render();
1062
1063   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
1064
1065   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
1066
1067   // flush the queue and render once
1068   application.SendNotification();
1069   application.Render();
1070
1071   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
1072
1073   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
1074
1075   // flush the queue and render once
1076   application.SendNotification();
1077   application.Render();
1078
1079   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
1080
1081   END_TEST;
1082 }
1083
1084 int UtcDaliActorGetCurrentAnchorPoint(void)
1085 {
1086   TestApplication application;
1087
1088   Actor actor = Actor::New();
1089
1090   Vector3 vector(0.7f, 0.8f, 0.9f);
1091   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1092
1093   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1094
1095   // flush the queue and render once
1096   application.SendNotification();
1097   application.Render();
1098
1099   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1100   END_TEST;
1101 }
1102
1103 int UtcDaliActorSetSize01(void)
1104 {
1105   TestApplication application;
1106
1107   Actor   actor = Actor::New();
1108   Vector3 vector(100.0f, 100.0f, 0.0f);
1109
1110   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1111
1112   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1113
1114   // Immediately retrieve the size after setting
1115   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1116   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1117   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1118   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1119   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1120
1121   // Flush the queue and render once
1122   application.SendNotification();
1123   application.Render();
1124
1125   // Check the size in the new frame
1126   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1127
1128   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1129   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1130   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1131   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1132   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1133
1134   // Check async behaviour
1135   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1136   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1137   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1138   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1139   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1140
1141   // Change the resize policy and check whether the size stays the same
1142   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1143
1144   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1145   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1146
1147   // Set a new size after resize policy is changed and check the new size
1148   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1149
1150   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1151   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1152
1153   // Change the resize policy again and check whether the new size stays the same
1154   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1155
1156   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1157   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1158
1159   // Set another new size after resize policy is changed and check the new size
1160   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1161
1162   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1163   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1164
1165   END_TEST;
1166 }
1167
1168 int UtcDaliActorSetSize02(void)
1169 {
1170   TestApplication application;
1171
1172   Actor   actor = Actor::New();
1173   Vector3 vector(100.0f, 100.0f, 100.0f);
1174
1175   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1176
1177   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1178
1179   // Immediately check the size after setting
1180   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1181   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1182
1183   // flush the queue and render once
1184   application.SendNotification();
1185   application.Render();
1186
1187   // Check the size in the new frame
1188   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1189
1190   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1191   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1192
1193   END_TEST;
1194 }
1195
1196 // SetSize(Vector2 size)
1197 int UtcDaliActorSetSize03(void)
1198 {
1199   TestApplication application;
1200
1201   Actor   actor = Actor::New();
1202   Vector3 vector(100.0f, 100.0f, 0.0f);
1203
1204   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1205
1206   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1207
1208   // Immediately check the size after setting
1209   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1210   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1211
1212   // flush the queue and render once
1213   application.SendNotification();
1214   application.Render();
1215
1216   // Check the size in the new frame
1217   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1218
1219   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1220   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1221
1222   END_TEST;
1223 }
1224
1225 // SetSize(Vector3 size)
1226 int UtcDaliActorSetSize04(void)
1227 {
1228   TestApplication application;
1229
1230   Actor   actor = Actor::New();
1231   Vector3 vector(100.0f, 100.0f, 100.0f);
1232
1233   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1234
1235   actor.SetProperty(Actor::Property::SIZE, vector);
1236
1237   // Immediately check the size after setting
1238   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1239   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1240
1241   // flush the queue and render once
1242   application.SendNotification();
1243   application.Render();
1244
1245   // Check the size in the new frame
1246   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1247
1248   application.GetScene().Add(actor);
1249   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1250
1251   // Immediately check the size after setting
1252   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1253   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1254
1255   // flush the queue and render once
1256   application.SendNotification();
1257   application.Render();
1258
1259   // Check the size in the new frame
1260   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1261
1262   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1263   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1264
1265   application.GetScene().Remove(actor);
1266   END_TEST;
1267 }
1268
1269 int UtcDaliActorSetSize05(void)
1270 {
1271   TestApplication application;
1272
1273   Actor   parent = Actor::New();
1274   Vector2 vector(200.0f, 200.0f);
1275   DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1276
1277   parent.SetProperty(Actor::Property::SIZE, vector);
1278   Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1279   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1280
1281   Actor child = Actor::New();
1282   DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1283   child.SetProperty(Actor::Property::SIZE, vector);
1284   size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1285   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1286
1287   // flush the queue and render once
1288   application.SendNotification();
1289   application.Render();
1290
1291   DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1292
1293   END_TEST;
1294 }
1295
1296 int UtcDaliActorSetSizeIndividual(void)
1297 {
1298   TestApplication application;
1299
1300   Actor actor = Actor::New();
1301
1302   Vector3 vector(0.7f, 0.8f, 0.9f);
1303   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1304
1305   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1306
1307   // Immediately check the width after setting
1308   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1309   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1310
1311   // flush the queue and render once
1312   application.SendNotification();
1313   application.Render();
1314
1315   // Check the width in the new frame
1316   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1317
1318   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1319   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1320
1321   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1322
1323   // Immediately check the height after setting
1324   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1325   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1326
1327   // flush the queue and render once
1328   application.SendNotification();
1329   application.Render();
1330
1331   // Check the height in the new frame
1332   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1333
1334   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1335   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1336
1337   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1338
1339   // Immediately check the depth after setting
1340   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1341   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1342
1343   // flush the queue and render once
1344   application.SendNotification();
1345   application.Render();
1346
1347   // Check the depth in the new frame
1348   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1349
1350   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1351   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1352
1353   // Change the resize policy and check whether the size stays the same
1354   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1355
1356   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1357   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1358
1359   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1360   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1361
1362   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1363   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1364
1365   // Change the resize policy again and check whether the size stays the same
1366   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1367
1368   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1369   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1370
1371   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1372   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1373
1374   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1375   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1376
1377   END_TEST;
1378 }
1379
1380 int UtcDaliActorSetSizeIndividual02(void)
1381 {
1382   TestApplication application;
1383
1384   Actor actor = Actor::New();
1385   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1386   application.GetScene().Add(actor);
1387
1388   Vector3 vector(100.0f, 200.0f, 400.0f);
1389   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1390
1391   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1392   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1393
1394   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1395   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1396
1397   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1398   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1399
1400   // flush the queue and render once
1401   application.SendNotification();
1402   application.Render();
1403
1404   // Check the width in the new frame
1405   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1406   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1407
1408   END_TEST;
1409 }
1410
1411 int UtcDaliActorGetCurrentSize(void)
1412 {
1413   TestApplication application;
1414
1415   Actor   actor = Actor::New();
1416   Vector3 vector(100.0f, 100.0f, 20.0f);
1417
1418   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1419
1420   actor.SetProperty(Actor::Property::SIZE, vector);
1421
1422   // flush the queue and render once
1423   application.SendNotification();
1424   application.Render();
1425
1426   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1427   END_TEST;
1428 }
1429
1430 int UtcDaliActorGetNaturalSize(void)
1431 {
1432   TestApplication application;
1433
1434   Actor   actor = Actor::New();
1435   Vector3 vector(0.0f, 0.0f, 0.0f);
1436
1437   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1438
1439   END_TEST;
1440 }
1441
1442 int UtcDaliActorGetCurrentSizeImmediate(void)
1443 {
1444   TestApplication application;
1445
1446   Actor   actor = Actor::New();
1447   Vector3 vector(100.0f, 100.0f, 20.0f);
1448
1449   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1450   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1451
1452   actor.SetProperty(Actor::Property::SIZE, vector);
1453
1454   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1455   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1456
1457   // flush the queue and render once
1458   application.SendNotification();
1459   application.Render();
1460
1461   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1462   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1463
1464   // Animation
1465   // Build the animation
1466   const float   durationSeconds = 2.0f;
1467   Animation     animation       = Animation::New(durationSeconds);
1468   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1469   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1470
1471   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1472
1473   application.GetScene().Add(actor);
1474
1475   // Start the animation
1476   animation.Play();
1477
1478   application.SendNotification();
1479   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1480
1481   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1482
1483   END_TEST;
1484 }
1485
1486 int UtcDaliActorCalculateScreenExtents(void)
1487 {
1488   TestApplication application;
1489
1490   Actor actor = Actor::New();
1491
1492   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1493   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1494
1495   application.GetScene().Add(actor);
1496
1497   application.SendNotification();
1498   application.Render();
1499
1500   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1501   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1502   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1503   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1504   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1505   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1506
1507   application.GetScene().Remove(actor);
1508   END_TEST;
1509 }
1510
1511 int UtcDaliActorCalculateCurrentScreenExtents(void)
1512 {
1513   TestApplication application;
1514
1515   Actor actor = Actor::New();
1516
1517   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1518   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1519
1520   application.GetScene().Add(actor);
1521
1522   application.SendNotification();
1523   application.Render();
1524
1525   auto expectedPosition = Vector2(2.0f, 2.0f);
1526   auto actualPosition   = DevelActor::CalculateScreenPosition(actor);
1527   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1528   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1529
1530   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1531   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1532   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1533   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1534   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1535   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1536
1537   Animation animation = Animation::New(1.0f);
1538   animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(6.0f, 4.0f, 0.0f));
1539   animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(3.0f, 7.0f, 1.0f));
1540   animation.Play();
1541
1542   application.SendNotification();
1543   application.Render(500u);
1544
1545   // Animate 50%.
1546   expectedPosition = Vector2(6.0f, 4.0f);
1547   actualPosition   = DevelActor::CalculateScreenPosition(actor);
1548   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1549   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1550
1551   expectedExtent = Rect<>(4.5f, 0.5f, 3.0f, 7.0f);
1552   actualExtent   = DevelActor::CalculateScreenExtents(actor);
1553   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1554   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1555   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1556   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1557
1558   expectedPosition = Vector2(4.0f, 3.0f);
1559   actualPosition   = actor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1560   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1561   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1562
1563   expectedExtent = Rect<>(3.0f, 1.0f, 2.0f, 4.0f);
1564   actualExtent   = DevelActor::CalculateCurrentScreenExtents(actor);
1565   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1566   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1567   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1568   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1569
1570   application.GetScene().Remove(actor);
1571   END_TEST;
1572 }
1573
1574 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1575 {
1576   TestApplication    application;
1577   Integration::Scene scene = application.GetScene();
1578
1579   // Make 3D Layer
1580   Layer layer = Layer::New();
1581   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1582   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1583   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1584
1585   scene.Add(layer);
1586
1587   // Build custom camera with top-view
1588   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1589   {
1590     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1591     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1592     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1593
1594     {
1595       std::ostringstream oss;
1596       oss << cameraPos << "\n";
1597       oss << cameraOrient << "\n";
1598       tet_printf("%s\n", oss.str().c_str());
1599     }
1600
1601     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1602     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1603
1604     // Now, upside : -Z, leftside : -X, foward : +Y
1605
1606     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1607     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1608     {
1609       std::ostringstream oss;
1610       oss << cameraPos << "\n";
1611       oss << cameraOrient << "\n";
1612       tet_printf("%s\n", oss.str().c_str());
1613     }
1614   }
1615
1616   Actor actor = Actor::New();
1617   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1618   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1619   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1620   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1621
1622   layer.Add(actor);
1623
1624   application.SendNotification();
1625   application.Render();
1626
1627   Vector2 sceneSize = scene.GetSize();
1628
1629   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1630   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1631   auto actualPosition = DevelActor::CalculateScreenPosition(actor);
1632   {
1633     std::ostringstream oss;
1634     oss << expectedExtent << "\n";
1635     oss << actualExtent << "\n";
1636     oss << actualPosition << "\n";
1637     tet_printf("%s\n", oss.str().c_str());
1638   }
1639
1640   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1641   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1642   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1643   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1644
1645   // Since anchor point is center, screen position is same as center of expect extents
1646   DALI_TEST_EQUALS(expectedExtent.x + expectedExtent.width * 0.5f, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1647   DALI_TEST_EQUALS(expectedExtent.y + expectedExtent.height * 0.5f, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1648
1649   END_TEST;
1650 }
1651
1652 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1653 {
1654   TestApplication    application;
1655   Integration::Scene scene     = application.GetScene();
1656   Vector2            sceneSize = scene.GetSize();
1657
1658   // Make 3D Layer
1659   Layer layer = Layer::New();
1660   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1661   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1662   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1663   layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1664   layer.SetProperty(Actor::Property::SIZE, sceneSize);
1665
1666   scene.Add(layer);
1667
1668   // Build custom camera with top-view
1669   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1670
1671   offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1672   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1673   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1674
1675   scene.Add(offscreenCameraActor);
1676   {
1677     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1678     Vector3    cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1679     Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1680
1681     {
1682       std::ostringstream oss;
1683       oss << cameraPos << "\n";
1684       oss << cameraOrient << "\n";
1685       tet_printf("%s\n", oss.str().c_str());
1686     }
1687
1688     offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1689     offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1690
1691     // Now, upside : -Z, leftside : -X, foward : +Y
1692
1693     cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1694     cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1695     {
1696       std::ostringstream oss;
1697       oss << cameraPos << "\n";
1698       oss << cameraOrient << "\n";
1699       tet_printf("%s\n", oss.str().c_str());
1700     }
1701   }
1702   Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1703   Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1704
1705   Actor sourceActor = Actor::New();
1706   sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1707   sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1708   sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1709   sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1710
1711   layer.Add(sourceActor);
1712
1713   // Create framebuffer
1714   unsigned int width(64);
1715   unsigned int height(64);
1716   Texture      texture     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1717   FrameBuffer  frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1718   frameBuffer.AttachColorTexture(texture);
1719
1720   Actor rootActor = Actor::New();
1721   rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1722   rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1723   rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1724   rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1725   scene.Add(rootActor);
1726
1727   RenderTaskList taskList = scene.GetRenderTaskList();
1728   RenderTask     newTask  = taskList.CreateTask();
1729   newTask.SetCameraActor(offscreenCameraActor);
1730   newTask.SetSourceActor(layer);
1731   newTask.SetInputEnabled(false);
1732   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1733   newTask.SetClearEnabled(true);
1734   newTask.SetExclusive(true);
1735   newTask.SetFrameBuffer(frameBuffer);
1736   newTask.SetScreenToFrameBufferMappingActor(rootActor);
1737
1738   application.SendNotification();
1739   application.Render(16u);
1740
1741   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1742                                sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1743                                sourceSize.x,
1744                                sourceSize.z};
1745   auto actualExtent   = DevelActor::CalculateCurrentScreenExtents(sourceActor);
1746   {
1747     std::ostringstream oss;
1748     oss << expectedExtent << "\n";
1749     oss << actualExtent << "\n";
1750     tet_printf("%s\n", oss.str().c_str());
1751   }
1752
1753   auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1754   auto actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1755   {
1756     std::ostringstream oss;
1757     oss << expectedScreen << "\n";
1758     oss << actualScreen << "\n";
1759     tet_printf("%s\n", oss.str().c_str());
1760   }
1761
1762   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1763   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1764   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1765   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1766
1767   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1768   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1769
1770   // Change rootActor's size and position
1771
1772   Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1773   Vector3 rootSize{200.0f, 100.0f, 0.0f};
1774
1775   rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1776   rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1777
1778   application.SendNotification();
1779   application.Render(16u);
1780
1781   expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1782                           sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1783                           sourceSize.x * rootSize.x / sceneSize.x,
1784                           sourceSize.z * rootSize.y / sceneSize.y};
1785   actualExtent   = DevelActor::CalculateCurrentScreenExtents(sourceActor);
1786   {
1787     std::ostringstream oss;
1788     oss << expectedExtent << "\n";
1789     oss << actualExtent << "\n";
1790     tet_printf("%s\n", oss.str().c_str());
1791   }
1792
1793   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};
1794   actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1795   {
1796     std::ostringstream oss;
1797     oss << expectedScreen << "\n";
1798     oss << actualScreen << "\n";
1799     tet_printf("%s\n", oss.str().c_str());
1800   }
1801
1802   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1803   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1804   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1805   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1806
1807   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1808   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1809
1810   END_TEST;
1811 }
1812
1813 // SetPosition(float x, float y)
1814 int UtcDaliActorSetPosition01(void)
1815 {
1816   TestApplication application;
1817
1818   Actor actor = Actor::New();
1819
1820   // Set to random to start off with
1821   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1822
1823   Vector3 vector(100.0f, 100.0f, 0.0f);
1824
1825   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1826
1827   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1828   // flush the queue and render once
1829   application.SendNotification();
1830   application.Render();
1831   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1832
1833   application.GetScene().Add(actor);
1834   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1835   // flush the queue and render once
1836   application.SendNotification();
1837   application.Render();
1838   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1839
1840   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1841   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1842   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1843   // flush the queue and render once
1844   application.SendNotification();
1845   application.Render();
1846   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1847
1848   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1849   // flush the queue and render once
1850   application.SendNotification();
1851   application.Render();
1852   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1853
1854   application.GetScene().Remove(actor);
1855   END_TEST;
1856 }
1857
1858 // SetPosition(float x, float y, float z)
1859 int UtcDaliActorSetPosition02(void)
1860 {
1861   TestApplication application;
1862
1863   Actor actor = Actor::New();
1864
1865   // Set to random to start off with
1866   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1867
1868   Vector3 vector(100.0f, 100.0f, 100.0f);
1869
1870   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1871
1872   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1873
1874   // flush the queue and render once
1875   application.SendNotification();
1876   application.Render();
1877
1878   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1879   END_TEST;
1880 }
1881
1882 // SetPosition(Vector3 position)
1883 int UtcDaliActorSetPosition03(void)
1884 {
1885   TestApplication application;
1886
1887   Actor actor = Actor::New();
1888
1889   // Set to random to start off with
1890   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1891
1892   Vector3 vector(100.0f, 100.0f, 100.0f);
1893
1894   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1895
1896   actor.SetProperty(Actor::Property::POSITION, vector);
1897
1898   // flush the queue and render once
1899   application.SendNotification();
1900   application.Render();
1901
1902   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1903   END_TEST;
1904 }
1905
1906 int UtcDaliActorSetX(void)
1907 {
1908   TestApplication application;
1909
1910   Actor actor = Actor::New();
1911
1912   Vector3 vector(100.0f, 0.0f, 0.0f);
1913
1914   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1915
1916   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1917
1918   // flush the queue and render once
1919   application.SendNotification();
1920   application.Render();
1921
1922   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1923   END_TEST;
1924 }
1925
1926 int UtcDaliActorSetY(void)
1927 {
1928   TestApplication application;
1929
1930   Actor actor = Actor::New();
1931
1932   Vector3 vector(0.0f, 100.0f, 0.0f);
1933
1934   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1935
1936   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1937
1938   // flush the queue and render once
1939   application.SendNotification();
1940   application.Render();
1941
1942   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1943   END_TEST;
1944 }
1945
1946 int UtcDaliActorSetZ(void)
1947 {
1948   TestApplication application;
1949
1950   Actor actor = Actor::New();
1951
1952   Vector3 vector(0.0f, 0.0f, 100.0f);
1953
1954   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1955
1956   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1957
1958   // flush the queue and render once
1959   application.SendNotification();
1960   application.Render();
1961
1962   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1963   END_TEST;
1964 }
1965
1966 int UtcDaliActorSetPositionProperties(void)
1967 {
1968   TestApplication application;
1969
1970   Actor actor = Actor::New();
1971
1972   Vector3 vector(0.7f, 0.8f, 0.9f);
1973   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1974
1975   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1976   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1977   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1978
1979   // flush the queue and render once
1980   application.SendNotification();
1981   application.Render();
1982
1983   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1984   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1985   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1986   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1987   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1988
1989   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1990   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1991   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1992
1993   // flush the queue and render once
1994   application.SendNotification();
1995   application.Render();
1996
1997   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1998   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1999   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
2000   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
2001   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
2002
2003   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
2004   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
2005   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
2006
2007   // flush the queue and render once
2008   application.SendNotification();
2009   application.Render();
2010
2011   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
2012   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
2013   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
2014   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
2015   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
2016
2017   END_TEST;
2018 }
2019
2020 int UtcDaliActorTranslateBy(void)
2021 {
2022   TestApplication application;
2023
2024   Actor   actor = Actor::New();
2025   Vector3 vector(100.0f, 100.0f, 100.0f);
2026
2027   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
2028
2029   actor.SetProperty(Actor::Property::POSITION, vector);
2030
2031   // flush the queue and render once
2032   application.SendNotification();
2033   application.Render();
2034
2035   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
2036
2037   actor.TranslateBy(vector);
2038
2039   // flush the queue and render once
2040   application.SendNotification();
2041   application.Render();
2042
2043   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
2044   END_TEST;
2045 }
2046
2047 int UtcDaliActorGetCurrentPosition(void)
2048 {
2049   TestApplication application;
2050
2051   Actor   actor = Actor::New();
2052   Vector3 setVector(100.0f, 100.0f, 0.0f);
2053   actor.SetProperty(Actor::Property::POSITION, setVector);
2054
2055   // flush the queue and render once
2056   application.SendNotification();
2057   application.Render();
2058
2059   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
2060   END_TEST;
2061 }
2062
2063 int UtcDaliActorGetCurrentWorldPosition(void)
2064 {
2065   TestApplication application;
2066
2067   Actor   parent = Actor::New();
2068   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
2069   parent.SetProperty(Actor::Property::POSITION, parentPosition);
2070   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2071   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2072   application.GetScene().Add(parent);
2073
2074   Actor child = Actor::New();
2075   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2076   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2077   Vector3 childPosition(6.0f, 6.0f, 6.0f);
2078   child.SetProperty(Actor::Property::POSITION, childPosition);
2079   parent.Add(child);
2080
2081   // The actors should not have a world position yet
2082   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2083   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2084
2085   application.SendNotification();
2086   application.Render(0);
2087
2088   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2089   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2090
2091   // The actors should have a world position now
2092   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2093   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2094   END_TEST;
2095 }
2096
2097 int UtcDaliActorSetInheritPosition(void)
2098 {
2099   tet_infoline("Testing Actor::SetInheritPosition");
2100   TestApplication application;
2101
2102   Actor   parent = Actor::New();
2103   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
2104   parent.SetProperty(Actor::Property::POSITION, parentPosition);
2105   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2106   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2107   application.GetScene().Add(parent);
2108
2109   Actor child = Actor::New();
2110   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2111   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2112   Vector3 childPosition(10.0f, 11.0f, 12.0f);
2113   child.SetProperty(Actor::Property::POSITION, childPosition);
2114   parent.Add(child);
2115
2116   // The actors should not have a world position yet
2117   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2118   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2119
2120   // first test default, which is to inherit position
2121   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2122   application.SendNotification();
2123   application.Render(0); // should only really call Update as Render is not required to update scene
2124   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2125   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2126   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2127   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2128
2129   //Change child position
2130   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
2131   child.SetProperty(Actor::Property::POSITION, childOffset);
2132
2133   // Use local position as world postion
2134   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
2135   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
2136   application.SendNotification();
2137   application.Render(0); // should only really call Update as Render is not required to update scene
2138   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2139   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2140   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2141   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
2142
2143   //Change back to inherit position from parent
2144   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
2145   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2146   application.SendNotification();
2147   application.Render(0); // should only really call Update as Render is not required to update scene
2148   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2149   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2150   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2151   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
2152   END_TEST;
2153 }
2154
2155 int UtcDaliActorInheritOpacity(void)
2156 {
2157   tet_infoline("Testing Actor::Inherit Opacity");
2158   TestApplication application;
2159
2160   Actor parent = Actor::New();
2161   Actor child  = Actor::New();
2162   parent.Add(child);
2163   application.GetScene().Add(parent);
2164
2165   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2166   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2167
2168   // flush the queue and render once
2169   application.SendNotification();
2170   application.Render();
2171
2172   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
2173
2174   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2175   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2176
2177   application.SendNotification();
2178   application.Render();
2179
2180   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2181   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2182   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2183   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2184   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2185   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2186
2187   END_TEST;
2188 }
2189
2190 // SetOrientation(float angleRadians, Vector3 axis)
2191 int UtcDaliActorSetOrientation01(void)
2192 {
2193   TestApplication application;
2194
2195   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2196   Actor      actor = Actor::New();
2197
2198   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2199
2200   // flush the queue and render once
2201   application.SendNotification();
2202   application.Render();
2203
2204   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2205   END_TEST;
2206 }
2207
2208 int UtcDaliActorSetOrientation02(void)
2209 {
2210   TestApplication application;
2211
2212   Actor actor = Actor::New();
2213
2214   Radian  angle(0.785f);
2215   Vector3 axis(1.0f, 1.0f, 0.0f);
2216
2217   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2218   Quaternion rotation(angle, axis);
2219   // flush the queue and render once
2220   application.SendNotification();
2221   application.Render();
2222   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2223
2224   application.GetScene().Add(actor);
2225   actor.RotateBy(Degree(360), axis);
2226   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2227
2228   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2229   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2230   // flush the queue and render once
2231   application.SendNotification();
2232   application.Render();
2233   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2234
2235   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2236   // flush the queue and render once
2237   application.SendNotification();
2238   application.Render();
2239   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2240
2241   application.GetScene().Remove(actor);
2242   END_TEST;
2243 }
2244
2245 // SetOrientation(float angleRadians, Vector3 axis)
2246 int UtcDaliActorSetOrientationProperty(void)
2247 {
2248   TestApplication application;
2249
2250   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2251   Actor      actor = Actor::New();
2252
2253   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2254   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2255
2256   // flush the queue and render once
2257   application.SendNotification();
2258   application.Render();
2259
2260   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2261   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2262   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2263   END_TEST;
2264 }
2265
2266 // RotateBy(float angleRadians, Vector3 axis)
2267 int UtcDaliActorRotateBy01(void)
2268 {
2269   TestApplication application;
2270
2271   Actor actor = Actor::New();
2272
2273   Radian angle(M_PI * 0.25f);
2274   actor.RotateBy((angle), Vector3::ZAXIS);
2275   // flush the queue and render once
2276   application.SendNotification();
2277   application.Render();
2278   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2279
2280   application.GetScene().Add(actor);
2281
2282   actor.RotateBy(angle, Vector3::ZAXIS);
2283   // flush the queue and render once
2284   application.SendNotification();
2285   application.Render();
2286   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2287
2288   application.GetScene().Remove(actor);
2289   END_TEST;
2290 }
2291
2292 // RotateBy(Quaternion relativeRotation)
2293 int UtcDaliActorRotateBy02(void)
2294 {
2295   TestApplication application;
2296
2297   Actor actor = Actor::New();
2298
2299   Radian     angle(M_PI * 0.25f);
2300   Quaternion rotation(angle, Vector3::ZAXIS);
2301   actor.RotateBy(rotation);
2302   // flush the queue and render once
2303   application.SendNotification();
2304   application.Render();
2305   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2306
2307   actor.RotateBy(rotation);
2308   // flush the queue and render once
2309   application.SendNotification();
2310   application.Render();
2311   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2312   END_TEST;
2313 }
2314
2315 int UtcDaliActorGetCurrentOrientation(void)
2316 {
2317   TestApplication application;
2318   Actor           actor = Actor::New();
2319
2320   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2321   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2322   // flush the queue and render once
2323   application.SendNotification();
2324   application.Render();
2325   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2326   END_TEST;
2327 }
2328
2329 int UtcDaliActorGetCurrentWorldOrientation(void)
2330 {
2331   tet_infoline("Testing Actor::GetCurrentWorldRotation");
2332   TestApplication application;
2333
2334   Actor      parent = Actor::New();
2335   Radian     rotationAngle(Degree(90.0f));
2336   Quaternion rotation(rotationAngle, Vector3::YAXIS);
2337   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2338   application.GetScene().Add(parent);
2339
2340   Actor child = Actor::New();
2341   child.SetProperty(Actor::Property::ORIENTATION, rotation);
2342   parent.Add(child);
2343
2344   // The actors should not have a world rotation yet
2345   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2346   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2347
2348   application.SendNotification();
2349   application.Render(0);
2350
2351   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2352   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2353
2354   // The actors should have a world rotation now
2355   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2356   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2357
2358   // turn off child rotation inheritance
2359   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2360   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2361   application.SendNotification();
2362   application.Render(0);
2363
2364   // The actors should have a world rotation now
2365   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2366   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2367   END_TEST;
2368 }
2369
2370 // SetScale(float scale)
2371 int UtcDaliActorSetScale01(void)
2372 {
2373   TestApplication application;
2374
2375   Actor actor = Actor::New();
2376
2377   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2378   actor.SetProperty(Actor::Property::SCALE, 0.25f);
2379
2380   Vector3 scale(10.0f, 10.0f, 10.0f);
2381   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2382
2383   actor.SetProperty(Actor::Property::SCALE, scale.x);
2384
2385   // flush the queue and render once
2386   application.SendNotification();
2387   application.Render();
2388
2389   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2390   END_TEST;
2391 }
2392
2393 // SetScale(float scaleX, float scaleY, float scaleZ)
2394 int UtcDaliActorSetScale02(void)
2395 {
2396   TestApplication application;
2397   Vector3         scale(10.0f, 10.0f, 10.0f);
2398
2399   Actor actor = Actor::New();
2400
2401   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2402   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2403
2404   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2405
2406   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2407   // flush the queue and render once
2408   application.SendNotification();
2409   application.Render();
2410   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2411
2412   // add to stage and test
2413   application.GetScene().Add(actor);
2414   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2415   // flush the queue and render once
2416   application.SendNotification();
2417   application.Render();
2418   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2419
2420   application.GetScene().Remove(actor);
2421
2422   END_TEST;
2423 }
2424
2425 // SetScale(Vector3 scale)
2426 int UtcDaliActorSetScale03(void)
2427 {
2428   TestApplication application;
2429   Vector3         scale(10.0f, 10.0f, 10.0f);
2430
2431   Actor actor = Actor::New();
2432
2433   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2434   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2435
2436   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2437
2438   actor.SetProperty(Actor::Property::SCALE, scale);
2439
2440   // flush the queue and render once
2441   application.SendNotification();
2442   application.Render();
2443
2444   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2445   END_TEST;
2446 }
2447
2448 int UtcDaliActorSetScaleIndividual(void)
2449 {
2450   TestApplication application;
2451
2452   Actor actor = Actor::New();
2453
2454   Vector3 vector(0.7f, 0.8f, 0.9f);
2455   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2456
2457   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2458   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2459
2460   // flush the queue and render once
2461   application.SendNotification();
2462   application.Render();
2463
2464   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2465   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2466   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2467
2468   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2469   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2470
2471   // flush the queue and render once
2472   application.SendNotification();
2473   application.Render();
2474
2475   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2476   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2477   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2478
2479   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2480   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2481
2482   // flush the queue and render once
2483   application.SendNotification();
2484   application.Render();
2485
2486   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2487   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2488   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2489
2490   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2491   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2492
2493   END_TEST;
2494 }
2495
2496 int UtcDaliActorScaleBy(void)
2497 {
2498   TestApplication application;
2499   Actor           actor = Actor::New();
2500   Vector3         vector(100.0f, 100.0f, 100.0f);
2501
2502   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2503
2504   actor.SetProperty(Actor::Property::SCALE, vector);
2505
2506   // flush the queue and render once
2507   application.SendNotification();
2508   application.Render();
2509
2510   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2511
2512   actor.ScaleBy(vector);
2513
2514   // flush the queue and render once
2515   application.SendNotification();
2516   application.Render();
2517
2518   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2519   END_TEST;
2520 }
2521
2522 int UtcDaliActorGetCurrentScale(void)
2523 {
2524   TestApplication application;
2525   Vector3         scale(12.0f, 1.0f, 2.0f);
2526
2527   Actor actor = Actor::New();
2528
2529   actor.SetProperty(Actor::Property::SCALE, scale);
2530
2531   // flush the queue and render once
2532   application.SendNotification();
2533   application.Render();
2534
2535   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2536   END_TEST;
2537 }
2538
2539 int UtcDaliActorGetCurrentWorldScale(void)
2540 {
2541   TestApplication application;
2542
2543   Actor   parent = Actor::New();
2544   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2545   parent.SetProperty(Actor::Property::SCALE, parentScale);
2546   application.GetScene().Add(parent);
2547
2548   Actor   child = Actor::New();
2549   Vector3 childScale(2.0f, 2.0f, 2.0f);
2550   child.SetProperty(Actor::Property::SCALE, childScale);
2551   parent.Add(child);
2552
2553   // The actors should not have a scale yet
2554   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2555   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2556
2557   // The actors should not have a world scale yet
2558   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2559   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2560
2561   application.SendNotification();
2562   application.Render(0);
2563
2564   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2565   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2566
2567   // The actors should have a world scale now
2568   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2569   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2570   END_TEST;
2571 }
2572
2573 int UtcDaliActorInheritScale(void)
2574 {
2575   tet_infoline("Testing Actor::SetInheritScale");
2576   TestApplication application;
2577
2578   Actor   parent = Actor::New();
2579   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2580   parent.SetProperty(Actor::Property::SCALE, parentScale);
2581   application.GetScene().Add(parent);
2582
2583   Actor   child = Actor::New();
2584   Vector3 childScale(2.0f, 2.0f, 2.0f);
2585   child.SetProperty(Actor::Property::SCALE, childScale);
2586   parent.Add(child);
2587
2588   application.SendNotification();
2589   application.Render(0);
2590
2591   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2592   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2593
2594   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2595   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2596
2597   application.SendNotification();
2598   application.Render(0);
2599
2600   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2601   END_TEST;
2602 }
2603
2604 int UtcDaliActorSetVisible(void)
2605 {
2606   TestApplication application;
2607
2608   Actor actor = Actor::New();
2609   actor.SetProperty(Actor::Property::VISIBLE, false);
2610   // flush the queue and render once
2611   application.SendNotification();
2612   application.Render();
2613   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2614
2615   actor.SetProperty(Actor::Property::VISIBLE, true);
2616   // flush the queue and render once
2617   application.SendNotification();
2618   application.Render();
2619   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2620
2621   // put actor on stage
2622   application.GetScene().Add(actor);
2623   actor.SetProperty(Actor::Property::VISIBLE, false);
2624   // flush the queue and render once
2625   application.SendNotification();
2626   application.Render();
2627   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2628   END_TEST;
2629 }
2630
2631 int UtcDaliActorIsVisible(void)
2632 {
2633   TestApplication application;
2634
2635   Actor actor = Actor::New();
2636
2637   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2638   END_TEST;
2639 }
2640
2641 int UtcDaliActorSetOpacity(void)
2642 {
2643   TestApplication application;
2644
2645   Actor actor = Actor::New();
2646   // initial opacity is 1
2647   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2648
2649   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2650   // flush the queue and render once
2651   application.SendNotification();
2652   application.Render();
2653   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2654
2655   // change opacity, actor is on stage to change is not immediate
2656   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2657   // flush the queue and render once
2658   application.SendNotification();
2659   application.Render();
2660   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2661
2662   // put actor on stage
2663   application.GetScene().Add(actor);
2664
2665   // change opacity, actor is on stage to change is not immediate
2666   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2667   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2668   // flush the queue and render once
2669   application.SendNotification();
2670   application.Render();
2671   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2672
2673   // change opacity, actor is on stage to change is not immediate
2674   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2675   // flush the queue and render once
2676   application.SendNotification();
2677   application.Render();
2678   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2679   END_TEST;
2680 }
2681
2682 int UtcDaliActorGetCurrentOpacity(void)
2683 {
2684   TestApplication application;
2685
2686   Actor actor = Actor::New();
2687   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2688
2689   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2690   // flush the queue and render once
2691   application.SendNotification();
2692   application.Render();
2693   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2694   END_TEST;
2695 }
2696
2697 int UtcDaliActorSetSensitive(void)
2698 {
2699   TestApplication application;
2700   Actor           actor = Actor::New();
2701
2702   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2703
2704   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2705
2706   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2707   END_TEST;
2708 }
2709
2710 int UtcDaliActorIsSensitive(void)
2711 {
2712   TestApplication application;
2713   Actor           actor = Actor::New();
2714   actor.SetProperty(Actor::Property::SENSITIVE, false);
2715
2716   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2717   END_TEST;
2718 }
2719
2720 int UtcDaliActorSetColor(void)
2721 {
2722   TestApplication application;
2723   Actor           actor = Actor::New();
2724   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2725
2726   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2727
2728   actor.SetProperty(Actor::Property::COLOR, color);
2729   // flush the queue and render once
2730   application.SendNotification();
2731   application.Render();
2732   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2733
2734   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2735   // flush the queue and render once
2736   application.SendNotification();
2737   application.Render();
2738   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2739
2740   application.GetScene().Add(actor);
2741   actor.SetProperty(Actor::Property::COLOR, color);
2742   // flush the queue and render once
2743   application.SendNotification();
2744   application.Render();
2745   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2746
2747   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2748   // flush the queue and render once
2749   application.SendNotification();
2750   application.Render();
2751   // Actor color is not clamped
2752   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2753   // world color is clamped
2754   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2755
2756   actor.SetProperty(Actor::Property::COLOR, color);
2757   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2758
2759   Vector3 newColor(1.0f, 0.0f, 0.0f);
2760   actor.SetProperty(Actor::Property::COLOR, newColor);
2761   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2762
2763   application.GetScene().Remove(actor);
2764   END_TEST;
2765 }
2766
2767 int UtcDaliActorSetColorIndividual(void)
2768 {
2769   TestApplication application;
2770
2771   Actor actor = Actor::New();
2772
2773   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2774   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2775
2776   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2777   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2778
2779   // flush the queue and render once
2780   application.SendNotification();
2781   application.Render();
2782
2783   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2784   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2785   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2786
2787   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2788   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2789
2790   // flush the queue and render once
2791   application.SendNotification();
2792   application.Render();
2793
2794   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2795   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2796   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2797
2798   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2799   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2800
2801   // flush the queue and render once
2802   application.SendNotification();
2803   application.Render();
2804
2805   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2806   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2807   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2808
2809   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2810   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2811
2812   // flush the queue and render once
2813   application.SendNotification();
2814   application.Render();
2815
2816   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2817   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2818   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2819
2820   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2821   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2822
2823   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2824
2825   // flush the queue and render once
2826   application.SendNotification();
2827   application.Render();
2828
2829   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2830
2831   END_TEST;
2832 }
2833
2834 int UtcDaliActorGetCurrentColor(void)
2835 {
2836   TestApplication application;
2837   Actor           actor = Actor::New();
2838   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2839
2840   actor.SetProperty(Actor::Property::COLOR, color);
2841   // flush the queue and render once
2842   application.SendNotification();
2843   application.Render();
2844   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2845   END_TEST;
2846 }
2847
2848 int UtcDaliActorGetCurrentWorldColor(void)
2849 {
2850   tet_infoline("Actor::GetCurrentWorldColor");
2851   TestApplication application;
2852
2853   Actor   parent = Actor::New();
2854   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2855   parent.SetProperty(Actor::Property::COLOR, parentColor);
2856   application.GetScene().Add(parent);
2857
2858   Actor   child = Actor::New();
2859   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2860   child.SetProperty(Actor::Property::COLOR, childColor);
2861   parent.Add(child);
2862
2863   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2864   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2865
2866   // verify the default color mode
2867   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2868
2869   // The actors should not have a world color yet
2870   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2871   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2872
2873   application.SendNotification();
2874   application.Render(0);
2875
2876   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2877   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2878
2879   // The actors should have a world color now
2880   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2881   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2882
2883   // use own color
2884   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2885   application.SendNotification();
2886   application.Render(0);
2887   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2888
2889   // use parent color
2890   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2891   application.SendNotification();
2892   application.Render(0);
2893   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2894   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2895
2896   // use parent alpha
2897   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2898   application.SendNotification();
2899   application.Render(0);
2900   Vector4 expectedColor(childColor);
2901   expectedColor.a *= parentColor.a;
2902   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2903   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2904   END_TEST;
2905 }
2906
2907 int UtcDaliActorSetColorMode(void)
2908 {
2909   tet_infoline("Actor::SetColorMode");
2910   TestApplication application;
2911   Actor           actor = Actor::New();
2912   Actor           child = Actor::New();
2913   actor.Add(child);
2914
2915   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2916   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2917
2918   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2919   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2920
2921   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2922   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2923
2924   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2925   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2926   END_TEST;
2927 }
2928
2929 int UtcDaliActorScreenToLocal(void)
2930 {
2931   TestApplication application;
2932   Actor           actor = Actor::New();
2933   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2934   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2935   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2936   application.GetScene().Add(actor);
2937
2938   // flush the queue and render once
2939   application.SendNotification();
2940   application.Render();
2941
2942   float localX;
2943   float localY;
2944
2945   application.SendNotification();
2946   application.Render();
2947
2948   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2949
2950   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2951   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2952   END_TEST;
2953 }
2954
2955 int UtcDaliActorSetLeaveRequired(void)
2956 {
2957   TestApplication application;
2958
2959   Actor actor = Actor::New();
2960
2961   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2962   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2963
2964   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2965   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2966   END_TEST;
2967 }
2968
2969 int UtcDaliActorGetLeaveRequired(void)
2970 {
2971   TestApplication application;
2972
2973   Actor actor = Actor::New();
2974
2975   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2976   END_TEST;
2977 }
2978
2979 int UtcDaliActorSetKeyboardFocusable(void)
2980 {
2981   TestApplication application;
2982
2983   Actor actor = Actor::New();
2984
2985   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2986   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2987
2988   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2989   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2990   END_TEST;
2991 }
2992
2993 int UtcDaliActorIsKeyboardFocusable(void)
2994 {
2995   TestApplication application;
2996
2997   Actor actor = Actor::New();
2998
2999   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
3000   END_TEST;
3001 }
3002
3003 int UtcDaliActorSetKeyboardFocusableChildren(void)
3004 {
3005   TestApplication application;
3006
3007   Actor actor = Actor::New();
3008
3009   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
3010   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
3011
3012   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
3013   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
3014   END_TEST;
3015 }
3016
3017 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
3018 {
3019   TestApplication application;
3020
3021   Actor actor = Actor::New();
3022
3023   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
3024   END_TEST;
3025 }
3026
3027 int UtcDaliActorSetTouchFocusable(void)
3028 {
3029   TestApplication application;
3030
3031   Actor actor = Actor::New();
3032
3033   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
3034   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
3035
3036   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
3037   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
3038   END_TEST;
3039 }
3040
3041 int UtcDaliActorIsTouchFocusable(void)
3042 {
3043   TestApplication application;
3044
3045   Actor actor = Actor::New();
3046
3047   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
3048   END_TEST;
3049 }
3050
3051 int UtcDaliActorSetUserInteractionEnabled(void)
3052 {
3053   TestApplication application;
3054   Actor           actor = Actor::New();
3055
3056   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
3057
3058   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
3059
3060   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
3061   END_TEST;
3062 }
3063
3064 int UtcDaliActorIsUserInteractionEnabled(void)
3065 {
3066   TestApplication application;
3067   Actor           actor = Actor::New();
3068   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3069
3070   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
3071   END_TEST;
3072 }
3073
3074 int UtcDaliActorRemoveConstraints(void)
3075 {
3076   tet_infoline(" UtcDaliActorRemoveConstraints");
3077   TestApplication application;
3078
3079   gTestConstraintCalled = false;
3080
3081   Actor actor = Actor::New();
3082
3083   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
3084   constraint.Apply();
3085   actor.RemoveConstraints();
3086
3087   DALI_TEST_CHECK(gTestConstraintCalled == false);
3088
3089   application.GetScene().Add(actor);
3090   constraint.Apply();
3091
3092   // flush the queue and render once
3093   application.SendNotification();
3094   application.Render();
3095
3096   actor.RemoveConstraints();
3097
3098   DALI_TEST_CHECK(gTestConstraintCalled == true);
3099   END_TEST;
3100 }
3101
3102 int UtcDaliActorRemoveConstraintTag(void)
3103 {
3104   tet_infoline(" UtcDaliActorRemoveConstraintTag");
3105   TestApplication application;
3106
3107   Actor actor = Actor::New();
3108
3109   // 1. Apply Constraint1 and Constraint2, and test...
3110   unsigned int result1 = 0u;
3111   unsigned int result2 = 0u;
3112
3113   unsigned   constraint1Tag = 1u;
3114   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
3115   constraint1.SetTag(constraint1Tag);
3116   constraint1.Apply();
3117
3118   unsigned   constraint2Tag = 2u;
3119   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
3120   constraint2.SetTag(constraint2Tag);
3121   constraint2.Apply();
3122
3123   application.GetScene().Add(actor);
3124   // flush the queue and render once
3125   application.SendNotification();
3126   application.Render();
3127
3128   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3129   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3130
3131   // 2. Remove Constraint1 and test...
3132   result1 = 0;
3133   result2 = 0;
3134   actor.RemoveConstraints(constraint1Tag);
3135   // make color property dirty, which will trigger constraints to be reapplied.
3136   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3137   // flush the queue and render once
3138   application.SendNotification();
3139   application.Render();
3140
3141   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3142   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3143
3144   // 3. Re-Apply Constraint1 and test...
3145   result1 = 0;
3146   result2 = 0;
3147   constraint1.Apply();
3148   // make color property dirty, which will trigger constraints to be reapplied.
3149   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3150   // flush the queue and render once
3151   application.SendNotification();
3152   application.Render();
3153
3154   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3155   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3156
3157   // 2. Remove Constraint2 and test...
3158   result1 = 0;
3159   result2 = 0;
3160   actor.RemoveConstraints(constraint2Tag);
3161   // make color property dirty, which will trigger constraints to be reapplied.
3162   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3163   // flush the queue and render once
3164   application.SendNotification();
3165   application.Render();
3166
3167   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3168   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3169
3170   // 2. Remove Constraint1 as well and test...
3171   result1 = 0;
3172   result2 = 0;
3173   actor.RemoveConstraints(constraint1Tag);
3174   // make color property dirty, which will trigger constraints to be reapplied.
3175   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3176   // flush the queue and render once
3177   application.SendNotification();
3178   application.Render();
3179
3180   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3181   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3182   END_TEST;
3183 }
3184
3185 int UtcDaliActorTouchedSignal(void)
3186 {
3187   TestApplication application;
3188
3189   ResetTouchCallbacks();
3190
3191   // get the root layer
3192   Actor actor = application.GetScene().GetRootLayer();
3193   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3194
3195   application.SendNotification();
3196   application.Render();
3197
3198   // connect to its touch signal
3199   actor.TouchedSignal().Connect(TestTouchCallback);
3200
3201   // simulate a touch event in the middle of the screen
3202   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3203   Dali::Integration::Point point;
3204   point.SetDeviceId(1);
3205   point.SetState(PointState::DOWN);
3206   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3207   Dali::Integration::TouchEvent touchEvent;
3208   touchEvent.AddPoint(point);
3209   application.ProcessEvent(touchEvent);
3210
3211   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3212   END_TEST;
3213 }
3214
3215 int UtcDaliActorGeoTouchedSignal(void)
3216 {
3217   TestApplication application;
3218
3219   application.GetScene().SetGeometryHittestEnabled(true);
3220   ResetTouchCallbacks(application);
3221
3222   // get the root layer
3223   Actor actor = application.GetScene().GetRootLayer();
3224   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3225
3226   application.SendNotification();
3227   application.Render();
3228
3229   // connect to its touch signal
3230   actor.TouchedSignal().Connect(TestTouchCallback);
3231
3232   // simulate a touch event in the middle of the screen
3233   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3234   Dali::Integration::Point point;
3235   point.SetDeviceId(1);
3236   point.SetState(PointState::DOWN);
3237   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3238   Dali::Integration::TouchEvent touchEvent;
3239   touchEvent.AddPoint(point);
3240   application.ProcessEvent(touchEvent);
3241
3242   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3243   END_TEST;
3244 }
3245
3246 int UtcDaliActorHoveredSignal(void)
3247 {
3248   TestApplication application;
3249
3250   gHoverCallBackCalled = false;
3251
3252   // get the root layer
3253   Actor actor = application.GetScene().GetRootLayer();
3254   DALI_TEST_CHECK(gHoverCallBackCalled == false);
3255
3256   application.SendNotification();
3257   application.Render();
3258
3259   // connect to its hover signal
3260   actor.HoveredSignal().Connect(TestCallback3);
3261
3262   // simulate a hover event in the middle of the screen
3263   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3264   Dali::Integration::Point point;
3265   point.SetDeviceId(1);
3266   point.SetState(PointState::MOTION);
3267   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3268   Dali::Integration::HoverEvent hoverEvent;
3269   hoverEvent.AddPoint(point);
3270   application.ProcessEvent(hoverEvent);
3271
3272   DALI_TEST_CHECK(gHoverCallBackCalled == true);
3273   END_TEST;
3274 }
3275
3276 int UtcDaliActorOnOffSceneSignal(void)
3277 {
3278   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3279
3280   TestApplication application;
3281
3282   // clean test data
3283   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3284   gActorNamesOnOffScene.clear();
3285
3286   Actor parent = Actor::New();
3287   parent.SetProperty(Actor::Property::NAME, "parent");
3288   parent.OnSceneSignal().Connect(OnSceneCallback);
3289   parent.OffSceneSignal().Connect(OffSceneCallback);
3290   // sanity check
3291   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3292   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3293
3294   // add parent to the scene
3295   application.GetScene().Add(parent);
3296   // onstage emitted, offstage not
3297   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3298   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3299   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3300
3301   // test adding a child, should get onstage emitted
3302   // clean test data
3303   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3304   gActorNamesOnOffScene.clear();
3305
3306   Actor child = Actor::New();
3307   child.SetProperty(Actor::Property::NAME, "child");
3308   child.OnSceneSignal().Connect(OnSceneCallback);
3309   child.OffSceneSignal().Connect(OffSceneCallback);
3310   parent.Add(child); // add child
3311   // onscene emitted, offscene not
3312   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3313   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3314   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3315
3316   // test removing parent from the scene
3317   // clean test data
3318   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3319   gActorNamesOnOffScene.clear();
3320
3321   application.GetScene().Remove(parent);
3322   // onscene not emitted, offscene is
3323   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3324   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3325   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3326   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3327
3328   // test adding parent back to the scene
3329   // clean test data
3330   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3331   gActorNamesOnOffScene.clear();
3332
3333   application.GetScene().Add(parent);
3334   // onscene emitted, offscene not
3335   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3336   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3337   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3338   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3339
3340   // test removing child
3341   // clean test data
3342   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3343   gActorNamesOnOffScene.clear();
3344
3345   parent.Remove(child);
3346   // onscene not emitted, offscene is
3347   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3348   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3349   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3350
3351   // test removing parent
3352   // clean test data
3353   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3354   gActorNamesOnOffScene.clear();
3355
3356   application.GetScene().Remove(parent);
3357   // onscene not emitted, offscene is
3358   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3359   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3360   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3361   END_TEST;
3362 }
3363
3364 int UtcDaliActorFindChildByName(void)
3365 {
3366   tet_infoline("Testing Dali::Actor::FindChildByName()");
3367   TestApplication application;
3368
3369   Actor parent = Actor::New();
3370   parent.SetProperty(Actor::Property::NAME, "parent");
3371   Actor first = Actor::New();
3372   first.SetProperty(Actor::Property::NAME, "first");
3373   Actor second = Actor::New();
3374   second.SetProperty(Actor::Property::NAME, "second");
3375
3376   parent.Add(first);
3377   first.Add(second);
3378
3379   Actor found = parent.FindChildByName("foo");
3380   DALI_TEST_CHECK(!found);
3381
3382   found = parent.FindChildByName("parent");
3383   DALI_TEST_CHECK(found == parent);
3384
3385   found = parent.FindChildByName("first");
3386   DALI_TEST_CHECK(found == first);
3387
3388   found = parent.FindChildByName("second");
3389   DALI_TEST_CHECK(found == second);
3390   END_TEST;
3391 }
3392
3393 int UtcDaliActorFindChildById(void)
3394 {
3395   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3396   TestApplication application;
3397
3398   Actor parent = Actor::New();
3399   Actor first  = Actor::New();
3400   Actor second = Actor::New();
3401
3402   parent.Add(first);
3403   first.Add(second);
3404
3405   Actor found = parent.FindChildById(100000);
3406   DALI_TEST_CHECK(!found);
3407
3408   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3409   DALI_TEST_CHECK(found == parent);
3410
3411   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3412   DALI_TEST_CHECK(found == first);
3413
3414   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3415   DALI_TEST_CHECK(found == second);
3416   END_TEST;
3417 }
3418
3419 int UtcDaliActorHitTest(void)
3420 {
3421   struct HitTestData
3422   {
3423   public:
3424     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3425     : mScale(scale),
3426       mTouchPoint(touchPoint),
3427       mResult(result)
3428     {
3429     }
3430
3431     Vector3 mScale;
3432     Vector2 mTouchPoint;
3433     bool    mResult;
3434   };
3435
3436   TestApplication application;
3437   tet_infoline(" UtcDaliActorHitTest");
3438
3439   // Fill a vector with different hit tests.
3440   struct HitTestData* hitTestData[] = {
3441     //                    scale                     touch point           result
3442     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3443     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3444     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.
3445     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3446     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.
3447     NULL,
3448   };
3449
3450   // get the root layer
3451   Actor actor = Actor::New();
3452   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3453   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3454
3455   application.GetScene().Add(actor);
3456
3457   ResetTouchCallbacks();
3458
3459   unsigned int index = 0;
3460   while(NULL != hitTestData[index])
3461   {
3462     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3463     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3464
3465     // flush the queue and render once
3466     application.SendNotification();
3467     application.Render();
3468
3469     DALI_TEST_CHECK(!gTouchCallBackCalled);
3470
3471     // connect to its touch signal
3472     actor.TouchedSignal().Connect(TestTouchCallback);
3473
3474     Dali::Integration::Point point;
3475     point.SetState(PointState::DOWN);
3476     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3477     Dali::Integration::TouchEvent event;
3478     event.AddPoint(point);
3479
3480     // flush the queue and render once
3481     application.SendNotification();
3482     application.Render();
3483     application.ProcessEvent(event);
3484
3485     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3486
3487     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3488       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3489                  hitTestData[index]->mScale.x,
3490                  hitTestData[index]->mScale.y,
3491                  hitTestData[index]->mScale.z,
3492                  hitTestData[index]->mTouchPoint.x,
3493                  hitTestData[index]->mTouchPoint.y,
3494                  hitTestData[index]->mResult);
3495
3496     ResetTouchCallbacks();
3497     ++index;
3498   }
3499   END_TEST;
3500 }
3501
3502 int UtcDaliActorGeoHitTest(void)
3503 {
3504   struct HitTestData
3505   {
3506   public:
3507     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3508     : mScale(scale),
3509       mTouchPoint(touchPoint),
3510       mResult(result)
3511     {
3512     }
3513
3514     Vector3 mScale;
3515     Vector2 mTouchPoint;
3516     bool    mResult;
3517   };
3518
3519   TestApplication application;
3520   tet_infoline(" UtcDaliActorHitTest");
3521
3522   // Fill a vector with different hit tests.
3523   struct HitTestData* hitTestData[] = {
3524     //                    scale                     touch point           result
3525     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3526     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3527     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.
3528     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3529     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.
3530     NULL,
3531   };
3532
3533   // get the root layer
3534   Actor actor = Actor::New();
3535   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3536   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3537
3538   application.GetScene().Add(actor);
3539   application.GetScene().SetGeometryHittestEnabled(true);
3540
3541   ResetTouchCallbacks(application);
3542
3543   unsigned int index = 0;
3544   while(NULL != hitTestData[index])
3545   {
3546     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3547     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3548
3549     // flush the queue and render once
3550     application.SendNotification();
3551     application.Render();
3552
3553     DALI_TEST_CHECK(!gTouchCallBackCalled);
3554
3555     // connect to its touch signal
3556     actor.TouchedSignal().Connect(TestTouchCallback);
3557
3558     Dali::Integration::Point point;
3559     point.SetState(PointState::DOWN);
3560     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3561     Dali::Integration::TouchEvent event;
3562     event.AddPoint(point);
3563
3564     // flush the queue and render once
3565     application.SendNotification();
3566     application.Render();
3567     application.ProcessEvent(event);
3568
3569     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3570
3571     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3572       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3573                  hitTestData[index]->mScale.x,
3574                  hitTestData[index]->mScale.y,
3575                  hitTestData[index]->mScale.z,
3576                  hitTestData[index]->mTouchPoint.x,
3577                  hitTestData[index]->mTouchPoint.y,
3578                  hitTestData[index]->mResult);
3579
3580     ResetTouchCallbacks(application);
3581     ++index;
3582   }
3583   END_TEST;
3584 }
3585
3586 int UtcDaliActorSetDrawMode(void)
3587 {
3588   TestApplication application;
3589   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3590
3591   Actor a = Actor::New();
3592
3593   application.GetScene().Add(a);
3594   application.SendNotification();
3595   application.Render(0);
3596   application.SendNotification();
3597   application.Render(1);
3598
3599   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3600
3601   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3602   application.SendNotification();
3603   application.Render(1);
3604
3605   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3606
3607   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3608   application.SendNotification();
3609   application.Render(1);
3610
3611   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3612   END_TEST;
3613 }
3614
3615 int UtcDaliActorSetDrawModeOverlayRender(void)
3616 {
3617   TestApplication application;
3618   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3619
3620   application.SendNotification();
3621   application.Render(1);
3622
3623   std::vector<GLuint> ids;
3624   ids.push_back(8);  // first rendered actor
3625   ids.push_back(9);  // second rendered actor
3626   ids.push_back(10); // third rendered actor
3627   application.GetGlAbstraction().SetNextTextureIds(ids);
3628
3629   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3630   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3631   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3632   Actor   a      = CreateRenderableActor(imageA);
3633   Actor   b      = CreateRenderableActor(imageB);
3634   Actor   c      = CreateRenderableActor(imageC);
3635
3636   application.SendNotification();
3637   application.Render(1);
3638
3639   //Textures are bound when first created. Clear bound textures vector
3640   application.GetGlAbstraction().ClearBoundTextures();
3641
3642   // Render a,b,c as regular non-overlays. so order will be:
3643   // a (8)
3644   // b (9)
3645   // c (10)
3646   application.GetScene().Add(a);
3647   application.GetScene().Add(b);
3648   application.GetScene().Add(c);
3649
3650   application.SendNotification();
3651   application.Render(1);
3652
3653   // Should be 3 textures changes.
3654   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3655   typedef std::vector<GLuint>::size_type TextureSize;
3656   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3657   if(boundTextures.size() == 3)
3658   {
3659     DALI_TEST_CHECK(boundTextures[0] == 8u);
3660     DALI_TEST_CHECK(boundTextures[1] == 9u);
3661     DALI_TEST_CHECK(boundTextures[2] == 10u);
3662   }
3663
3664   // Now texture ids have been set, we can monitor their render order.
3665   // render a as an overlay (last), so order will be:
3666   // b (9)
3667   // c (10)
3668   // a (8)
3669   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3670   application.GetGlAbstraction().ClearBoundTextures();
3671
3672   application.SendNotification();
3673   application.Render(1);
3674
3675   // Should be 3 texture changes.
3676   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3677   if(boundTextures.size() == 3)
3678   {
3679     DALI_TEST_CHECK(boundTextures[0] == 9u);
3680     DALI_TEST_CHECK(boundTextures[1] == 10u);
3681     DALI_TEST_CHECK(boundTextures[2] == 8u);
3682   }
3683   END_TEST;
3684 }
3685
3686 int UtcDaliActorSetDrawModeOverlayWithClipping(void)
3687 {
3688   TestApplication application;
3689   tet_infoline(" UtcDaliActorSetDrawModeOverlayWithClipping");
3690
3691   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3692   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3693   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3694
3695   const Vector2 surfaceSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3696   const Vector2 imageSize(16.0f, 16.0f);
3697
3698   std::vector<GLuint> ids;
3699   ids.push_back(8);  // first rendered actor
3700   ids.push_back(9);  // second rendered actor
3701   ids.push_back(10); // third rendered actor
3702   ids.push_back(11); // forth rendered actor
3703   application.GetGlAbstraction().SetNextTextureIds(ids);
3704
3705   Actor a = CreateActorWithContent16x16();
3706   Actor b = CreateActorWithContent16x16();
3707   Actor c = CreateActorWithContent16x16();
3708   Actor d = CreateActorWithContent16x16();
3709
3710   application.SendNotification();
3711   application.Render();
3712
3713   //Textures are bound when first created. Clear bound textures vector
3714   application.GetGlAbstraction().ClearBoundTextures();
3715
3716   b[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3717   b[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3718   b[Actor::Property::DRAW_MODE]     = DrawMode::OVERLAY_2D;
3719   b[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3720
3721   c[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3722   c[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3723   c[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3724   c[Actor::Property::POSITION]      = Vector2(100.0f, -100.0f);
3725
3726   application.GetScene().Add(a);
3727   application.GetScene().Add(b);
3728   application.GetScene().Add(c);
3729   b.Add(d);
3730
3731   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3732
3733   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3734   typedef std::vector<GLuint>::size_type TextureSize;
3735   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(4), TEST_LOCATION);
3736   if(boundTextures.size() == 4)
3737   {
3738     DALI_TEST_CHECK(boundTextures[0] == 8u);
3739     DALI_TEST_CHECK(boundTextures[1] == 10u);
3740     DALI_TEST_CHECK(boundTextures[2] == 9u);
3741     DALI_TEST_CHECK(boundTextures[3] == 11u);
3742   }
3743
3744   // Check scissor test was enabled.
3745   std::ostringstream scissor;
3746   scissor << std::hex << GL_SCISSOR_TEST;
3747   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3748
3749   // Check the scissor was set, and the coordinates are correct.
3750   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3751   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3752
3753   application.GetGlAbstraction().ClearBoundTextures();
3754
3755   // Remove a Renderer of overlay actor
3756   Renderer renderer = b.GetRendererAt(0);
3757   b.RemoveRenderer(renderer);
3758
3759   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3760
3761   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3762   if(boundTextures.size() == 3)
3763   {
3764     DALI_TEST_CHECK(boundTextures[0] == 8u);
3765     DALI_TEST_CHECK(boundTextures[1] == 10u);
3766     DALI_TEST_CHECK(boundTextures[2] == 11u);
3767   }
3768
3769   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3770   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3771
3772   END_TEST;
3773 }
3774
3775 int UtcDaliActorGetCurrentWorldMatrix(void)
3776 {
3777   TestApplication application;
3778   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3779
3780   Actor parent = Actor::New();
3781   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3782   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3783   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3784   Radian     rotationAngle(Degree(85.0f));
3785   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3786   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3787   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3788   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3789   parent.SetProperty(Actor::Property::SCALE, parentScale);
3790   application.GetScene().Add(parent);
3791
3792   Actor child = Actor::New();
3793   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3794   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3795   Radian     childRotationAngle(Degree(23.0f));
3796   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3797   Vector3    childScale(2.0f, 2.0f, 2.0f);
3798   child.SetProperty(Actor::Property::POSITION, childPosition);
3799   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3800   child.SetProperty(Actor::Property::SCALE, childScale);
3801   parent.Add(child);
3802
3803   application.SendNotification();
3804   application.Render(0);
3805   application.Render();
3806   application.SendNotification();
3807
3808   Matrix parentMatrix(false);
3809   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3810
3811   Matrix childMatrix(false);
3812   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3813
3814   //Child matrix should be the composition of child and parent
3815   Matrix childWorldMatrix(false);
3816   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3817
3818   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3819   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3820   END_TEST;
3821 }
3822
3823 int UtcDaliActorConstrainedToWorldMatrix(void)
3824 {
3825   TestApplication application;
3826   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3827
3828   Actor parent = Actor::New();
3829   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3830   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3831   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3832   Radian     rotationAngle(Degree(85.0f));
3833   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3834   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3835   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3836   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3837   parent.SetProperty(Actor::Property::SCALE, parentScale);
3838   application.GetScene().Add(parent);
3839
3840   Actor child = Actor::New();
3841   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3842   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3843   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3844   posConstraint.Apply();
3845
3846   application.GetScene().Add(child);
3847
3848   application.SendNotification();
3849   application.Render(0);
3850   application.Render();
3851   application.SendNotification();
3852
3853   Matrix parentMatrix(false);
3854   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3855
3856   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3857   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3858   END_TEST;
3859 }
3860
3861 int UtcDaliActorConstrainedToOrientation(void)
3862 {
3863   TestApplication application;
3864   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3865
3866   Actor parent = Actor::New();
3867   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3868   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3869   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3870   Radian     rotationAngle(Degree(85.0f));
3871   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3872   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3873   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3874   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3875   parent.SetProperty(Actor::Property::SCALE, parentScale);
3876   application.GetScene().Add(parent);
3877
3878   Actor child = Actor::New();
3879   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3880   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3881   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3882   posConstraint.Apply();
3883
3884   application.GetScene().Add(child);
3885
3886   application.SendNotification();
3887   application.Render(0);
3888   application.Render();
3889   application.SendNotification();
3890
3891   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3892   END_TEST;
3893 }
3894
3895 int UtcDaliActorConstrainedToOpacity(void)
3896 {
3897   TestApplication application;
3898   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3899
3900   Actor parent = Actor::New();
3901   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3902   application.GetScene().Add(parent);
3903
3904   Actor      child             = Actor::New();
3905   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3906   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3907   opacityConstraint.Apply();
3908
3909   application.GetScene().Add(child);
3910
3911   application.SendNotification();
3912   application.Render(0);
3913   application.Render();
3914   application.SendNotification();
3915
3916   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3917
3918   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3919
3920   application.SendNotification();
3921   application.Render(0);
3922   application.Render();
3923   application.SendNotification();
3924
3925   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3926
3927   END_TEST;
3928 }
3929
3930 int UtcDaliActorUnparent(void)
3931 {
3932   TestApplication application;
3933   tet_infoline(" UtcDaliActorUnparent");
3934
3935   Actor parent = Actor::New();
3936   application.GetScene().Add(parent);
3937
3938   Actor child = Actor::New();
3939
3940   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3941   DALI_TEST_CHECK(!child.GetParent());
3942
3943   // Test that calling Unparent with no parent is a NOOP
3944   child.Unparent();
3945
3946   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3947   DALI_TEST_CHECK(!child.GetParent());
3948
3949   // Test that Unparent works
3950   parent.Add(child);
3951
3952   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3953   DALI_TEST_CHECK(parent == child.GetParent());
3954
3955   child.Unparent();
3956
3957   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3958   DALI_TEST_CHECK(!child.GetParent());
3959
3960   // Test that UnparentAndReset works
3961   parent.Add(child);
3962
3963   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3964   DALI_TEST_CHECK(parent == child.GetParent());
3965
3966   UnparentAndReset(child);
3967
3968   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3969   DALI_TEST_CHECK(!child);
3970
3971   // Test that UnparentAndReset is a NOOP with empty handle
3972   UnparentAndReset(child);
3973
3974   DALI_TEST_CHECK(!child);
3975   END_TEST;
3976 }
3977
3978 int UtcDaliActorGetChildAt(void)
3979 {
3980   TestApplication application;
3981   tet_infoline(" UtcDaliActorGetChildAt");
3982
3983   Actor parent = Actor::New();
3984   application.GetScene().Add(parent);
3985
3986   Actor child0 = Actor::New();
3987   parent.Add(child0);
3988
3989   Actor child1 = Actor::New();
3990   parent.Add(child1);
3991
3992   Actor child2 = Actor::New();
3993   parent.Add(child2);
3994
3995   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3996   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3997   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3998   END_TEST;
3999 }
4000
4001 int UtcDaliActorSetGetOverlay(void)
4002 {
4003   TestApplication application;
4004   tet_infoline(" UtcDaliActorSetGetOverlay");
4005
4006   Actor parent = Actor::New();
4007   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4008   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
4009   END_TEST;
4010 }
4011
4012 int UtcDaliActorCreateDestroy(void)
4013 {
4014   Actor* actor = new Actor;
4015   DALI_TEST_CHECK(actor);
4016   delete actor;
4017   END_TEST;
4018 }
4019
4020 namespace
4021 {
4022 struct PropertyStringIndex
4023 {
4024   const char* const     name;
4025   const Property::Index index;
4026   const Property::Type  type;
4027 };
4028
4029 const PropertyStringIndex PROPERTY_TABLE[] =
4030   {
4031     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
4032     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
4033     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
4034     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
4035     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
4036     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
4037     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
4038     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
4039     {"size", Actor::Property::SIZE, Property::VECTOR3},
4040     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
4041     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
4042     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
4043     {"position", Actor::Property::POSITION, Property::VECTOR3},
4044     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
4045     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
4046     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
4047     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
4048     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
4049     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
4050     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
4051     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
4052     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
4053     {"scale", Actor::Property::SCALE, Property::VECTOR3},
4054     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
4055     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
4056     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
4057     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
4058     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
4059     {"color", Actor::Property::COLOR, Property::VECTOR4},
4060     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
4061     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
4062     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
4063     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
4064     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
4065     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
4066     {"name", Actor::Property::NAME, Property::STRING},
4067     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
4068     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
4069     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
4070     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
4071     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
4072     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
4073     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
4074     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
4075     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
4076     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
4077     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
4078     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
4079     {"padding", Actor::Property::PADDING, Property::VECTOR4},
4080     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
4081     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
4082     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
4083     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
4084     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
4085 };
4086 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
4087 } // unnamed namespace
4088
4089 int UtcDaliActorProperties(void)
4090 {
4091   TestApplication application;
4092
4093   Actor actor = Actor::New();
4094
4095   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
4096   {
4097     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
4098     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
4099     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
4100     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
4101   }
4102   END_TEST;
4103 }
4104
4105 int UtcDaliRelayoutProperties_ResizePolicies(void)
4106 {
4107   TestApplication application;
4108
4109   Actor actor = Actor::New();
4110
4111   // Defaults
4112   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
4113   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
4114
4115   // Set resize policy for all dimensions
4116   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
4117   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
4118   {
4119     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
4120   }
4121
4122   // Set individual dimensions
4123   const char* const widthPolicy  = "FILL_TO_PARENT";
4124   const char* const heightPolicy = "FIXED";
4125
4126   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
4127   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
4128
4129   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
4130   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
4131
4132   // Set individual dimensions using enums
4133   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
4134   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
4135
4136   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
4137   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
4138
4139   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
4140   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
4141
4142   END_TEST;
4143 }
4144
4145 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
4146 {
4147   TestApplication application;
4148
4149   Actor actor = Actor::New();
4150
4151   // Defaults
4152   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
4153
4154   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
4155   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
4156   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
4157
4158   // Set
4159   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
4160   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
4161
4162   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
4163   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
4164
4165   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
4166   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
4167
4168   END_TEST;
4169 }
4170
4171 int UtcDaliRelayoutProperties_SizeModeFactor(void)
4172 {
4173   TestApplication application;
4174
4175   Actor actor = Actor::New();
4176
4177   // Defaults
4178   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
4179   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
4180
4181   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
4182   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
4183   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
4184
4185   // Set
4186   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
4187
4188   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
4189   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
4190
4191   END_TEST;
4192 }
4193
4194 int UtcDaliRelayoutProperties_DimensionDependency(void)
4195 {
4196   TestApplication application;
4197
4198   Actor actor = Actor::New();
4199
4200   // Defaults
4201   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4202   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
4203
4204   // Set
4205   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
4206   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
4207
4208   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
4209   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
4210
4211   // Test setting another resize policy
4212   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
4213   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4214
4215   END_TEST;
4216 }
4217
4218 int UtcDaliRelayoutProperties_Padding(void)
4219 {
4220   TestApplication application;
4221
4222   Actor actor = Actor::New();
4223
4224   // Data
4225   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
4226
4227   // PADDING
4228   actor.SetProperty(Actor::Property::PADDING, padding);
4229   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
4230
4231   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4232
4233   END_TEST;
4234 }
4235
4236 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
4237 {
4238   TestApplication application;
4239
4240   Actor actor = Actor::New();
4241
4242   // Data
4243   Vector2 minSize(1.0f, 2.0f);
4244
4245   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
4246   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
4247
4248   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4249
4250   Vector2 maxSize(3.0f, 4.0f);
4251
4252   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
4253   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
4254
4255   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4256
4257   END_TEST;
4258 }
4259
4260 int UtcDaliActorGetHeightForWidth(void)
4261 {
4262   TestApplication application;
4263
4264   Actor actor = Actor::New();
4265
4266   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
4267
4268   END_TEST;
4269 }
4270
4271 int UtcDaliActorGetWidthForHeight(void)
4272 {
4273   TestApplication application;
4274
4275   Actor actor = Actor::New();
4276
4277   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
4278
4279   END_TEST;
4280 }
4281
4282 int UtcDaliActorGetRelayoutSize(void)
4283 {
4284   TestApplication application;
4285
4286   Actor actor = Actor::New();
4287
4288   // Add actor to stage
4289   application.GetScene().Add(actor);
4290
4291   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
4292
4293   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
4294   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
4295
4296   // Flush the queue and render once
4297   application.SendNotification();
4298   application.Render();
4299
4300   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
4301
4302   END_TEST;
4303 }
4304
4305 int UtcDaliActorSetPadding(void)
4306 {
4307   TestApplication application;
4308
4309   Actor actor = Actor::New();
4310
4311   Padding padding;
4312   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4313
4314   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
4315   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
4316   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
4317   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
4318
4319   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
4320   actor.SetProperty(Actor::Property::PADDING, padding2);
4321
4322   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4323
4324   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
4325   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
4326   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
4327   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
4328
4329   END_TEST;
4330 }
4331
4332 int UtcDaliActorSetMinimumSize(void)
4333 {
4334   TestApplication application;
4335
4336   Actor actor = Actor::New();
4337
4338   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4339
4340   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
4341   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
4342
4343   Vector2 size2(1.0f, 2.0f);
4344   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
4345
4346   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4347
4348   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4349   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4350
4351   END_TEST;
4352 }
4353
4354 int UtcDaliActorSetMaximumSize(void)
4355 {
4356   TestApplication application;
4357
4358   Actor actor = Actor::New();
4359
4360   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4361
4362   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
4363   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
4364
4365   Vector2 size2(1.0f, 2.0f);
4366   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
4367
4368   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4369
4370   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4371   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4372
4373   END_TEST;
4374 }
4375
4376 int UtcDaliActorOnRelayoutSignal(void)
4377 {
4378   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
4379
4380   TestApplication application;
4381
4382   // Clean test data
4383   gOnRelayoutCallBackCalled = false;
4384   gActorNamesRelayout.clear();
4385
4386   Actor actor = Actor::New();
4387   actor.SetProperty(Actor::Property::NAME, "actor");
4388   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4389
4390   // Sanity check
4391   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4392
4393   // Add actor to stage
4394   application.GetScene().Add(actor);
4395
4396   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4397   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4398
4399   // Flush the queue and render once
4400   application.SendNotification();
4401   application.Render();
4402
4403   // OnRelayout emitted
4404   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4405   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4406
4407   END_TEST;
4408 }
4409
4410 int UtcDaliActorGetHierachyDepth(void)
4411 {
4412   TestApplication application;
4413   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4414
4415   /* Build tree of actors:
4416    *
4417    *                      Depth
4418    *
4419    *       A (parent)       1
4420    *      / \
4421    *     B   C              2`
4422    *    / \   \
4423    *   D   E   F            3
4424    *
4425    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4426    */
4427   Integration::Scene stage(application.GetScene());
4428
4429   Actor actorA = Actor::New();
4430   Actor actorB = Actor::New();
4431   Actor actorC = Actor::New();
4432   Actor actorD = Actor::New();
4433   Actor actorE = Actor::New();
4434   Actor actorF = Actor::New();
4435
4436   //Test that root actor has depth equal 0
4437   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4438
4439   //Test actors return depth -1 when not connected to the tree
4440   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4441   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4442   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4443   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4444   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4445   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4446
4447   //Create the hierarchy
4448   stage.Add(actorA);
4449   actorA.Add(actorB);
4450   actorA.Add(actorC);
4451   actorB.Add(actorD);
4452   actorB.Add(actorE);
4453   actorC.Add(actorF);
4454
4455   //Test actors return correct depth
4456   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4457   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4458   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4459   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4460   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4461   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4462
4463   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4464   actorA.Remove(actorB);
4465
4466   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4467   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4468   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4469
4470   //Removing actorA from the stage. All actors should have depth equal -1
4471   stage.Remove(actorA);
4472
4473   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4474   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4475   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4476   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4477   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4478   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4479
4480   END_TEST;
4481 }
4482
4483 int UtcDaliActorAnchorPointPropertyAsString(void)
4484 {
4485   TestApplication application;
4486
4487   Actor actor = Actor::New();
4488
4489   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4490   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4491
4492   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4493   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4494
4495   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4496   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4497
4498   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4499   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4500
4501   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4502   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4503
4504   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4505   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4506
4507   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4508   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4509
4510   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4511   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4512
4513   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4514   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4515
4516   // Invalid should not change anything
4517   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4518   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4519
4520   END_TEST;
4521 }
4522
4523 int UtcDaliActorParentOriginPropertyAsString(void)
4524 {
4525   TestApplication application;
4526
4527   Actor actor = Actor::New();
4528
4529   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4530   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4531
4532   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4533   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4534
4535   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4536   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4537
4538   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4539   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4540
4541   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4542   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4543
4544   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4545   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4546
4547   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4548   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4549
4550   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4551   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4552
4553   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4554   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4555
4556   // Invalid should not change anything
4557   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4558   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4559
4560   END_TEST;
4561 }
4562
4563 int UtcDaliActorColorModePropertyAsString(void)
4564 {
4565   TestApplication application;
4566
4567   Actor actor = Actor::New();
4568
4569   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4570   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4571
4572   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4573   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4574
4575   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4576   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4577
4578   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4579   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4580
4581   // Invalid should not change anything
4582   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4583   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4584
4585   END_TEST;
4586 }
4587
4588 int UtcDaliActorDrawModePropertyAsString(void)
4589 {
4590   TestApplication application;
4591
4592   Actor actor = Actor::New();
4593
4594   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4595   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4596
4597   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4598   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4599
4600   // Invalid should not change anything
4601   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4602   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4603
4604   END_TEST;
4605 }
4606
4607 int UtcDaliActorColorModePropertyAsEnum(void)
4608 {
4609   TestApplication application;
4610
4611   Actor actor = Actor::New();
4612
4613   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4614   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4615
4616   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4617   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4618
4619   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4620   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4621
4622   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4623   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4624
4625   END_TEST;
4626 }
4627
4628 int UtcDaliActorDrawModePropertyAsEnum(void)
4629 {
4630   TestApplication application;
4631
4632   Actor actor = Actor::New();
4633
4634   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4635   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4636
4637   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4638   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4639
4640   END_TEST;
4641 }
4642
4643 int UtcDaliActorAddRendererP(void)
4644 {
4645   tet_infoline("Testing Actor::AddRenderer");
4646   TestApplication application;
4647
4648   Actor actor = Actor::New();
4649
4650   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4651
4652   Geometry geometry = CreateQuadGeometry();
4653   Shader   shader   = CreateShader();
4654   Renderer renderer = Renderer::New(geometry, shader);
4655
4656   actor.AddRenderer(renderer);
4657   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4658   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4659
4660   END_TEST;
4661 }
4662
4663 int UtcDaliActorAddSameRenderer(void)
4664 {
4665   tet_infoline("Testing Actor::AddRenderer");
4666   TestApplication application;
4667
4668   Actor actor = Actor::New();
4669
4670   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4671
4672   Geometry geometry  = CreateQuadGeometry();
4673   Shader   shader    = CreateShader();
4674   Renderer renderer1 = Renderer::New(geometry, shader);
4675   Renderer renderer2 = Renderer::New(geometry, shader);
4676   Renderer renderer3 = Renderer::New(geometry, shader);
4677
4678   DALI_TEST_EQUALS(actor.AddRenderer(renderer1), 0U, TEST_LOCATION);
4679   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4680   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer1, TEST_LOCATION);
4681
4682   DALI_TEST_EQUALS(actor.AddRenderer(renderer2), 1U, TEST_LOCATION);
4683   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
4684   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer1, TEST_LOCATION);
4685   DALI_TEST_EQUALS(actor.GetRendererAt(1), renderer2, TEST_LOCATION);
4686
4687   DALI_TEST_EQUALS(actor.AddRenderer(renderer1), 0U, TEST_LOCATION);
4688   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
4689   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer1, TEST_LOCATION);
4690   DALI_TEST_EQUALS(actor.GetRendererAt(1), renderer2, TEST_LOCATION);
4691
4692   DALI_TEST_EQUALS(actor.AddRenderer(renderer3), 2U, TEST_LOCATION);
4693   DALI_TEST_EQUALS(actor.GetRendererCount(), 3u, TEST_LOCATION);
4694   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer1, TEST_LOCATION);
4695   DALI_TEST_EQUALS(actor.GetRendererAt(1), renderer2, TEST_LOCATION);
4696   DALI_TEST_EQUALS(actor.GetRendererAt(2), renderer3, TEST_LOCATION);
4697
4698   DALI_TEST_EQUALS(actor.AddRenderer(renderer2), 1U, TEST_LOCATION);
4699   DALI_TEST_EQUALS(actor.GetRendererCount(), 3u, TEST_LOCATION);
4700   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer1, TEST_LOCATION);
4701   DALI_TEST_EQUALS(actor.GetRendererAt(1), renderer2, TEST_LOCATION);
4702   DALI_TEST_EQUALS(actor.GetRendererAt(2), renderer3, TEST_LOCATION);
4703
4704   END_TEST;
4705 }
4706
4707 int UtcDaliActorAddRendererN01(void)
4708 {
4709   tet_infoline("Testing Actor::AddRenderer");
4710   TestApplication application;
4711
4712   Actor    actor = Actor::New();
4713   Renderer renderer;
4714
4715   // try illegal Add
4716   try
4717   {
4718     actor.AddRenderer(renderer);
4719     tet_printf("Assertion test failed - no Exception\n");
4720     tet_result(TET_FAIL);
4721   }
4722   catch(Dali::DaliException& e)
4723   {
4724     DALI_TEST_PRINT_ASSERT(e);
4725     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4726     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4727   }
4728   catch(...)
4729   {
4730     tet_printf("Assertion test failed - wrong Exception\n");
4731     tet_result(TET_FAIL);
4732   }
4733
4734   END_TEST;
4735 }
4736
4737 int UtcDaliActorAddRendererN02(void)
4738 {
4739   tet_infoline("UtcDaliActorAddRendererN02");
4740
4741   Actor    actor;
4742   Renderer renderer;
4743
4744   {
4745     TestApplication application;
4746
4747     Geometry geometry = CreateQuadGeometry();
4748     Shader   shader   = CreateShader();
4749     renderer          = Renderer::New(geometry, shader);
4750
4751     actor = Actor::New();
4752   }
4753
4754   // try illegal AddRenderer
4755   try
4756   {
4757     actor.AddRenderer(renderer);
4758     tet_printf("Assertion test failed - no Exception\n");
4759     tet_result(TET_FAIL);
4760   }
4761   catch(Dali::DaliException& e)
4762   {
4763     DALI_TEST_PRINT_ASSERT(e);
4764     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4765   }
4766   catch(...)
4767   {
4768     tet_printf("Assertion test failed - wrong Exception\n");
4769     tet_result(TET_FAIL);
4770   }
4771
4772   END_TEST;
4773 }
4774
4775 int UtcDaliActorAddRendererOnScene(void)
4776 {
4777   tet_infoline("Testing Actor::AddRenderer");
4778   TestApplication application;
4779
4780   Actor actor = Actor::New();
4781   application.GetScene().Add(actor);
4782
4783   application.SendNotification();
4784   application.Render(0);
4785
4786   Geometry geometry = CreateQuadGeometry();
4787   Shader   shader   = CreateShader();
4788   Renderer renderer = Renderer::New(geometry, shader);
4789
4790   application.SendNotification();
4791   application.Render(0);
4792
4793   try
4794   {
4795     actor.AddRenderer(renderer);
4796     tet_result(TET_PASS);
4797   }
4798   catch(...)
4799   {
4800     tet_result(TET_FAIL);
4801   }
4802
4803   END_TEST;
4804 }
4805
4806 int UtcDaliActorRemoveRendererP1(void)
4807 {
4808   tet_infoline("Testing Actor::RemoveRenderer");
4809   TestApplication application;
4810
4811   Actor actor = Actor::New();
4812
4813   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4814
4815   {
4816     Geometry geometry = CreateQuadGeometry();
4817     Shader   shader   = CreateShader();
4818     Renderer renderer = Renderer::New(geometry, shader);
4819
4820     actor.AddRenderer(renderer);
4821     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4822     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4823
4824     application.SendNotification();
4825     application.Render();
4826   }
4827
4828   {
4829     Renderer renderer = actor.GetRendererAt(0);
4830     actor.RemoveRenderer(renderer);
4831     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4832
4833     application.SendNotification();
4834     application.Render();
4835   }
4836
4837   // Call one final time to ensure that the renderer is actually removed after
4838   // the handle goes out of scope, and excercises the deletion code path in
4839   // scene graph and render.
4840   application.SendNotification();
4841   application.Render();
4842
4843   END_TEST;
4844 }
4845
4846 int UtcDaliActorRemoveRendererP2(void)
4847 {
4848   tet_infoline("Testing Actor::RemoveRenderer");
4849   TestApplication application;
4850
4851   Actor actor = Actor::New();
4852
4853   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4854
4855   Geometry geometry = CreateQuadGeometry();
4856   Shader   shader   = CreateShader();
4857   Renderer renderer = Renderer::New(geometry, shader);
4858
4859   actor.AddRenderer(renderer);
4860   application.SendNotification();
4861   application.Render();
4862
4863   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4864   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4865
4866   actor.RemoveRenderer(0);
4867   application.SendNotification();
4868   application.Render();
4869
4870   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4871
4872   // Shut down whilst holding onto the renderer handle.
4873   END_TEST;
4874 }
4875
4876 int UtcDaliActorRemoveRendererP3(void)
4877 {
4878   tet_infoline("Testing Actor::RemoveRenderer");
4879   TestApplication application;
4880
4881   Actor actor1 = Actor::New();
4882   Actor actor2 = Actor::New();
4883   Actor actor3 = Actor::New();
4884
4885   application.GetScene().Add(actor1);
4886   application.GetScene().Add(actor2);
4887   application.GetScene().Add(actor3);
4888
4889   // Make each actors size bigger than zero, so we can assuem that actor is rendered
4890   actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4891   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4892   actor3.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4893
4894   // Register some dummy property to seperate actor1 and actor2 in Render::Renderer
4895   actor1.RegisterProperty("dummy1", 1);
4896   actor2.RegisterProperty("dummy2", 2.0f);
4897   actor3.RegisterProperty("dummy3", Vector2(3.0f, 4.0f));
4898
4899   DALI_TEST_EQUALS(actor1.GetRendererCount(), 0u, TEST_LOCATION);
4900   DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
4901   DALI_TEST_EQUALS(actor3.GetRendererCount(), 0u, TEST_LOCATION);
4902
4903   Geometry geometry  = CreateQuadGeometry();
4904   Shader   shader    = CreateShader();
4905   Renderer renderer1 = Renderer::New(geometry, shader);
4906   Renderer renderer2 = Renderer::New(geometry, shader);
4907
4908   actor1.AddRenderer(renderer1);
4909   actor1.AddRenderer(renderer2);
4910   actor2.AddRenderer(renderer1);
4911   actor2.AddRenderer(renderer2);
4912   actor3.AddRenderer(renderer1);
4913   actor3.AddRenderer(renderer2);
4914   application.SendNotification();
4915   application.Render();
4916
4917   DALI_TEST_EQUALS(actor1.GetRendererCount(), 2u, TEST_LOCATION);
4918   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer1, TEST_LOCATION);
4919   DALI_TEST_EQUALS(actor1.GetRendererAt(1), renderer2, TEST_LOCATION);
4920
4921   DALI_TEST_EQUALS(actor2.GetRendererCount(), 2u, TEST_LOCATION);
4922   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4923   DALI_TEST_EQUALS(actor2.GetRendererAt(1), renderer2, TEST_LOCATION);
4924
4925   DALI_TEST_EQUALS(actor3.GetRendererCount(), 2u, TEST_LOCATION);
4926   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer1, TEST_LOCATION);
4927   DALI_TEST_EQUALS(actor3.GetRendererAt(1), renderer2, TEST_LOCATION);
4928
4929   actor1.RemoveRenderer(0);
4930   actor2.RemoveRenderer(1);
4931   actor3.RemoveRenderer(0);
4932   application.SendNotification();
4933   application.Render();
4934
4935   DALI_TEST_EQUALS(actor1.GetRendererCount(), 1u, TEST_LOCATION);
4936   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer2, TEST_LOCATION);
4937   DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
4938   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4939   DALI_TEST_EQUALS(actor3.GetRendererCount(), 1u, TEST_LOCATION);
4940   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer2, TEST_LOCATION);
4941
4942   // Shut down whilst holding onto the renderer handle.
4943   END_TEST;
4944 }
4945
4946 int UtcDaliActorRemoveRendererN(void)
4947 {
4948   tet_infoline("Testing Actor::RemoveRenderer");
4949   TestApplication application;
4950
4951   Actor actor = Actor::New();
4952
4953   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4954
4955   Geometry geometry = CreateQuadGeometry();
4956   Shader   shader   = CreateShader();
4957   Renderer renderer = Renderer::New(geometry, shader);
4958
4959   actor.AddRenderer(renderer);
4960   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4961   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4962
4963   actor.RemoveRenderer(10);
4964   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4965   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4966
4967   END_TEST;
4968 }
4969
4970 int UtcDaliActorPropertyClippingP(void)
4971 {
4972   // This test checks the clippingMode property.
4973   tet_infoline("Testing Actor::Property::ClippingMode: P");
4974   TestApplication application;
4975
4976   Actor actor = Actor::New();
4977
4978   // Check default clippingEnabled value.
4979   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4980
4981   int  value          = 0;
4982   bool getValueResult = getValue.Get(value);
4983   DALI_TEST_CHECK(getValueResult);
4984
4985   if(getValueResult)
4986   {
4987     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4988   }
4989
4990   // Check setting the property to the stencil mode.
4991   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4992
4993   // Check the new value was set.
4994   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4995   getValueResult = getValue.Get(value);
4996   DALI_TEST_CHECK(getValueResult);
4997
4998   if(getValueResult)
4999   {
5000     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
5001   }
5002
5003   // Check setting the property to the scissor mode.
5004   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5005
5006   // Check the new value was set.
5007   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
5008   getValueResult = getValue.Get(value);
5009   DALI_TEST_CHECK(getValueResult);
5010
5011   if(getValueResult)
5012   {
5013     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
5014   }
5015   END_TEST;
5016 }
5017
5018 int UtcDaliActorPropertyClippingN(void)
5019 {
5020   // Negative test case for Clipping.
5021   tet_infoline("Testing Actor::Property::ClippingMode: N");
5022   TestApplication application;
5023
5024   Actor actor = Actor::New();
5025
5026   // Check default clippingEnabled value.
5027   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
5028
5029   int  value          = 0;
5030   bool getValueResult = getValue.Get(value);
5031   DALI_TEST_CHECK(getValueResult);
5032
5033   if(getValueResult)
5034   {
5035     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
5036   }
5037
5038   // Check setting an invalid property value won't change the current property value.
5039   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
5040
5041   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
5042   getValueResult = getValue.Get(value);
5043   DALI_TEST_CHECK(getValueResult);
5044
5045   if(getValueResult)
5046   {
5047     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
5048   }
5049
5050   END_TEST;
5051 }
5052
5053 int UtcDaliActorPropertyClippingActor(void)
5054 {
5055   // This test checks that an actor is correctly setup for clipping.
5056   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
5057   TestApplication application;
5058
5059   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5060   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5061   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5062   size_t             startIndex          = 0u;
5063
5064   // Create a clipping actor.
5065   Actor actorDepth1Clip = CreateActorWithContent16x16();
5066   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5067   application.GetScene().Add(actorDepth1Clip);
5068
5069   // Gather the call trace.
5070   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5071
5072   // Check we are writing to the color buffer.
5073   CheckColorMask(glAbstraction, true);
5074
5075   // Check the stencil buffer was enabled.
5076   std::ostringstream oss;
5077   oss << std::hex << GL_STENCIL_TEST;
5078   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
5079
5080   // Check the stencil buffer was cleared.
5081   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
5082
5083   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
5084   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
5085   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
5086   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5087
5088   END_TEST;
5089 }
5090
5091 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
5092 {
5093   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
5094   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
5095   TestApplication application;
5096
5097   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5098   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5099   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5100   size_t             startIndex          = 0u;
5101
5102   // Create a clipping actor.
5103   Actor actorDepth1Clip = CreateActorWithContent16x16();
5104   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5105   application.GetScene().Add(actorDepth1Clip);
5106
5107   // Gather the call trace.
5108   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5109
5110   // Check we are writing to the color buffer.
5111   CheckColorMask(glAbstraction, true);
5112
5113   // Check the stencil buffer was enabled.
5114   std::ostringstream oss;
5115   oss << std::hex << GL_STENCIL_TEST;
5116   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
5117
5118   // Check the stencil buffer was cleared.
5119   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
5120
5121   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
5122   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
5123   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
5124   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5125
5126   // Now disable the clipping
5127   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
5128
5129   // Gather the call trace.
5130   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5131
5132   // Check the stencil buffer was disabled.
5133   std::ostringstream stencil;
5134   stencil << std::hex << GL_STENCIL_TEST;
5135   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
5136
5137   // Ensure all values in stencil-mask are set to 1.
5138   startIndex = 0u;
5139   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
5140
5141   END_TEST;
5142 }
5143
5144 int UtcDaliActorPropertyClippingNestedChildren(void)
5145 {
5146   // This test checks that a hierarchy of actors are clipped correctly by
5147   // writing to and reading from the correct bit-planes of the stencil buffer.
5148   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
5149   TestApplication    application;
5150   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5151   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5152   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5153
5154   // Create a clipping actor.
5155   Actor actorDepth1Clip = CreateActorWithContent16x16();
5156   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5157   application.GetScene().Add(actorDepth1Clip);
5158
5159   // Create a child actor.
5160   Actor childDepth2 = CreateActorWithContent16x16();
5161   actorDepth1Clip.Add(childDepth2);
5162
5163   // Create another clipping actor.
5164   Actor childDepth2Clip = CreateActorWithContent16x16();
5165   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5166   childDepth2.Add(childDepth2Clip);
5167
5168   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
5169   // This tests the sort algorithm.
5170   Actor childDepth3 = CreateActorWithContent16x16();
5171   childDepth2Clip.Add(childDepth3);
5172   Actor childDepth4 = CreateActorWithContent16x16();
5173   childDepth3.Add(childDepth4);
5174
5175   // Gather the call trace.
5176   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5177
5178   // Check we are writing to the color buffer.
5179   CheckColorMask(glAbstraction, true);
5180
5181   // Check the stencil buffer was enabled.
5182   std::ostringstream oss;
5183   oss << std::hex << GL_STENCIL_TEST;
5184   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
5185
5186   // Perform the test twice, once for 2D layer, and once for 3D.
5187   for(unsigned int i = 0u; i < 2u; ++i)
5188   {
5189     size_t startIndex = 0u;
5190
5191     // Check the stencil buffer was cleared.
5192     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
5193
5194     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
5195     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
5196     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
5197     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5198
5199     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
5200     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
5201     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
5202
5203     // Check we are set up to write to the second bitplane of the stencil buffer (only).
5204     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
5205     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
5206     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5207
5208     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
5209     // (Both must be set to pass the check).
5210     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
5211     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
5212
5213     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
5214     if(i == 0u)
5215     {
5216       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
5217       GenerateTrace(application, enabledDisableTrace, stencilTrace);
5218     }
5219   }
5220
5221   END_TEST;
5222 }
5223
5224 int UtcDaliActorPropertyClippingActorDrawOrder(void)
5225 {
5226   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
5227   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
5228   TestApplication    application;
5229   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5230   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5231
5232   /* We create a small tree of actors as follows:
5233
5234                            A
5235                           / \
5236      Clipping enabled -> B   D
5237                          |   |
5238                          C   E
5239
5240      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
5241   */
5242   Actor actors[5];
5243   for(int i = 0; i < 5; ++i)
5244   {
5245     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
5246     Actor   actor = CreateRenderableActor(image);
5247
5248     // Setup dimensions and position so actor is not skipped by culling.
5249     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
5250     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
5251
5252     if(i == 0)
5253     {
5254       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5255     }
5256     else
5257     {
5258       float b = i > 2 ? 1.0f : -1.0f;
5259       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
5260     }
5261
5262     actors[i] = actor;
5263   }
5264
5265   // Enable clipping on the actor at the top of the left branch.
5266   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5267
5268   // Build the scene graph.
5269   application.GetScene().Add(actors[0]);
5270
5271   // Left branch:
5272   actors[0].Add(actors[1]);
5273   actors[1].Add(actors[2]);
5274
5275   // Right branch:
5276   actors[0].Add(actors[3]);
5277   actors[3].Add(actors[4]);
5278
5279   // Gather the call trace.
5280   enabledDisableTrace.Reset();
5281   enabledDisableTrace.Enable(true);
5282   application.SendNotification();
5283   application.Render();
5284   enabledDisableTrace.Enable(false);
5285
5286   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
5287
5288      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
5289            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
5290   */
5291   size_t             startIndex = 0u;
5292   std::ostringstream blend;
5293   blend << std::hex << GL_BLEND;
5294   std::ostringstream stencil;
5295   stencil << std::hex << GL_STENCIL_TEST;
5296
5297   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
5298   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5299   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5300
5301   // Swap the clipping actor from top of left branch to top of right branch.
5302   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
5303   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5304
5305   // Gather the call trace.
5306   enabledDisableTrace.Reset();
5307   enabledDisableTrace.Enable(true);
5308   application.SendNotification();
5309   application.Render();
5310   enabledDisableTrace.Enable(false);
5311
5312   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
5313   // This proves the draw order has remained the same.
5314   startIndex = 0u;
5315   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5316   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5317
5318   END_TEST;
5319 }
5320
5321 int UtcDaliActorPropertyScissorClippingActor01(void)
5322 {
5323   // This test checks that an actor is correctly setup for clipping.
5324   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
5325   TestApplication application;
5326
5327   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5328   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5329   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5330
5331   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5332   const Vector2 imageSize(16.0f, 16.0f);
5333
5334   // Create a clipping actor.
5335   Actor clippingActorA = CreateActorWithContent16x16();
5336   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5337   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5338   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5339   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5340   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5341   application.GetScene().Add(clippingActorA);
5342
5343   // Gather the call trace.
5344   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5345
5346   // Check we are writing to the color buffer.
5347   CheckColorMask(glAbstraction, true);
5348
5349   // Check scissor test was enabled.
5350
5351   std::ostringstream scissor;
5352   scissor << std::hex << GL_SCISSOR_TEST;
5353   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5354
5355   // Check the scissor was set, and the coordinates are correct.
5356   std::stringstream compareParametersString;
5357   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
5358   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5359
5360   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5361   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5362
5363   // Gather the call trace.
5364   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5365
5366   // Check the scissor was set, and the coordinates are correct.
5367   compareParametersString.str(std::string());
5368   compareParametersString.clear();
5369   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
5370   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5371
5372   END_TEST;
5373 }
5374
5375 int UtcDaliActorPropertyScissorClippingActor02(void)
5376 {
5377   // This test checks that an actor is correctly setup for clipping.
5378   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
5379   TestApplication application;
5380
5381   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5382   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5383   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5384
5385   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5386   const Vector2 actorSize(16.0f, 16.0f);
5387
5388   // Create a clipping actor.
5389   Actor clippingActorA                  = CreateRenderableActor();
5390   clippingActorA[Actor::Property::SIZE] = actorSize;
5391
5392   Renderer renderer = clippingActorA.GetRendererAt(0);
5393   DALI_TEST_CHECK(renderer);
5394
5395   // Make Renderer opacity 0.
5396   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
5397
5398   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5399   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5400   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5401   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5402   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5403   application.GetScene().Add(clippingActorA);
5404
5405   // Gather the call trace.
5406   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5407
5408   // Check we are writing to the color buffer.
5409   CheckColorMask(glAbstraction, true);
5410
5411   // Check scissor test was enabled.
5412
5413   std::ostringstream scissor;
5414   scissor << std::hex << GL_SCISSOR_TEST;
5415   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5416
5417   // Check the scissor was set, and the coordinates are correct.
5418   std::stringstream compareParametersString;
5419   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5420   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5421
5422   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5423   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5424
5425   // Gather the call trace.
5426   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5427
5428   // Check the scissor was set, and the coordinates are correct.
5429   compareParametersString.str(std::string());
5430   compareParametersString.clear();
5431   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5432   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5433
5434   END_TEST;
5435 }
5436 int UtcDaliActorPropertyScissorClippingActorWihtoutRenderer(void)
5437 {
5438   // This test checks that an actor is correctly setup for clipping.
5439   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor without renderer");
5440   TestApplication application;
5441
5442   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5443   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5444   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5445
5446   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5447   const Vector2 actorSize(16.0f, 16.0f);
5448
5449   // Create a clipping actor without renderer
5450   Actor clippingActorA                  = Actor::New();
5451   clippingActorA[Actor::Property::SIZE] = actorSize;
5452
5453   // Add dummy actor, to make application would be rendering.
5454   Actor dummyActor                  = CreateRenderableActor();
5455   dummyActor[Actor::Property::SIZE] = actorSize;
5456   clippingActorA.Add(dummyActor);
5457
5458   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5459   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5460   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5461   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5462   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5463   application.GetScene().Add(clippingActorA);
5464
5465   // Gather the call trace.
5466   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5467
5468   // Check we are writing to the color buffer.
5469   CheckColorMask(glAbstraction, true);
5470
5471   // Check scissor test was enabled.
5472
5473   std::ostringstream scissor;
5474   scissor << std::hex << GL_SCISSOR_TEST;
5475   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5476
5477   // Check the scissor was set, and the coordinates are correct.
5478   std::stringstream compareParametersString;
5479   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5480   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5481
5482   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5483   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5484
5485   // Gather the call trace.
5486   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5487
5488   // Check the scissor was set, and the coordinates are correct.
5489   compareParametersString.str(std::string());
5490   compareParametersString.clear();
5491   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5492   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5493
5494   END_TEST;
5495 }
5496
5497 int UtcDaliActorPropertyScissorClippingActorWihtoutRendererUnderLayer3D(void)
5498 {
5499   // This test checks that an actor is correctly setup for clipping.
5500   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor without renderer under layer 3d");
5501   TestApplication application;
5502
5503   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5504   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5505   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5506
5507   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5508   const Vector2 actorSize(16.0f, 16.0f);
5509
5510   // Make root layer as LAYER_3D, to make we follow 3d flow.
5511   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
5512
5513   // Create a clipping actor without renderer
5514   Actor clippingActorA                  = Actor::New();
5515   clippingActorA[Actor::Property::SIZE] = actorSize;
5516
5517   // Add dummy actor, to make application would be rendering.
5518   Actor dummyActor                  = CreateRenderableActor();
5519   dummyActor[Actor::Property::SIZE] = actorSize;
5520   clippingActorA.Add(dummyActor);
5521
5522   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5523   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5524   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5525   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5526   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5527   application.GetScene().Add(clippingActorA);
5528
5529   // Gather the call trace.
5530   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5531
5532   // Check we are writing to the color buffer.
5533   CheckColorMask(glAbstraction, true);
5534
5535   // Check scissor test was enabled.
5536
5537   std::ostringstream scissor;
5538   scissor << std::hex << GL_SCISSOR_TEST;
5539   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5540
5541   // Check the scissor was set, and the coordinates are correct.
5542   std::stringstream compareParametersString;
5543   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5544   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5545
5546   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5547   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5548
5549   // Gather the call trace.
5550   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5551
5552   // Check the scissor was set, and the coordinates are correct.
5553   compareParametersString.str(std::string());
5554   compareParametersString.clear();
5555   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5556   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5557
5558   END_TEST;
5559 }
5560
5561 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5562 {
5563   // This test checks that an actor is correctly setup for clipping.
5564   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5565   TestApplication application;
5566
5567   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5568   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5569   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5570
5571   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5572   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5573   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5574
5575   // Create a clipping actors.
5576   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5577   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5578
5579   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5580   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5581   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5582
5583   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5584   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5585   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5586
5587   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5588   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5589
5590   application.GetScene().Add(clippingActorA);
5591   application.GetScene().Add(clippingActorB);
5592
5593   // Gather the call trace.
5594   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5595
5596   // Check we are writing to the color buffer.
5597   CheckColorMask(glAbstraction, true);
5598
5599   // Check scissor test was enabled.
5600   std::ostringstream scissor;
5601   scissor << std::hex << GL_SCISSOR_TEST;
5602   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5603
5604   // Check the scissor was set, and the coordinates are correct.
5605   std::stringstream compareParametersString;
5606
5607   std::string clipA("0, 500, 480, 200");
5608   std::string clipB("0, 380, 480, 40");
5609
5610   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5611   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5612
5613   END_TEST;
5614 }
5615
5616 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5617 {
5618   // This test checks that an actor is correctly setup for clipping.
5619   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5620   TestApplication application;
5621
5622   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5623   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5624   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5625
5626   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5627   const Vector2 imageSize(16.0f, 16.0f);
5628
5629   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5630
5631      A is drawn first - with scissor clipping on
5632      B is drawn second - also with scissor clipping on
5633      C is the generated clipping region, the intersection ( A ∩ B )
5634
5635            ┏━━━━━━━┓                   ┌───────┐
5636            ┃     B ┃                   │     B │
5637        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5638        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5639        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5640        │ A     │                   ┊ A     ┊
5641        └───────┘                   └┄┄┄┄┄┄┄┘
5642
5643      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5644   */
5645
5646   // Create a clipping actor.
5647   Actor clippingActorA = CreateActorWithContent16x16();
5648   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5649   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5650   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5651   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5652   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5653   application.GetScene().Add(clippingActorA);
5654
5655   // Create a child clipping actor.
5656   Actor clippingActorB = CreateActorWithContent16x16();
5657   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5658   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5659   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5660   clippingActorA.Add(clippingActorB);
5661
5662   // positionModifiers is an array of positions to position B around.
5663   // expect is an array of expected scissor clip coordinate results.
5664   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5665   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5666
5667   // Loop through each overlap combination.
5668   for(unsigned int test = 0u; test < 4u; ++test)
5669   {
5670     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5671     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5672     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5673
5674     // Gather the call trace.
5675     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5676
5677     // Check we are writing to the color buffer.
5678     CheckColorMask(glAbstraction, true);
5679
5680     // Check scissor test was enabled.
5681     std::ostringstream scissor;
5682     scissor << std::hex << GL_SCISSOR_TEST;
5683     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5684
5685     // Check the scissor was set, and the coordinates are correct.
5686     const Vector4&    expectResults(expect[test]);
5687     std::stringstream compareParametersString;
5688     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5689     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5690   }
5691
5692   END_TEST;
5693 }
5694
5695 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5696 {
5697   // This test checks that an actor is correctly setup for clipping.
5698   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5699   TestApplication application;
5700
5701   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5702   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5703   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5704
5705   /* Create a nest of 2 scissors and siblings of the parent.
5706
5707             stage
5708               |
5709         ┌─────┐─────┐
5710         A     C     D
5711         |           |
5712         B           E
5713   */
5714
5715   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5716   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5717   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5718   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5719   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5720   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5721
5722   // Create a clipping actors.
5723   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5724   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5725   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5726   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5727   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5728
5729   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5730   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5731   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5732
5733   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5734   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5735   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5736
5737   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5738   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5739   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5740
5741   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5742   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5743   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5744
5745   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5746   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5747
5748   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5749   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5750   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5751   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5752   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5753
5754   application.GetScene().Add(clippingActorA);
5755   clippingActorA.Add(clippingActorB);
5756   application.GetScene().Add(clippingActorC);
5757   application.GetScene().Add(clippingActorD);
5758   clippingActorD.Add(clippingActorE);
5759
5760   // Gather the call trace.
5761   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5762
5763   // Check we are writing to the color buffer.
5764   CheckColorMask(glAbstraction, true);
5765
5766   // Check scissor test was enabled.
5767   std::ostringstream scissor;
5768   scissor << std::hex << GL_SCISSOR_TEST;
5769   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5770
5771   // Check the scissor was set, and the coordinates are correct.
5772   std::string clipA("0, 500, 480, 200");
5773   std::string clipB("0, 580, 480, 40");
5774   std::string clipC("0, 200, 480, 200");
5775   std::string clipD("0, 300, 480, 200");
5776
5777   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5778   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5779   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5780   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5781   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5782
5783   END_TEST;
5784 }
5785
5786 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5787 {
5788   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5789   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5790   TestApplication application;
5791
5792   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5793   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5794   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5795
5796   // Create a clipping actor.
5797   Actor actorDepth1Clip = CreateActorWithContent16x16();
5798   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5799   application.GetScene().Add(actorDepth1Clip);
5800
5801   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5802   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5803
5804   // Gather the call trace.
5805   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5806
5807   // Check we are writing to the color buffer.
5808   CheckColorMask(glAbstraction, true);
5809
5810   // Check the stencil buffer was not enabled.
5811   std::ostringstream stencil;
5812   stencil << std::hex << GL_STENCIL_TEST;
5813   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5814
5815   // Check stencil functions are not called.
5816   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5817   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5818
5819   // Check that scissor clipping is overriden by the renderer properties.
5820   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5821
5822   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5823
5824   // Gather the call trace.
5825   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5826
5827   // Check the stencil buffer was not enabled.
5828   std::ostringstream scissor;
5829   scissor << std::hex << GL_SCISSOR_TEST;
5830   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5831
5832   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5833
5834   END_TEST;
5835 }
5836
5837 int UtcDaliActorPropertyClippingActorCulled(void)
5838 {
5839   // This test checks that child actors are clipped by an culled parent actor.
5840   tet_infoline("Testing child actors are clipped by an culled parent actor");
5841   TestApplication application;
5842
5843   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5844   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5845   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5846
5847   const Vector2 actorSize(160.0f, 160.0f);
5848
5849   // Create a clipping actor.
5850   Actor clippingActorA                  = CreateRenderableActor();
5851   clippingActorA[Actor::Property::SIZE] = actorSize;
5852
5853   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5854   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5855   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5856   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5857   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5858   application.GetScene().Add(clippingActorA);
5859
5860   // Create a child actor
5861   Actor childActor                              = CreateRenderableActor();
5862   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5863   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5864   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5865   childActor[Actor::Property::INHERIT_POSITION] = false;
5866
5867   // Gather the call trace.
5868   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5869
5870   // Check scissor test was enabled.
5871   std::ostringstream scissor;
5872   scissor << std::hex << GL_SCISSOR_TEST;
5873   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5874
5875   // Check the scissor was set, and the coordinates are correct.
5876   std::stringstream compareParametersString;
5877   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5878   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5879
5880   // Move the clipping actor out of screen
5881   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5882
5883   // Gather the call trace.
5884   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5885
5886   // Check the scissor was set, and the coordinates are correct.
5887   compareParametersString.str(std::string());
5888   compareParametersString.clear();
5889   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5890   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5891
5892   END_TEST;
5893 }
5894
5895 int UtcDaliGetPropertyN(void)
5896 {
5897   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5898   TestApplication application;
5899
5900   Actor actor = Actor::New();
5901
5902   unsigned int propertyCount = actor.GetPropertyCount();
5903   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5904   END_TEST;
5905 }
5906
5907 int UtcDaliActorRaiseLower(void)
5908 {
5909   tet_infoline("UtcDaliActor Raise and Lower test\n");
5910
5911   TestApplication application;
5912
5913   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5914   Debug::Filter::EnableGlobalTrace();
5915
5916   Integration::Scene stage(application.GetScene());
5917
5918   Actor actorA = Actor::New();
5919   Actor actorB = Actor::New();
5920   Actor actorC = Actor::New();
5921
5922   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5923   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5924
5925   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5926   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5927
5928   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5929   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5930
5931   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5932   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5933
5934   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5935   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5936
5937   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5938   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5939
5940   stage.Add(actorA);
5941   stage.Add(actorB);
5942   stage.Add(actorC);
5943
5944   ResetTouchCallbacks();
5945
5946   application.SendNotification();
5947   application.Render();
5948
5949   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5950   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5951   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5952
5953   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5954   // Only top actor will get touched.
5955   actorA.TouchedSignal().Connect(TestTouchCallback);
5956   actorB.TouchedSignal().Connect(TestTouchCallback2);
5957   actorC.TouchedSignal().Connect(TestTouchCallback3);
5958
5959   // Connect ChildOrderChangedSignal
5960   bool                     orderChangedSignal(false);
5961   Actor                    orderChangedActor;
5962   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5963   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5964
5965   Dali::Integration::Point point;
5966   point.SetDeviceId(1);
5967   point.SetState(PointState::DOWN);
5968   point.SetScreenPosition(Vector2(10.f, 10.f));
5969   Dali::Integration::TouchEvent touchEvent;
5970   touchEvent.AddPoint(point);
5971
5972   application.ProcessEvent(touchEvent);
5973
5974   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5975   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5976   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5977
5978   ResetTouchCallbacks();
5979
5980   tet_printf("Testing Raising of Actor\n");
5981
5982   int preActorOrder(0);
5983   int postActorOrder(0);
5984
5985   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5986   value.Get(preActorOrder);
5987
5988   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5989   actorB.Raise();
5990   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5991   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5992
5993   // Ensure sort order is calculated before next touch event
5994   application.SendNotification();
5995
5996   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5997   value.Get(postActorOrder);
5998
5999   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
6000
6001   application.ProcessEvent(touchEvent);
6002
6003   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6004   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6005   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6006
6007   ResetTouchCallbacks();
6008
6009   tet_printf("Testing Lowering of Actor\n");
6010
6011   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6012   value.Get(preActorOrder);
6013
6014   orderChangedSignal = false;
6015
6016   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6017   actorB.Lower();
6018   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6019   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6020
6021   application.SendNotification(); // ensure sort order calculated before next touch event
6022
6023   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6024   value.Get(postActorOrder);
6025
6026   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
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   Debug::Filter::DisableGlobalTrace();
6037   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
6038
6039   END_TEST;
6040 }
6041
6042 int UtcDaliActorGeoTouchRaiseLower(void)
6043 {
6044   tet_infoline("UtcDaliActor Raise and Lower test\n");
6045
6046   TestApplication application;
6047
6048   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
6049   Debug::Filter::EnableGlobalTrace();
6050
6051   Integration::Scene stage(application.GetScene());
6052
6053   Actor actorA = Actor::New();
6054   Actor actorB = Actor::New();
6055   Actor actorC = Actor::New();
6056
6057   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6058   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6059
6060   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6061   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6062
6063   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6064   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6065
6066   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6067   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6068
6069   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6070   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6071
6072   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6073   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6074
6075   stage.Add(actorA);
6076   stage.Add(actorB);
6077   stage.Add(actorC);
6078
6079   application.GetScene().SetGeometryHittestEnabled(true);
6080   ResetTouchCallbacks(application);
6081
6082   application.SendNotification();
6083   application.Render();
6084
6085   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6086   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6087   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6088
6089   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6090   // Only top actor will get touched.
6091   actorA.TouchedSignal().Connect(TestTouchCallback);
6092   actorB.TouchedSignal().Connect(TestTouchCallback2);
6093   actorC.TouchedSignal().Connect(TestTouchCallback3);
6094
6095   // Connect ChildOrderChangedSignal
6096   bool                     orderChangedSignal(false);
6097   Actor                    orderChangedActor;
6098   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6099   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6100
6101   Dali::Integration::Point point;
6102   point.SetDeviceId(1);
6103   point.SetState(PointState::DOWN);
6104   point.SetScreenPosition(Vector2(10.f, 10.f));
6105   Dali::Integration::TouchEvent touchEvent;
6106   touchEvent.AddPoint(point);
6107
6108   application.ProcessEvent(touchEvent);
6109
6110   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6111   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6112   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6113
6114   ResetTouchCallbacks(application);
6115
6116   tet_printf("Testing Raising of Actor\n");
6117
6118   int preActorOrder(0);
6119   int postActorOrder(0);
6120
6121   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6122   value.Get(preActorOrder);
6123
6124   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6125   actorB.Raise();
6126   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6127   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6128
6129   // Ensure sort order is calculated before next touch event
6130   application.SendNotification();
6131
6132   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6133   value.Get(postActorOrder);
6134
6135   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
6136
6137   application.ProcessEvent(touchEvent);
6138
6139   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6140   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6141   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6142
6143   ResetTouchCallbacks(application);
6144
6145   tet_printf("Testing Lowering of Actor\n");
6146
6147   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6148   value.Get(preActorOrder);
6149
6150   orderChangedSignal = false;
6151
6152   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6153   actorB.Lower();
6154   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6155   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6156
6157   application.SendNotification(); // ensure sort order calculated before next touch event
6158
6159   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6160   value.Get(postActorOrder);
6161
6162   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
6163
6164   application.ProcessEvent(touchEvent);
6165
6166   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6167   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6168   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6169
6170   ResetTouchCallbacks(application);
6171
6172   Debug::Filter::DisableGlobalTrace();
6173   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
6174
6175   END_TEST;
6176 }
6177
6178 int UtcDaliActorRaiseToTopLowerToBottom(void)
6179 {
6180   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
6181
6182   TestApplication application;
6183
6184   Integration::Scene stage(application.GetScene());
6185
6186   Actor actorA = Actor::New();
6187   Actor actorB = Actor::New();
6188   Actor actorC = Actor::New();
6189
6190   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6191   // enables checking of which actor the uniform is assigned too
6192   Shader shaderA = CreateShader();
6193   shaderA.RegisterProperty("uRendererColor", 1.f);
6194
6195   Shader shaderB = CreateShader();
6196   shaderB.RegisterProperty("uRendererColor", 2.f);
6197
6198   Shader shaderC = CreateShader();
6199   shaderC.RegisterProperty("uRendererColor", 3.f);
6200
6201   Geometry geometry = CreateQuadGeometry();
6202
6203   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6204   Renderer rendererA = Renderer::New(geometry, shaderA);
6205   actorA.AddRenderer(rendererA);
6206
6207   Renderer rendererB = Renderer::New(geometry, shaderB);
6208   actorB.AddRenderer(rendererB);
6209
6210   Renderer rendererC = Renderer::New(geometry, shaderC);
6211   actorC.AddRenderer(rendererC);
6212
6213   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6214   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6215
6216   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6217   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6218
6219   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6220   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6221
6222   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6223   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6224
6225   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6226   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6227
6228   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6229   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6230
6231   stage.Add(actorA);
6232   stage.Add(actorB);
6233   stage.Add(actorC);
6234
6235   ResetTouchCallbacks();
6236
6237   // Connect ChildOrderChangedSignal
6238   bool                     orderChangedSignal(false);
6239   Actor                    orderChangedActor;
6240   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6241   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6242
6243   // Set up gl abstraction trace so can query the set uniform order
6244   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6245   glAbstraction.EnableSetUniformCallTrace(true);
6246   glAbstraction.ResetSetUniformCallStack();
6247
6248   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6249
6250   application.SendNotification();
6251   application.Render();
6252
6253   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
6254
6255   // Test order of uniforms in stack
6256   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6257   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6258   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6259
6260   bool CBA = (indexC > indexB) && (indexB > indexA);
6261
6262   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6263
6264   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6265   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6266   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6267
6268   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6269   // Only top actor will get touched.
6270   actorA.TouchedSignal().Connect(TestTouchCallback);
6271   actorB.TouchedSignal().Connect(TestTouchCallback2);
6272   actorC.TouchedSignal().Connect(TestTouchCallback3);
6273
6274   Dali::Integration::Point point;
6275   point.SetDeviceId(1);
6276   point.SetState(PointState::DOWN);
6277   point.SetScreenPosition(Vector2(10.f, 10.f));
6278   Dali::Integration::TouchEvent touchEvent;
6279   touchEvent.AddPoint(point);
6280
6281   application.ProcessEvent(touchEvent);
6282
6283   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6284   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6285   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6286
6287   ResetTouchCallbacks();
6288
6289   tet_printf("RaiseToTop ActorA\n");
6290
6291   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6292   actorA.RaiseToTop();
6293   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6294   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6295
6296   application.SendNotification(); // ensure sorting order is calculated before next touch event
6297
6298   application.ProcessEvent(touchEvent);
6299
6300   glSetUniformStack.Reset();
6301
6302   application.SendNotification();
6303   application.Render();
6304
6305   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6306
6307   // Test order of uniforms in stack
6308   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6309   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6310   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6311
6312   tet_infoline("Testing A above C and B at bottom\n");
6313   bool ACB = (indexA > indexC) && (indexC > indexB);
6314
6315   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
6316
6317   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6318   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6319   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6320
6321   ResetTouchCallbacks();
6322
6323   tet_printf("RaiseToTop ActorB\n");
6324
6325   orderChangedSignal = false;
6326
6327   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6328   actorB.RaiseToTop();
6329   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6330   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6331
6332   application.SendNotification(); // Ensure sort order is calculated before next touch event
6333
6334   application.ProcessEvent(touchEvent);
6335
6336   glSetUniformStack.Reset();
6337
6338   application.SendNotification();
6339   application.Render();
6340
6341   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6342
6343   // Test order of uniforms in stack
6344   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6345   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6346   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6347
6348   tet_infoline("Testing B above A and C at bottom\n");
6349   bool BAC = (indexB > indexA) && (indexA > indexC);
6350
6351   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
6352
6353   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6354   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6355   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6356
6357   ResetTouchCallbacks();
6358
6359   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
6360
6361   orderChangedSignal = false;
6362
6363   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6364   actorA.LowerToBottom();
6365   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6366   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6367
6368   application.SendNotification();
6369   application.Render();
6370
6371   orderChangedSignal = false;
6372
6373   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6374   actorB.LowerToBottom();
6375   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6376   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6377
6378   application.SendNotification();
6379   application.Render();
6380
6381   application.ProcessEvent(touchEvent);
6382
6383   glSetUniformStack.Reset();
6384
6385   application.SendNotification();
6386   application.Render();
6387
6388   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6389
6390   // Test order of uniforms in stack
6391   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6392   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6393   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6394
6395   tet_infoline("Testing C above A and B at bottom\n");
6396   bool CAB = (indexC > indexA) && (indexA > indexB);
6397
6398   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
6399
6400   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6401   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6402   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6403
6404   ResetTouchCallbacks();
6405
6406   END_TEST;
6407 }
6408
6409 int UtcDaliActorGeoTouchRaiseToTopLowerToBottom(void)
6410 {
6411   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
6412
6413   TestApplication application;
6414
6415   Integration::Scene stage(application.GetScene());
6416
6417   Actor actorA = Actor::New();
6418   Actor actorB = Actor::New();
6419   Actor actorC = Actor::New();
6420
6421   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6422   // enables checking of which actor the uniform is assigned too
6423   Shader shaderA = CreateShader();
6424   shaderA.RegisterProperty("uRendererColor", 1.f);
6425
6426   Shader shaderB = CreateShader();
6427   shaderB.RegisterProperty("uRendererColor", 2.f);
6428
6429   Shader shaderC = CreateShader();
6430   shaderC.RegisterProperty("uRendererColor", 3.f);
6431
6432   Geometry geometry = CreateQuadGeometry();
6433
6434   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6435   Renderer rendererA = Renderer::New(geometry, shaderA);
6436   actorA.AddRenderer(rendererA);
6437
6438   Renderer rendererB = Renderer::New(geometry, shaderB);
6439   actorB.AddRenderer(rendererB);
6440
6441   Renderer rendererC = Renderer::New(geometry, shaderC);
6442   actorC.AddRenderer(rendererC);
6443
6444   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6445   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6446
6447   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6448   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6449
6450   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6451   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6452
6453   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6454   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6455
6456   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6457   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6458
6459   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6460   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6461
6462   stage.Add(actorA);
6463   stage.Add(actorB);
6464   stage.Add(actorC);
6465
6466   application.GetScene().SetGeometryHittestEnabled(true);
6467   ResetTouchCallbacks(application);
6468
6469   // Connect ChildOrderChangedSignal
6470   bool                     orderChangedSignal(false);
6471   Actor                    orderChangedActor;
6472   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6473   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6474
6475   // Set up gl abstraction trace so can query the set uniform order
6476   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6477   glAbstraction.EnableSetUniformCallTrace(true);
6478   glAbstraction.ResetSetUniformCallStack();
6479
6480   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6481
6482   application.SendNotification();
6483   application.Render();
6484
6485   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
6486
6487   // Test order of uniforms in stack
6488   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6489   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6490   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6491
6492   bool CBA = (indexC > indexB) && (indexB > indexA);
6493
6494   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6495
6496   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6497   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6498   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6499
6500   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6501   // Only top actor will get touched.
6502   actorA.TouchedSignal().Connect(TestTouchCallback);
6503   actorB.TouchedSignal().Connect(TestTouchCallback2);
6504   actorC.TouchedSignal().Connect(TestTouchCallback3);
6505
6506   Dali::Integration::Point point;
6507   point.SetDeviceId(1);
6508   point.SetState(PointState::DOWN);
6509   point.SetScreenPosition(Vector2(10.f, 10.f));
6510   Dali::Integration::TouchEvent touchEvent;
6511   touchEvent.AddPoint(point);
6512
6513   application.ProcessEvent(touchEvent);
6514
6515   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6516   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6517   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6518
6519   ResetTouchCallbacks(application);
6520
6521   tet_printf("RaiseToTop ActorA\n");
6522
6523   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6524   actorA.RaiseToTop();
6525   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6526   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6527
6528   application.SendNotification(); // ensure sorting order is calculated before next touch event
6529
6530   application.ProcessEvent(touchEvent);
6531
6532   glSetUniformStack.Reset();
6533
6534   application.SendNotification();
6535   application.Render();
6536
6537   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6538
6539   // Test order of uniforms in stack
6540   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6541   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6542   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6543
6544   tet_infoline("Testing A above C and B at bottom\n");
6545   bool ACB = (indexA > indexC) && (indexC > indexB);
6546
6547   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
6548
6549   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6550   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6551   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6552
6553   ResetTouchCallbacks(application);
6554
6555   tet_printf("RaiseToTop ActorB\n");
6556
6557   orderChangedSignal = false;
6558
6559   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6560   actorB.RaiseToTop();
6561   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6562   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6563
6564   application.SendNotification(); // Ensure sort order is calculated before next touch event
6565
6566   application.ProcessEvent(touchEvent);
6567
6568   glSetUniformStack.Reset();
6569
6570   application.SendNotification();
6571   application.Render();
6572
6573   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6574
6575   // Test order of uniforms in stack
6576   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6577   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6578   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6579
6580   tet_infoline("Testing B above A and C at bottom\n");
6581   bool BAC = (indexB > indexA) && (indexA > indexC);
6582
6583   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
6584
6585   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6586   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6587   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6588
6589   ResetTouchCallbacks(application);
6590
6591   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
6592
6593   orderChangedSignal = false;
6594
6595   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6596   actorA.LowerToBottom();
6597   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6598   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6599
6600   application.SendNotification();
6601   application.Render();
6602
6603   orderChangedSignal = false;
6604
6605   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6606   actorB.LowerToBottom();
6607   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6608   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6609
6610   application.SendNotification();
6611   application.Render();
6612
6613   application.ProcessEvent(touchEvent);
6614
6615   glSetUniformStack.Reset();
6616
6617   application.SendNotification();
6618   application.Render();
6619
6620   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6621
6622   // Test order of uniforms in stack
6623   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6624   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6625   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6626
6627   tet_infoline("Testing C above A and B at bottom\n");
6628   bool CAB = (indexC > indexA) && (indexA > indexB);
6629
6630   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
6631
6632   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6633   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6634   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6635
6636   ResetTouchCallbacks(application);
6637
6638   END_TEST;
6639 }
6640
6641 int UtcDaliActorRaiseAbove(void)
6642 {
6643   tet_infoline("UtcDaliActor RaiseToAbove test \n");
6644
6645   TestApplication application;
6646
6647   Integration::Scene stage(application.GetScene());
6648
6649   Actor actorA = Actor::New();
6650   Actor actorB = Actor::New();
6651   Actor actorC = Actor::New();
6652
6653   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6654   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6655
6656   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6657   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6658
6659   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6660   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6661
6662   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6663   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6664
6665   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6666   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6667
6668   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6669   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6670
6671   stage.Add(actorA);
6672   stage.Add(actorB);
6673   stage.Add(actorC);
6674
6675   ResetTouchCallbacks();
6676
6677   application.SendNotification();
6678   application.Render();
6679
6680   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6681   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6682   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6683
6684   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6685   // Only top actor will get touched.
6686   actorA.TouchedSignal().Connect(TestTouchCallback);
6687   actorB.TouchedSignal().Connect(TestTouchCallback2);
6688   actorC.TouchedSignal().Connect(TestTouchCallback3);
6689
6690   bool                     orderChangedSignal(false);
6691   Actor                    orderChangedActor;
6692   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6693   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6694
6695   Dali::Integration::Point point;
6696   point.SetDeviceId(1);
6697   point.SetState(PointState::DOWN);
6698   point.SetScreenPosition(Vector2(10.f, 10.f));
6699   Dali::Integration::TouchEvent touchEvent;
6700   touchEvent.AddPoint(point);
6701
6702   application.ProcessEvent(touchEvent);
6703
6704   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6705   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6706   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6707
6708   ResetTouchCallbacks();
6709
6710   tet_printf("Raise actor B Above Actor C\n");
6711
6712   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6713   actorB.RaiseAbove(actorC);
6714   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6715   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6716
6717   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6718   application.SendNotification();
6719   application.ProcessEvent(touchEvent);
6720
6721   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6722   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6723   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6724
6725   ResetTouchCallbacks();
6726
6727   tet_printf("Raise actor A Above Actor B\n");
6728
6729   orderChangedSignal = false;
6730
6731   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6732   actorA.RaiseAbove(actorB);
6733   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6734   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6735
6736   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6737   application.SendNotification();
6738
6739   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6740
6741   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6742   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6743   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6744
6745   ResetTouchCallbacks();
6746
6747   END_TEST;
6748 }
6749
6750 int UtcDaliActorGeoTouchRaiseAbove(void)
6751 {
6752   tet_infoline("UtcDaliActor RaiseToAbove test \n");
6753
6754   TestApplication application;
6755
6756   Integration::Scene stage(application.GetScene());
6757
6758   Actor actorA = Actor::New();
6759   Actor actorB = Actor::New();
6760   Actor actorC = Actor::New();
6761
6762   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6763   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6764
6765   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6766   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6767
6768   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6769   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6770
6771   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6772   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6773
6774   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6775   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6776
6777   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6778   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6779
6780   stage.Add(actorA);
6781   stage.Add(actorB);
6782   stage.Add(actorC);
6783
6784   application.GetScene().SetGeometryHittestEnabled(true);
6785   ResetTouchCallbacks(application);
6786
6787   application.SendNotification();
6788   application.Render();
6789
6790   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6791   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6792   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6793
6794   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6795   // Only top actor will get touched.
6796   actorA.TouchedSignal().Connect(TestTouchCallback);
6797   actorB.TouchedSignal().Connect(TestTouchCallback2);
6798   actorC.TouchedSignal().Connect(TestTouchCallback3);
6799
6800   bool                     orderChangedSignal(false);
6801   Actor                    orderChangedActor;
6802   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6803   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6804
6805   Dali::Integration::Point point;
6806   point.SetDeviceId(1);
6807   point.SetState(PointState::DOWN);
6808   point.SetScreenPosition(Vector2(10.f, 10.f));
6809   Dali::Integration::TouchEvent touchEvent;
6810   touchEvent.AddPoint(point);
6811
6812   application.ProcessEvent(touchEvent);
6813
6814   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6815   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6816   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6817
6818   ResetTouchCallbacks(application);
6819
6820   tet_printf("Raise actor B Above Actor C\n");
6821
6822   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6823   actorB.RaiseAbove(actorC);
6824   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6825   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6826
6827   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6828   application.SendNotification();
6829   application.ProcessEvent(touchEvent);
6830
6831   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6832   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6833   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6834
6835   ResetTouchCallbacks(application);
6836
6837   tet_printf("Raise actor A Above Actor B\n");
6838
6839   orderChangedSignal = false;
6840
6841   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6842   actorA.RaiseAbove(actorB);
6843   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6844   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6845
6846   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6847   application.SendNotification();
6848
6849   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6850
6851   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6852   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6853   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6854
6855   ResetTouchCallbacks(application);
6856
6857   END_TEST;
6858 }
6859
6860 int UtcDaliActorRaiseAbove2(void)
6861 {
6862   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
6863
6864   TestApplication application;
6865
6866   Integration::Scene stage(application.GetScene());
6867
6868   Actor actorA = Actor::New();
6869   Actor actorB = Actor::New();
6870   Actor actorC = Actor::New();
6871
6872   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6873   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6874
6875   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6876   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6877
6878   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6879   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6880
6881   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6882   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6883
6884   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6885   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6886
6887   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6888   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6889
6890   stage.Add(actorA);
6891   stage.Add(actorB);
6892   stage.Add(actorC);
6893
6894   ResetTouchCallbacks();
6895
6896   application.SendNotification();
6897   application.Render();
6898
6899   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6900   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6901   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6902
6903   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6904   // Only top actor will get touched.
6905   actorA.TouchedSignal().Connect(TestTouchCallback);
6906   actorB.TouchedSignal().Connect(TestTouchCallback2);
6907   actorC.TouchedSignal().Connect(TestTouchCallback3);
6908
6909   bool                     orderChangedSignal(false);
6910   Actor                    orderChangedActor;
6911   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6912   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6913
6914   Dali::Integration::Point point;
6915   point.SetDeviceId(1);
6916   point.SetState(PointState::DOWN);
6917   point.SetScreenPosition(Vector2(10.f, 10.f));
6918   Dali::Integration::TouchEvent touchEvent;
6919   touchEvent.AddPoint(point);
6920
6921   application.ProcessEvent(touchEvent);
6922
6923   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6924   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6925   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6926
6927   ResetTouchCallbacks();
6928
6929   tet_printf("Raise actor B Above Actor C\n");
6930
6931   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6932   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
6933   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
6934   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6935   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6936
6937   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6938   application.SendNotification();
6939   application.ProcessEvent(touchEvent);
6940
6941   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6942   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6943   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6944
6945   ResetTouchCallbacks();
6946
6947   tet_printf("Raise actor A Above Actor B\n");
6948
6949   orderChangedSignal = false;
6950
6951   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6952   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
6953   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6954   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6955   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6956
6957   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6958   application.SendNotification();
6959
6960   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6961
6962   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6963   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6964   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6965
6966   ResetTouchCallbacks();
6967
6968   END_TEST;
6969 }
6970
6971 int UtcDaliActorGeoTouchRaiseAbove2(void)
6972 {
6973   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
6974
6975   TestApplication application;
6976
6977   Integration::Scene stage(application.GetScene());
6978
6979   Actor actorA = Actor::New();
6980   Actor actorB = Actor::New();
6981   Actor actorC = Actor::New();
6982
6983   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6984   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6985
6986   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6987   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6988
6989   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6990   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6991
6992   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6993   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6994
6995   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6996   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6997
6998   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6999   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7000
7001   stage.Add(actorA);
7002   stage.Add(actorB);
7003   stage.Add(actorC);
7004
7005   application.GetScene().SetGeometryHittestEnabled(true);
7006   ResetTouchCallbacks(application);
7007
7008   application.SendNotification();
7009   application.Render();
7010
7011   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7012   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7013   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7014
7015   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7016   // Only top actor will get touched.
7017   actorA.TouchedSignal().Connect(TestTouchCallback);
7018   actorB.TouchedSignal().Connect(TestTouchCallback2);
7019   actorC.TouchedSignal().Connect(TestTouchCallback3);
7020
7021   bool                     orderChangedSignal(false);
7022   Actor                    orderChangedActor;
7023   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7024   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
7025
7026   Dali::Integration::Point point;
7027   point.SetDeviceId(1);
7028   point.SetState(PointState::DOWN);
7029   point.SetScreenPosition(Vector2(10.f, 10.f));
7030   Dali::Integration::TouchEvent touchEvent;
7031   touchEvent.AddPoint(point);
7032
7033   application.ProcessEvent(touchEvent);
7034
7035   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7036   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7037   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7038
7039   ResetTouchCallbacks(application);
7040
7041   tet_printf("Raise actor B Above Actor C\n");
7042
7043   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7044   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
7045   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
7046   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7047   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7048
7049   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7050   application.SendNotification();
7051   application.ProcessEvent(touchEvent);
7052
7053   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7054   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7055   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7056
7057   ResetTouchCallbacks(application);
7058
7059   tet_printf("Raise actor A Above Actor B\n");
7060
7061   orderChangedSignal = false;
7062
7063   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7064   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
7065   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
7066   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7067   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
7068
7069   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7070   application.SendNotification();
7071
7072   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
7073
7074   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
7075   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7076   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7077
7078   ResetTouchCallbacks(application);
7079
7080   END_TEST;
7081 }
7082
7083 int UtcDaliActorLowerBelow(void)
7084 {
7085   tet_infoline("UtcDaliActor LowerBelow test \n");
7086
7087   TestApplication application;
7088
7089   Integration::Scene stage(application.GetScene());
7090
7091   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7092   // enables checking of which actor the uniform is assigned too
7093   Shader shaderA = CreateShader();
7094   shaderA.RegisterProperty("uRendererColor", 1.f);
7095
7096   Shader shaderB = CreateShader();
7097   shaderB.RegisterProperty("uRendererColor", 2.f);
7098
7099   Shader shaderC = CreateShader();
7100   shaderC.RegisterProperty("uRendererColor", 3.f);
7101
7102   Actor actorA = Actor::New();
7103   Actor actorB = Actor::New();
7104   Actor actorC = Actor::New();
7105
7106   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7107   Geometry geometry = CreateQuadGeometry();
7108
7109   Renderer rendererA = Renderer::New(geometry, shaderA);
7110   actorA.AddRenderer(rendererA);
7111
7112   Renderer rendererB = Renderer::New(geometry, shaderB);
7113   actorB.AddRenderer(rendererB);
7114
7115   Renderer rendererC = Renderer::New(geometry, shaderC);
7116   actorC.AddRenderer(rendererC);
7117
7118   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7119   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7120
7121   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7122   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7123
7124   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7125   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7126
7127   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7128   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7129
7130   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7131   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7132
7133   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7134   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7135
7136   Actor container = Actor::New();
7137   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7138   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7139   stage.Add(container);
7140
7141   container.Add(actorA);
7142   container.Add(actorB);
7143   container.Add(actorC);
7144
7145   ResetTouchCallbacks();
7146
7147   // Connect ChildOrderChangedSignal
7148   bool                     orderChangedSignal(false);
7149   Actor                    orderChangedActor;
7150   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7151   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7152
7153   // Set up gl abstraction trace so can query the set uniform order
7154   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7155   glAbstraction.EnableSetUniformCallTrace(true);
7156   glAbstraction.ResetSetUniformCallStack();
7157   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7158
7159   glAbstraction.ResetSetUniformCallStack();
7160
7161   application.SendNotification();
7162   application.Render();
7163
7164   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7165
7166   // Test order of uniforms in stack
7167   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7168   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7169   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7170
7171   tet_infoline("Testing C above B and A at bottom\n");
7172   bool CBA = (indexC > indexB) && (indexB > indexA);
7173
7174   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7175
7176   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7177   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7178   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7179
7180   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7181   // Only top actor will get touched.
7182   actorA.TouchedSignal().Connect(TestTouchCallback);
7183   actorB.TouchedSignal().Connect(TestTouchCallback2);
7184   actorC.TouchedSignal().Connect(TestTouchCallback3);
7185
7186   Dali::Integration::Point point;
7187   point.SetDeviceId(1);
7188   point.SetState(PointState::DOWN);
7189   point.SetScreenPosition(Vector2(10.f, 10.f));
7190   Dali::Integration::TouchEvent touchEvent;
7191   touchEvent.AddPoint(point);
7192
7193   tet_infoline("UtcDaliActor Test Set up completed \n");
7194
7195   application.ProcessEvent(touchEvent);
7196
7197   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7198   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7199   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7200
7201   ResetTouchCallbacks();
7202
7203   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");
7204
7205   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7206   actorC.LowerBelow(actorB);
7207   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7208   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7209
7210   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7211   application.SendNotification();
7212   application.Render();
7213
7214   application.ProcessEvent(touchEvent); // touch event
7215
7216   glSetUniformStack.Reset();
7217
7218   application.SendNotification();
7219   application.Render();
7220
7221   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7222
7223   // Test order of uniforms in stack
7224   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7225   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7226   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7227
7228   tet_infoline("Testing render order is A, C, B");
7229   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7230   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7231
7232   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7233   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7234   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7235
7236   ResetTouchCallbacks();
7237
7238   tet_printf("Lower actor C below Actor A leaving B on top\n");
7239
7240   orderChangedSignal = false;
7241
7242   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7243   actorC.LowerBelow(actorA);
7244   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7245   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7246
7247   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7248   application.SendNotification();
7249   application.Render();
7250
7251   application.ProcessEvent(touchEvent);
7252
7253   glSetUniformStack.Reset();
7254
7255   application.Render();
7256   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7257
7258   // Test order of uniforms in stack
7259   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7260   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7261   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7262
7263   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7264   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7265
7266   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7267   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7268   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7269
7270   ResetTouchCallbacks();
7271
7272   tet_printf("Lower actor B below Actor C leaving A on top\n");
7273
7274   orderChangedSignal = false;
7275
7276   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7277   actorB.LowerBelow(actorC);
7278   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7279   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7280
7281   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7282   application.SendNotification();
7283   application.Render();
7284
7285   application.ProcessEvent(touchEvent);
7286
7287   glSetUniformStack.Reset();
7288
7289   application.Render();
7290   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7291
7292   // Test order of uniforms in stack
7293   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7294   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7295   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7296
7297   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7298   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7299
7300   END_TEST;
7301 }
7302
7303 int UtcDaliActorGeoTouchLowerBelow(void)
7304 {
7305   tet_infoline("UtcDaliActor LowerBelow test \n");
7306
7307   TestApplication application;
7308
7309   Integration::Scene stage(application.GetScene());
7310
7311   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7312   // enables checking of which actor the uniform is assigned too
7313   Shader shaderA = CreateShader();
7314   shaderA.RegisterProperty("uRendererColor", 1.f);
7315
7316   Shader shaderB = CreateShader();
7317   shaderB.RegisterProperty("uRendererColor", 2.f);
7318
7319   Shader shaderC = CreateShader();
7320   shaderC.RegisterProperty("uRendererColor", 3.f);
7321
7322   Actor actorA = Actor::New();
7323   Actor actorB = Actor::New();
7324   Actor actorC = Actor::New();
7325
7326   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7327   Geometry geometry = CreateQuadGeometry();
7328
7329   Renderer rendererA = Renderer::New(geometry, shaderA);
7330   actorA.AddRenderer(rendererA);
7331
7332   Renderer rendererB = Renderer::New(geometry, shaderB);
7333   actorB.AddRenderer(rendererB);
7334
7335   Renderer rendererC = Renderer::New(geometry, shaderC);
7336   actorC.AddRenderer(rendererC);
7337
7338   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7339   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7340
7341   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7342   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7343
7344   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7345   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7346
7347   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7348   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7349
7350   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7351   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7352
7353   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7354   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7355
7356   Actor container = Actor::New();
7357   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7358   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7359   stage.Add(container);
7360
7361   container.Add(actorA);
7362   container.Add(actorB);
7363   container.Add(actorC);
7364
7365   application.GetScene().SetGeometryHittestEnabled(true);
7366   ResetTouchCallbacks(application);
7367
7368   // Connect ChildOrderChangedSignal
7369   bool                     orderChangedSignal(false);
7370   Actor                    orderChangedActor;
7371   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7372   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7373
7374   // Set up gl abstraction trace so can query the set uniform order
7375   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7376   glAbstraction.EnableSetUniformCallTrace(true);
7377   glAbstraction.ResetSetUniformCallStack();
7378   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7379
7380   glAbstraction.ResetSetUniformCallStack();
7381
7382   application.SendNotification();
7383   application.Render();
7384
7385   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7386
7387   // Test order of uniforms in stack
7388   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7389   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7390   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7391
7392   tet_infoline("Testing C above B and A at bottom\n");
7393   bool CBA = (indexC > indexB) && (indexB > indexA);
7394
7395   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7396
7397   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7398   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7399   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7400
7401   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7402   // Only top actor will get touched.
7403   actorA.TouchedSignal().Connect(TestTouchCallback);
7404   actorB.TouchedSignal().Connect(TestTouchCallback2);
7405   actorC.TouchedSignal().Connect(TestTouchCallback3);
7406
7407   Dali::Integration::Point point;
7408   point.SetDeviceId(1);
7409   point.SetState(PointState::DOWN);
7410   point.SetScreenPosition(Vector2(10.f, 10.f));
7411   Dali::Integration::TouchEvent touchEvent;
7412   touchEvent.AddPoint(point);
7413
7414   tet_infoline("UtcDaliActor Test Set up completed \n");
7415
7416   application.ProcessEvent(touchEvent);
7417
7418   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7419   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7420   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7421
7422   ResetTouchCallbacks(application);
7423
7424   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");
7425
7426   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7427   actorC.LowerBelow(actorB);
7428   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7429   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7430
7431   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7432   application.SendNotification();
7433   application.Render();
7434
7435   application.ProcessEvent(touchEvent); // touch event
7436
7437   glSetUniformStack.Reset();
7438
7439   application.SendNotification();
7440   application.Render();
7441
7442   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7443
7444   // Test order of uniforms in stack
7445   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7446   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7447   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7448
7449   tet_infoline("Testing render order is A, C, B");
7450   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7451   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7452
7453   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7454   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7455   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7456
7457   ResetTouchCallbacks(application);
7458
7459   tet_printf("Lower actor C below Actor A leaving B on top\n");
7460
7461   orderChangedSignal = false;
7462
7463   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7464   actorC.LowerBelow(actorA);
7465   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7466   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7467
7468   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7469   application.SendNotification();
7470   application.Render();
7471
7472   application.ProcessEvent(touchEvent);
7473
7474   glSetUniformStack.Reset();
7475
7476   application.Render();
7477   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7478
7479   // Test order of uniforms in stack
7480   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7481   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7482   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7483
7484   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7485   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7486
7487   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7488   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7489   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7490
7491   ResetTouchCallbacks(application);
7492
7493   tet_printf("Lower actor B below Actor C leaving A on top\n");
7494
7495   orderChangedSignal = false;
7496
7497   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7498   actorB.LowerBelow(actorC);
7499   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7500   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7501
7502   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7503   application.SendNotification();
7504   application.Render();
7505
7506   application.ProcessEvent(touchEvent);
7507
7508   glSetUniformStack.Reset();
7509
7510   application.Render();
7511   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7512
7513   // Test order of uniforms in stack
7514   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7515   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7516   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7517
7518   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7519   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7520
7521   END_TEST;
7522 }
7523
7524 int UtcDaliActorLowerBelow2(void)
7525 {
7526   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
7527
7528   TestApplication application;
7529
7530   Integration::Scene stage(application.GetScene());
7531
7532   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7533   // enables checking of which actor the uniform is assigned too
7534   Shader shaderA = CreateShader();
7535   shaderA.RegisterProperty("uRendererColor", 1.f);
7536
7537   Shader shaderB = CreateShader();
7538   shaderB.RegisterProperty("uRendererColor", 2.f);
7539
7540   Shader shaderC = CreateShader();
7541   shaderC.RegisterProperty("uRendererColor", 3.f);
7542
7543   Actor actorA = Actor::New();
7544   Actor actorB = Actor::New();
7545   Actor actorC = Actor::New();
7546
7547   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7548   Geometry geometry = CreateQuadGeometry();
7549
7550   Renderer rendererA = Renderer::New(geometry, shaderA);
7551   actorA.AddRenderer(rendererA);
7552
7553   Renderer rendererB = Renderer::New(geometry, shaderB);
7554   actorB.AddRenderer(rendererB);
7555
7556   Renderer rendererC = Renderer::New(geometry, shaderC);
7557   actorC.AddRenderer(rendererC);
7558
7559   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7560   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7561
7562   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7563   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7564
7565   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7566   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7567
7568   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7569   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7570
7571   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7572   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7573
7574   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7575   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7576
7577   Actor container = Actor::New();
7578   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7579   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7580   stage.Add(container);
7581
7582   container.Add(actorA);
7583   container.Add(actorB);
7584   container.Add(actorC);
7585
7586   ResetTouchCallbacks();
7587
7588   // Connect ChildOrderChangedSignal
7589   bool                     orderChangedSignal(false);
7590   Actor                    orderChangedActor;
7591   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7592   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7593
7594   // Set up gl abstraction trace so can query the set uniform order
7595   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7596   glAbstraction.EnableSetUniformCallTrace(true);
7597   glAbstraction.ResetSetUniformCallStack();
7598   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7599
7600   glAbstraction.ResetSetUniformCallStack();
7601
7602   application.SendNotification();
7603   application.Render();
7604
7605   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7606
7607   // Test order of uniforms in stack
7608   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7609   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7610   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7611
7612   tet_infoline("Testing C above B and A at bottom\n");
7613   bool CBA = (indexC > indexB) && (indexB > indexA);
7614
7615   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7616
7617   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7618   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7619   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7620
7621   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7622   // Only top actor will get touched.
7623   actorA.TouchedSignal().Connect(TestTouchCallback);
7624   actorB.TouchedSignal().Connect(TestTouchCallback2);
7625   actorC.TouchedSignal().Connect(TestTouchCallback3);
7626
7627   Dali::Integration::Point point;
7628   point.SetDeviceId(1);
7629   point.SetState(PointState::DOWN);
7630   point.SetScreenPosition(Vector2(10.f, 10.f));
7631   Dali::Integration::TouchEvent touchEvent;
7632   touchEvent.AddPoint(point);
7633
7634   tet_infoline("UtcDaliActor Test Set up completed \n");
7635
7636   application.ProcessEvent(touchEvent);
7637
7638   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7639   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7640   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7641
7642   ResetTouchCallbacks();
7643
7644   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");
7645
7646   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7647   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
7648   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7649   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7650
7651   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7652   application.SendNotification();
7653   application.Render();
7654
7655   application.ProcessEvent(touchEvent); // touch event
7656
7657   glSetUniformStack.Reset();
7658
7659   application.SendNotification();
7660   application.Render();
7661
7662   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7663
7664   // Test order of uniforms in stack
7665   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7666   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7667   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7668
7669   tet_infoline("Testing render order is A, C, B");
7670   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7671   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7672
7673   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7674   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7675   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7676
7677   ResetTouchCallbacks();
7678
7679   tet_printf("Lower actor C below Actor A leaving B on top\n");
7680
7681   orderChangedSignal = false;
7682
7683   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7684   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
7685   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7686   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7687
7688   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7689   application.SendNotification();
7690   application.Render();
7691
7692   application.ProcessEvent(touchEvent);
7693
7694   glSetUniformStack.Reset();
7695
7696   application.Render();
7697   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7698
7699   // Test order of uniforms in stack
7700   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7701   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7702   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7703
7704   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7705   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7706
7707   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7708   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7709   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7710
7711   ResetTouchCallbacks();
7712
7713   tet_printf("Lower actor B below Actor C leaving A on top\n");
7714
7715   orderChangedSignal = false;
7716
7717   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7718   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
7719   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7720   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7721
7722   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7723   application.SendNotification();
7724   application.Render();
7725
7726   application.ProcessEvent(touchEvent);
7727
7728   glSetUniformStack.Reset();
7729
7730   application.Render();
7731   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7732
7733   // Test order of uniforms in stack
7734   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7735   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7736   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7737
7738   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7739   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7740
7741   END_TEST;
7742 }
7743
7744 int UtcDaliActorGeoTouchLowerBelow2(void)
7745 {
7746   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
7747
7748   TestApplication application;
7749
7750   Integration::Scene stage(application.GetScene());
7751
7752   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7753   // enables checking of which actor the uniform is assigned too
7754   Shader shaderA = CreateShader();
7755   shaderA.RegisterProperty("uRendererColor", 1.f);
7756
7757   Shader shaderB = CreateShader();
7758   shaderB.RegisterProperty("uRendererColor", 2.f);
7759
7760   Shader shaderC = CreateShader();
7761   shaderC.RegisterProperty("uRendererColor", 3.f);
7762
7763   Actor actorA = Actor::New();
7764   Actor actorB = Actor::New();
7765   Actor actorC = Actor::New();
7766
7767   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7768   Geometry geometry = CreateQuadGeometry();
7769
7770   Renderer rendererA = Renderer::New(geometry, shaderA);
7771   actorA.AddRenderer(rendererA);
7772
7773   Renderer rendererB = Renderer::New(geometry, shaderB);
7774   actorB.AddRenderer(rendererB);
7775
7776   Renderer rendererC = Renderer::New(geometry, shaderC);
7777   actorC.AddRenderer(rendererC);
7778
7779   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7780   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7781
7782   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7783   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7784
7785   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7786   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7787
7788   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7789   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7790
7791   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7792   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7793
7794   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7795   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7796
7797   Actor container = Actor::New();
7798   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7799   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7800   stage.Add(container);
7801
7802   container.Add(actorA);
7803   container.Add(actorB);
7804   container.Add(actorC);
7805
7806   application.GetScene().SetGeometryHittestEnabled(true);
7807   ResetTouchCallbacks(application);
7808
7809   // Connect ChildOrderChangedSignal
7810   bool                     orderChangedSignal(false);
7811   Actor                    orderChangedActor;
7812   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7813   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7814
7815   // Set up gl abstraction trace so can query the set uniform order
7816   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7817   glAbstraction.EnableSetUniformCallTrace(true);
7818   glAbstraction.ResetSetUniformCallStack();
7819   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7820
7821   glAbstraction.ResetSetUniformCallStack();
7822
7823   application.SendNotification();
7824   application.Render();
7825
7826   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7827
7828   // Test order of uniforms in stack
7829   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7830   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7831   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7832
7833   tet_infoline("Testing C above B and A at bottom\n");
7834   bool CBA = (indexC > indexB) && (indexB > indexA);
7835
7836   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7837
7838   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7839   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7840   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7841
7842   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7843   // Only top actor will get touched.
7844   actorA.TouchedSignal().Connect(TestTouchCallback);
7845   actorB.TouchedSignal().Connect(TestTouchCallback2);
7846   actorC.TouchedSignal().Connect(TestTouchCallback3);
7847
7848   Dali::Integration::Point point;
7849   point.SetDeviceId(1);
7850   point.SetState(PointState::DOWN);
7851   point.SetScreenPosition(Vector2(10.f, 10.f));
7852   Dali::Integration::TouchEvent touchEvent;
7853   touchEvent.AddPoint(point);
7854
7855   tet_infoline("UtcDaliActor Test Set up completed \n");
7856
7857   application.ProcessEvent(touchEvent);
7858
7859   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7860   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7861   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7862
7863   ResetTouchCallbacks(application);
7864
7865   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");
7866
7867   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7868   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
7869   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7870   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7871
7872   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7873   application.SendNotification();
7874   application.Render();
7875
7876   application.ProcessEvent(touchEvent); // touch event
7877
7878   glSetUniformStack.Reset();
7879
7880   application.SendNotification();
7881   application.Render();
7882
7883   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7884
7885   // Test order of uniforms in stack
7886   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7887   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7888   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7889
7890   tet_infoline("Testing render order is A, C, B");
7891   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7892   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7893
7894   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7895   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7896   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7897
7898   ResetTouchCallbacks(application);
7899
7900   tet_printf("Lower actor C below Actor A leaving B on top\n");
7901
7902   orderChangedSignal = false;
7903
7904   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7905   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
7906   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7907   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7908
7909   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7910   application.SendNotification();
7911   application.Render();
7912
7913   application.ProcessEvent(touchEvent);
7914
7915   glSetUniformStack.Reset();
7916
7917   application.Render();
7918   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7919
7920   // Test order of uniforms in stack
7921   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7922   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7923   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7924
7925   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7926   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7927
7928   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7929   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7930   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7931
7932   ResetTouchCallbacks(application);
7933
7934   tet_printf("Lower actor B below Actor C leaving A on top\n");
7935
7936   orderChangedSignal = false;
7937
7938   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7939   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
7940   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7941   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7942
7943   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7944   application.SendNotification();
7945   application.Render();
7946
7947   application.ProcessEvent(touchEvent);
7948
7949   glSetUniformStack.Reset();
7950
7951   application.Render();
7952   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7953
7954   // Test order of uniforms in stack
7955   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7956   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7957   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7958
7959   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7960   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7961
7962   END_TEST;
7963 }
7964
7965 int UtcDaliActorRaiseAboveDifferentParentsN(void)
7966 {
7967   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
7968
7969   TestApplication application;
7970
7971   Integration::Scene stage(application.GetScene());
7972
7973   Actor parentA = Actor::New();
7974   Actor parentB = Actor::New();
7975   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7976   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7977   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7978   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7979
7980   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7981   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7982
7983   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7984   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7985
7986   stage.Add(parentA);
7987   stage.Add(parentB);
7988
7989   Actor actorA = Actor::New();
7990   Actor actorB = Actor::New();
7991   Actor actorC = Actor::New();
7992
7993   parentA.Add(actorA);
7994   parentA.Add(actorB);
7995
7996   tet_printf("Actor C added to different parent from A and B \n");
7997   parentB.Add(actorC);
7998
7999   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8000   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8001
8002   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8003   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8004
8005   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8006   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8007
8008   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8009   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8010
8011   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8012   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8013
8014   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8015   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8016
8017   ResetTouchCallbacks();
8018
8019   // Connect ChildOrderChangedSignal
8020   bool                     orderChangedSignal(false);
8021   Actor                    orderChangedActor;
8022   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8023   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8024
8025   application.SendNotification();
8026   application.Render();
8027
8028   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8029   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8030   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8031
8032   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8033   // Only top actor will get touched.
8034   actorA.TouchedSignal().Connect(TestTouchCallback);
8035   actorB.TouchedSignal().Connect(TestTouchCallback2);
8036   actorC.TouchedSignal().Connect(TestTouchCallback3);
8037
8038   Dali::Integration::Point point;
8039   point.SetDeviceId(1);
8040   point.SetState(PointState::DOWN);
8041   point.SetScreenPosition(Vector2(10.f, 10.f));
8042   Dali::Integration::TouchEvent touchEvent;
8043   touchEvent.AddPoint(point);
8044
8045   application.ProcessEvent(touchEvent);
8046
8047   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8048   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8049   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8050
8051   ResetTouchCallbacks();
8052
8053   tet_printf("Raise actor A Above Actor C which have different parents\n");
8054
8055   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8056   actorA.RaiseAbove(actorC);
8057   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8058
8059   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8060   application.SendNotification();
8061
8062   application.ProcessEvent(touchEvent); // touch event
8063
8064   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8065   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8066   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8067
8068   ResetTouchCallbacks();
8069
8070   END_TEST;
8071 }
8072
8073 int UtcDaliActorGeoTouchRaiseAboveDifferentParentsN(void)
8074 {
8075   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
8076
8077   TestApplication application;
8078
8079   Integration::Scene stage(application.GetScene());
8080
8081   Actor parentA = Actor::New();
8082   Actor parentB = Actor::New();
8083   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8084   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8085   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8086   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8087
8088   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8089   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8090
8091   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8092   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8093
8094   stage.Add(parentA);
8095   stage.Add(parentB);
8096
8097   Actor actorA = Actor::New();
8098   Actor actorB = Actor::New();
8099   Actor actorC = Actor::New();
8100
8101   parentA.Add(actorA);
8102   parentA.Add(actorB);
8103
8104   tet_printf("Actor C added to different parent from A and B \n");
8105   parentB.Add(actorC);
8106
8107   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8108   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8109
8110   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8111   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8112
8113   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8114   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8115
8116   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8117   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8118
8119   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8120   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8121
8122   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8123   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8124
8125   application.GetScene().SetGeometryHittestEnabled(true);
8126   ResetTouchCallbacks(application);
8127
8128   // Connect ChildOrderChangedSignal
8129   bool                     orderChangedSignal(false);
8130   Actor                    orderChangedActor;
8131   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8132   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8133
8134   application.SendNotification();
8135   application.Render();
8136
8137   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8138   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8139   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8140
8141   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8142   // Only top actor will get touched.
8143   actorA.TouchedSignal().Connect(TestTouchCallback);
8144   actorB.TouchedSignal().Connect(TestTouchCallback2);
8145   actorC.TouchedSignal().Connect(TestTouchCallback3);
8146
8147   Dali::Integration::Point point;
8148   point.SetDeviceId(1);
8149   point.SetState(PointState::DOWN);
8150   point.SetScreenPosition(Vector2(10.f, 10.f));
8151   Dali::Integration::TouchEvent touchEvent;
8152   touchEvent.AddPoint(point);
8153
8154   application.ProcessEvent(touchEvent);
8155
8156   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8157   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8158   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8159
8160   ResetTouchCallbacks(application);
8161
8162   tet_printf("Raise actor A Above Actor C which have different parents\n");
8163
8164   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8165   actorA.RaiseAbove(actorC);
8166   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8167
8168   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8169   application.SendNotification();
8170
8171   application.ProcessEvent(touchEvent); // touch event
8172
8173   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8174   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8175   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8176
8177   ResetTouchCallbacks(application);
8178
8179   END_TEST;
8180 }
8181
8182 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
8183 {
8184   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
8185
8186   TestApplication application;
8187
8188   Integration::Scene stage(application.GetScene());
8189
8190   Actor actorA = Actor::New();
8191   Actor actorB = Actor::New();
8192   Actor actorC = Actor::New();
8193
8194   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8195   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8196
8197   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8198   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8199
8200   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8201   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8202
8203   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8204   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8205
8206   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8207   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8208
8209   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8210   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8211
8212   ResetTouchCallbacks();
8213
8214   // Connect ChildOrderChangedSignal
8215   bool                     orderChangedSignal(false);
8216   Actor                    orderChangedActor;
8217   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8218   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8219
8220   application.SendNotification();
8221   application.Render();
8222
8223   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8224   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8225   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8226
8227   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8228   // Only top actor will get touched.
8229   actorA.TouchedSignal().Connect(TestTouchCallback);
8230   actorB.TouchedSignal().Connect(TestTouchCallback2);
8231   actorC.TouchedSignal().Connect(TestTouchCallback3);
8232
8233   Dali::Integration::Point point;
8234   point.SetDeviceId(1);
8235   point.SetState(PointState::DOWN);
8236   point.SetScreenPosition(Vector2(10.f, 10.f));
8237   Dali::Integration::TouchEvent touchEvent;
8238   touchEvent.AddPoint(point);
8239
8240   tet_printf("Raise actor A Above Actor C which have no parents\n");
8241
8242   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8243   actorA.RaiseAbove(actorC);
8244   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8245
8246   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8247   application.SendNotification();
8248
8249   application.ProcessEvent(touchEvent);
8250
8251   tet_printf("Not parented so RaiseAbove should show no effect\n");
8252
8253   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8254   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8255   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8256
8257   ResetTouchCallbacks();
8258
8259   orderChangedSignal = false;
8260
8261   stage.Add(actorB);
8262   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
8263
8264   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8265   actorA.LowerBelow(actorC);
8266   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8267
8268   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8269   application.SendNotification();
8270   application.Render();
8271
8272   application.ProcessEvent(touchEvent);
8273
8274   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
8275   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8276   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8277   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8278
8279   ResetTouchCallbacks();
8280
8281   orderChangedSignal = false;
8282
8283   tet_printf("Adding Actor A to stage, will be on top\n");
8284
8285   stage.Add(actorA);
8286   application.SendNotification();
8287   application.Render();
8288
8289   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
8290
8291   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8292   actorB.RaiseAbove(actorC);
8293   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8294
8295   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8296   application.SendNotification();
8297
8298   application.ProcessEvent(touchEvent);
8299
8300   tet_printf("C not parented so RaiseAbove should show no effect\n");
8301   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8302   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8303   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8304
8305   ResetTouchCallbacks();
8306
8307   orderChangedSignal = false;
8308
8309   tet_printf("Lower actor A below Actor C when only A has a parent\n");
8310
8311   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8312   actorA.LowerBelow(actorC);
8313   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8314
8315   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8316   application.SendNotification();
8317
8318   application.ProcessEvent(touchEvent);
8319
8320   tet_printf("C not parented so LowerBelow should show no effect\n");
8321   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8322   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8323   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8324
8325   ResetTouchCallbacks();
8326
8327   orderChangedSignal = false;
8328
8329   stage.Add(actorC);
8330
8331   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8332   actorA.RaiseAbove(actorC);
8333   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8334   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8335
8336   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8337   application.SendNotification();
8338   application.Render();
8339
8340   application.ProcessEvent(touchEvent);
8341
8342   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
8343   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8344   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8345   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8346
8347   END_TEST;
8348 }
8349
8350 int UtcDaliActorGeoTouchRaiseLowerWhenUnparentedTargetN(void)
8351 {
8352   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
8353
8354   TestApplication application;
8355
8356   Integration::Scene stage(application.GetScene());
8357
8358   Actor actorA = Actor::New();
8359   Actor actorB = Actor::New();
8360   Actor actorC = Actor::New();
8361
8362   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8363   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8364
8365   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8366   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8367
8368   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8369   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8370
8371   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8372   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8373
8374   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8375   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8376
8377   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8378   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8379
8380   application.GetScene().SetGeometryHittestEnabled(true);
8381   ResetTouchCallbacks(application);
8382
8383   // Connect ChildOrderChangedSignal
8384   bool                     orderChangedSignal(false);
8385   Actor                    orderChangedActor;
8386   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8387   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8388
8389   application.SendNotification();
8390   application.Render();
8391
8392   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8393   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8394   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8395
8396   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8397   // Only top actor will get touched.
8398   actorA.TouchedSignal().Connect(TestTouchCallback);
8399   actorB.TouchedSignal().Connect(TestTouchCallback2);
8400   actorC.TouchedSignal().Connect(TestTouchCallback3);
8401
8402   Dali::Integration::Point point;
8403   point.SetDeviceId(1);
8404   point.SetState(PointState::DOWN);
8405   point.SetScreenPosition(Vector2(10.f, 10.f));
8406   Dali::Integration::TouchEvent touchEvent;
8407   touchEvent.AddPoint(point);
8408
8409   tet_printf("Raise actor A Above Actor C which have no parents\n");
8410
8411   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8412   actorA.RaiseAbove(actorC);
8413   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8414
8415   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8416   application.SendNotification();
8417
8418   application.ProcessEvent(touchEvent);
8419
8420   tet_printf("Not parented so RaiseAbove should show no effect\n");
8421
8422   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8423   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8424   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8425
8426   ResetTouchCallbacks(application);
8427
8428   orderChangedSignal = false;
8429
8430   stage.Add(actorB);
8431   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
8432
8433   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8434   actorA.LowerBelow(actorC);
8435   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8436
8437   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8438   application.SendNotification();
8439   application.Render();
8440
8441   application.ProcessEvent(touchEvent);
8442
8443   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
8444   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8445   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8446   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8447
8448   ResetTouchCallbacks(application);
8449
8450   orderChangedSignal = false;
8451
8452   tet_printf("Adding Actor A to stage, will be on top\n");
8453
8454   stage.Add(actorA);
8455   application.SendNotification();
8456   application.Render();
8457
8458   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
8459
8460   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8461   actorB.RaiseAbove(actorC);
8462   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8463
8464   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8465   application.SendNotification();
8466
8467   application.ProcessEvent(touchEvent);
8468
8469   tet_printf("C not parented so RaiseAbove should show no effect\n");
8470   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8471   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8472   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8473
8474   ResetTouchCallbacks(application);
8475
8476   orderChangedSignal = false;
8477
8478   tet_printf("Lower actor A below Actor C when only A has a parent\n");
8479
8480   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8481   actorA.LowerBelow(actorC);
8482   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8483
8484   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8485   application.SendNotification();
8486
8487   application.ProcessEvent(touchEvent);
8488
8489   tet_printf("C not parented so LowerBelow should show no effect\n");
8490   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8491   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8492   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8493
8494   ResetTouchCallbacks(application);
8495
8496   orderChangedSignal = false;
8497
8498   stage.Add(actorC);
8499
8500   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8501   actorA.RaiseAbove(actorC);
8502   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8503   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8504
8505   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8506   application.SendNotification();
8507   application.Render();
8508
8509   application.ProcessEvent(touchEvent);
8510
8511   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
8512   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8513   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8514   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8515
8516   END_TEST;
8517 }
8518
8519 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
8520 {
8521   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
8522
8523   TestApplication application;
8524
8525   Integration::Scene stage(application.GetScene());
8526
8527   Actor actorA = Actor::New();
8528   Actor actorB = Actor::New();
8529   Actor actorC = Actor::New();
8530
8531   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8532   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8533
8534   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8535   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8536
8537   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8538   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8539
8540   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8541   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8542
8543   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8544   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8545
8546   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8547   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8548
8549   ResetTouchCallbacks();
8550
8551   // Connect ChildOrderChangedSignal
8552   bool                     orderChangedSignal(false);
8553   Actor                    orderChangedActor;
8554   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8555   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8556
8557   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8558   // Only top actor will get touched.
8559   actorA.TouchedSignal().Connect(TestTouchCallback);
8560   actorB.TouchedSignal().Connect(TestTouchCallback2);
8561   actorC.TouchedSignal().Connect(TestTouchCallback3);
8562
8563   Dali::Integration::Point point;
8564   point.SetDeviceId(1);
8565   point.SetState(PointState::DOWN);
8566   point.SetScreenPosition(Vector2(10.f, 10.f));
8567   Dali::Integration::TouchEvent touchEvent;
8568   touchEvent.AddPoint(point);
8569
8570   stage.Add(actorA);
8571   tet_printf("Raise actor B Above Actor C but B not parented\n");
8572
8573   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8574   actorB.Raise();
8575   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8576
8577   application.SendNotification();
8578   application.Render();
8579
8580   application.ProcessEvent(touchEvent);
8581
8582   tet_printf("Not parented so RaiseAbove should show no effect\n");
8583
8584   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8585   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8586   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8587
8588   tet_printf("Raise actor B Above Actor C but B not parented\n");
8589   ResetTouchCallbacks();
8590
8591   orderChangedSignal = false;
8592
8593   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8594   actorC.Lower();
8595   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8596
8597   // Sort actor tree before next touch event
8598   application.SendNotification();
8599   application.Render();
8600
8601   application.ProcessEvent(touchEvent);
8602
8603   tet_printf("Not parented so RaiseAbove should show no effect\n");
8604
8605   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8606   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8607   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8608   ResetTouchCallbacks();
8609
8610   orderChangedSignal = false;
8611
8612   tet_printf("Lower actor C below B but C not parented\n");
8613
8614   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8615   actorB.Lower();
8616   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8617
8618   // Sort actor tree before next touch event
8619   application.SendNotification();
8620   application.Render();
8621
8622   application.ProcessEvent(touchEvent);
8623
8624   tet_printf("Not parented so Lower should show no effect\n");
8625
8626   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8627   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8628   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8629   ResetTouchCallbacks();
8630
8631   orderChangedSignal = false;
8632
8633   tet_printf("Raise actor B to top\n");
8634
8635   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8636   actorB.RaiseToTop();
8637   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8638
8639   // Sort actor tree before next touch event
8640   application.SendNotification();
8641   application.Render();
8642
8643   application.ProcessEvent(touchEvent);
8644
8645   tet_printf("Not parented so RaiseToTop should show no effect\n");
8646
8647   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8648   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8649   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8650   ResetTouchCallbacks();
8651
8652   orderChangedSignal = false;
8653
8654   tet_printf("Add ActorB to stage so only Actor C not parented\n");
8655
8656   stage.Add(actorB);
8657
8658   tet_printf("Lower actor C to Bottom, B stays at top\n");
8659
8660   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8661   actorC.LowerToBottom();
8662   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8663
8664   application.SendNotification();
8665   application.Render();
8666
8667   application.ProcessEvent(touchEvent);
8668
8669   tet_printf("Not parented so LowerToBottom should show no effect\n");
8670
8671   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8672   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8673   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8674   ResetTouchCallbacks();
8675
8676   END_TEST;
8677 }
8678
8679 int UtcDaliActorGeoTouchTestAllAPIwhenActorNotParented(void)
8680 {
8681   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
8682
8683   TestApplication application;
8684
8685   Integration::Scene stage(application.GetScene());
8686
8687   Actor actorA = Actor::New();
8688   Actor actorB = Actor::New();
8689   Actor actorC = Actor::New();
8690
8691   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8692   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8693
8694   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8695   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8696
8697   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8698   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8699
8700   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8701   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8702
8703   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8704   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8705
8706   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8707   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8708
8709   application.GetScene().SetGeometryHittestEnabled(true);
8710   ResetTouchCallbacks(application);
8711
8712   // Connect ChildOrderChangedSignal
8713   bool                     orderChangedSignal(false);
8714   Actor                    orderChangedActor;
8715   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8716   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8717
8718   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8719   // Only top actor will get touched.
8720   actorA.TouchedSignal().Connect(TestTouchCallback);
8721   actorB.TouchedSignal().Connect(TestTouchCallback2);
8722   actorC.TouchedSignal().Connect(TestTouchCallback3);
8723
8724   Dali::Integration::Point point;
8725   point.SetDeviceId(1);
8726   point.SetState(PointState::DOWN);
8727   point.SetScreenPosition(Vector2(10.f, 10.f));
8728   Dali::Integration::TouchEvent touchEvent;
8729   touchEvent.AddPoint(point);
8730
8731   stage.Add(actorA);
8732   tet_printf("Raise actor B Above Actor C but B not parented\n");
8733
8734   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8735   actorB.Raise();
8736   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8737
8738   application.SendNotification();
8739   application.Render();
8740
8741   application.ProcessEvent(touchEvent);
8742
8743   tet_printf("Not parented so RaiseAbove should show no effect\n");
8744
8745   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8746   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8747   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8748
8749   tet_printf("Raise actor B Above Actor C but B not parented\n");
8750   ResetTouchCallbacks(application);
8751
8752   orderChangedSignal = false;
8753
8754   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8755   actorC.Lower();
8756   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8757
8758   // Sort actor tree before next touch event
8759   application.SendNotification();
8760   application.Render();
8761
8762   application.ProcessEvent(touchEvent);
8763
8764   tet_printf("Not parented so RaiseAbove should show no effect\n");
8765
8766   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8767   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8768   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8769   ResetTouchCallbacks(application);
8770
8771   orderChangedSignal = false;
8772
8773   tet_printf("Lower actor C below B but C not parented\n");
8774
8775   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8776   actorB.Lower();
8777   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8778
8779   // Sort actor tree before next touch event
8780   application.SendNotification();
8781   application.Render();
8782
8783   application.ProcessEvent(touchEvent);
8784
8785   tet_printf("Not parented so Lower should show no effect\n");
8786
8787   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8788   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8789   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8790   ResetTouchCallbacks(application);
8791
8792   orderChangedSignal = false;
8793
8794   tet_printf("Raise actor B to top\n");
8795
8796   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8797   actorB.RaiseToTop();
8798   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8799
8800   // Sort actor tree before next touch event
8801   application.SendNotification();
8802   application.Render();
8803
8804   application.ProcessEvent(touchEvent);
8805
8806   tet_printf("Not parented so RaiseToTop should show no effect\n");
8807
8808   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8809   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8810   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8811   ResetTouchCallbacks(application);
8812
8813   orderChangedSignal = false;
8814
8815   tet_printf("Add ActorB to stage so only Actor C not parented\n");
8816
8817   stage.Add(actorB);
8818
8819   tet_printf("Lower actor C to Bottom, B stays at top\n");
8820
8821   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8822   actorC.LowerToBottom();
8823   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8824
8825   application.SendNotification();
8826   application.Render();
8827
8828   application.ProcessEvent(touchEvent);
8829
8830   tet_printf("Not parented so LowerToBottom should show no effect\n");
8831
8832   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8833   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8834   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8835   ResetTouchCallbacks(application);
8836
8837   END_TEST;
8838 }
8839
8840 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
8841 {
8842   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
8843
8844   TestApplication application;
8845
8846   Integration::Scene stage(application.GetScene());
8847
8848   Actor actorA = Actor::New();
8849   Actor actorB = Actor::New();
8850   Actor actorC = Actor::New();
8851
8852   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8853   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8854
8855   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8856   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8857
8858   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8859   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8860
8861   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8862   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8863
8864   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8865   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8866
8867   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8868   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8869
8870   stage.Add(actorA);
8871   stage.Add(actorB);
8872   stage.Add(actorC);
8873
8874   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8875   // Only top actor will get touched.
8876   actorA.TouchedSignal().Connect(TestTouchCallback);
8877   actorB.TouchedSignal().Connect(TestTouchCallback2);
8878   actorC.TouchedSignal().Connect(TestTouchCallback3);
8879
8880   ResetTouchCallbacks();
8881
8882   // Connect ChildOrderChangedSignal
8883   bool                     orderChangedSignal(false);
8884   Actor                    orderChangedActor;
8885   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8886   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8887
8888   application.SendNotification();
8889   application.Render();
8890
8891   Dali::Integration::Point point;
8892   point.SetDeviceId(1);
8893   point.SetState(PointState::DOWN);
8894   point.SetScreenPosition(Vector2(10.f, 10.f));
8895   Dali::Integration::TouchEvent touchEvent;
8896   touchEvent.AddPoint(point);
8897
8898   application.ProcessEvent(touchEvent);
8899
8900   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8901   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8902   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8903
8904   ResetTouchCallbacks();
8905
8906   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
8907
8908   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8909   actorA.RaiseAbove(actorA);
8910   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8911   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8912
8913   application.SendNotification();
8914   application.Render();
8915
8916   application.ProcessEvent(touchEvent);
8917
8918   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
8919
8920   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8921   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8922   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8923
8924   ResetTouchCallbacks();
8925
8926   orderChangedSignal = false;
8927
8928   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8929   actorA.RaiseAbove(actorC);
8930   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8931   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8932
8933   application.SendNotification();
8934   application.Render();
8935
8936   application.ProcessEvent(touchEvent);
8937
8938   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
8939   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8940   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8941   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8942
8943   END_TEST;
8944 }
8945
8946 int UtcDaliActorGeoTouchRaiseAboveActorAndTargetTheSameN(void)
8947 {
8948   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
8949
8950   TestApplication application;
8951
8952   Integration::Scene stage(application.GetScene());
8953
8954   Actor actorA = Actor::New();
8955   Actor actorB = Actor::New();
8956   Actor actorC = Actor::New();
8957
8958   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8959   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8960
8961   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8962   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8963
8964   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8965   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8966
8967   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8968   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8969
8970   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8971   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8972
8973   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8974   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8975
8976   stage.Add(actorA);
8977   stage.Add(actorB);
8978   stage.Add(actorC);
8979
8980   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8981   // Only top actor will get touched.
8982   actorA.TouchedSignal().Connect(TestTouchCallback);
8983   actorB.TouchedSignal().Connect(TestTouchCallback2);
8984   actorC.TouchedSignal().Connect(TestTouchCallback3);
8985
8986   application.GetScene().SetGeometryHittestEnabled(true);
8987   ResetTouchCallbacks(application);
8988
8989   // Connect ChildOrderChangedSignal
8990   bool                     orderChangedSignal(false);
8991   Actor                    orderChangedActor;
8992   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8993   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8994
8995   application.SendNotification();
8996   application.Render();
8997
8998   Dali::Integration::Point point;
8999   point.SetDeviceId(1);
9000   point.SetState(PointState::DOWN);
9001   point.SetScreenPosition(Vector2(10.f, 10.f));
9002   Dali::Integration::TouchEvent touchEvent;
9003   touchEvent.AddPoint(point);
9004
9005   application.ProcessEvent(touchEvent);
9006
9007   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
9008   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
9009   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
9010
9011   ResetTouchCallbacks(application);
9012
9013   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
9014
9015   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
9016   actorA.RaiseAbove(actorA);
9017   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
9018   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
9019
9020   application.SendNotification();
9021   application.Render();
9022
9023   application.ProcessEvent(touchEvent);
9024
9025   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
9026
9027   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
9028   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
9029   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
9030
9031   ResetTouchCallbacks(application);
9032
9033   orderChangedSignal = false;
9034
9035   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
9036   actorA.RaiseAbove(actorC);
9037   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
9038   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
9039
9040   application.SendNotification();
9041   application.Render();
9042
9043   application.ProcessEvent(touchEvent);
9044
9045   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
9046   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
9047   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
9048   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
9049
9050   END_TEST;
9051 }
9052
9053 int UtcDaliActorGetScreenPosition(void)
9054 {
9055   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
9056
9057   TestApplication application;
9058
9059   Integration::Scene stage(application.GetScene());
9060
9061   Actor actorA = Actor::New();
9062   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9063
9064   Vector2 size2(10.0f, 20.0f);
9065   actorA.SetProperty(Actor::Property::SIZE, size2);
9066
9067   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9068
9069   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
9070
9071   stage.Add(actorA);
9072
9073   application.SendNotification();
9074   application.Render();
9075
9076   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9077   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9078
9079   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
9080   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
9081
9082   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9083   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9084
9085   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
9086
9087   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9088
9089   application.SendNotification();
9090   application.Render();
9091
9092   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9093   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9094
9095   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
9096   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
9097
9098   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9099   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9100
9101   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
9102
9103   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9104
9105   application.SendNotification();
9106   application.Render();
9107
9108   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9109   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9110
9111   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
9112   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
9113
9114   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9115   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9116
9117   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
9118
9119   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
9120
9121   application.SendNotification();
9122   application.Render();
9123
9124   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9125   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9126
9127   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
9128   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
9129
9130   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
9131   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9132
9133   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
9134
9135   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
9136
9137   application.SendNotification();
9138   application.Render();
9139
9140   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9141   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9142
9143   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
9144   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
9145
9146   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
9147   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
9148
9149   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
9150
9151   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9152   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
9153
9154   Actor actorB = Actor::New();
9155   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9156   actorB.SetProperty(Actor::Property::SIZE, size2);
9157   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
9158   actorA.Add(actorB);
9159
9160   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
9161
9162   application.SendNotification();
9163   application.Render();
9164
9165   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9166
9167   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
9168   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
9169
9170   END_TEST;
9171 }
9172
9173 int UtcDaliActorGetScreenPositionAfterScaling(void)
9174 {
9175   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
9176
9177   TestApplication application;
9178
9179   Integration::Scene stage(application.GetScene());
9180
9181   Actor actorA = Actor::New();
9182   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9183
9184   Vector2 size2(10.0f, 20.0f);
9185   actorA.SetProperty(Actor::Property::SIZE, size2);
9186   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
9187   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9188
9189   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
9190
9191   stage.Add(actorA);
9192
9193   application.SendNotification();
9194   application.Render();
9195
9196   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9197   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9198
9199   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
9200   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9201
9202   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9203   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9204
9205   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
9206
9207   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9208
9209   application.SendNotification();
9210   application.Render();
9211
9212   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9213   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9214
9215   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
9216   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9217
9218   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
9219   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
9220
9221   END_TEST;
9222 }
9223
9224 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
9225 {
9226   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
9227
9228   TestApplication application;
9229
9230   Integration::Scene stage(application.GetScene());
9231
9232   Actor actorA = Actor::New();
9233   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9234   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9235   Vector2 size2(10.0f, 20.0f);
9236   actorA.SetProperty(Actor::Property::SIZE, size2);
9237   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9238
9239   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9240
9241   stage.Add(actorA);
9242
9243   application.SendNotification();
9244   application.Render();
9245
9246   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9247   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9248
9249   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9250   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9251
9252   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
9253   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
9254
9255   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
9256
9257   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
9258   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9259
9260   application.SendNotification();
9261   application.Render();
9262
9263   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9264   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9265
9266   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
9267   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9268
9269   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
9270   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
9271
9272   END_TEST;
9273   END_TEST;
9274 }
9275
9276 int UtcDaliActorGetScreenPositionWithChildActors(void)
9277 {
9278   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
9279
9280   TestApplication application;
9281
9282   Integration::Scene stage(application.GetScene());
9283
9284   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9285
9286   Actor actorA = Actor::New();
9287   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9288   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9289   Vector2 size1(10.0f, 20.0f);
9290   actorA.SetProperty(Actor::Property::SIZE, size1);
9291   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9292
9293   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9294
9295   Actor parentActorA = Actor::New();
9296   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9297   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9298   Vector2 size2(30.0f, 60.0f);
9299   parentActorA.SetProperty(Actor::Property::SIZE, size2);
9300   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9301
9302   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
9303
9304   stage.Add(parentActorA);
9305   parentActorA.Add(actorA);
9306
9307   application.SendNotification();
9308   application.Render();
9309
9310   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9311   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9312
9313   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9314   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9315
9316   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
9317   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
9318
9319   tet_infoline("Test 2\n");
9320
9321   tet_infoline("change parent anchor point and parent origin then check screen position \n");
9322
9323   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
9324   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
9325
9326   application.SendNotification();
9327   application.Render();
9328
9329   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9330   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9331
9332   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
9333   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9334
9335   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
9336   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
9337
9338   END_TEST;
9339 }
9340
9341 int UtcDaliActorGetScreenPositionWithChildActors02(void)
9342 {
9343   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
9344
9345   TestApplication application;
9346
9347   Integration::Scene stage(application.GetScene());
9348
9349   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9350
9351   Actor actorA = Actor::New();
9352   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9353   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9354   Vector2 size1(10.0f, 20.0f);
9355   actorA.SetProperty(Actor::Property::SIZE, size1);
9356   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9357
9358   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9359
9360   Actor parentActorA = Actor::New();
9361   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9362   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9363   Vector2 size2(30.0f, 60.0f);
9364   parentActorA.SetProperty(Actor::Property::SIZE, size2);
9365   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9366
9367   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
9368
9369   Actor grandParentActorA = Actor::New();
9370   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
9371   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
9372   Vector2 size3(60.0f, 120.0f);
9373   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
9374   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9375
9376   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
9377
9378   stage.Add(grandParentActorA);
9379   grandParentActorA.Add(parentActorA);
9380
9381   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
9382
9383   parentActorA.Add(actorA);
9384
9385   application.SendNotification();
9386   application.Render();
9387
9388   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9389   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9390
9391   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9392   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9393
9394   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
9395   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
9396
9397   END_TEST;
9398 }
9399
9400 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
9401 {
9402   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
9403
9404   TestApplication application;
9405
9406   Integration::Scene stage(application.GetScene());
9407
9408   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9409
9410   Actor actorA = Actor::New();
9411   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9412   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9413   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9414   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
9415   stage.Add(actorA);
9416
9417   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9418
9419   Actor actorB = Actor::New();
9420   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9421   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9422   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9423   Vector2 actorBSize(30.0f, 60.0f);
9424   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
9425   stage.Add(actorB);
9426
9427   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9428
9429   Actor actorC = Actor::New();
9430   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9431   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9432   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9433   Vector2 actorCSize(60.0f, 120.0f);
9434   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
9435   stage.Add(actorC);
9436
9437   application.SendNotification();
9438   application.Render();
9439
9440   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
9441
9442   Vector2 center(stage.GetSize() * 0.5f);
9443
9444   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9445   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9446   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9447
9448   tet_infoline("Add scale to all actors");
9449
9450   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
9451   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
9452   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
9453
9454   application.SendNotification();
9455   application.Render();
9456
9457   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
9458   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
9459   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
9460
9461   END_TEST;
9462 }
9463
9464 int UtcDaliActorGetScreenPositionResizeScene(void)
9465 {
9466   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
9467
9468   TestApplication    application;
9469   Integration::Scene scene = application.GetScene();
9470
9471   Actor actorA = Actor::New();
9472   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9473   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9474   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
9475
9476   scene.Add(actorA);
9477
9478   application.SendNotification();
9479   application.Render();
9480
9481   Vector2 sceneSize           = scene.GetSize();
9482   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9483
9484   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9485
9486   // Resize the scene
9487   Vector2 newSize(1000.0f, 2000.0f);
9488   DALI_TEST_CHECK(scene.GetSize() != newSize);
9489
9490   scene.SurfaceResized(newSize.width, newSize.height);
9491
9492   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9493
9494   // The screen position should not be updated yet
9495   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9496
9497   application.SendNotification();
9498   application.Render();
9499
9500   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9501
9502   // The screen position should be updated
9503   sceneSize = scene.GetSize();
9504   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9505
9506   END_TEST;
9507 }
9508
9509 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
9510 {
9511   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
9512
9513   TestApplication    application;
9514   Integration::Scene scene = application.GetScene();
9515
9516   // Make 3D Layer
9517   Layer layer = scene.GetRootLayer();
9518   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
9519
9520   // Build custom camera with top-view
9521   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
9522   {
9523     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
9524     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
9525     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
9526
9527     {
9528       std::ostringstream oss;
9529       oss << cameraPos << "\n";
9530       oss << cameraOrient << "\n";
9531       tet_printf("%s\n", oss.str().c_str());
9532     }
9533
9534     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
9535     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
9536
9537     // Now, upside : -Z, leftside : -X, foward : +Y
9538
9539     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
9540     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
9541     {
9542       std::ostringstream oss;
9543       oss << cameraPos << "\n";
9544       oss << cameraOrient << "\n";
9545       tet_printf("%s\n", oss.str().c_str());
9546     }
9547   }
9548
9549   Actor actorA = Actor::New();
9550   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9551   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9552   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
9553   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
9554
9555   Actor actorB = Actor::New();
9556   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9557   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9558   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
9559   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
9560
9561   scene.Add(actorA);
9562   scene.Add(actorB);
9563
9564   application.SendNotification();
9565   application.Render();
9566
9567   Vector2 sceneSize           = scene.GetSize();
9568   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9569
9570   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
9571
9572   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9573
9574   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
9575
9576   END_TEST;
9577 }
9578
9579 int utcDaliActorPositionUsesAnchorPoint(void)
9580 {
9581   TestApplication application;
9582   tet_infoline("Check default behaviour\n");
9583
9584   Actor actor = Actor::New();
9585   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9586   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9587   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9588   application.GetScene().Add(actor);
9589
9590   application.SendNotification();
9591   application.Render();
9592
9593   tet_infoline("Check that the world position is in the center\n");
9594   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
9595
9596   tet_infoline("Set the position uses anchor point property to false\n");
9597   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9598
9599   application.SendNotification();
9600   application.Render();
9601
9602   tet_infoline("Check that the world position has changed appropriately\n");
9603   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9604
9605   END_TEST;
9606 }
9607
9608 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
9609 {
9610   TestApplication application;
9611   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9612
9613   Actor actor = Actor::New();
9614   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9615   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9616   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9617   actor.SetProperty(Actor::Property::SCALE, 2.0f);
9618   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9619   application.GetScene().Add(actor);
9620
9621   application.SendNotification();
9622   application.Render();
9623
9624   tet_infoline("Check the world position is the same as it would be without a scale\n");
9625   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9626
9627   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9628   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9629   application.SendNotification();
9630   application.Render();
9631   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
9632
9633   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9634   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9635   application.SendNotification();
9636   application.Render();
9637   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
9638
9639   END_TEST;
9640 }
9641
9642 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
9643 {
9644   TestApplication application;
9645   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9646
9647   Actor actor = Actor::New();
9648   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9649   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9650   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9651   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
9652   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9653   application.GetScene().Add(actor);
9654
9655   application.SendNotification();
9656   application.Render();
9657
9658   tet_infoline("Check the world position is the same as it would be without a rotation\n");
9659   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9660
9661   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9662   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9663   application.SendNotification();
9664   application.Render();
9665   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
9666
9667   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9668   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9669   application.SendNotification();
9670   application.Render();
9671   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
9672
9673   END_TEST;
9674 }
9675
9676 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
9677 {
9678   TestApplication application;
9679   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9680
9681   Actor actor = Actor::New();
9682   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9683   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9684   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9685   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
9686   actor.SetProperty(Actor::Property::SCALE, 2.0f);
9687   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9688   application.GetScene().Add(actor);
9689
9690   application.SendNotification();
9691   application.Render();
9692
9693   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
9694   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9695
9696   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9697   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9698   application.SendNotification();
9699   application.Render();
9700   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
9701
9702   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9703   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9704   application.SendNotification();
9705   application.Render();
9706   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
9707
9708   END_TEST;
9709 }
9710
9711 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
9712 {
9713   TestApplication application;
9714   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9715
9716   Actor parent = Actor::New();
9717
9718   application.GetScene().Add(parent);
9719   Vector2 stageSize(application.GetScene().GetSize());
9720
9721   Actor actor = Actor::New();
9722   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9723   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9724   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9725   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
9726   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
9727   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9728   parent.Add(actor);
9729
9730   application.SendNotification();
9731   application.Render();
9732
9733   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
9734
9735   tet_infoline("Check the world position is in the right place\n");
9736   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9737
9738   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
9739   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9740   application.SendNotification();
9741   application.Render();
9742   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9743
9744   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
9745   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9746   application.SendNotification();
9747   application.Render();
9748   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9749
9750   END_TEST;
9751 }
9752
9753 int utcDaliActorVisibilityChangeSignalSelf(void)
9754 {
9755   TestApplication application;
9756   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
9757
9758   Actor actor = Actor::New();
9759
9760   VisibilityChangedFunctorData data;
9761   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
9762
9763   actor.SetProperty(Actor::Property::VISIBLE, false);
9764
9765   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9766
9767   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
9768   data.Reset();
9769
9770   actor.SetProperty(Actor::Property::VISIBLE, false);
9771   data.Check(false /* not called */, TEST_LOCATION);
9772
9773   tet_infoline("Change the visibility using properties, ensure called");
9774   data.Reset();
9775
9776   actor.SetProperty(Actor::Property::VISIBLE, true);
9777   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9778
9779   tet_infoline("Set the visibility to current using properties, ensure not called");
9780   data.Reset();
9781
9782   actor.SetProperty(Actor::Property::VISIBLE, true);
9783   data.Check(false /* not called */, TEST_LOCATION);
9784
9785   END_TEST;
9786 }
9787
9788 int utcDaliActorVisibilityChangeSignalChildren(void)
9789 {
9790   TestApplication application;
9791   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
9792
9793   Actor parent = Actor::New();
9794   Actor child  = Actor::New();
9795   parent.Add(child);
9796
9797   Actor grandChild = Actor::New();
9798   child.Add(grandChild);
9799
9800   VisibilityChangedFunctorData parentData;
9801   VisibilityChangedFunctorData childData;
9802   VisibilityChangedFunctorData grandChildData;
9803
9804   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
9805   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
9806   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
9807
9808   parent.SetProperty(Actor::Property::VISIBLE, false);
9809   parentData.Check(false /* not called */, TEST_LOCATION);
9810   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9811   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9812
9813   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
9814   parentData.Reset();
9815   childData.Reset();
9816   grandChildData.Reset();
9817
9818   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
9819
9820   parent.SetProperty(Actor::Property::VISIBLE, true);
9821   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9822   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9823   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9824
9825   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
9826   parentData.Reset();
9827   childData.Reset();
9828   grandChildData.Reset();
9829
9830   parent.SetProperty(Actor::Property::VISIBLE, true);
9831   parentData.Check(false /* not called */, TEST_LOCATION);
9832   childData.Check(false /* not called */, TEST_LOCATION);
9833   grandChildData.Check(false /* not called */, TEST_LOCATION);
9834
9835   END_TEST;
9836 }
9837
9838 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
9839 {
9840   TestApplication application;
9841   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
9842
9843   Actor actor = Actor::New();
9844   application.GetScene().Add(actor);
9845
9846   application.SendNotification();
9847   application.Render();
9848
9849   VisibilityChangedFunctorData data;
9850   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
9851
9852   Animation animation = Animation::New(1.0f);
9853   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
9854
9855   data.Check(false, TEST_LOCATION);
9856   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9857   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9858
9859   tet_infoline("Play the animation and check the property value");
9860   animation.Play();
9861
9862   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9863   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
9864
9865   tet_infoline("Animation not currently finished, so the current visibility should still be true");
9866   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9867
9868   application.SendNotification();
9869   application.Render(1100); // After the animation
9870
9871   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
9872
9873   END_TEST;
9874 }
9875
9876 int utcDaliActorVisibilityChangeSignalByName(void)
9877 {
9878   TestApplication application;
9879   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
9880
9881   Actor actor = Actor::New();
9882
9883   bool signalCalled = false;
9884   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
9885   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9886   actor.SetProperty(Actor::Property::VISIBLE, false);
9887   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
9888
9889   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
9890   signalCalled = false;
9891   actor.SetProperty(Actor::Property::VISIBLE, false);
9892   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9893
9894   tet_infoline("Change the visibility using properties, ensure called");
9895   actor.SetProperty(Actor::Property::VISIBLE, true);
9896   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
9897
9898   tet_infoline("Set the visibility to current using properties, ensure not called");
9899   signalCalled = false;
9900
9901   actor.SetProperty(Actor::Property::VISIBLE, true);
9902   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9903
9904   END_TEST;
9905 }
9906
9907 int utcDaliActorInheritedVisibilityChangeSignal1(void)
9908 {
9909   TestApplication application;
9910   tet_infoline("Check that the inherited visibility change signal is called when the visibility changes for the actor itself");
9911
9912   Actor parentActor = Actor::New();
9913   Actor actor       = Actor::New();
9914
9915   InheritedVisibilityChangedFunctorData data;
9916   actor.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(data));
9917
9918   parentActor.Add(actor);
9919   data.Check(false, TEST_LOCATION);
9920
9921   data.Reset();
9922   application.GetScene().Add(parentActor);
9923   data.Check(true, actor, true, TEST_LOCATION);
9924
9925   data.Reset();
9926   actor.SetProperty(Actor::Property::VISIBLE, false);
9927   data.Check(true, actor, false, TEST_LOCATION);
9928
9929   data.Reset();
9930   actor.SetProperty(Actor::Property::VISIBLE, false);
9931   data.Check(false, TEST_LOCATION);
9932
9933   data.Reset();
9934   actor.SetProperty(Actor::Property::VISIBLE, true);
9935   data.Check(true, actor, true, TEST_LOCATION);
9936
9937   data.Reset();
9938   actor.SetProperty(Actor::Property::VISIBLE, true);
9939   data.Check(false, TEST_LOCATION);
9940
9941   END_TEST;
9942 }
9943
9944 int utcDaliActorInheritedVisibilityChangeSignal2(void)
9945 {
9946   TestApplication application;
9947   tet_infoline("Check that the inherited visibility change signal is called when the actor or one of the parent become on scene or off scene");
9948
9949   Actor parentActor = Actor::New();
9950   Actor childActor  = Actor::New();
9951
9952   InheritedVisibilityChangedFunctorData dataP, dataC;
9953   parentActor.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataP));
9954   childActor.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataC));
9955
9956   dataP.Reset();
9957   dataC.Reset();
9958   parentActor.Add(childActor);
9959   dataP.Check(false, TEST_LOCATION);
9960   dataC.Check(false, TEST_LOCATION);
9961
9962   dataP.Reset();
9963   dataC.Reset();
9964   application.GetScene().Add(parentActor);
9965   dataP.Check(true, parentActor, true, TEST_LOCATION);
9966   dataC.Check(true, childActor, true, TEST_LOCATION);
9967
9968   dataP.Reset();
9969   dataC.Reset();
9970   childActor.Unparent();
9971   dataP.Check(false, TEST_LOCATION);
9972   dataC.Check(true, childActor, false, TEST_LOCATION);
9973
9974   dataP.Reset();
9975   dataC.Reset();
9976   childActor.SetProperty(Actor::Property::VISIBLE, false);
9977   dataP.Check(false, TEST_LOCATION);
9978   dataC.Check(false, TEST_LOCATION);
9979
9980   dataP.Reset();
9981   dataC.Reset();
9982   parentActor.Add(childActor);
9983   dataP.Check(false, TEST_LOCATION);
9984   dataC.Check(false, TEST_LOCATION);
9985
9986   dataP.Reset();
9987   dataC.Reset();
9988   childActor.SetProperty(Actor::Property::VISIBLE, true);
9989   dataP.Check(false, TEST_LOCATION);
9990   dataC.Check(true, childActor, true, TEST_LOCATION);
9991
9992   dataP.Reset();
9993   dataC.Reset();
9994   parentActor.SetProperty(Actor::Property::VISIBLE, false);
9995   dataP.Check(true, parentActor, false, TEST_LOCATION);
9996   dataC.Check(true, childActor, false, TEST_LOCATION);
9997
9998   dataP.Reset();
9999   dataC.Reset();
10000   childActor.Unparent();
10001   dataP.Check(false, TEST_LOCATION);
10002   dataC.Check(false, TEST_LOCATION);
10003
10004   dataP.Reset();
10005   dataC.Reset();
10006   parentActor.SetProperty(Actor::Property::VISIBLE, true);
10007   dataP.Check(true, parentActor, true, TEST_LOCATION);
10008   dataC.Check(false, TEST_LOCATION);
10009
10010   dataP.Reset();
10011   dataC.Reset();
10012   parentActor.Add(childActor);
10013   dataP.Check(false, TEST_LOCATION);
10014   dataC.Check(true, childActor, true, TEST_LOCATION);
10015
10016   dataP.Reset();
10017   dataC.Reset();
10018   parentActor.Remove(childActor);
10019   dataP.Check(false, TEST_LOCATION);
10020   dataC.Check(true, childActor, false, TEST_LOCATION);
10021
10022   END_TEST;
10023 }
10024
10025 int utcDaliActorInheritedVisibilityChangeSignal3(void)
10026 {
10027   TestApplication application;
10028   tet_infoline("Check that the inherited visibility change signal is called when the visibility changes for the parent actor");
10029
10030   Actor parentActor = Actor::New();
10031   Actor actor       = Actor::New();
10032   parentActor.Add(actor);
10033
10034   InheritedVisibilityChangedFunctorData data;
10035   actor.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(data));
10036
10037   application.GetScene().Add(parentActor);
10038   data.Check(true, actor, true, TEST_LOCATION);
10039
10040   // Case 1
10041   // Parent true -> false : called
10042   // actor true -> false  : not called
10043   // actor false -> true  : not called
10044   data.Reset();
10045   parentActor.SetProperty(Actor::Property::VISIBLE, false);
10046   data.Check(true, actor, false, TEST_LOCATION);
10047
10048   data.Reset();
10049   actor.SetProperty(Actor::Property::VISIBLE, false);
10050   data.Check(false, TEST_LOCATION);
10051
10052   data.Reset();
10053   actor.SetProperty(Actor::Property::VISIBLE, true);
10054   data.Check(false, TEST_LOCATION);
10055
10056   // Prepare Case 2
10057   // Parent : false
10058   // actor : false
10059   data.Reset();
10060   actor.SetProperty(Actor::Property::VISIBLE, false);
10061   data.Check(false, TEST_LOCATION);
10062
10063   // Case 2
10064   // actor : false
10065   // parent false -> true : not called
10066   data.Reset();
10067   parentActor.SetProperty(Actor::Property::VISIBLE, true);
10068   data.Check(false, TEST_LOCATION);
10069
10070   // Prepare Case 3
10071   // parent : false
10072   // actor : true
10073   data.Reset();
10074   parentActor.SetProperty(Actor::Property::VISIBLE, false);
10075   data.Check(false, TEST_LOCATION);
10076
10077   data.Reset();
10078   actor.SetProperty(Actor::Property::VISIBLE, true);
10079   data.Check(false, TEST_LOCATION);
10080
10081   // Case 3
10082   // actor : true
10083   // parent false -> true : called
10084   parentActor.SetProperty(Actor::Property::VISIBLE, true);
10085   data.Check(true, actor, true, TEST_LOCATION);
10086
10087   END_TEST;
10088 }
10089
10090 namespace
10091 {
10092 InheritedVisibilityChangedFunctorData dataPA, dataPB, dataCA, dataCB, dataCC;
10093 void                                  ResetInheritedVisibilityChangedFunctorData()
10094 {
10095   dataPA.Reset();
10096   dataPB.Reset();
10097   dataCA.Reset();
10098   dataCB.Reset();
10099   dataCC.Reset();
10100 }
10101 } // namespace
10102
10103 int utcDaliActorInheritedVisibilityChangeSignal4(void)
10104 {
10105   TestApplication application;
10106   tet_infoline("Check that the inherited visibility change signal is in tree");
10107
10108   /**
10109    * ParentA
10110    *    |
10111    * ParentB
10112    *    |
10113    * ChildA   ChildB   ChildC
10114    */
10115
10116   Actor parentA = Actor::New();
10117   Actor parentB = Actor::New();
10118   Actor childA  = Actor::New();
10119   Actor childB  = Actor::New();
10120   Actor childC  = Actor::New();
10121   parentA.Add(parentB);
10122   parentB.Add(childA);
10123   parentB.Add(childB);
10124   parentB.Add(childC);
10125
10126   parentA.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataPA));
10127   parentB.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataPB));
10128   childA.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataCA));
10129   childB.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataCB));
10130   childC.InheritedVisibilityChangedSignal().Connect(&application, InheritedVisibilityChangedFunctor(dataCC));
10131
10132   ResetInheritedVisibilityChangedFunctorData();
10133   application.GetScene().Add(parentA);
10134   dataPA.Check(true, parentA, true, TEST_LOCATION);
10135   dataPB.Check(true, parentB, true, TEST_LOCATION);
10136   dataCA.Check(true, childA, true, TEST_LOCATION);
10137   dataCB.Check(true, childB, true, TEST_LOCATION);
10138   dataCC.Check(true, childC, true, TEST_LOCATION);
10139
10140   ResetInheritedVisibilityChangedFunctorData();
10141   parentA.SetProperty(Actor::Property::VISIBLE, false);
10142   dataPA.Check(true, parentA, false, TEST_LOCATION);
10143   dataPB.Check(true, parentB, false, TEST_LOCATION);
10144   dataCA.Check(true, childA, false, TEST_LOCATION);
10145   dataCB.Check(true, childB, false, TEST_LOCATION);
10146   dataCC.Check(true, childC, false, TEST_LOCATION);
10147
10148   ResetInheritedVisibilityChangedFunctorData();
10149   childA.SetProperty(Actor::Property::VISIBLE, false);
10150   dataPA.Check(false, TEST_LOCATION);
10151   dataPB.Check(false, TEST_LOCATION);
10152   dataCA.Check(false, TEST_LOCATION);
10153   dataCB.Check(false, TEST_LOCATION);
10154   dataCC.Check(false, TEST_LOCATION);
10155
10156   ResetInheritedVisibilityChangedFunctorData();
10157   parentB.SetProperty(Actor::Property::VISIBLE, false);
10158   dataPA.Check(false, TEST_LOCATION);
10159   dataPB.Check(false, TEST_LOCATION);
10160   dataCA.Check(false, TEST_LOCATION);
10161   dataCB.Check(false, TEST_LOCATION);
10162   dataCC.Check(false, TEST_LOCATION);
10163
10164   ResetInheritedVisibilityChangedFunctorData();
10165   parentA.SetProperty(Actor::Property::VISIBLE, true);
10166   dataPA.Check(true, parentA, true, TEST_LOCATION);
10167   dataPB.Check(false, TEST_LOCATION);
10168   dataCA.Check(false, TEST_LOCATION);
10169   dataCB.Check(false, TEST_LOCATION);
10170   dataCC.Check(false, TEST_LOCATION);
10171
10172   ResetInheritedVisibilityChangedFunctorData();
10173   parentB.SetProperty(Actor::Property::VISIBLE, true);
10174   dataPA.Check(false, TEST_LOCATION);
10175   dataPB.Check(true, parentB, true, TEST_LOCATION);
10176   dataCA.Check(false, TEST_LOCATION);
10177   dataCB.Check(true, childB, true, TEST_LOCATION);
10178   dataCC.Check(true, childC, true, TEST_LOCATION);
10179
10180   END_TEST;
10181 }
10182
10183 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
10184 {
10185   gLayoutDirectionType = type;
10186 }
10187
10188 int UtcDaliActorLayoutDirectionProperty(void)
10189 {
10190   TestApplication application;
10191   tet_infoline("Check layout direction property");
10192
10193   Actor actor0 = Actor::New();
10194   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10195   application.GetScene().Add(actor0);
10196
10197   application.SendNotification();
10198   application.Render();
10199
10200   Actor actor1 = Actor::New();
10201   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10202   Actor actor2 = Actor::New();
10203   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10204   Actor actor3 = Actor::New();
10205   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10206   Actor actor4 = Actor::New();
10207   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10208   Actor actor5 = Actor::New();
10209   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10210   Actor actor6 = Actor::New();
10211   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10212   Actor actor7 = Actor::New();
10213   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10214   Actor actor8 = Actor::New();
10215   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10216   Actor actor9 = Actor::New();
10217   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10218
10219   actor1.Add(actor2);
10220   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
10221   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
10222
10223   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
10224   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
10225   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
10226
10227   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10228   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10229   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
10230
10231   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
10232   actor0.Add(actor1);
10233   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10234   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10235
10236   application.GetScene().Add(actor3);
10237   actor3.Add(actor4);
10238   actor4.Add(actor5);
10239   actor5.Add(actor6);
10240   actor5.Add(actor7);
10241   actor7.Add(actor8);
10242   actor8.Add(actor9);
10243   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
10244   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
10245
10246   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
10247   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
10248   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
10249
10250   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
10251
10252   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10253   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10254   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10255   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10256   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10257   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10258   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10259
10260   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
10261   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10262   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10263
10264   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
10265   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10266   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10267   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
10268
10269   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
10270   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10271   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10272
10273   END_TEST;
10274 }
10275
10276 struct LayoutDirectionFunctor
10277 {
10278   LayoutDirectionFunctor(bool& signalCalled)
10279   : mSignalCalled(signalCalled)
10280   {
10281   }
10282
10283   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
10284   : mSignalCalled(rhs.mSignalCalled)
10285   {
10286   }
10287
10288   void operator()()
10289   {
10290     mSignalCalled = true;
10291   }
10292
10293   bool& mSignalCalled;
10294 };
10295
10296 int UtcDaliActorLayoutDirectionSignal(void)
10297 {
10298   TestApplication application;
10299   tet_infoline("Check changing layout direction property sends a signal");
10300
10301   Actor actor = Actor::New();
10302   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
10303   application.GetScene().Add(actor);
10304   bool                   signalCalled = false;
10305   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
10306
10307   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
10308   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
10309
10310   // Test that writing the same value doesn't send a signal
10311   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
10312   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
10313
10314   // Test that writing a different value sends the signal
10315   signalCalled = false;
10316   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
10317   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
10318
10319   signalCalled = false;
10320   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
10321   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
10322
10323   END_TEST;
10324 }
10325
10326 struct ChildAddedSignalCheck
10327 {
10328   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
10329   : mSignalReceived(signalReceived),
10330     mChildHandle(childHandle)
10331   {
10332   }
10333
10334   void operator()(Actor childHandle)
10335   {
10336     mSignalReceived = true;
10337     mChildHandle    = childHandle;
10338   }
10339   void operator()()
10340   {
10341     mSignalReceived = true;
10342     mChildHandle    = Actor();
10343   }
10344
10345   bool&  mSignalReceived;
10346   Actor& mChildHandle;
10347 };
10348
10349 int UtcDaliChildAddedSignalP1(void)
10350 {
10351   TestApplication application;
10352   auto            stage = application.GetScene();
10353
10354   bool  signalReceived = false;
10355   Actor childActor;
10356
10357   ChildAddedSignalCheck signal(signalReceived, childActor);
10358   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
10359   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10360
10361   auto actorA = Actor::New();
10362   stage.Add(actorA);
10363   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10364   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
10365   signalReceived = false;
10366
10367   auto actorB = Actor::New();
10368   stage.Add(actorB);
10369   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10370   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
10371
10372   END_TEST;
10373 }
10374
10375 int UtcDaliChildAddedSignalP2(void)
10376 {
10377   TestApplication application;
10378   auto            stage = application.GetScene();
10379
10380   bool  signalReceived = false;
10381   Actor childActor;
10382
10383   ChildAddedSignalCheck signal(signalReceived, childActor);
10384   tet_infoline("Connect to childAdded signal by name");
10385
10386   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
10387   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10388
10389   auto actorA = Actor::New();
10390   stage.Add(actorA);
10391   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10392
10393   // Can't test which actor was added; signal signature is void() when connecting via name.
10394   signalReceived = false;
10395
10396   auto actorB = Actor::New();
10397   stage.Add(actorB);
10398   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10399
10400   END_TEST;
10401 }
10402
10403 int UtcDaliChildAddedSignalN(void)
10404 {
10405   TestApplication application;
10406   auto            stage = application.GetScene();
10407
10408   bool  signalReceived = false;
10409   Actor childActor;
10410
10411   ChildAddedSignalCheck signal(signalReceived, childActor);
10412   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
10413   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10414
10415   auto actorA = Actor::New();
10416   stage.Add(actorA);
10417   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10418   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
10419   signalReceived = false;
10420
10421   auto actorB = Actor::New();
10422   actorA.Add(actorB);
10423   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10424   END_TEST;
10425 }
10426
10427 struct ChildRemovedSignalCheck
10428 {
10429   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
10430   : mSignalReceived(signalReceived),
10431     mChildHandle(childHandle)
10432   {
10433   }
10434
10435   void operator()(Actor childHandle)
10436   {
10437     mSignalReceived = true;
10438     mChildHandle    = childHandle;
10439   }
10440
10441   void operator()()
10442   {
10443     mSignalReceived = true;
10444   }
10445
10446   bool&  mSignalReceived;
10447   Actor& mChildHandle;
10448 };
10449
10450 int UtcDaliChildRemovedSignalP1(void)
10451 {
10452   TestApplication application;
10453   auto            stage = application.GetScene();
10454
10455   bool  signalReceived = false;
10456   Actor childActor;
10457
10458   ChildRemovedSignalCheck signal(signalReceived, childActor);
10459   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
10460   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10461
10462   auto actorA = Actor::New();
10463   stage.Add(actorA);
10464   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10465   DALI_TEST_CHECK(!childActor);
10466
10467   stage.Remove(actorA);
10468   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
10469   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10470
10471   signalReceived = false;
10472   auto actorB    = Actor::New();
10473   stage.Add(actorB);
10474   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10475
10476   stage.Remove(actorB);
10477   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10478   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
10479
10480   END_TEST;
10481 }
10482
10483 int UtcDaliChildRemovedSignalP2(void)
10484 {
10485   TestApplication application;
10486   auto            stage = application.GetScene();
10487
10488   bool  signalReceived = false;
10489   Actor childActor;
10490
10491   ChildAddedSignalCheck signal(signalReceived, childActor);
10492   tet_infoline("Connect to childRemoved signal by name");
10493
10494   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
10495   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10496
10497   auto actorA = Actor::New();
10498   stage.Add(actorA);
10499   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10500
10501   stage.Remove(actorA);
10502   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10503
10504   signalReceived = false;
10505   auto actorB    = Actor::New();
10506   stage.Add(actorB);
10507   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10508
10509   stage.Remove(actorB);
10510   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10511
10512   END_TEST;
10513 }
10514
10515 int UtcDaliChildRemovedSignalN(void)
10516 {
10517   TestApplication application;
10518   auto            stage = application.GetScene();
10519
10520   bool  signalReceived = false;
10521   Actor childActor;
10522
10523   ChildRemovedSignalCheck signal(signalReceived, childActor);
10524   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
10525   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10526
10527   auto actorA = Actor::New();
10528   stage.Add(actorA);
10529
10530   auto actorB = Actor::New();
10531   actorA.Add(actorB);
10532
10533   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10534   DALI_TEST_CHECK(!childActor);
10535
10536   actorA.Remove(actorB);
10537   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10538   END_TEST;
10539 }
10540
10541 int UtcDaliChildMovedSignalP(void)
10542 {
10543   TestApplication application;
10544   auto            stage = application.GetScene();
10545
10546   bool  addedASignalReceived   = false;
10547   bool  removedASignalReceived = false;
10548   bool  addedBSignalReceived   = false;
10549   bool  removedBSignalReceived = false;
10550   Actor childActor;
10551
10552   auto actorA = Actor::New();
10553   auto actorB = Actor::New();
10554   stage.Add(actorA);
10555   stage.Add(actorB);
10556
10557   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
10558   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
10559   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
10560   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
10561
10562   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
10563   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
10564   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
10565   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
10566
10567   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
10568   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10569   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10570   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10571
10572   // Create a child of A
10573
10574   auto child = Actor::New();
10575   actorA.Add(child);
10576
10577   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
10578   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10579   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10580   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10581   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
10582
10583   // Move child to B:
10584   addedASignalReceived   = false;
10585   addedBSignalReceived   = false;
10586   removedASignalReceived = false;
10587   removedBSignalReceived = false;
10588
10589   actorB.Add(child); // Expect this child to be re-parented
10590   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
10591   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
10592   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
10593   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10594
10595   // Move child back to A:
10596   addedASignalReceived   = false;
10597   addedBSignalReceived   = false;
10598   removedASignalReceived = false;
10599   removedBSignalReceived = false;
10600
10601   actorA.Add(child); // Expect this child to be re-parented
10602   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
10603   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10604   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10605   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
10606
10607   END_TEST;
10608 }
10609
10610 int UtcDaliActorSwitchParentP(void)
10611 {
10612   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
10613   TestApplication application;
10614
10615   Actor parent1 = Actor::New();
10616   Actor child   = Actor::New();
10617
10618   application.GetScene().Add(parent1);
10619
10620   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
10621
10622   child.OnSceneSignal().Connect(OnSceneCallback);
10623   child.OffSceneSignal().Connect(OffSceneCallback);
10624
10625   // sanity check
10626   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
10627   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10628
10629   parent1.Add(child);
10630
10631   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
10632
10633   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
10634   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10635
10636   Actor parent2 = Actor::New();
10637   application.GetScene().Add(parent2);
10638
10639   bool                  addSignalReceived = false;
10640   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
10641   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
10642   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
10643
10644   bool                    removedSignalReceived = false;
10645   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
10646   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
10647   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
10648
10649   DevelActor::SwitchParent(child, parent2);
10650
10651   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
10652   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
10653
10654   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
10655   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
10656
10657   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
10658   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10659   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
10660   DALI_TEST_CHECK(child.GetParent() == parent2);
10661
10662   END_TEST;
10663 }
10664
10665 int utcDaliActorCulled(void)
10666 {
10667   TestApplication application;
10668   auto            stage = application.GetScene();
10669
10670   tet_infoline("Check that the actor is culled if the actor is out of the screen");
10671
10672   Actor actor = Actor::New();
10673   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
10674
10675   Geometry geometry = CreateQuadGeometry();
10676   Shader   shader   = CreateShader();
10677   Renderer renderer = Renderer::New(geometry, shader);
10678   actor.AddRenderer(renderer);
10679
10680   stage.Add(actor);
10681
10682   application.SendNotification();
10683   application.Render(0);
10684
10685   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
10686
10687   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
10688   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
10689
10690   // Connect NotifySignal
10691   bool                              propertyNotificationSignal(false);
10692   PropertyNotification              source;
10693   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
10694   notification.NotifySignal().Connect(&application, f);
10695
10696   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
10697
10698   application.SendNotification();
10699   application.Render();
10700
10701   application.SendNotification();
10702
10703   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
10704
10705   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
10706   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
10707   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
10708
10709   END_TEST;
10710 }
10711
10712 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
10713 {
10714   TestApplication application;
10715   auto            stage = application.GetScene();
10716
10717   tet_infoline("Ensure we clear the screen when the last actor is removed");
10718
10719   Actor actor = CreateRenderableActor();
10720   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
10721   stage.Add(actor);
10722
10723   application.SendNotification();
10724   application.Render();
10725
10726   auto&      glAbstraction    = application.GetGlAbstraction();
10727   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
10728
10729   actor.Unparent();
10730
10731   application.SendNotification();
10732   application.Render();
10733
10734   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
10735
10736   END_TEST;
10737 }
10738
10739 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
10740 {
10741   TestApplication application;
10742   auto            stage = application.GetScene();
10743
10744   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
10745
10746   Actor actor = CreateRenderableActor();
10747   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
10748   stage.Add(actor);
10749
10750   application.SendNotification();
10751   application.Render();
10752
10753   auto&      glAbstraction    = application.GetGlAbstraction();
10754   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
10755
10756   actor.SetProperty(Actor::Property::VISIBLE, false);
10757
10758   application.SendNotification();
10759   application.Render();
10760
10761   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
10762
10763   END_TEST;
10764 }
10765
10766 int utcDaliActorGetSizeAfterAnimation(void)
10767 {
10768   TestApplication application;
10769   tet_infoline("Check the actor size before / after an animation is finished");
10770
10771   Vector3 actorSize(100.0f, 100.0f, 0.0f);
10772
10773   Actor actor = Actor::New();
10774   actor.SetProperty(Actor::Property::SIZE, actorSize);
10775   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10776   application.GetScene().Add(actor);
10777
10778   // Size should be updated without rendering.
10779   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10780   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10781
10782   application.SendNotification();
10783   application.Render();
10784
10785   // Size and current size should be updated.
10786   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10787   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10788   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10789   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10790   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10791
10792   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10793   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10794   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10795   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10796   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10797
10798   // Set size again
10799   actorSize = Vector3(200.0f, 200.0f, 0.0f);
10800   actor.SetProperty(Actor::Property::SIZE, actorSize);
10801
10802   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10803   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10804
10805   Vector3 targetValue(10.0f, 20.0f, 0.0f);
10806
10807   Animation animation = Animation::New(1.0f);
10808   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
10809   animation.Play();
10810
10811   // Size should be updated without rendering.
10812   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10813   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10814
10815   application.SendNotification();
10816   application.Render(1100); // After the animation
10817
10818   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10819   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10820   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10821   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10822   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10823
10824   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10825   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10826   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10827   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10828   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10829
10830   targetValue.width = 50.0f;
10831
10832   animation.Clear();
10833   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
10834   animation.Play();
10835
10836   application.SendNotification();
10837   application.Render(1100); // After the animation
10838
10839   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10840   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10841   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10842   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10843   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10844
10845   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10846   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10847   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10848   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10849   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10850
10851   targetValue.height = 70.0f;
10852
10853   animation.Clear();
10854   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
10855   animation.Play();
10856
10857   application.SendNotification();
10858   application.Render(1100); // After the animation
10859
10860   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10861   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10862   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10863   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10864   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10865
10866   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10867   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10868   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10869   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10870   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10871
10872   Vector3 offset(10.0f, 20.0f, 0.0f);
10873
10874   animation.Clear();
10875   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
10876   animation.Play();
10877
10878   application.SendNotification();
10879   application.Render(1100); // After the animation
10880
10881   targetValue += offset;
10882
10883   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10884   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10885   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10886   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10887   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10888
10889   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10890   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10891   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10892   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10893   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10894
10895   offset.width = 20.0f;
10896
10897   animation.Clear();
10898   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
10899   animation.Play();
10900
10901   application.SendNotification();
10902   application.Render(1100); // After the animation
10903
10904   targetValue.width += offset.width;
10905
10906   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10907   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10908   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10909   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10910   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10911
10912   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10913   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10914   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10915   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10916   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10917
10918   offset.height = 10.0f;
10919
10920   animation.Clear();
10921   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
10922   animation.Play();
10923
10924   application.SendNotification();
10925   application.Render(1100); // After the animation
10926
10927   targetValue.height += offset.height;
10928
10929   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10930   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10931   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10932   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10933   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10934
10935   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10936   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10937   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10938   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10939   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10940
10941   // Set size again
10942   actorSize = Vector3(300.0f, 300.0f, 0.0f);
10943
10944   actor.SetProperty(Actor::Property::SIZE, actorSize);
10945
10946   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10947   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10948
10949   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10950   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10951
10952   application.SendNotification();
10953   application.Render();
10954
10955   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10956   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10957
10958   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10959   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10960
10961   END_TEST;
10962 }
10963
10964 int utcDaliActorGetSizeAfterAnimation2(void)
10965 {
10966   TestApplication application;
10967   tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
10968
10969   Vector3 actorSize(100.0f, 100.0f, 0.0f);
10970
10971   Actor actor = Actor::New();
10972   actor.SetProperty(Actor::Property::SIZE, actorSize);
10973   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10974   application.GetScene().Add(actor);
10975
10976   // Size should be updated without rendering.
10977   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10978   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10979
10980   application.SendNotification();
10981   application.Render();
10982
10983   // Size and current size should be updated.
10984   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10985   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10986   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10987   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10988   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10989
10990   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10991   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10992   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10993   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10994   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10995
10996   // Set size again
10997   actorSize = Vector3(200.0f, 200.0f, 0.0f);
10998   actor.SetProperty(Actor::Property::SIZE, actorSize);
10999
11000   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11001   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11002
11003   Vector3 targetValue(actorSize);
11004
11005   Animation animation = Animation::New(1.0f);
11006   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
11007   animation.Play();
11008
11009   // Size should be updated without rendering.
11010   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11011   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11012
11013   application.SendNotification();
11014   application.Render(100); // During the animation
11015
11016   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11017   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11018   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
11019   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
11020   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
11021
11022   // We should get target value because targetValue is equal to current actor size.
11023   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11024   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11025   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
11026   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
11027   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
11028
11029   application.SendNotification();
11030   application.Render(1000); // After animation finished
11031
11032   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11033   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11034
11035   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11036   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11037
11038   END_TEST;
11039 }
11040
11041 int utcDaliActorRelayoutAndAnimation(void)
11042 {
11043   TestApplication application;
11044   tet_infoline("Check the actor size when relayoutting and playing animation");
11045
11046   Vector3 parentSize(300.0f, 300.0f, 0.0f);
11047   Vector3 actorSize(100.0f, 100.0f, 0.0f);
11048
11049   {
11050     Actor parentA = Actor::New();
11051     parentA.SetProperty(Actor::Property::SIZE, parentSize);
11052     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11053     application.GetScene().Add(parentA);
11054
11055     Actor parentB = Actor::New();
11056     parentB.SetProperty(Actor::Property::SIZE, parentSize);
11057     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11058     application.GetScene().Add(parentB);
11059
11060     Actor actor = Actor::New();
11061     actor.SetProperty(Actor::Property::SIZE, actorSize);
11062     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11063     parentA.Add(actor);
11064
11065     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11066     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11067
11068     Vector3 targetValue(200.0f, 200.0f, 0.0f);
11069
11070     Animation animation = Animation::New(1.0f);
11071     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
11072     animation.Play();
11073
11074     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11075     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11076
11077     application.SendNotification();
11078     application.Render(1100); // After the animation
11079
11080     // Size and current size should be updated.
11081     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11082     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11083
11084     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11085     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11086
11087     // Trigger relayout
11088     parentB.Add(actor);
11089
11090     application.SendNotification();
11091     application.Render();
11092
11093     // Size and current size should be same.
11094     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11095     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11096
11097     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11098     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11099
11100     actor.Unparent();
11101     parentA.Unparent();
11102     parentB.Unparent();
11103   }
11104
11105   {
11106     Actor parentA = Actor::New();
11107     parentA.SetProperty(Actor::Property::SIZE, parentSize);
11108     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11109     application.GetScene().Add(parentA);
11110
11111     Actor parentB = Actor::New();
11112     parentB.SetProperty(Actor::Property::SIZE, parentSize);
11113     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11114     application.GetScene().Add(parentB);
11115
11116     Actor actor = Actor::New();
11117     actor.SetProperty(Actor::Property::SIZE, actorSize);
11118     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11119     parentA.Add(actor);
11120
11121     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11122     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11123
11124     application.SendNotification();
11125     application.Render();
11126
11127     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11128     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11129
11130     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11131     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11132
11133     Vector3 targetValue(200.0f, 200.0f, 0.0f);
11134
11135     // Make an animation
11136     Animation animation = Animation::New(1.0f);
11137     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
11138     animation.Play();
11139
11140     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11141     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11142
11143     application.SendNotification();
11144     application.Render(1100); // After the animation
11145
11146     // Size and current size should be updated.
11147     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11148     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11149
11150     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11151     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11152
11153     // Trigger relayout
11154     parentB.Add(actor);
11155
11156     application.SendNotification();
11157     application.Render();
11158
11159     // Size and current size should be same.
11160     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
11161     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11162
11163     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
11164     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
11165
11166     actor.Unparent();
11167     parentA.Unparent();
11168     parentB.Unparent();
11169   }
11170
11171   END_TEST;
11172 }
11173
11174 int utcDaliActorPartialUpdate(void)
11175 {
11176   TestApplication application(
11177     TestApplication::DEFAULT_SURFACE_WIDTH,
11178     TestApplication::DEFAULT_SURFACE_HEIGHT,
11179     TestApplication::DEFAULT_HORIZONTAL_DPI,
11180     TestApplication::DEFAULT_VERTICAL_DPI,
11181     true,
11182     true);
11183
11184   tet_infoline("Check the damaged area");
11185
11186   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11187
11188   std::vector<Rect<int>> damagedRects;
11189   Rect<int>              clippingRect;
11190   application.SendNotification();
11191   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11192
11193   // First render pass, nothing to render, adaptor would just do swap buffer.
11194   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11195
11196   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11197   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11198
11199   Actor actor = CreateRenderableActor();
11200   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11201   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11202   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11203   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11204   application.GetScene().Add(actor);
11205
11206   application.SendNotification();
11207
11208   // 1. Actor added, damaged rect is added size of actor
11209   damagedRects.clear();
11210   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11211   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11212
11213   // Aligned by 16
11214   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11215   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11216   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11217   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11218   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11219   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11220   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11221
11222   // 2. Set new size
11223   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
11224   application.SendNotification();
11225
11226   damagedRects.clear();
11227   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11228   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11229
11230   // Aligned by 16
11231   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
11232   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11233   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11234   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11235   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11236   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11237   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11238
11239   // 3. Set new position
11240   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
11241   application.SendNotification();
11242
11243   damagedRects.clear();
11244   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11245   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11246
11247   // Aligned by 16
11248   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
11249   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11250   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11251   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11252   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11253   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11254   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11255
11256   application.GetScene().Remove(actor);
11257   application.SendNotification();
11258
11259   // Actor removed, last a dirty rect is reported.
11260   damagedRects.clear();
11261   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11262   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11263
11264   clippingRect = damagedRects[0];
11265
11266   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
11267   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
11268
11269   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11270   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11271   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11272   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11273   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11274
11275   END_TEST;
11276 }
11277
11278 int utcDaliActorPartialUpdateSetColor(void)
11279 {
11280   TestApplication application(
11281     TestApplication::DEFAULT_SURFACE_WIDTH,
11282     TestApplication::DEFAULT_SURFACE_HEIGHT,
11283     TestApplication::DEFAULT_HORIZONTAL_DPI,
11284     TestApplication::DEFAULT_VERTICAL_DPI,
11285     true,
11286     true);
11287
11288   tet_infoline("Check uniform update");
11289
11290   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11291
11292   std::vector<Rect<int>> damagedRects;
11293   Rect<int>              clippingRect;
11294   application.SendNotification();
11295   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11296
11297   // First render pass, nothing to render, adaptor would just do swap buffer.
11298   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11299
11300   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11301   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11302
11303   Actor actor = CreateRenderableActor();
11304   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11305   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11306   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11307   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11308   application.GetScene().Add(actor);
11309
11310   application.SendNotification();
11311
11312   // 1. Actor added, damaged rect is added size of actor
11313   damagedRects.clear();
11314   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11315   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11316
11317   // Aligned by 16
11318   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11319   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11320   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11321   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11322   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11323   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11324   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11325
11326   damagedRects.clear();
11327   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11328   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11329
11330   damagedRects.clear();
11331   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11332   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11333
11334   // 2. Set new color
11335   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
11336   application.SendNotification();
11337
11338   damagedRects.clear();
11339   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11340   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11341
11342   // Aligned by 16
11343   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11344   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11345   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11346   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11347   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11348   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11349   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11350
11351   END_TEST;
11352 }
11353
11354 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
11355 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
11356 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
11357 const char* const RENDER_SHADOW_VERTEX_SOURCE =
11358   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
11359   " uniform mediump mat4 uLightCameraViewMatrix;\n"
11360   "\n"
11361   "void main()\n"
11362   "{\n"
11363   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
11364   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
11365   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
11366   "}\n";
11367
11368 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
11369   "uniform lowp vec4 uShadowColor;\n"
11370   "void main()\n"
11371   "{\n"
11372   "  lowp float alpha;\n"
11373   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
11374   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
11375   "}\n";
11376
11377 int utcDaliActorPartialUpdateSetProperty(void)
11378 {
11379   TestApplication application(
11380     TestApplication::DEFAULT_SURFACE_WIDTH,
11381     TestApplication::DEFAULT_SURFACE_HEIGHT,
11382     TestApplication::DEFAULT_HORIZONTAL_DPI,
11383     TestApplication::DEFAULT_VERTICAL_DPI,
11384     true,
11385     true);
11386
11387   tet_infoline("Set/Update property with partial update");
11388
11389   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11390
11391   std::vector<Rect<int>> damagedRects;
11392   Rect<int>              clippingRect;
11393   application.SendNotification();
11394   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11395
11396   // First render pass, nothing to render, adaptor would just do swap buffer.
11397   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11398
11399   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11400   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11401
11402   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
11403   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
11404   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11405   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11406   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11407   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11408   application.GetScene().Add(actor);
11409
11410   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
11411
11412   damagedRects.clear();
11413   application.SendNotification();
11414   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11415   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11416
11417   // Aligned by 16
11418   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11419   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11420   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11421   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11422   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11423   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11424   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11425
11426   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
11427   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
11428
11429   damagedRects.clear();
11430   application.SendNotification();
11431   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11432   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11433
11434   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11435   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11436   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11437   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11438   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11439   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11440
11441   // Should be no damage rects, nothing changed
11442   damagedRects.clear();
11443   application.SendNotification();
11444   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11445   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11446
11447   // Should be 1 damage rect due to change in size
11448   damagedRects.clear();
11449   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
11450   application.SendNotification();
11451   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11452   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11453
11454   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
11455   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11456   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11457   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11458   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11459   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11460   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11461
11462   damagedRects.clear();
11463   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11464   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11465
11466   END_TEST;
11467 }
11468
11469 int utcDaliActorPartialUpdateTwoActors(void)
11470 {
11471   TestApplication application(
11472     TestApplication::DEFAULT_SURFACE_WIDTH,
11473     TestApplication::DEFAULT_SURFACE_HEIGHT,
11474     TestApplication::DEFAULT_HORIZONTAL_DPI,
11475     TestApplication::DEFAULT_VERTICAL_DPI,
11476     true,
11477     true);
11478
11479   tet_infoline("Check the damaged rects with partial update and two actors");
11480
11481   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11482
11483   Actor actor = CreateRenderableActor();
11484   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
11485   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
11486   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11487   application.GetScene().Add(actor);
11488
11489   Actor actor2 = CreateRenderableActor();
11490   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
11491   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
11492   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11493   application.GetScene().Add(actor2);
11494
11495   application.SendNotification();
11496   std::vector<Rect<int>> damagedRects;
11497   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11498
11499   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
11500   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
11501
11502   // in screen coordinates, adaptor would calculate it using previous frames information
11503   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
11504   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11505
11506   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11507   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11508   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11509   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11510
11511   // Change a Renderer of actor1
11512   Geometry geometry    = CreateQuadGeometry();
11513   Shader   shader      = CreateShader();
11514   Renderer newRenderer = Renderer::New(geometry, shader);
11515   Renderer renderer    = actor.GetRendererAt(0);
11516
11517   actor.RemoveRenderer(renderer);
11518   actor.AddRenderer(newRenderer);
11519
11520   damagedRects.clear();
11521
11522   application.SendNotification();
11523   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11524
11525   DALI_TEST_CHECK(damagedRects.size() > 0);
11526   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
11527
11528   // in screen coordinates, adaptor would calculate it using previous frames information
11529   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11530
11531   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11532   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11533   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11534   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11535
11536   END_TEST;
11537 }
11538
11539 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
11540 {
11541   TestApplication application(
11542     TestApplication::DEFAULT_SURFACE_WIDTH,
11543     TestApplication::DEFAULT_SURFACE_HEIGHT,
11544     TestApplication::DEFAULT_HORIZONTAL_DPI,
11545     TestApplication::DEFAULT_VERTICAL_DPI,
11546     true,
11547     true);
11548
11549   tet_infoline("Check the damaged rect with partial update and update area hint");
11550
11551   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11552
11553   Actor actor = CreateRenderableActor();
11554   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11555   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11556   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11557   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11558   application.GetScene().Add(actor);
11559
11560   application.SendNotification();
11561   std::vector<Rect<int>> damagedRects;
11562   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11563
11564   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11565
11566   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
11567   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11568
11569   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11570
11571   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11572   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11573   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11574   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11575
11576   // Reset
11577   actor.Unparent();
11578
11579   damagedRects.clear();
11580   application.SendNotification();
11581   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11582
11583   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11584   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11585
11586   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11587
11588   damagedRects.clear();
11589   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11590   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11591
11592   // Ensure the damaged rect is empty
11593   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11594
11595   // Change UPDATE_AREA_HINT
11596   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
11597   application.GetScene().Add(actor);
11598
11599   application.SendNotification();
11600   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11601
11602   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11603
11604   clippingRect = Rect<int>(64, 704, 48, 48);
11605   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11606
11607   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11608
11609   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11610   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11611   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11612   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11613
11614   // Reset
11615   actor.Unparent();
11616
11617   damagedRects.clear();
11618   application.SendNotification();
11619   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11620
11621   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11622   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11623
11624   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11625
11626   damagedRects.clear();
11627   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11628   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11629
11630   // Ensure the damaged rect is empty
11631   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11632
11633   // Change UPDATE_AREA_HINT
11634   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
11635   application.GetScene().Add(actor);
11636
11637   application.SendNotification();
11638   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11639
11640   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11641
11642   clippingRect = Rect<int>(0, 720, 80, 80);
11643   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11644
11645   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11646
11647   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11648   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11649   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11650   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11651
11652   END_TEST;
11653 }
11654
11655 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
11656 {
11657   TestApplication application(
11658     TestApplication::DEFAULT_SURFACE_WIDTH,
11659     TestApplication::DEFAULT_SURFACE_HEIGHT,
11660     TestApplication::DEFAULT_HORIZONTAL_DPI,
11661     TestApplication::DEFAULT_VERTICAL_DPI,
11662     true,
11663     true);
11664
11665   tet_infoline("Check the damaged rect with partial update and update area hint");
11666
11667   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11668
11669   Actor actor = CreateRenderableActor();
11670   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11671   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11672   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11673   application.GetScene().Add(actor);
11674
11675   application.SendNotification();
11676   std::vector<Rect<int>> damagedRects;
11677   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11678
11679   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11680
11681   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
11682   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11683
11684   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11685
11686   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11687   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11688   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11689   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11690
11691   damagedRects.clear();
11692   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11693   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11694
11695   // Ensure the damaged rect is empty
11696   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11697
11698   // Change UPDATE_AREA_HINT
11699   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11700
11701   application.SendNotification();
11702   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11703
11704   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11705
11706   clippingRect = Rect<int>(32, 704, 80, 80);
11707   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11708
11709   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11710
11711   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11712   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11713   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11714   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11715
11716   damagedRects.clear();
11717   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11718   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11719
11720   // Ensure the damaged rect is empty
11721   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11722
11723   // Change UPDATE_AREA_HINT
11724   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
11725   application.GetScene().Add(actor);
11726
11727   application.SendNotification();
11728   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11729
11730   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11731
11732   clippingRect = Rect<int>(32, 688, 96, 96);
11733   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11734
11735   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11736
11737   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11738   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11739   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11740   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11741
11742   END_TEST;
11743 }
11744
11745 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
11746 {
11747   TestApplication application(
11748     TestApplication::DEFAULT_SURFACE_WIDTH,
11749     TestApplication::DEFAULT_SURFACE_HEIGHT,
11750     TestApplication::DEFAULT_HORIZONTAL_DPI,
11751     TestApplication::DEFAULT_VERTICAL_DPI,
11752     true,
11753     true);
11754
11755   tet_infoline("Check the damaged rect with partial update and update area hint");
11756
11757   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11758
11759   Actor actor = CreateRenderableActor();
11760   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11761   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11762   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11763   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11764   application.GetScene().Add(actor);
11765
11766   application.SendNotification();
11767   std::vector<Rect<int>> damagedRects;
11768   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11769
11770   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11771
11772   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
11773   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11774
11775   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11776
11777   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11778   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11779   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11780   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11781
11782   damagedRects.clear();
11783   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11784   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11785
11786   // Ensure the damaged rect is empty
11787   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11788
11789   // Set UPDATE_AREA_HINT twice before rendering
11790   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
11791   application.SendNotification();
11792
11793   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
11794   application.SendNotification();
11795
11796   damagedRects.clear();
11797   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11798
11799   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11800
11801   clippingRect = Rect<int>(32, 704, 96, 96);
11802   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11803
11804   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11805
11806   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11807   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11808   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11809   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11810
11811   END_TEST;
11812 }
11813
11814 int utcDaliActorPartialUpdateAnimation01(void)
11815 {
11816   TestApplication application(
11817     TestApplication::DEFAULT_SURFACE_WIDTH,
11818     TestApplication::DEFAULT_SURFACE_HEIGHT,
11819     TestApplication::DEFAULT_HORIZONTAL_DPI,
11820     TestApplication::DEFAULT_VERTICAL_DPI,
11821     true,
11822     true);
11823
11824   tet_infoline("Check the damaged area with partial update and animation");
11825
11826   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11827   drawTrace.Enable(true);
11828   drawTrace.Reset();
11829
11830   Actor actor1 = CreateRenderableActor();
11831   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11832   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
11833   application.GetScene().Add(actor1);
11834
11835   Actor actor2 = CreateRenderableActor();
11836   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11837   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11838   application.GetScene().Add(actor2);
11839
11840   std::vector<Rect<int>> damagedRects;
11841   Rect<int>              clippingRect;
11842   Rect<int>              expectedRect1, expectedRect2;
11843
11844   application.SendNotification();
11845   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11846
11847   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
11848
11849   // Aligned by 16
11850   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
11851   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
11852   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
11853
11854   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11855   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11856
11857   // Make an animation
11858   Animation animation = Animation::New(1.0f);
11859   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
11860   animation.Play();
11861
11862   application.SendNotification();
11863
11864   damagedRects.clear();
11865   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11866   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11867   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11868
11869   drawTrace.Reset();
11870   damagedRects.clear();
11871
11872   // In animation deley time
11873   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11874   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11875   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11876
11877   // Skip rendering
11878   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
11879
11880   drawTrace.Reset();
11881   damagedRects.clear();
11882
11883   // Also in animation deley time
11884   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11885   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
11886   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11887
11888   // Skip rendering
11889   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
11890
11891   // Unparent 2 actors and make a new actor
11892   actor1.Unparent();
11893   actor2.Unparent();
11894
11895   Actor actor3 = CreateRenderableActor();
11896   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11897   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11898   application.GetScene().Add(actor3);
11899
11900   application.SendNotification();
11901
11902   // Started animation
11903   damagedRects.clear();
11904   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11905   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
11906
11907   // One of dirty rect is actor3's.
11908   // We don't know the exact dirty rect of actor1 and actor2.
11909   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
11910
11911   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11912   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11913
11914   // Finished animation, but the actor was already unparented
11915   damagedRects.clear();
11916   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11917
11918   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11919
11920   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11921   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11922
11923   END_TEST;
11924 }
11925
11926 int utcDaliActorPartialUpdateAnimation02(void)
11927 {
11928   TestApplication application(
11929     TestApplication::DEFAULT_SURFACE_WIDTH,
11930     TestApplication::DEFAULT_SURFACE_HEIGHT,
11931     TestApplication::DEFAULT_HORIZONTAL_DPI,
11932     TestApplication::DEFAULT_VERTICAL_DPI,
11933     true,
11934     true);
11935
11936   tet_infoline("Check the damaged area with partial update and animation delay");
11937
11938   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11939   drawTrace.Enable(true);
11940   drawTrace.Reset();
11941
11942   Actor actor = CreateRenderableActor();
11943   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11944   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11945   application.GetScene().Add(actor);
11946
11947   std::vector<Rect<int>> damagedRects;
11948   Rect<int>              clippingRect;
11949
11950   application.SendNotification();
11951   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11952
11953   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11954
11955   // Aligned by 16
11956   clippingRect = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
11957   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11958
11959   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11960
11961   // Make an animation
11962   Renderer  renderer  = actor.GetRendererAt(0);
11963   Animation animation = Animation::New(1.0f);
11964   animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f, TimePeriod(0.5f, 0.5f));
11965   animation.SetLoopCount(3);
11966   animation.Play();
11967
11968   application.SendNotification();
11969
11970   damagedRects.clear();
11971   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11972   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11973
11974   // Delay time
11975   damagedRects.clear();
11976   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11977   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11978
11979   clippingRect = Rect<int>(0, 784, 32, 32);
11980   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11981
11982   // Started animation
11983   damagedRects.clear();
11984   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11985   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11986
11987   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11988
11989   // Delay time
11990   damagedRects.clear();
11991   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11992
11993   // The property is reset to base value. Should be updated
11994   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11995
11996   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11997
11998   // Next render during delay time
11999   damagedRects.clear();
12000   application.PreRenderWithPartialUpdate(50, nullptr, damagedRects);
12001
12002   // Should not be updated
12003   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12004
12005   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12006
12007   END_TEST;
12008 }
12009
12010 int utcDaliActorPartialUpdateChangeVisibility(void)
12011 {
12012   TestApplication application(
12013     TestApplication::DEFAULT_SURFACE_WIDTH,
12014     TestApplication::DEFAULT_SURFACE_HEIGHT,
12015     TestApplication::DEFAULT_HORIZONTAL_DPI,
12016     TestApplication::DEFAULT_VERTICAL_DPI,
12017     true,
12018     true);
12019
12020   tet_infoline("Check the damaged rect with partial update and visibility change");
12021
12022   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12023
12024   Actor actor = CreateRenderableActor();
12025   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
12026   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
12027   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
12028   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12029   application.GetScene().Add(actor);
12030
12031   application.SendNotification();
12032
12033   std::vector<Rect<int>> damagedRects;
12034   Rect<int>              clippingRect;
12035
12036   // 1. Actor added, damaged rect is added size of actor
12037   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12038   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12039
12040   // Aligned by 16
12041   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12042   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12043   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12044   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12045   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12046   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12047   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12048
12049   damagedRects.clear();
12050   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12051   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12052
12053   // Ensure the damaged rect is empty
12054   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12055
12056   // 2. Make the Actor invisible
12057   actor.SetProperty(Actor::Property::VISIBLE, false);
12058   application.SendNotification();
12059
12060   damagedRects.clear();
12061   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12062   DALI_TEST_CHECK(damagedRects.size() > 0);
12063   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12064
12065   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12066   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12067   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12068   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12069   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12070
12071   // 3. Make the Actor visible again
12072   actor.SetProperty(Actor::Property::VISIBLE, true);
12073   application.SendNotification();
12074
12075   damagedRects.clear();
12076   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12077   DALI_TEST_CHECK(damagedRects.size() > 0);
12078   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12079
12080   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12081   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12082   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12083   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12084   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12085
12086   END_TEST;
12087 }
12088
12089 int utcDaliActorPartialUpdateOnOffScene(void)
12090 {
12091   TestApplication application(
12092     TestApplication::DEFAULT_SURFACE_WIDTH,
12093     TestApplication::DEFAULT_SURFACE_HEIGHT,
12094     TestApplication::DEFAULT_HORIZONTAL_DPI,
12095     TestApplication::DEFAULT_VERTICAL_DPI,
12096     true,
12097     true);
12098
12099   tet_infoline("Check the damaged rect with partial update and on/off scene");
12100
12101   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12102
12103   Actor actor = CreateRenderableActor();
12104   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
12105   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
12106   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
12107   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12108   application.GetScene().Add(actor);
12109
12110   application.SendNotification();
12111
12112   std::vector<Rect<int>> damagedRects;
12113   Rect<int>              clippingRect;
12114
12115   // 1. Actor added, damaged rect is added size of actor
12116   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12117   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12118
12119   // Aligned by 16
12120   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12121   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12122   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12123   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12124   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12125   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12126   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12127
12128   damagedRects.clear();
12129   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12130   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12131
12132   damagedRects.clear();
12133   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12134   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12135
12136   // Ensure the damaged rect is empty
12137   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12138
12139   // 2. Remove the Actor from the Scene
12140   actor.Unparent();
12141   application.SendNotification();
12142
12143   damagedRects.clear();
12144   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12145   DALI_TEST_CHECK(damagedRects.size() > 0);
12146   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12147
12148   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12149   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12150   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12151   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12152   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12153
12154   // 3. Add the Actor to the Scene again
12155   application.GetScene().Add(actor);
12156   application.SendNotification();
12157
12158   damagedRects.clear();
12159   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12160   DALI_TEST_CHECK(damagedRects.size() > 0);
12161   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12162
12163   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12164   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12165   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12166   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12167   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12168
12169   END_TEST;
12170 }
12171
12172 int utcDaliActorPartialUpdateSkipRendering(void)
12173 {
12174   TestApplication application(
12175     TestApplication::DEFAULT_SURFACE_WIDTH,
12176     TestApplication::DEFAULT_SURFACE_HEIGHT,
12177     TestApplication::DEFAULT_HORIZONTAL_DPI,
12178     TestApplication::DEFAULT_VERTICAL_DPI,
12179     true,
12180     true);
12181
12182   tet_infoline("Check to skip rendering in case of the empty damaged rect");
12183
12184   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
12185   drawTrace.Enable(true);
12186   drawTrace.Reset();
12187
12188   Actor actor1 = CreateRenderableActor();
12189   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
12190   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
12191   application.GetScene().Add(actor1);
12192
12193   std::vector<Rect<int>> damagedRects;
12194   Rect<int>              clippingRect;
12195   Rect<int>              expectedRect1;
12196
12197   application.SendNotification();
12198   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12199
12200   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12201
12202   // Aligned by 16
12203   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
12204   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
12205
12206   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12207   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12208
12209   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
12210
12211   damagedRects.clear();
12212   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12213   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12214   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12215
12216   // Remove the actor
12217   actor1.Unparent();
12218
12219   application.SendNotification();
12220
12221   damagedRects.clear();
12222   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12223
12224   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
12225
12226   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12227   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12228
12229   // Render again without any change
12230   damagedRects.clear();
12231   drawTrace.Reset();
12232   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12233
12234   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12235
12236   clippingRect = Rect<int>();
12237   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12238
12239   // Skip rendering
12240   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
12241
12242   // Add the actor again
12243   application.GetScene().Add(actor1);
12244
12245   application.SendNotification();
12246
12247   damagedRects.clear();
12248   drawTrace.Reset();
12249   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12250
12251   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
12252
12253   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12254   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12255
12256   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
12257
12258   END_TEST;
12259 }
12260
12261 int utcDaliActorPartialUpdate3DNode(void)
12262 {
12263   TestApplication application(
12264     TestApplication::DEFAULT_SURFACE_WIDTH,
12265     TestApplication::DEFAULT_SURFACE_HEIGHT,
12266     TestApplication::DEFAULT_HORIZONTAL_DPI,
12267     TestApplication::DEFAULT_VERTICAL_DPI,
12268     true,
12269     true);
12270
12271   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
12272
12273   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
12274   drawTrace.Enable(true);
12275   drawTrace.Reset();
12276
12277   Actor actor1 = CreateRenderableActor();
12278   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
12279   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
12280   application.GetScene().Add(actor1);
12281
12282   std::vector<Rect<int>> damagedRects;
12283   Rect<int>              clippingRect;
12284
12285   application.SendNotification();
12286   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12287
12288   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12289
12290   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12291   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12292
12293   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
12294
12295   // Change the layer to 3D
12296   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
12297
12298   application.SendNotification();
12299
12300   damagedRects.clear();
12301   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12302
12303   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12304   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
12305
12306   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12307   drawTrace.Reset();
12308   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12309
12310   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
12311
12312   // Change the layer to 2D
12313   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
12314
12315   application.SendNotification();
12316
12317   damagedRects.clear();
12318   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12319
12320   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12321
12322   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12323   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12324
12325   // Make 3D transform
12326   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
12327
12328   application.SendNotification();
12329
12330   damagedRects.clear();
12331   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12332
12333   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12334   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
12335
12336   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
12337   drawTrace.Reset();
12338   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12339
12340   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
12341
12342   END_TEST;
12343 }
12344
12345 int utcDaliActorPartialUpdateNotRenderableActor(void)
12346 {
12347   TestApplication application(
12348     TestApplication::DEFAULT_SURFACE_WIDTH,
12349     TestApplication::DEFAULT_SURFACE_HEIGHT,
12350     TestApplication::DEFAULT_HORIZONTAL_DPI,
12351     TestApplication::DEFAULT_VERTICAL_DPI,
12352     true,
12353     true);
12354
12355   tet_infoline("Check the damaged rect with not renderable parent actor");
12356
12357   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12358
12359   Actor parent                          = Actor::New();
12360   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12361   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12362   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12363   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12364   application.GetScene().Add(parent);
12365
12366   Actor child                          = CreateRenderableActor();
12367   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12368   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12369   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12370   parent.Add(child);
12371
12372   application.SendNotification();
12373
12374   std::vector<Rect<int>> damagedRects;
12375
12376   // 1. Actor added, damaged rect is added size of actor
12377   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12378   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12379
12380   // Aligned by 16
12381   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12382   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12383
12384   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12385   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12386   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12387   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12388   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12389
12390   damagedRects.clear();
12391   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12392   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12393
12394   damagedRects.clear();
12395   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12396   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12397
12398   // Ensure the damaged rect is empty
12399   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12400
12401   END_TEST;
12402 }
12403
12404 int utcDaliActorPartialUpdateChangeTransparency(void)
12405 {
12406   TestApplication application(
12407     TestApplication::DEFAULT_SURFACE_WIDTH,
12408     TestApplication::DEFAULT_SURFACE_HEIGHT,
12409     TestApplication::DEFAULT_HORIZONTAL_DPI,
12410     TestApplication::DEFAULT_VERTICAL_DPI,
12411     true,
12412     true);
12413
12414   tet_infoline("Check the damaged rect with changing transparency");
12415
12416   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12417
12418   Actor actor                          = CreateRenderableActor();
12419   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12420   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12421   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12422   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12423   application.GetScene().Add(actor);
12424
12425   application.SendNotification();
12426
12427   std::vector<Rect<int>> damagedRects;
12428
12429   // Actor added, damaged rect is added size of actor
12430   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12431   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12432
12433   // Aligned by 16
12434   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12435   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12436
12437   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12438   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12439   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12440   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12441   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12442
12443   damagedRects.clear();
12444   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12445   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12446
12447   // Ensure the damaged rect is empty
12448   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12449
12450   // Make the actor transparent by changing opacity of the Renderer
12451   // It changes a uniform value
12452   Renderer renderer                          = actor.GetRendererAt(0);
12453   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
12454
12455   application.SendNotification();
12456
12457   // The damaged rect should be same
12458   damagedRects.clear();
12459   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12460   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12461   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12462   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12463
12464   damagedRects.clear();
12465   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12466   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12467
12468   // Ensure the damaged rect is empty
12469   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12470
12471   // Make the actor opaque again
12472   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
12473
12474   application.SendNotification();
12475
12476   // The damaged rect should not be empty
12477   damagedRects.clear();
12478   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12479   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12480   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12481   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12482
12483   damagedRects.clear();
12484   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12485   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12486
12487   // Ensure the damaged rect is empty
12488   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12489
12490   // Make the actor translucent
12491   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
12492
12493   application.SendNotification();
12494
12495   // The damaged rect should not be empty
12496   damagedRects.clear();
12497   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12498   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12499   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12500   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12501
12502   damagedRects.clear();
12503   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12504   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12505
12506   // Ensure the damaged rect is empty
12507   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12508
12509   // Change Renderer opacity - also translucent
12510   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
12511
12512   application.SendNotification();
12513
12514   // The damaged rect should not be empty
12515   damagedRects.clear();
12516   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12517   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12518   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12519   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12520
12521   damagedRects.clear();
12522   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12523   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12524
12525   // Ensure the damaged rect is empty
12526   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12527
12528   // Make the actor culled
12529   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
12530
12531   application.SendNotification();
12532
12533   // The damaged rect should be same
12534   damagedRects.clear();
12535   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12536   DALI_TEST_CHECK(damagedRects.size() > 0);
12537   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12538   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12539
12540   damagedRects.clear();
12541   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12542   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12543
12544   // Ensure the damaged rect is empty
12545   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12546
12547   // Make the actor not culled again
12548   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
12549
12550   application.SendNotification();
12551
12552   // The damaged rect should not be empty
12553   damagedRects.clear();
12554   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12555   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12556   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12557   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12558
12559   END_TEST;
12560 }
12561
12562 int utcDaliActorPartialUpdateChangeParentOpacity(void)
12563 {
12564   TestApplication application(
12565     TestApplication::DEFAULT_SURFACE_WIDTH,
12566     TestApplication::DEFAULT_SURFACE_HEIGHT,
12567     TestApplication::DEFAULT_HORIZONTAL_DPI,
12568     TestApplication::DEFAULT_VERTICAL_DPI,
12569     true,
12570     true);
12571
12572   tet_infoline("Check the damaged rect with changing parent's opacity");
12573
12574   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12575
12576   Actor parent                          = Actor::New();
12577   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12578   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12579   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12580   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12581   application.GetScene().Add(parent);
12582
12583   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
12584   Actor   child                        = CreateRenderableActor(texture);
12585   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12586   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12587   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12588   parent.Add(child);
12589
12590   application.SendNotification();
12591
12592   std::vector<Rect<int>> damagedRects;
12593
12594   // Actor added, damaged rect is added size of actor
12595   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12596   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12597
12598   // Aligned by 16
12599   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12600   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12601
12602   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12603   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12604   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12605   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12606   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12607
12608   damagedRects.clear();
12609   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12610   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12611
12612   damagedRects.clear();
12613   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12614   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12615
12616   // Ensure the damaged rect is empty
12617   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12618
12619   // Change the parent's opacity
12620   parent[Actor::Property::OPACITY] = 0.5f;
12621
12622   application.SendNotification();
12623
12624   // The damaged rect should be same
12625   damagedRects.clear();
12626   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12627   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12628   DALI_TEST_CHECK(damagedRects.size() > 0);
12629   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12630
12631   END_TEST;
12632 }
12633
12634 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
12635 {
12636   TestApplication application(
12637     TestApplication::DEFAULT_SURFACE_WIDTH,
12638     TestApplication::DEFAULT_SURFACE_HEIGHT,
12639     TestApplication::DEFAULT_HORIZONTAL_DPI,
12640     TestApplication::DEFAULT_VERTICAL_DPI,
12641     true,
12642     true);
12643
12644   tet_infoline("Check the damaged rect with adding / removing renderer");
12645
12646   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12647
12648   Actor actor                          = CreateRenderableActor();
12649   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12650   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12651   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12652   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12653   application.GetScene().Add(actor);
12654
12655   application.SendNotification();
12656
12657   std::vector<Rect<int>> damagedRects;
12658
12659   // Actor added, damaged rect is added size of actor
12660   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12661   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12662
12663   // Aligned by 16
12664   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12665   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12666
12667   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12668   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12669   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12670   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12671   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12672
12673   damagedRects.clear();
12674   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12675   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12676
12677   damagedRects.clear();
12678   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12679   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12680
12681   // Remove the Renderer
12682   Renderer renderer = actor.GetRendererAt(0);
12683   actor.RemoveRenderer(renderer);
12684
12685   application.SendNotification();
12686
12687   // The damaged rect should be the actor area
12688   damagedRects.clear();
12689   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12690   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12691   DALI_TEST_CHECK(damagedRects.size() > 0);
12692   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12693
12694   damagedRects.clear();
12695   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12696   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12697
12698   // Ensure the damaged rect is empty
12699   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12700
12701   // Add the Renderer again
12702   actor.AddRenderer(renderer);
12703
12704   application.SendNotification();
12705
12706   // The damaged rect should be the actor area
12707   damagedRects.clear();
12708   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12709   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12710   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12711   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12712
12713   END_TEST;
12714 }
12715
12716 int utcDaliActorPartialUpdate3DTransform(void)
12717 {
12718   TestApplication application(
12719     TestApplication::DEFAULT_SURFACE_WIDTH,
12720     TestApplication::DEFAULT_SURFACE_HEIGHT,
12721     TestApplication::DEFAULT_HORIZONTAL_DPI,
12722     TestApplication::DEFAULT_VERTICAL_DPI,
12723     true,
12724     true);
12725
12726   tet_infoline("Check the damaged rect with 3D transformed actors");
12727
12728   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12729
12730   Actor actor1                          = CreateRenderableActor();
12731   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12732   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12733   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12734   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12735   application.GetScene().Add(actor1);
12736
12737   // Add a new actor
12738   Actor actor2                          = CreateRenderableActor();
12739   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12740   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
12741   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12742   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12743   application.GetScene().Add(actor2);
12744
12745   application.SendNotification();
12746
12747   std::vector<Rect<int>> damagedRects;
12748
12749   // Actor added, damaged rect is added size of actor
12750   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12751   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12752
12753   // Aligned by 16
12754   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
12755   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
12756   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
12757
12758   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12759   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12760
12761   damagedRects.clear();
12762   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12763   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12764   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12765
12766   damagedRects.clear();
12767   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12768   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12769   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12770
12771   // Rotate actor1 on y axis
12772   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
12773
12774   // Remove actor2
12775   actor2.Unparent();
12776
12777   application.SendNotification();
12778
12779   damagedRects.clear();
12780   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12781
12782   // Should update full area
12783   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12784   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12785   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12786   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12787
12788   // Add actor2 again
12789   application.GetScene().Add(actor2);
12790
12791   application.SendNotification();
12792
12793   damagedRects.clear();
12794   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12795
12796   // Should update full area
12797   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12798   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12799   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12800   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12801
12802   // Reset the orientation of actor1
12803   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
12804
12805   application.SendNotification();
12806
12807   damagedRects.clear();
12808   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12809
12810   // Should update full area
12811   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12812   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12813   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12814   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12815
12816   // Make actor2 dirty
12817   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
12818
12819   application.SendNotification();
12820
12821   damagedRects.clear();
12822   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12823
12824   clippingRect2 = Rect<int>(160, 608, 48, 48);
12825   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12826   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
12827
12828   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
12829   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
12830   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
12831   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
12832   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
12833
12834   // Remove actor1
12835   actor1.Unparent();
12836
12837   application.SendNotification();
12838
12839   damagedRects.clear();
12840   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12841   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12842   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12843
12844   // Rotate actor1 on y axis
12845   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
12846
12847   // Add actor1 again
12848   application.GetScene().Add(actor1);
12849
12850   application.SendNotification();
12851
12852   damagedRects.clear();
12853   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12854
12855   // Should update full area
12856   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12857   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12858   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12859   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12860
12861   END_TEST;
12862 }
12863
12864 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
12865 {
12866   TestApplication application(
12867     TestApplication::DEFAULT_SURFACE_WIDTH,
12868     TestApplication::DEFAULT_SURFACE_HEIGHT,
12869     TestApplication::DEFAULT_HORIZONTAL_DPI,
12870     TestApplication::DEFAULT_VERTICAL_DPI,
12871     true,
12872     true);
12873
12874   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
12875
12876   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12877
12878   Actor actor = CreateRenderableActor();
12879
12880   // Create another renderer
12881   Geometry geometry  = CreateQuadGeometry();
12882   Shader   shader    = CreateShader();
12883   Renderer renderer2 = Renderer::New(geometry, shader);
12884   actor.AddRenderer(renderer2);
12885
12886   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12887   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12888   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12889   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12890   application.GetScene().Add(actor);
12891
12892   application.SendNotification();
12893
12894   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
12895
12896   std::vector<Rect<int>> damagedRects;
12897
12898   // Actor added, damaged rect is added size of actor
12899   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12900   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12901
12902   // Aligned by 16
12903   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12904   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
12905
12906   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12907   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12908   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12909   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12910   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12911
12912   damagedRects.clear();
12913   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12914   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12915
12916   // Ensure the damaged rect is empty
12917   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12918
12919   // Make renderer2 dirty
12920   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
12921
12922   application.SendNotification();
12923
12924   // The damaged rect should be the actor area
12925   damagedRects.clear();
12926   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12927
12928   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12929   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12930   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12931
12932   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12933
12934   damagedRects.clear();
12935   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12936   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12937
12938   // Ensure the damaged rect is empty
12939   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12940
12941   // Make renderer2 dirty
12942   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
12943
12944   application.SendNotification();
12945
12946   // The damaged rect should be the actor area
12947   damagedRects.clear();
12948   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12949
12950   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12951   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12952   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12953
12954   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12955
12956   damagedRects.clear();
12957   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12958   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12959
12960   // Ensure the damaged rect is empty
12961   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12962
12963   END_TEST;
12964 }
12965
12966 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
12967 {
12968   TestApplication application(
12969     TestApplication::DEFAULT_SURFACE_WIDTH,
12970     TestApplication::DEFAULT_SURFACE_HEIGHT,
12971     TestApplication::DEFAULT_HORIZONTAL_DPI,
12972     TestApplication::DEFAULT_VERTICAL_DPI,
12973     true,
12974     true);
12975
12976   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
12977
12978   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12979
12980   Actor actor                          = CreateRenderableActor();
12981   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12982   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12983   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12984   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12985   application.GetScene().Add(actor);
12986
12987   // Create another actor which has the same renderer with actor1
12988   Actor    actor2   = Actor::New();
12989   Renderer renderer = actor.GetRendererAt(0);
12990   actor2.AddRenderer(renderer);
12991   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12992   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12993   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12994   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12995   application.GetScene().Add(actor2);
12996
12997   application.SendNotification();
12998
12999   std::vector<Rect<int>> damagedRects;
13000
13001   // Actor added, damaged rect is added size of actor
13002   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13003   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
13004
13005   // Aligned by 16
13006   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
13007   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
13008
13009   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13010   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
13011   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
13012   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
13013   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
13014
13015   damagedRects.clear();
13016   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13017   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13018
13019   // Ensure the damaged rect is empty
13020   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
13021
13022   // Make renderer dirty
13023   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
13024
13025   application.SendNotification();
13026
13027   // The damaged rect should be the actor area
13028   damagedRects.clear();
13029   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13030
13031   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
13032   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
13033   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
13034
13035   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13036
13037   damagedRects.clear();
13038   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13039   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13040
13041   // Ensure the damaged rect is empty
13042   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
13043
13044   END_TEST;
13045 }
13046
13047 int utcDaliActorPartialUpdateUseTextureUpdateArea01(void)
13048 {
13049   TestApplication application(
13050     TestApplication::DEFAULT_SURFACE_WIDTH,
13051     TestApplication::DEFAULT_SURFACE_HEIGHT,
13052     TestApplication::DEFAULT_HORIZONTAL_DPI,
13053     TestApplication::DEFAULT_VERTICAL_DPI,
13054     true,
13055     true);
13056
13057   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property");
13058
13059   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
13060
13061   Actor actor                              = CreateRenderableActor();
13062   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
13063   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
13064   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
13065   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
13066   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
13067
13068   // Create a native image source.
13069   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
13070   Texture                texture         = Texture::New(*testNativeImage);
13071   TextureSet             textureSet      = TextureSet::New();
13072   textureSet.SetTexture(0u, texture);
13073   actor.GetRendererAt(0).SetTextures(textureSet);
13074
13075   application.GetScene().Add(actor);
13076
13077   application.SendNotification();
13078
13079   std::vector<Rect<int>> damagedRects;
13080
13081   // Actor added, damaged rect is added size of actor
13082   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13083   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13084
13085   // Aligned by 16
13086   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
13087   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13088
13089   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13090   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
13091   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
13092   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
13093   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
13094
13095   // Set USE_TEXTURE_UPDATE_AREA
13096   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
13097
13098   // Set updated area of native image
13099   testNativeImage->SetUpdatedArea(Rect<uint32_t>(16, 16, 48, 48));
13100
13101   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13102   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
13103
13104   application.SendNotification();
13105
13106   damagedRects.clear();
13107   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13108   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13109   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13110
13111   // Aligned by 16
13112   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
13113   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13114
13115   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13116
13117   END_TEST;
13118 }
13119
13120 int utcDaliActorPartialUpdateUseTextureUpdateArea02(void)
13121 {
13122   TestApplication application(
13123     TestApplication::DEFAULT_SURFACE_WIDTH,
13124     TestApplication::DEFAULT_SURFACE_HEIGHT,
13125     TestApplication::DEFAULT_HORIZONTAL_DPI,
13126     TestApplication::DEFAULT_VERTICAL_DPI,
13127     true,
13128     true);
13129
13130   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property and multiple native textures");
13131
13132   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
13133
13134   Actor actor                              = CreateRenderableActor();
13135   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
13136   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
13137   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
13138   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
13139   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
13140
13141   // Create a native image source.
13142   TestNativeImagePointer testNativeImage1 = TestNativeImage::New(64u, 64u);
13143   Texture                texture1         = Texture::New(*testNativeImage1);
13144   TestNativeImagePointer testNativeImage2 = TestNativeImage::New(64u, 64u);
13145   Texture                texture2         = Texture::New(*testNativeImage2);
13146
13147   TextureSet textureSet = TextureSet::New();
13148   textureSet.SetTexture(0u, texture1);
13149   textureSet.SetTexture(1u, texture2);
13150   actor.GetRendererAt(0).SetTextures(textureSet);
13151
13152   application.GetScene().Add(actor);
13153
13154   application.SendNotification();
13155
13156   std::vector<Rect<int>> damagedRects;
13157
13158   // Actor added, damaged rect is added size of actor
13159   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13160   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13161
13162   // Aligned by 16
13163   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
13164   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13165
13166   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13167   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
13168   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
13169   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
13170   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
13171
13172   // Set USE_TEXTURE_UPDATE_AREA
13173   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
13174
13175   // Set updated area of native image
13176   testNativeImage1->SetUpdatedArea(Rect<uint32_t>(0, 0, 32, 32));
13177   testNativeImage2->SetUpdatedArea(Rect<uint32_t>(32, 0, 32, 32));
13178
13179   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13180   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
13181
13182   application.SendNotification();
13183
13184   damagedRects.clear();
13185   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13186   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13187   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13188
13189   // Aligned by 16
13190   clippingRect = Rect<int>(0, 752, 80, 64); // in screen coordinates
13191   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13192
13193   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13194
13195   END_TEST;
13196 }
13197
13198 int utcDaliActorPartialUpdateUseTextureUpdateArea03(void)
13199 {
13200   TestApplication application(
13201     TestApplication::DEFAULT_SURFACE_WIDTH,
13202     TestApplication::DEFAULT_SURFACE_HEIGHT,
13203     TestApplication::DEFAULT_HORIZONTAL_DPI,
13204     TestApplication::DEFAULT_VERTICAL_DPI,
13205     true,
13206     true);
13207
13208   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property and multiple normal textures");
13209
13210   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
13211
13212   uint32_t width = 64, height = 64;
13213
13214   Texture texture1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, width, height);
13215   Texture texture2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, width, height);
13216   Actor   actor    = CreateRenderableActor(texture1);
13217   actor.GetRendererAt(0).GetTextures().SetTexture(1u, texture2);
13218
13219   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
13220   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
13221   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
13222   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
13223   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
13224
13225   application.GetScene().Add(actor);
13226
13227   application.SendNotification();
13228
13229   std::vector<Rect<int>> damagedRects;
13230
13231   // Actor added, damaged rect is added size of actor
13232   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13233   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13234
13235   // Aligned by 16
13236   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
13237   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13238
13239   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13240   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
13241   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
13242   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
13243   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
13244
13245   // Set USE_TEXTURE_UPDATE_AREA
13246   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
13247
13248   int       bufferSize = width * height * 4;
13249   uint8_t*  buffer     = reinterpret_cast<uint8_t*>(malloc(bufferSize));
13250   PixelData pixelData  = PixelData::New(buffer, bufferSize, width, height, Pixel::Format::RGBA8888, PixelData::FREE);
13251
13252   // Update textures
13253   texture1.Upload(pixelData, 0u, 0u, 0u, 0u, 32u, 32u);
13254   texture2.Upload(pixelData, 0u, 0u, 32u, 0u, 32u, 32u);
13255
13256   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13257   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
13258
13259   application.SendNotification();
13260
13261   damagedRects.clear();
13262   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13263   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13264   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13265
13266   // Aligned by 16
13267   clippingRect = Rect<int>(0, 752, 80, 64); // in screen coordinates
13268   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13269
13270   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
13271
13272   // Update full area of the texture
13273   texture1.Upload(pixelData);
13274
13275   application.SendNotification();
13276
13277   damagedRects.clear();
13278   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
13279   application.RenderWithPartialUpdate(damagedRects, clippingRect);
13280   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
13281
13282   // Aligned by 16
13283   clippingRect = Rect<int>(0, 736, 80, 80); // in screen coordinates
13284   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
13285
13286   END_TEST;
13287 }
13288
13289 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
13290 {
13291   TestApplication application;
13292
13293   Actor actor = Actor::New();
13294   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
13295   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
13296   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
13297   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
13298   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
13299   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
13300   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
13301   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
13302   END_TEST;
13303 }
13304
13305 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
13306 {
13307   TestApplication application;
13308
13309   Actor actor = Actor::New();
13310
13311   // Make sure setting invalid types does not cause a crash
13312   try
13313   {
13314     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
13315     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
13316     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
13317     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
13318     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
13319     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
13320     tet_result(TET_PASS);
13321   }
13322   catch(...)
13323   {
13324     tet_result(TET_FAIL);
13325   }
13326   END_TEST;
13327 }
13328
13329 int UtcDaliActorTouchAreaOffsetPropertyP(void)
13330 {
13331   TestApplication application;
13332
13333   Actor     actor           = Actor::New();
13334   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
13335   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
13336   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
13337   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
13338   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
13339   END_TEST;
13340 }
13341
13342 int UtcDaliActorTouchAreaOffsetPropertyN(void)
13343 {
13344   TestApplication application;
13345
13346   Actor actor = Actor::New();
13347
13348   // Make sure setting invalid types does not cause a crash
13349   try
13350   {
13351     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
13352     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
13353     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
13354     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
13355     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
13356     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
13357     tet_result(TET_PASS);
13358   }
13359   catch(...)
13360   {
13361     tet_result(TET_FAIL);
13362   }
13363   END_TEST;
13364 }
13365
13366 int UtcDaliActorLowerBelowNegative(void)
13367 {
13368   TestApplication application;
13369   Dali::Actor     instance;
13370   try
13371   {
13372     Dali::Actor arg1;
13373     instance.LowerBelow(arg1);
13374     DALI_TEST_CHECK(false); // Should not get here
13375   }
13376   catch(...)
13377   {
13378     DALI_TEST_CHECK(true); // We expect an assert
13379   }
13380   END_TEST;
13381 }
13382
13383 int UtcDaliActorRaiseAboveNegative(void)
13384 {
13385   TestApplication application;
13386   Dali::Actor     instance;
13387   try
13388   {
13389     Dali::Actor arg1;
13390     instance.RaiseAbove(arg1);
13391     DALI_TEST_CHECK(false); // Should not get here
13392   }
13393   catch(...)
13394   {
13395     DALI_TEST_CHECK(true); // We expect an assert
13396   }
13397   END_TEST;
13398 }
13399
13400 int UtcDaliActorRaiseToTopNegative(void)
13401 {
13402   TestApplication application;
13403   Dali::Actor     instance;
13404   try
13405   {
13406     instance.RaiseToTop();
13407     DALI_TEST_CHECK(false); // Should not get here
13408   }
13409   catch(...)
13410   {
13411     DALI_TEST_CHECK(true); // We expect an assert
13412   }
13413   END_TEST;
13414 }
13415
13416 int UtcDaliActorAddRendererNegative(void)
13417 {
13418   TestApplication application;
13419   Dali::Actor     instance;
13420   try
13421   {
13422     Dali::Renderer arg1;
13423     instance.AddRenderer(arg1);
13424     DALI_TEST_CHECK(false); // Should not get here
13425   }
13426   catch(...)
13427   {
13428     DALI_TEST_CHECK(true); // We expect an assert
13429   }
13430   END_TEST;
13431 }
13432
13433 int UtcDaliActorTouchedSignalNegative(void)
13434 {
13435   TestApplication application;
13436   Dali::Actor     instance;
13437   try
13438   {
13439     instance.TouchedSignal();
13440     DALI_TEST_CHECK(false); // Should not get here
13441   }
13442   catch(...)
13443   {
13444     DALI_TEST_CHECK(true); // We expect an assert
13445   }
13446   END_TEST;
13447 }
13448
13449 int UtcDaliActorTranslateByNegative(void)
13450 {
13451   TestApplication application;
13452   Dali::Actor     instance;
13453   try
13454   {
13455     Dali::Vector3 arg1;
13456     instance.TranslateBy(arg1);
13457     DALI_TEST_CHECK(false); // Should not get here
13458   }
13459   catch(...)
13460   {
13461     DALI_TEST_CHECK(true); // We expect an assert
13462   }
13463   END_TEST;
13464 }
13465
13466 int UtcDaliActorFindChildByIdNegative(void)
13467 {
13468   TestApplication application;
13469   Dali::Actor     instance;
13470   try
13471   {
13472     unsigned int arg1 = 0u;
13473     instance.FindChildById(arg1);
13474     DALI_TEST_CHECK(false); // Should not get here
13475   }
13476   catch(...)
13477   {
13478     DALI_TEST_CHECK(true); // We expect an assert
13479   }
13480   END_TEST;
13481 }
13482
13483 int UtcDaliActorGetRendererAtNegative(void)
13484 {
13485   TestApplication application;
13486   Dali::Actor     instance;
13487   try
13488   {
13489     unsigned int arg1 = 0u;
13490     instance.GetRendererAt(arg1);
13491     DALI_TEST_CHECK(false); // Should not get here
13492   }
13493   catch(...)
13494   {
13495     DALI_TEST_CHECK(true); // We expect an assert
13496   }
13497   END_TEST;
13498 }
13499
13500 int UtcDaliActorHoveredSignalNegative(void)
13501 {
13502   TestApplication application;
13503   Dali::Actor     instance;
13504   try
13505   {
13506     instance.HoveredSignal();
13507     DALI_TEST_CHECK(false); // Should not get here
13508   }
13509   catch(...)
13510   {
13511     DALI_TEST_CHECK(true); // We expect an assert
13512   }
13513   END_TEST;
13514 }
13515
13516 int UtcDaliActorLowerToBottomNegative(void)
13517 {
13518   TestApplication application;
13519   Dali::Actor     instance;
13520   try
13521   {
13522     instance.LowerToBottom();
13523     DALI_TEST_CHECK(false); // Should not get here
13524   }
13525   catch(...)
13526   {
13527     DALI_TEST_CHECK(true); // We expect an assert
13528   }
13529   END_TEST;
13530 }
13531
13532 int UtcDaliActorOnSceneSignalNegative(void)
13533 {
13534   TestApplication application;
13535   Dali::Actor     instance;
13536   try
13537   {
13538     instance.OnSceneSignal();
13539     DALI_TEST_CHECK(false); // Should not get here
13540   }
13541   catch(...)
13542   {
13543     DALI_TEST_CHECK(true); // We expect an assert
13544   }
13545   END_TEST;
13546 }
13547
13548 int UtcDaliActorOffSceneSignalNegative(void)
13549 {
13550   TestApplication application;
13551   Dali::Actor     instance;
13552   try
13553   {
13554     instance.OffSceneSignal();
13555     DALI_TEST_CHECK(false); // Should not get here
13556   }
13557   catch(...)
13558   {
13559     DALI_TEST_CHECK(true); // We expect an assert
13560   }
13561   END_TEST;
13562 }
13563
13564 int UtcDaliActorRemoveRendererNegative01(void)
13565 {
13566   TestApplication application;
13567   Dali::Actor     instance;
13568   try
13569   {
13570     unsigned int arg1 = 0u;
13571     instance.RemoveRenderer(arg1);
13572     DALI_TEST_CHECK(false); // Should not get here
13573   }
13574   catch(...)
13575   {
13576     DALI_TEST_CHECK(true); // We expect an assert
13577   }
13578   END_TEST;
13579 }
13580
13581 int UtcDaliActorRemoveRendererNegative02(void)
13582 {
13583   TestApplication application;
13584   Dali::Actor     instance;
13585   try
13586   {
13587     Dali::Renderer arg1;
13588     instance.RemoveRenderer(arg1);
13589     DALI_TEST_CHECK(false); // Should not get here
13590   }
13591   catch(...)
13592   {
13593     DALI_TEST_CHECK(true); // We expect an assert
13594   }
13595   END_TEST;
13596 }
13597
13598 int UtcDaliActorFindChildByNameNegative(void)
13599 {
13600   TestApplication application;
13601   Dali::Actor     instance;
13602   try
13603   {
13604     std::string arg1;
13605     instance.FindChildByName(arg1);
13606     DALI_TEST_CHECK(false); // Should not get here
13607   }
13608   catch(...)
13609   {
13610     DALI_TEST_CHECK(true); // We expect an assert
13611   }
13612   END_TEST;
13613 }
13614
13615 int UtcDaliActorSetResizePolicyNegative(void)
13616 {
13617   TestApplication application;
13618   Dali::Actor     instance;
13619   try
13620   {
13621     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
13622     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
13623     instance.SetResizePolicy(arg1, arg2);
13624     DALI_TEST_CHECK(false); // Should not get here
13625   }
13626   catch(...)
13627   {
13628     DALI_TEST_CHECK(true); // We expect an assert
13629   }
13630   END_TEST;
13631 }
13632
13633 int UtcDaliActorOnRelayoutSignalNegative(void)
13634 {
13635   TestApplication application;
13636   Dali::Actor     instance;
13637   try
13638   {
13639     instance.OnRelayoutSignal();
13640     DALI_TEST_CHECK(false); // Should not get here
13641   }
13642   catch(...)
13643   {
13644     DALI_TEST_CHECK(true); // We expect an assert
13645   }
13646   END_TEST;
13647 }
13648
13649 int UtcDaliActorWheelEventSignalNegative(void)
13650 {
13651   TestApplication application;
13652   Dali::Actor     instance;
13653   try
13654   {
13655     instance.WheelEventSignal();
13656     DALI_TEST_CHECK(false); // Should not get here
13657   }
13658   catch(...)
13659   {
13660     DALI_TEST_CHECK(true); // We expect an assert
13661   }
13662   END_TEST;
13663 }
13664
13665 int UtcDaliActorGetHeightForWidthNegative(void)
13666 {
13667   TestApplication application;
13668   Dali::Actor     instance;
13669   try
13670   {
13671     float arg1 = 0.0f;
13672     instance.GetHeightForWidth(arg1);
13673     DALI_TEST_CHECK(false); // Should not get here
13674   }
13675   catch(...)
13676   {
13677     DALI_TEST_CHECK(true); // We expect an assert
13678   }
13679   END_TEST;
13680 }
13681
13682 int UtcDaliActorGetWidthForHeightNegative(void)
13683 {
13684   TestApplication application;
13685   Dali::Actor     instance;
13686   try
13687   {
13688     float arg1 = 0.0f;
13689     instance.GetWidthForHeight(arg1);
13690     DALI_TEST_CHECK(false); // Should not get here
13691   }
13692   catch(...)
13693   {
13694     DALI_TEST_CHECK(true); // We expect an assert
13695   }
13696   END_TEST;
13697 }
13698
13699 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
13700 {
13701   TestApplication application;
13702   Dali::Actor     instance;
13703   try
13704   {
13705     instance.LayoutDirectionChangedSignal();
13706     DALI_TEST_CHECK(false); // Should not get here
13707   }
13708   catch(...)
13709   {
13710     DALI_TEST_CHECK(true); // We expect an assert
13711   }
13712   END_TEST;
13713 }
13714
13715 int UtcDaliActorAddNegative(void)
13716 {
13717   TestApplication application;
13718   Dali::Actor     instance;
13719   try
13720   {
13721     Dali::Actor arg1;
13722     instance.Add(arg1);
13723     DALI_TEST_CHECK(false); // Should not get here
13724   }
13725   catch(...)
13726   {
13727     DALI_TEST_CHECK(true); // We expect an assert
13728   }
13729   END_TEST;
13730 }
13731
13732 int UtcDaliActorLowerNegative(void)
13733 {
13734   TestApplication application;
13735   Dali::Actor     instance;
13736   try
13737   {
13738     instance.Lower();
13739     DALI_TEST_CHECK(false); // Should not get here
13740   }
13741   catch(...)
13742   {
13743     DALI_TEST_CHECK(true); // We expect an assert
13744   }
13745   END_TEST;
13746 }
13747
13748 int UtcDaliActorRaiseNegative(void)
13749 {
13750   TestApplication application;
13751   Dali::Actor     instance;
13752   try
13753   {
13754     instance.Raise();
13755     DALI_TEST_CHECK(false); // Should not get here
13756   }
13757   catch(...)
13758   {
13759     DALI_TEST_CHECK(true); // We expect an assert
13760   }
13761   END_TEST;
13762 }
13763
13764 int UtcDaliActorRemoveNegative(void)
13765 {
13766   TestApplication application;
13767   Dali::Actor     instance;
13768   try
13769   {
13770     Dali::Actor arg1;
13771     instance.Remove(arg1);
13772     DALI_TEST_CHECK(false); // Should not get here
13773   }
13774   catch(...)
13775   {
13776     DALI_TEST_CHECK(true); // We expect an assert
13777   }
13778   END_TEST;
13779 }
13780
13781 int UtcDaliActorScaleByNegative(void)
13782 {
13783   TestApplication application;
13784   Dali::Actor     instance;
13785   try
13786   {
13787     Dali::Vector3 arg1;
13788     instance.ScaleBy(arg1);
13789     DALI_TEST_CHECK(false); // Should not get here
13790   }
13791   catch(...)
13792   {
13793     DALI_TEST_CHECK(true); // We expect an assert
13794   }
13795   END_TEST;
13796 }
13797
13798 int UtcDaliActorGetLayerNegative(void)
13799 {
13800   TestApplication application;
13801   Dali::Actor     instance;
13802   try
13803   {
13804     instance.GetLayer();
13805     DALI_TEST_CHECK(false); // Should not get here
13806   }
13807   catch(...)
13808   {
13809     DALI_TEST_CHECK(true); // We expect an assert
13810   }
13811   END_TEST;
13812 }
13813
13814 int UtcDaliActorRotateByNegative01(void)
13815 {
13816   TestApplication application;
13817   Dali::Actor     instance;
13818   try
13819   {
13820     Dali::Quaternion arg1;
13821     instance.RotateBy(arg1);
13822     DALI_TEST_CHECK(false); // Should not get here
13823   }
13824   catch(...)
13825   {
13826     DALI_TEST_CHECK(true); // We expect an assert
13827   }
13828   END_TEST;
13829 }
13830
13831 int UtcDaliActorRotateByNegative02(void)
13832 {
13833   TestApplication application;
13834   Dali::Actor     instance;
13835   try
13836   {
13837     Dali::Radian  arg1;
13838     Dali::Vector3 arg2;
13839     instance.RotateBy(arg1, arg2);
13840     DALI_TEST_CHECK(false); // Should not get here
13841   }
13842   catch(...)
13843   {
13844     DALI_TEST_CHECK(true); // We expect an assert
13845   }
13846   END_TEST;
13847 }
13848
13849 int UtcDaliActorUnparentNegative(void)
13850 {
13851   TestApplication application;
13852   Dali::Actor     instance;
13853   try
13854   {
13855     instance.Unparent();
13856     DALI_TEST_CHECK(false); // Should not get here
13857   }
13858   catch(...)
13859   {
13860     DALI_TEST_CHECK(true); // We expect an assert
13861   }
13862   END_TEST;
13863 }
13864
13865 int UtcDaliActorGetChildAtNegative(void)
13866 {
13867   TestApplication application;
13868   Dali::Actor     instance;
13869   try
13870   {
13871     unsigned int arg1 = 0u;
13872     instance.GetChildAt(arg1);
13873     DALI_TEST_CHECK(false); // Should not get here
13874   }
13875   catch(...)
13876   {
13877     DALI_TEST_CHECK(true); // We expect an assert
13878   }
13879   END_TEST;
13880 }
13881
13882 int UtcDaliActorGetChildCountNegative(void)
13883 {
13884   TestApplication application;
13885   Dali::Actor     instance;
13886   try
13887   {
13888     instance.GetChildCount();
13889     DALI_TEST_CHECK(false); // Should not get here
13890   }
13891   catch(...)
13892   {
13893     DALI_TEST_CHECK(true); // We expect an assert
13894   }
13895   END_TEST;
13896 }
13897
13898 int UtcDaliActorGetTargetSizeNegative(void)
13899 {
13900   TestApplication application;
13901   Dali::Actor     instance;
13902   try
13903   {
13904     instance.GetTargetSize();
13905     DALI_TEST_CHECK(false); // Should not get here
13906   }
13907   catch(...)
13908   {
13909     DALI_TEST_CHECK(true); // We expect an assert
13910   }
13911   END_TEST;
13912 }
13913
13914 int UtcDaliActorScreenToLocalNegative(void)
13915 {
13916   TestApplication application;
13917   Dali::Actor     instance;
13918   try
13919   {
13920     float arg1 = 0.0f;
13921     float arg2 = 0.0f;
13922     float arg3 = 0.0f;
13923     float arg4 = 0.0f;
13924     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
13925     DALI_TEST_CHECK(false); // Should not get here
13926   }
13927   catch(...)
13928   {
13929     DALI_TEST_CHECK(true); // We expect an assert
13930   }
13931   END_TEST;
13932 }
13933
13934 int UtcDaliActorGetNaturalSizeNegative(void)
13935 {
13936   TestApplication application;
13937   Dali::Actor     instance;
13938   try
13939   {
13940     instance.GetNaturalSize();
13941     DALI_TEST_CHECK(false); // Should not get here
13942   }
13943   catch(...)
13944   {
13945     DALI_TEST_CHECK(true); // We expect an assert
13946   }
13947   END_TEST;
13948 }
13949
13950 int UtcDaliActorGetRelayoutSizeNegative(void)
13951 {
13952   TestApplication application;
13953   Dali::Actor     instance;
13954   try
13955   {
13956     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
13957     instance.GetRelayoutSize(arg1);
13958     DALI_TEST_CHECK(false); // Should not get here
13959   }
13960   catch(...)
13961   {
13962     DALI_TEST_CHECK(true); // We expect an assert
13963   }
13964   END_TEST;
13965 }
13966
13967 int UtcDaliActorGetResizePolicyNegative(void)
13968 {
13969   TestApplication application;
13970   Dali::Actor     instance;
13971   try
13972   {
13973     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
13974     instance.GetResizePolicy(arg1);
13975     DALI_TEST_CHECK(false); // Should not get here
13976   }
13977   catch(...)
13978   {
13979     DALI_TEST_CHECK(true); // We expect an assert
13980   }
13981   END_TEST;
13982 }
13983
13984 int UtcDaliActorGetRendererCountNegative(void)
13985 {
13986   TestApplication application;
13987   Dali::Actor     instance;
13988   try
13989   {
13990     instance.GetRendererCount();
13991     DALI_TEST_CHECK(false); // Should not get here
13992   }
13993   catch(...)
13994   {
13995     DALI_TEST_CHECK(true); // We expect an assert
13996   }
13997   END_TEST;
13998 }
13999
14000 int UtcDaliActorGetParentNegative(void)
14001 {
14002   TestApplication application;
14003   Dali::Actor     instance;
14004   try
14005   {
14006     instance.GetParent();
14007     DALI_TEST_CHECK(false); // Should not get here
14008   }
14009   catch(...)
14010   {
14011     DALI_TEST_CHECK(true); // We expect an assert
14012   }
14013   END_TEST;
14014 }
14015
14016 int UtcDaliActorPropertyBlendEquation(void)
14017 {
14018   TestApplication application;
14019
14020   tet_infoline("Test SetProperty AdvancedBlendEquation");
14021
14022   Geometry geometry  = CreateQuadGeometry();
14023   Shader   shader    = CreateShader();
14024   Renderer renderer1 = Renderer::New(geometry, shader);
14025
14026   Actor actor = Actor::New();
14027   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
14028
14029   actor.AddRenderer(renderer1);
14030   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
14031   application.GetScene().Add(actor);
14032
14033   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
14034   {
14035     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
14036     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
14037     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
14038   }
14039
14040   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
14041   {
14042     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
14043     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
14044     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
14045   }
14046
14047   Renderer renderer2 = Renderer::New(geometry, shader);
14048   actor.AddRenderer(renderer2);
14049
14050   END_TEST;
14051 }
14052
14053 int UtcDaliActorRegisterProperty(void)
14054 {
14055   tet_infoline("Test property registration and uniform map update\n");
14056
14057   TestApplication application;
14058
14059   Geometry geometry  = CreateQuadGeometry();
14060   Shader   shader    = CreateShader();
14061   Renderer renderer1 = Renderer::New(geometry, shader);
14062   Renderer renderer2 = Renderer::New(geometry, shader);
14063
14064   Actor actor1 = Actor::New();
14065   actor1.AddRenderer(renderer1);
14066   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
14067   actor1.RegisterProperty("uCustom", 1);
14068   application.GetScene().Add(actor1);
14069
14070   Actor actor2 = Actor::New();
14071   actor2.AddRenderer(renderer2);
14072   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
14073   application.GetScene().Add(actor2);
14074
14075   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
14076   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
14077   glAbstraction.EnableSetUniformCallTrace(true);
14078
14079   application.SendNotification();
14080   application.Render();
14081
14082   std::stringstream out;
14083   out.str("1");
14084   std::string params;
14085
14086   // Test uniform value of the custom property
14087   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
14088   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
14089
14090   // Make invisible
14091   actor1[Actor::Property::VISIBLE] = false;
14092
14093   application.SendNotification();
14094   application.Render();
14095
14096   // Make visible again
14097   actor1[Actor::Property::VISIBLE] = true;
14098   actor1["uCustom"]                = 2;
14099
14100   glAbstraction.ResetSetUniformCallStack();
14101
14102   application.SendNotification();
14103   application.Render();
14104
14105   out.str("2");
14106
14107   // The uniform value should not be changed
14108   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
14109   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
14110
14111   END_TEST;
14112 }
14113
14114 int UtcDaliActorDoesWantedHitTest(void)
14115 {
14116   struct HitTestData
14117   {
14118   public:
14119     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
14120     : mScale(scale),
14121       mTouchPoint(touchPoint),
14122       mResult(result)
14123     {
14124     }
14125
14126     Vector3 mScale;
14127     Vector2 mTouchPoint;
14128     bool    mResult;
14129   };
14130
14131   TestApplication application;
14132   tet_infoline(" UtcDaliActorDoesWantedHitTest");
14133
14134   // Fill a vector with different hit tests.
14135   struct HitTestData* hitTestData[] = {
14136     //                    scale                     touch point           result
14137     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
14138     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
14139     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.
14140     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
14141     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.
14142     NULL,
14143   };
14144
14145   // get the root layer
14146   Actor actor = Actor::New();
14147   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
14148   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
14149
14150   Actor lowerActor = Actor::New();
14151   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
14152   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
14153
14154   // actor and lowerActor have no relationship.
14155   application.GetScene().Add(lowerActor);
14156   application.GetScene().Add(actor);
14157
14158   ResetTouchCallbacks();
14159   gHitTestTouchCallBackCalled = false;
14160
14161   unsigned int index = 0;
14162   while(NULL != hitTestData[index])
14163   {
14164     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
14165     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
14166
14167     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
14168     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
14169
14170     // flush the queue and render once
14171     application.SendNotification();
14172     application.Render();
14173
14174     DALI_TEST_CHECK(!gTouchCallBackCalled);
14175     DALI_TEST_CHECK(!gTouchCallBackCalled2);
14176     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
14177
14178     // connect to its touch signal
14179     actor.TouchedSignal().Connect(TestTouchCallback);
14180     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
14181
14182     // connect to its hit-test signal
14183     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
14184
14185     Dali::Integration::Point point;
14186     point.SetState(PointState::DOWN);
14187     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
14188     Dali::Integration::TouchEvent event;
14189     event.AddPoint(point);
14190
14191     // flush the queue and render once
14192     application.SendNotification();
14193     application.Render();
14194     application.ProcessEvent(event);
14195
14196     // check hit-test events
14197     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
14198     // Passed all hit-tests of actor.
14199     DALI_TEST_CHECK(gTouchCallBackCalled == false);
14200     // The lowerActor was hit-tested.
14201     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
14202
14203     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
14204       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
14205                  hitTestData[index]->mScale.x,
14206                  hitTestData[index]->mScale.y,
14207                  hitTestData[index]->mScale.z,
14208                  hitTestData[index]->mTouchPoint.x,
14209                  hitTestData[index]->mTouchPoint.y,
14210                  hitTestData[index]->mResult);
14211
14212     ResetTouchCallbacks();
14213     gHitTestTouchCallBackCalled = false;
14214     ++index;
14215   }
14216   END_TEST;
14217 }
14218
14219 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
14220 {
14221   TestApplication application;
14222
14223   Actor actor = Actor::New();
14224   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
14225   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
14226   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
14227   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
14228   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
14229   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
14230   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
14231   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
14232   END_TEST;
14233 }
14234
14235 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
14236 {
14237   TestApplication application;
14238
14239   Actor actor = Actor::New();
14240
14241   // Make sure setting invalid types does not cause a crash
14242   try
14243   {
14244     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
14245     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
14246     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
14247     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
14248     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
14249     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
14250     tet_result(TET_PASS);
14251   }
14252   catch(...)
14253   {
14254     tet_result(TET_FAIL);
14255   }
14256   END_TEST;
14257 }
14258
14259 int UtcDaliActorCalculateWorldTransform01(void)
14260 {
14261   TestApplication application;
14262
14263   tet_infoline("Test that actor position inheritance produces right transform matrix");
14264
14265   Actor rootActor   = Actor::New();
14266   Actor branchActor = Actor::New();
14267   Actor leafActor   = Actor::New();
14268
14269   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
14270   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14271   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14272
14273   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14274   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14275   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14276
14277   // Set anchor point to the same value as parent origin
14278   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
14279   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
14280   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
14281
14282   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14283   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14284   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14285
14286   application.GetScene().Add(rootActor);
14287   rootActor.Add(branchActor);
14288   branchActor.Add(leafActor);
14289
14290   application.SendNotification();
14291   application.Render(0);
14292   application.SendNotification();
14293   application.Render(0);
14294
14295   Matrix m = DevelActor::GetWorldTransform(leafActor);
14296
14297   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14298   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14299
14300   Vector3    worldPos;
14301   Vector3    worldScale;
14302   Quaternion worldRotation;
14303   m.GetTransformComponents(worldPos, worldRotation, worldScale);
14304   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
14305
14306   END_TEST;
14307 }
14308
14309 int UtcDaliActorCalculateWorldTransform02(void)
14310 {
14311   TestApplication application;
14312
14313   tet_infoline("Test that actor position produces right transform matrix");
14314
14315   Actor rootActor   = Actor::New();
14316   Actor branchActor = Actor::New();
14317   Actor leafActor   = Actor::New();
14318
14319   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
14320   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14321   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14322
14323   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14324   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14325   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14326
14327   // Set anchor point to the same value as parent origin
14328   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14329   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14330   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14331
14332   application.GetScene().Add(rootActor);
14333   rootActor.Add(branchActor);
14334   branchActor.Add(leafActor);
14335
14336   leafActor[Actor::Property::INHERIT_POSITION]    = false;
14337   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
14338   leafActor[Actor::Property::INHERIT_SCALE]       = false;
14339
14340   application.SendNotification();
14341   application.Render(0);
14342   application.SendNotification();
14343   application.Render(0);
14344
14345   Matrix m = DevelActor::GetWorldTransform(leafActor);
14346
14347   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14348   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14349
14350   END_TEST;
14351 }
14352
14353 int UtcDaliActorCalculateWorldTransform03(void)
14354 {
14355   TestApplication application;
14356
14357   tet_infoline("Test that actor position produces right transform matrix");
14358
14359   Actor rootActor   = Actor::New();
14360   Actor branchActor = Actor::New();
14361   Actor leafActor   = Actor::New();
14362
14363   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
14364   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14365   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14366
14367   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14368   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14369   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14370
14371   // Set anchor point to the same value as parent origin
14372   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14373   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14374   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14375
14376   application.GetScene().Add(rootActor);
14377   rootActor.Add(branchActor);
14378   branchActor.Add(leafActor);
14379
14380   leafActor[Actor::Property::INHERIT_POSITION]    = true;
14381   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
14382   leafActor[Actor::Property::INHERIT_SCALE]       = false;
14383
14384   application.SendNotification();
14385   application.Render(0);
14386   application.SendNotification();
14387   application.Render(0);
14388
14389   Matrix m = DevelActor::GetWorldTransform(leafActor);
14390
14391   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14392   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14393
14394   END_TEST;
14395 }
14396
14397 int UtcDaliActorCalculateWorldTransform04(void)
14398 {
14399   TestApplication application;
14400
14401   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
14402
14403   Actor rootActor   = Actor::New();
14404   Actor branchActor = Actor::New();
14405   Actor leafActor   = Actor::New();
14406
14407   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14408   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14409   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14410
14411   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14412   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14413   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14414
14415   // Set anchor point to the same value as parent origin
14416   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14417   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14418   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14419   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14420
14421   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14422   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14423
14424   application.GetScene().Add(rootActor);
14425   rootActor.Add(branchActor);
14426   branchActor.Add(leafActor);
14427
14428   application.SendNotification();
14429   application.Render(0);
14430   application.SendNotification();
14431   application.Render(0);
14432
14433   Matrix m = DevelActor::GetWorldTransform(leafActor);
14434
14435   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14436   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14437
14438   END_TEST;
14439 }
14440
14441 int UtcDaliActorCalculateWorldTransform05(void)
14442 {
14443   TestApplication application;
14444
14445   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14446
14447   Actor rootActor   = Actor::New();
14448   Actor branchActor = Actor::New();
14449   Actor leafActor   = Actor::New();
14450
14451   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14452   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14453   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14454
14455   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14456   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14457   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14458
14459   // Set anchor point to the same value as parent origin
14460   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14461   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14462   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14463   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14464
14465   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14466   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14467
14468   leafActor[Actor::Property::INHERIT_POSITION]    = false;
14469   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
14470
14471   application.GetScene().Add(rootActor);
14472   rootActor.Add(branchActor);
14473   branchActor.Add(leafActor);
14474
14475   application.SendNotification();
14476   application.Render(0);
14477   application.SendNotification();
14478   application.Render(0);
14479
14480   Matrix m = DevelActor::GetWorldTransform(leafActor);
14481
14482   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14483   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14484
14485   END_TEST;
14486 }
14487
14488 int UtcDaliActorCalculateWorldTransform06(void)
14489 {
14490   TestApplication application;
14491
14492   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14493
14494   Actor rootActor   = Actor::New();
14495   Actor branchActor = Actor::New();
14496   Actor leafActor   = Actor::New();
14497
14498   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14499   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14500   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14501
14502   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14503   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14504   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14505
14506   // Set anchor point to the same value as parent origin
14507   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14508   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14509   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14510   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14511
14512   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
14513   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
14514   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
14515
14516   leafActor[Actor::Property::INHERIT_POSITION] = false;
14517   leafActor[Actor::Property::INHERIT_SCALE]    = false;
14518
14519   application.GetScene().Add(rootActor);
14520   rootActor.Add(branchActor);
14521   branchActor.Add(leafActor);
14522
14523   application.SendNotification();
14524   application.Render(0);
14525   application.SendNotification();
14526   application.Render(0);
14527
14528   Matrix m = DevelActor::GetWorldTransform(leafActor);
14529
14530   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14531   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14532
14533   END_TEST;
14534 }
14535
14536 int UtcDaliActorCalculateWorldTransform07(void)
14537 {
14538   TestApplication application;
14539
14540   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14541
14542   Actor rootActor   = Actor::New();
14543   Actor branchActor = Actor::New();
14544   Actor leafActor   = Actor::New();
14545
14546   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14547   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14548   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14549
14550   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14551   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14552   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14553
14554   // Set anchor point to the same value as parent origin
14555   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14556   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14557   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14558
14559   // This should be ignored.
14560   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14561   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14562
14563   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
14564   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
14565   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
14566
14567   leafActor[Actor::Property::INHERIT_POSITION]           = false;
14568   leafActor[Actor::Property::INHERIT_SCALE]              = false;
14569   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
14570
14571   application.GetScene().Add(rootActor);
14572   rootActor.Add(branchActor);
14573   branchActor.Add(leafActor);
14574
14575   application.SendNotification();
14576   application.Render(0);
14577   application.SendNotification();
14578   application.Render(0);
14579
14580   Matrix m = DevelActor::GetWorldTransform(leafActor);
14581
14582   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14583   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14584
14585   END_TEST;
14586 }
14587
14588 int UtcDaliActorCalculateWorldTransform08(void)
14589 {
14590   TestApplication application;
14591
14592   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14593
14594   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)};
14595
14596   struct TestCase
14597   {
14598     bool translation;
14599     bool rotation;
14600     bool scaling;
14601   };
14602   TestCase testCases[] = {
14603     {false, false, true},
14604     {false, true, false},
14605     {true, false, false},
14606     {false, true, true},
14607     {true, false, true},
14608     {true, true, false},
14609     {false, false, false},
14610     {true, true, true},
14611   };
14612
14613   Actor rootActor = Actor::New();
14614   Actor leafActor = Actor::New();
14615
14616   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
14617   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
14618   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14619   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
14620   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14621   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14622
14623   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
14624   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
14625   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14626   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
14627   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
14628   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
14629   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
14630
14631   application.GetScene().Add(rootActor);
14632   rootActor.Add(leafActor);
14633
14634   for(uint32_t i = 0; i < 8; ++i)
14635   {
14636     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
14637     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
14638     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
14639
14640     application.SendNotification();
14641     application.Render(0);
14642     application.SendNotification();
14643     application.Render(0);
14644
14645     Matrix m            = DevelActor::GetWorldTransform(leafActor);
14646     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14647
14648     Vector3 worldPosition1 = Vector3(m.GetTranslation());
14649     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
14650
14651     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
14652     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
14653   }
14654
14655   END_TEST;
14656 }
14657
14658 int UtcDaliActorCalculateWorldColor01(void)
14659 {
14660   TestApplication application;
14661
14662   tet_infoline("Test that actor inheritance of color produces right final color");
14663
14664   Actor rootActor   = Actor::New();
14665   Actor branchActor = Actor::New();
14666   Actor leafActor   = Actor::New();
14667
14668   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14669   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14670   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14671
14672   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14673   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14674   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14675
14676   rootActor[Actor::Property::COLOR] = Color::WHITE;
14677   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
14678   branchActor[Actor::Property::COLOR] = testColor1;
14679   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14680
14681   // Default is to inherit:
14682   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
14683
14684   application.GetScene().Add(rootActor);
14685   rootActor.Add(branchActor);
14686   branchActor.Add(leafActor);
14687
14688   application.SendNotification();
14689   application.Render(16);
14690   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14691   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14692
14693   application.SendNotification();
14694   application.Render(16);
14695   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14696   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14697
14698   application.SendNotification();
14699   application.Render(16);
14700   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14701   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14702
14703   color = DevelActor::GetWorldColor(leafActor);
14704
14705   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14706   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14707
14708   END_TEST;
14709 }
14710
14711 int UtcDaliActorCalculateWorldColor02(void)
14712 {
14713   TestApplication application;
14714
14715   tet_infoline("Test that actor uses own color");
14716
14717   Actor rootActor   = Actor::New();
14718   Actor branchActor = Actor::New();
14719   Actor leafActor   = Actor::New();
14720
14721   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14722   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14723   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14724
14725   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14726   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14727   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14728
14729   rootActor[Actor::Property::COLOR]   = Color::WHITE;
14730   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14731   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14732
14733   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
14734
14735   application.GetScene().Add(rootActor);
14736   rootActor.Add(branchActor);
14737   branchActor.Add(leafActor);
14738
14739   application.SendNotification();
14740   application.Render(0);
14741
14742   Vector4 color = DevelActor::GetWorldColor(leafActor);
14743
14744   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14745   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14746   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
14747   END_TEST;
14748 }
14749
14750 int UtcDaliActorCalculateWorldColor03(void)
14751 {
14752   TestApplication application;
14753
14754   tet_infoline("Test that actor uses parent color");
14755
14756   Actor rootActor   = Actor::New();
14757   Actor branchActor = Actor::New();
14758   Actor leafActor   = Actor::New();
14759
14760   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14761   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14762   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14763
14764   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14765   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14766   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14767
14768   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
14769   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14770   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14771
14772   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
14773
14774   application.GetScene().Add(rootActor);
14775   rootActor.Add(branchActor);
14776   branchActor.Add(leafActor);
14777
14778   application.SendNotification();
14779   application.Render(0);
14780
14781   Vector4 color = DevelActor::GetWorldColor(leafActor);
14782
14783   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14784   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14785   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
14786   END_TEST;
14787 }
14788
14789 int UtcDaliActorCalculateWorldColor04(void)
14790 {
14791   TestApplication application;
14792
14793   tet_infoline("Test that actor blends with parent color");
14794
14795   Actor rootActor   = Actor::New();
14796   Actor branchActor = Actor::New();
14797   Actor leafActor   = Actor::New();
14798
14799   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14800   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14801   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14802
14803   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14804   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14805   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14806
14807   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
14808   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14809   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14810
14811   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
14812
14813   application.GetScene().Add(rootActor);
14814   rootActor.Add(branchActor);
14815   branchActor.Add(leafActor);
14816
14817   application.SendNotification();
14818   application.Render(0);
14819
14820   Vector4 color = DevelActor::GetWorldColor(leafActor);
14821
14822   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14823   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14824
14825   END_TEST;
14826 }
14827
14828 int UtcDaliActorCalculateLookAt(void)
14829 {
14830   TestApplication application;
14831
14832   tet_infoline("Test that actor rotate right value of orientation");
14833
14834   Actor actor = Actor::New();
14835
14836   actor[Actor::Property::POSITION]      = Vector3(100.0f, 0.0f, 0.0f);
14837   actor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14838   actor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14839
14840   application.GetScene().Add(actor);
14841
14842   application.SendNotification();
14843   application.Render(0);
14844
14845   Quaternion actorQuaternion;
14846
14847   tet_printf("Test with target only\n");
14848   Dali::DevelActor::LookAt(actor, Vector3::ZERO);
14849   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14850   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
14851
14852   tet_printf("Test with target + up\n");
14853   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::ZAXIS);
14854   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14855   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS) * Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
14856
14857   tet_printf("Test with target + up + localForward\n");
14858   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_XAXIS);
14859   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14860   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(180.0f)), Vector3::XAXIS), TEST_LOCATION);
14861
14862   tet_printf("Test with target + up + localForward + localUp\n");
14863   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_YAXIS, Vector3::XAXIS);
14864   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14865   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_ZAXIS), TEST_LOCATION);
14866
14867   // Reset quaternion
14868   actor[Actor::Property::ORIENTATION] = Quaternion();
14869
14870   Actor actor2                           = Actor::New();
14871   actor2[Actor::Property::POSITION]      = Vector3(0.0f, 50.0f, -10.0f);
14872   actor2[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14873   actor2[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14874   actor.Add(actor2);
14875
14876   tet_printf("Test whether lookat calculate well by using event side values only\n");
14877   Dali::DevelActor::LookAt(actor2, Vector3(100.0f, 50.0f, 1.0f));
14878   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14879   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
14880
14881   actor[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0f)), Vector3::ZAXIS);
14882
14883   DALI_TEST_EQUALS(Dali::DevelActor::GetWorldTransform(actor2).GetTranslation3(), Vector3(50.0f, 0.0f, -10.0f), TEST_LOCATION);
14884
14885   tet_printf("Test whether lookat calculate well inherit by parent orientation\n");
14886   Dali::DevelActor::LookAt(actor2, Vector3(50.0f, 0.0f, 1.0f), Vector3::NEGATIVE_XAXIS);
14887   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14888   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
14889
14890   END_TEST;
14891 }
14892
14893 int UtcDaliActorIsHittable(void)
14894 {
14895   TestApplication application;
14896
14897   Actor   parent = Actor::New();
14898   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
14899   parent.SetProperty(Actor::Property::COLOR, parentColor);
14900   application.GetScene().Add(parent);
14901
14902   Actor   actor = Actor::New();
14903   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
14904   actor.SetProperty(Actor::Property::COLOR, childColor);
14905   parent.Add(actor);
14906
14907   actor.SetProperty(Actor::Property::SENSITIVE, true);
14908   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
14909   actor.SetProperty(Actor::Property::VISIBLE, true);
14910
14911   application.SendNotification();
14912   application.Render();
14913
14914   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == true);
14915
14916   actor.SetProperty(Actor::Property::SENSITIVE, false);
14917   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14918   actor.SetProperty(Actor::Property::SENSITIVE, true);
14919
14920   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
14921   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14922   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
14923
14924   actor.SetProperty(Actor::Property::VISIBLE, false);
14925   application.SendNotification();
14926   application.Render();
14927   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14928
14929   END_TEST;
14930 }
14931
14932 int UtcDaliActorGetTouchRequired(void)
14933 {
14934   TestApplication application;
14935
14936   Actor actor = Actor::New();
14937   DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == false);
14938
14939   actor.TouchedSignal().Connect(TestTouchCallback);
14940   DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == true);
14941
14942   END_TEST;
14943 }
14944
14945 int UtcDaliActorDispatchTouchMotionPropertyP(void)
14946 {
14947   TestApplication application;
14948
14949   Actor actor = Actor::New();
14950   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION).Get<bool>(), true, TEST_LOCATION);
14951   actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, false);
14952   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION).Get<bool>(), false, TEST_LOCATION);
14953   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::DISPATCH_TOUCH_MOTION), Property::BOOLEAN, TEST_LOCATION);
14954   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::DISPATCH_TOUCH_MOTION), true, TEST_LOCATION);
14955   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::DISPATCH_TOUCH_MOTION), false, TEST_LOCATION);
14956   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::DISPATCH_TOUCH_MOTION), false, TEST_LOCATION);
14957   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::DISPATCH_TOUCH_MOTION), "dispatchTouchMotion", TEST_LOCATION);
14958   END_TEST;
14959 }
14960
14961 int UtcDaliActorDispatchTouchMotionPropertyN(void)
14962 {
14963   TestApplication application;
14964
14965   Actor actor = Actor::New();
14966
14967   // Make sure setting invalid types does not cause a crash
14968   try
14969   {
14970     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, 1.0f);
14971     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector2::ONE);
14972     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector3::ONE);
14973     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector4::ONE);
14974     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Property::Map());
14975     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Property::Array());
14976     tet_result(TET_PASS);
14977   }
14978   catch(...)
14979   {
14980     tet_result(TET_FAIL);
14981   }
14982   END_TEST;
14983 }
14984
14985 int UtcDaliActorDispatchHoverMotionPropertyP(void)
14986 {
14987   TestApplication application;
14988
14989   Actor actor = Actor::New();
14990   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION).Get<bool>(), true, TEST_LOCATION);
14991   actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, false);
14992   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION).Get<bool>(), false, TEST_LOCATION);
14993   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::DISPATCH_HOVER_MOTION), Property::BOOLEAN, TEST_LOCATION);
14994   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::DISPATCH_HOVER_MOTION), true, TEST_LOCATION);
14995   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::DISPATCH_HOVER_MOTION), false, TEST_LOCATION);
14996   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::DISPATCH_HOVER_MOTION), false, TEST_LOCATION);
14997   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::DISPATCH_HOVER_MOTION), "dispatchHoverMotion", TEST_LOCATION);
14998   END_TEST;
14999 }
15000
15001 int UtcDaliActorDispatchHoverMotionPropertyN(void)
15002 {
15003   TestApplication application;
15004
15005   Actor actor = Actor::New();
15006
15007   // Make sure setting invalid types does not cause a crash
15008   try
15009   {
15010     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, 1.0f);
15011     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector2::ONE);
15012     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector3::ONE);
15013     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector4::ONE);
15014     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Property::Map());
15015     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Property::Array());
15016     tet_result(TET_PASS);
15017   }
15018   catch(...)
15019   {
15020     tet_result(TET_FAIL);
15021   }
15022   END_TEST;
15023 }